Windows Network Troubleshooting Cheat Sheet

Windows network troubleshooting commands in one place: ipconfig, Test-NetConnection, netstat, nslookup, route, netsh firewall and SMB checks, organised by symptom.

Start by symptom

No address, or 169.254.x.x
ipconfig /all
Name does not resolve
nslookup host
Resolves but will not connect
tnc host -Port 443
Slow or dropping
pathping -q 50 host
Which process owns the port
netstat -ano
Traffic takes the wrong path
route print -4
Work up the stack. Link, address, route, name, port, application. Testing the application first is how an afternoon disappears into a problem that was a missing route.

Address and interface

TaskCommand
Everything about every adapteripconfig /all
Release and renew DHCPipconfig /release then ipconfig /renew
Adapter link state and speedGet-NetAdapter
Errors and discards on the NICGet-NetAdapterStatistics
Bounce an adapterRestart-NetAdapter -Name "Ethernet"
Addresses, PowerShell styleGet-NetIPAddress -AddressFamily IPv4
Full config of one interfacenetsh interface ip show config name="Ethernet"
Set a static addressnetsh interface ip set address "Ethernet" static 10.0.0.5 255.255.255.0 10.0.0.1
Set DNS serversnetsh interface ip set dns "Ethernet" static 10.0.0.10
Back to DHCPnetsh interface ip set address "Ethernet" dhcp

Reachability and path

TaskCommand
The one command that answers most questionsTest-NetConnection host -Port 443
Short form with full outputtnc host -InformationLevel Detailed
Trace with the route includedtnc host -TraceRoute
Continuous ping with timestampsping -t host
Ping a fixed size, no fragmentationping -f -l 1472 host
Trace, no name lookups, 15 hopstracert -d -h 15 host
Find which hop loses packetspathping -q 50 host
Test several hosts at onceTest-Connection srv01,srv02 -Count 2
ICMP is not permission to conclude anything. Plenty of firewalls drop ping while passing TCP, so a failed ping proves nothing on its own. Test-NetConnection -Port is the test that matches how the application actually connects.

Ports and sockets

TaskCommand
Every connection with its PIDnetstat -ano
Include the executable, needs elevationnetstat -abno
One port onlynetstat -ano | findstr :443
What is listening, PowerShell styleGet-NetTCPConnection -State Listen
Listening ports with the process nameGet-NetTCPConnection -State Listen | Select LocalPort,@{n='Proc';e={(Get-Process -Id $_.OwningProcess).Name}}
Translate a PIDtasklist /fi "pid eq 4321"
Per-protocol statisticsnetstat -s -p tcp
Interface counters, errors includednetstat -e
PID 4 is not a bug. Port 445 and often 80 belong to the System process, so nothing shows up in Task Manager to kill. That is http.sys or the SMB server, and the fix is a service change, not an end task.

DNS

TaskCommand
Resolve a namenslookup host.corp.local
Ask a specific servernslookup host.corp.local 10.0.0.10
One record typenslookup -type=MX example.com
See which server actually answerednslookup -debug host
PowerShell, scriptable outputResolve-DnsName host -Type A
Bypass the client cacheResolve-DnsName host -DnsOnly -Server 10.0.0.10
Reverse lookupResolve-DnsName 10.0.0.25 -Type PTR
Clear the client cacheipconfig /flushdns
Read the client cacheipconfig /displaydns
Re-register this host in DNSipconfig /registerdns
Check the hosts file before blaming DNStype %SystemRoot%\System32\drivers\etc\hosts
The answer may not come from the server you think. The hosts file, the client cache and the suffix search list all resolve before the query leaves the machine. nslookup -debug shows which one won.

ARP and routing

TaskCommand
Local ARP cachearp -a
One entryarp -a 10.0.0.1
Flush the cachearp -d *
Flush it properly on modern Windowsnetsh interface ip delete arpcache
Routing table, IPv4 onlyroute print -4
Add a persistent routeroute -p add 10.20.0.0 mask 255.255.0.0 10.0.0.1
Delete a routeroute delete 10.20.0.0
PowerShell view, with interface indexGet-NetRoute -AddressFamily IPv4
Which route will be used for a targetFind-NetRoute -RemoteIPAddress 10.20.0.5
Two default gateways is not redundancy. If route print shows two 0.0.0.0 routes on different adapters, traffic follows the lower metric and the other path fails intermittently. That is the usual cause of “it works on Wi-Fi but not on the dock”.

