netsh trace
netsh trace is the tracer built into Windows: it records ETW events from the networking stack and, with capture=yes, the packets too, all in one .etl file. Nothing has to be installed, which makes it the go-to tool on remote or locked-down Windows servers.
131.1 Why is it used?
- Capture packets on a Windows machine where Wireshark cannot be installed (servers, customer PCs, locked-down boxes).
- Record ETW (Event Tracing for Windows) events from DNS Client, Winsock, TCPIP, Wi-Fi, so you see what happened inside Windows, not just on the wire.
- Built in since Windows 7 / Server 2008 R2; runs in an elevated CMD or PowerShell.
- Output: one .etl file (events + packets) plus an optional .cab bundle with config, logs and a report.
- Not available on Linux / macOS: there you use tcpdump or tshark.
131.2 How it works
- netsh trace start opens an ETW session; the chosen scenario or provider decides which components write events.
- capture=yes adds a copy of every packet (via NDIS-PacketCapture) to the same .etl file; the default is capture=no (events only).
- You reproduce the problem, then run netsh trace stop: traces are merged and the .cab report is generated.
- Wireshark does not open .etl directly: convert it to pcapng with etl2pcapng or pktmon etl2pcap (previous video).
- netsh trace convert only produces TXT/CSV/XML/EVTX or an HTML report, never pcapng.
- Step 1
1.Admin CMD on PC 192.168.1.10: netsh trace start capture=yes -> ETW session starts
- Step 2
2.Browser connects to example.com: Winsock-AFD and TCPIP providers write events (rows 1-2 in net.etl)
- Step 3
3.TCP SYN to port 443 leaves via router 192.168.1.1; its copy goes into net.etl (row 3)
- Step 4
4.Server replies SYN ACK; the reply is recorded too (row 4)
- Step 5
5.netsh trace stop -> C:\Logs\net.etl (events + packets) and net.cab (config, logs, report)
One file holds both what Windows did and what went on the wire
- Step 1
1.netsh trace start capture=yes tracefile=C:\Logs\net.etl maxsize=512
- Step 2
2.Reproduce the problem
- Step 3
3.netsh trace stop -> net.etl + net.cab
- Step 4
4.etl2pcapng / pktmon etl2pcap -> net.pcapng
- Step 5
5.Open in Wireshark or tshark on an analysis laptop
- Step 6
6.netsh trace show status: confirm no session is left running
131.3 Context and show commands
- Context commands (5): ? and help list the commands, <command> ? prints full usage and defaults, dump prints the context config script, postreset restores tracing settings after a network stack reset.
- show has 10 subcommands and none of them start anything, so they are safe to run as a normal user.
- show status tells you whether a session is running: always run it after your work.
netsh trace ?netsh trace start ?netsh trace show statusC:\> netsh trace ?Commands in this context:? - Displays a list of commands.convert - Converts a trace file to an HTML report.correlate - Normalizes or filters a trace file to a new output file.diagnose - Start a diagnose session.dump - Displays a configuration script.export - Exports a scenario to a WPR profile.help - Displays a list of commands.merge - Merges trace files and adds symbols metadata.postreset - show - List interfaces, providers and tracing state.start - Starts tracing.stop - Stops tracing. C:\> netsh trace start ?...Defaults: capture=no (specifies whether packet capture is enabled maxSize=250 MB (specifies the maximum trace file size, 0=no maximum) fileMode=circular traceFile=%LOCALAPPDATA%\Temp\NetTraces\[sessionname]NetTrace.etl C:\> netsh trace show statusThere is no trace session currently in progress.131.4 start: session and scenarios
- A scenario is a ready-made preset that turns on the right providers for one problem (InternetClient = web, DNS, proxy).
- show scenarios lists 18 scenarios on this Windows 11 build; names differ by build: show scenario LAN gave an invalid value error, so check names on your machine.
- sessionname=web names the session so two traces can run together; scenario=A,B combines scenarios.
- globalLevel goes from 1 (critical) to 5 (verbose): the bigger the number, the more detail.
netsh trace show scenariosnetsh trace show scenario LANnetsh trace show globalkeywordsandlevelsC:\> netsh trace show scenariosAvailable scenarios (18):AddressAcquisition : Troubleshoot address acquisition related issuesFileSharing : Troubleshoot common file and printer sharing problemsInternetClient : Troubleshoot web connectivity issuesNetConnection : Troubleshoot network connection related issues... C:\> netsh trace show scenario LANInvalid value "LAN" for command option "name". C:\> netsh trace show globalkeywordsandlevelsLevels (value) - 5 element(s)win:Critical (1)win:Error (2)win:Warning (3)win:Informational (4)win:Verbose (5)131.5 start: packet capture and filters
| Option | What it does |
|---|---|
| capture=yes / no | Capture packets too / events only (default no) |
| capturetype=physical | vmswitch | both | Physical NIC (default), Hyper-V vSwitch, or both |
| IPv4.Address=192.168.1.10 | Only one host; (a,b) = any in list; !(a) = exclude |
| Protocol=TCP | Only TCP (or a number like 17 for UDP); !(TCP,UDP) excludes |
| Ethernet.Type=IPv4 | Only this EtherType |
| CaptureInterface="Ethernet" | Only one interface (name or GUID) |
| PacketTruncateBytes=256 | Keep only the first N bytes of each packet, small file |
- Capture filters work only with capture=yes (show capturefilterhelp says so).
131.6 start: output file and providers
netsh trace start capture=yes ^ tracefile=C:\Logs\net.etl maxsize=512Trace configuration:Status: RunningTrace File: C:\Logs\net.etlCircular: OnMax Size: 512 MBReport: Off| Option | Meaning |
|---|---|
| traceFile=C:\Logs\net.etl | Path of the ETL file |
| maxSize=1024 | Size limit in MB (default 250, 0 = none) |
| fileMode=circular | single | append | Ring buffer, oldest overwritten (default) / one file up to maxSize / add to old file |
| bufferSize=1024 | Buffer in KB (default 512) |
| report=yes | no | disabled | Create HTML/CAB report on stop |
| persistent=yes | Keep tracing across reboots (boot-time problems) |
| correlation, perfMerge | Group related events / add performance metadata |
- Without a scenario, turn on one ETW provider directly: provider=Microsoft-Windows-TCPIP keywords=... level=...; repeat for more providers.
- show providers lists 1220 providers on this machine (DNS-Client, NDIS-PacketCapture, TCPIP, Winsock-AFD...).
- show scenario InternetClient shows it enables WinINet and TCPIP at level 5 (Verbose) and Dhcp-Client at level 4.
131.7 stop, convert, correlate, diagnose
netsh trace stopnetsh trace stop sessionname=webC:\> netsh trace stopMerging traces ... doneGenerating data collection ... doneThe trace file ... compiled as "C:\Logs\net.cab".Tracing session was successfully stopped.| Command | Purpose | Key options |
|---|---|---|
| stop | End the session (can take 1-2 min) | sessionname= |
| convert | ETL to readable format | dump=TXT|CSV|XML|EVTX|No, report=yes, tmfpath, manpath |
| correlate | Filter/normalize ETL into a new ETL | filter=<Activity ID>, retainpii=no (drops PII incl. packets) |
| diagnose | Start a diagnose session for a scenario | report, capture, saveSessionTrace |
| export | Scenario providers to a WPR profile | file=C:\Logs\ic.wprp |
| merge | Combine ETL files, last name = output | merge a.etl b.etl merged.etl |
131.8 Analysis: reading the pcapng in tshark
capinfos -t -c -u /tmp/net.pcapngtshark -r /tmp/net.pcapngtshark -r /tmp/net.pcapng -q -z conv,ipNumber of packets: 19Capture duration: 1.090854723 second 4 0.000066939 192.168.151.10 → 192.168.151.20 ICMP 98 Echo (ping) request5 0.000169851 192.168.151.20 → 192.168.151.10 ICMP 98 Echo (ping) reply8 1.035722912 192.168.151.10 → 192.168.151.20 TCP 74 47084 → 80 [SYN]9 1.035861999 192.168.151.20 → 192.168.151.10 TCP 74 80 → 47084 [SYN, ACK]10 1.035892562 192.168.151.10 → 192.168.151.20 TCP 66 47084 → 80 [ACK]11 1.036375358 192.168.151.10 → 192.168.151.20 HTTP 143 GET / HTTP/1.115 1.077947201 192.168.151.20 → 192.168.151.10 HTTP 86 HTTP/1.0 200 OK (text/html) IPv4 Conversations192.168.151.10 <-> 192.168.151.20 7 739 bytes 9 743 bytes 16 1482 bytes 0.000066939 1.0908131.9 Common mistakes
- Forgetting capture=yes: the default records only events, no packets.
- Trying to open .etl in Wireshark, or expecting netsh trace convert to produce pcapng: use etl2pcapng / pktmon etl2pcap.
- Thinking netsh trace is just packet capture: the ETW events often show the cause (DNS, Winsock, Wi-Fi) even with capture=no, and the file stays small.
- Copying scenario names from docs (LAN, WLAN) without checking show scenarios on your build.
- Leaving a session running: check netsh trace show status; closing the window during stop.
131.10 Interview tips
- "Capture on a Windows server without installing Wireshark?" -> elevated CMD: netsh trace start capture=yes tracefile=... maxsize=..., repro, netsh trace stop.
- You get .etl + .cab; convert to pcapng with etl2pcapng and analyse in Wireshark; narrow with IPv4.Address=.
- Mention ETW: netsh trace records Windows component events, not just packets.
- Use correlate retainpii=no before sharing a trace outside your team.