Online admissions open for the SEO, web development and networking & cybersecurity courses. Enquire for the next batch.

Network Commands for Windows and Linux: A Practical Reference

5 min read Updated By the SkillNewton team

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.

TaskWindowsLinux
Show addressesipconfig /all, Get-NetIPAddressip addr
Show routesroute print, Get-NetRouteip route
Test reachabilitypingping -c 4
Trace the pathtracert, pathpingtraceroute, tracepath, mtr
Query DNSnslookup, Resolve-DnsNamedig, nslookup
List connections and portsnetstat -ano, Get-NetTCPConnectionss -tulpn
Show ARP or neighbour cachearp -aip neigh
Test a TCP portTest-NetConnection -Portcurl, 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 use

The 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 report

A 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 lookup

When 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) cache

In 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

  1. Check your own address and gateway with ipconfig or ip addr and ip route.
  2. Ping the gateway, then a known public IP address.
  3. Resolve the target name with nslookup or dig.
  4. Test the service port with Test-NetConnection or curl.
  5. If it still fails, trace the path with tracert, traceroute or mtr.

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.

  1. Your IPv4 address, prefix, gateway and DNS servers, and the MAC address of the active interface.
  2. Ping results to the gateway and to 1.1.1.1, with average round-trip time.
  3. The A and AAAA records for example.com from two different resolvers.
  4. A trace to example.com with the number of hops and any non-responding hops.
  5. A list of every listening port on your machine and the process that owns it.
  6. A successful port test to example.com on 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 curl in Windows PowerShell 5.1 and getting Invoke-WebRequest output instead.
  • Running ss -tulpn without sudo and 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.

Want to Learn This Properly?

The Networking & Cybersecurity: Foundation & Practical Implementation (Online) turns guides like this into practised skills, with projects on real websites.

WhatsApp Call Us Now

Free counselling

Send an Enquiry

Tell us which course you are interested in. We reply by email or phone with the next batch and how to enrol.

Protected by reCAPTCHA. Google Privacy and Terms apply.

We reply by email or phone within working hours. No spam.