Firewall

TaskCommand
Which profile is active and is it onGet-NetFirewallProfile | Select Name,Enabled
Same, classicnetsh advfirewall show allprofiles
Open a port inboundnetsh advfirewall firewall add rule name="App 8443" dir=in action=allow protocol=TCP localport=8443
Same in PowerShellNew-NetFirewallRule -DisplayName "App 8443" -Direction Inbound -Protocol TCP -LocalPort 8443 -Action Allow
Find the rule that blocks a portGet-NetFirewallPortFilter | Where LocalPort -eq 445
Rules for one programnetsh advfirewall firewall show rule name=all dir=in | findstr /i "8443"
Reset the whole firewall to defaultsnetsh advfirewall reset
Check the profile first. A rule in the Domain profile does nothing while the adapter is classified as Public, which happens on every machine that boots before the DC is reachable. Get-NetConnectionProfile tells you which one is in force.

Shares and SMB

TaskCommand
Map a drivenet use Z: \\SRV01\share /persistent:yes
Map as another accountnet use Z: \\SRV01\share /user:DOM\svc
Drop every mapping and cached sessionnet use * /delete /y
Shares on a remote servernet view \\SRV01
Shares on this machinenet share
Live SMB sessions and dialectGet-SmbConnection
Is SMB even reachabletnc SRV01 -Port 445
Open files held on a serveropenfiles /query /fo table
Old credentials survive a password change. A cached SMB session keeps presenting the old password and locks the account out every few minutes. net use * /delete /y on the offending machine, then check Credential Manager, is the fix.

Capture and reset

TaskCommand
Start a capture, no extra toolingnetsh trace start capture=yes tracefile=C:\temp\net.etl maxsize=512
Stop itnetsh trace stop
Packet capture on modern Windowspktmon start --etw -c --pkt-size 0
Stop and convert to textpktmon stop then pktmon etl2txt PktMon.etl
Which rule or component dropped a packetpktmon list and pktmon counters
Wi-Fi state and signalnetsh wlan show interfaces
Wi-Fi connection history reportnetsh wlan show wlanreport
Reset the TCP/IP stacknetsh int ip reset
Reset Winsocknetsh winsock reset
The resets need a reboot. netsh int ip reset and netsh winsock reset rewrite registry state and take effect only after a restart. They also remove third-party LSP entries, so run them as a deliberate step, not as a first guess.

Symptom to command

SymptomRun this, in order
APIPA address 169.254.x.xGet-NetAdapter, ipconfig /release, ipconfig /renew, then check the DHCP scope
Some names resolve, others do notnslookup -debug name, ipconfig /all for the suffix list, ipconfig /flushdns
Resolves, pings, will not connecttnc host -Port n both ways, then the firewall profile on the target
Connection drops under loadGet-NetAdapterStatistics for discards, then pathping -q 50
Two machines fight over one addressarp -a on a third host, System log events 4198 and 4199
Traffic leaves the wrong interfaceroute print -4, Get-NetIPInterface for metrics
Port already in use at service startnetstat -ano | findstr :port, then tasklist /fi "pid eq n"
Mapped drive gone after rebootnet use, then check the drive is mapped by the same user context, not elevated
Works by IP, fails by nameDNS or SPN. Start with nslookup, then Kerberos.

FAQ

Ping fails but the application works. Which do I trust?
The application. ICMP is commonly blocked while TCP passes, so a failed ping is evidence about ICMP and nothing else. Test the port the application actually uses with Test-NetConnection -Port.
netstat shows a port held by PID 4. How do I free it?
PID 4 is the System process, so the listener belongs to a kernel driver: usually http.sys for 80 and 443, or the SMB server for 445. Move your service to another port, or stop the responsible service. netsh http show servicestate shows who reserved an HTTP port.
Why does a mapped drive disappear in an elevated console?
Mappings belong to a logon session, and the elevated token is a different session. Either map inside the elevated context, or set EnableLinkedConnections to 1 in the registry and reboot.
How do I capture packets without installing anything?
netsh trace start capture=yes on any supported Windows, or pktmon on Windows 10 1809 and later. Both produce an .etl that Wireshark or Network Monitor can open after conversion, which is enough for a first look on a server where you cannot install tools.
Is there a reliable way to test throughput from the command line?
Not with the built-in tools alone. Copy a large file with robocopy and read the reported rate, or run iperf3 on both ends. A browser speed test measures your internet link, not the path between two servers.