Network Commands for Windows and Linux: A Practical Reference
What are the most useful network commands?
Network commands are built-in tools for checking how a computer is connected and where traffic stops. The core set is ping for reachability, tracert or traceroute for the path, ipconfig or ip for addresses and routes, nslookup or dig for DNS, netstat or ss for open connections, arp for MAC mappings, and curl or Test-NetConnection for testing a specific service port.
Windows and Linux equivalents at a glance
Most network tasks have a command on both systems, but the names and options differ. Windows commands run in Command Prompt or PowerShell; Linux commands run in any shell. The table maps each job to its usual tool.
| Task | Windows | Linux |
|---|---|---|
| Show addresses | ipconfig /all, Get-NetIPAddress | ip addr |
| Show routes | route print, Get-NetRoute | ip route |
| Test reachability | ping | ping -c 4 |
| Trace the path | tracert, pathping | traceroute, tracepath, mtr |
| Query DNS | nslookup, Resolve-DnsName | dig, nslookup |
| List connections and ports | netstat -ano, Get-NetTCPConnection | ss -tulpn |
| Show ARP or neighbour cache | arp -a | ip neigh |
| Test a TCP port | Test-NetConnection -Port | curl, nc -zv |
If any of the underlying ideas are new, read the IP addressing guide and the TCP/IP model first, because every command here reports on addresses, routes or ports.
Addresses and routes: ipconfig, ip and route
:: Windows (Command Prompt)
ipconfig :: address, mask and gateway per adapter
ipconfig /all :: adds MAC, DHCP server, DNS servers and lease times
ipconfig /release :: give up the DHCP lease
ipconfig /renew :: request a new lease
ipconfig /flushdns :: clear the local DNS cache
route print :: routing table, IPv4 and IPv6
# Linux
ip addr # every interface and its addresses (short form: ip a)
ip link # interface state and MAC addresses
ip route # routing table; "default via" is the gateway
ip route get 8.8.8.8 # which route and source address a packet would useThe older Linux commands ifconfig, route -n and netstat come from the net-tools package, which many distributions no longer install by default. The ip and ss commands from iproute2 replace them, and the Linux networking guide shows how to change settings rather than just read them.
Reachability and path: ping, tracert, traceroute and mtr
ping sends ICMP echo requests and reports the round-trip time of each reply. Windows sends four by default; Linux keeps going until you press Ctrl+C unless you add -c. A failed ping does not always mean the host is down, because many firewalls block ICMP.
ping 192.168.1.1 # Windows: 4 requests
ping -t 192.168.1.1 # Windows: continuous until Ctrl+C
ping -c 4 192.168.1.1 # Linux: 4 requests
ping -6 example.com # force IPv6 (both systems)
tracert -d example.com # Windows: ICMP-based, -d skips name lookups
traceroute -n example.com # Linux: UDP probes by default
sudo traceroute -T -p 443 example.com # Linux: TCP probes to port 443
pathping example.com # Windows: path plus loss per hop
mtr -rwc 50 example.com # Linux: 50 cycles, wide reportA trace lists each router (hop) on the way, using the TTL field: each router that decrements it to zero sends back an ICMP time-exceeded message. Lines of * * * mean that hop did not reply, which is common and harmless if later hops answer. mtr combines ping and traceroute, sending probes repeatedly so you can see loss and delay per hop over time.
DNS lookups: nslookup, dig and Resolve-DnsName
nslookup example.com # Windows and Linux
nslookup -type=mx example.com 1.1.1.1 # MX records from a chosen resolver
Resolve-DnsName example.com -Type AAAA # PowerShell
dig example.com +short # Linux and macOS
dig @8.8.8.8 example.com MX # ask a specific resolver
dig -x 192.0.2.10 # reverse lookupWhen a name fails but the IP address works, the fault is name resolution, not connectivity. The DNS guide explains record types and status codes such as NXDOMAIN and SERVFAIL.
Connections and neighbours: netstat, ss and arp
netstat -ano # Windows: all connections with process IDs
netstat -ano | findstr :443 # filter for port 443
Get-NetTCPConnection -State Listen # PowerShell: listening TCP ports
tasklist /fi "PID eq 4321" # name the process behind a PID
ss -tulpn # Linux: listening TCP/UDP with processes (sudo for all)
ss -tn state established # current TCP sessions
arp -a # Windows: IP to MAC mappings
ip neigh # Linux: neighbour (ARP and NDP) cacheIn ss -tulpn, a service listening on 0.0.0.0 or [::] accepts connections on every interface, while 127.0.0.1 means local only. Checking this is a routine hardening step. The ARP cache helps spot duplicate IP addresses: two different MAC addresses appearing for one IP over a short time point to a conflict. Port numbers themselves are listed in ports and protocols.
Testing a service: curl and Test-NetConnection
Ping proves only that ICMP gets through. To prove that a web server, database or SSH service answers, test the actual TCP port.
Test-NetConnection example.com -Port 443 # PowerShell, alias tnc
Test-NetConnection 10.0.0.5 -Port 3389 -InformationLevel Detailed
curl -I https://example.com # response headers only
curl -v https://example.com # show DNS, TCP, TLS and HTTP steps
curl.exe -I https://example.com # Windows PowerShell: avoids the curl alias
nc -zv 10.0.0.5 22 # Linux: is TCP port 22 open?Test-NetConnection reports TcpTestSucceeded : True when the port accepts a connection. In Windows PowerShell 5.1, curl is an alias for Invoke-WebRequest, so type curl.exe to run the real curl that ships with current Windows versions.
A quick diagnostic order
- Check your own address and gateway with
ipconfigorip addrandip route. - Ping the gateway, then a known public IP address.
- Resolve the target name with
nslookupordig. - Test the service port with
Test-NetConnectionorcurl. - If it still fails, trace the path with
tracert,tracerouteormtr.
The full method behind this order is covered in network troubleshooting.
Practical exercise: build a connectivity report
On a Windows or Linux machine you own, record the following in a text file.
- Your IPv4 address, prefix, gateway and DNS servers, and the MAC address of the active interface.
- Ping results to the gateway and to
1.1.1.1, with average round-trip time. - The A and AAAA records for
example.comfrom two different resolvers. - A trace to
example.comwith the number of hops and any non-responding hops. - A list of every listening port on your machine and the process that owns it.
- A successful port test to
example.comon port 443.
You are done when every item has its command and output, and you can explain one unexpected listening port. These labs run on real equipment in the Networking Foundation course.
Common mistakes
- Concluding a server is down because it does not answer ping, when ICMP is simply filtered.
- Reading loss at a single middle hop in a trace as a fault on the whole path.
- Typing
curlin Windows PowerShell 5.1 and gettingInvoke-WebRequestoutput instead. - Running
ss -tulpnwithoutsudoand missing the process names of system services. - Testing only the name or only the IP address, which hides whether DNS is the fault.
Frequently asked questions
Why does tracert work but traceroute fails on the same network?
Windows tracert sends ICMP echo requests, while Linux traceroute sends UDP probes by default. A firewall that allows ICMP but blocks high UDP ports stops the Linux trace. Try traceroute -I for ICMP or -T for TCP.
Is netstat still available on Windows?
Yes. netstat is still included in Windows. PowerShell cmdlets such as Get-NetTCPConnection return objects you can filter and sort, which is handier in scripts.
Can I install mtr on Windows?
mtr is a Linux and macOS tool. On Windows, pathping gives a similar per-hop loss report, and you can run mtr inside Windows Subsystem for Linux.