Check network status and DNS resolution on Linux and Windows
Layer-by-layer network status commands for Linux and Windows, with DNS tests using dig, nslookup and DNS over HTTPS.
A quick reference of commands to check network status layer by layer, with DNS tests, on Linux and Windows.
Linux
Layer 1: physical layer
ip link show # interface state (up/down)
ethtool eth0 # speed, duplex and packet drop information
lspci | less
lspci | grep -i intel
lspci | grep -i broadcom
lspci | grep -i wireless # Wi-Fi adapters
lshw -C network | grep -B 1 -A 12 'Wireless interface'
Layer 2: data link layer
ip neighbor show # neighbour table of the kernel (MAC addresses)
arp # ARP cache contents
Layer 3: network layer
ip address show # IP address of each interface
ifconfig -a # IP addresses of all interfaces
ping www.google.com
traceroute www.google.com
ip route show # routing table
nslookup www.google.com # DNS lookup
dig google.com # DNS lookup
drill google.com
Layer 4: transport layer
ss -tunlp4 # statistics about network connections
telnet database.example.com 3306 # check the remote port status
nc 192.0.2.10 -u 80 # check the remote port status (UDP)
nc -zv host01 3306 # -z: scan only, send no data; -v: verbose
netstat -anpl # all network connections
nstat # network statistics
netstat --statistics --tcp
netstat --statistics --udp
Windows
Layer 4: transport layer
netstat -s # protocol statistics
DNS tests
Query a specific DNS server:
nslookup www.mega.nz 192.0.2.11
powershell "(Invoke-WebRequest -UseBasicParsing -Uri 'https://192.0.2.11/dns-query?name=www.mega.nz' -Headers @{'Accept' = 'application/dns-json'}).RawContent"
Query the SOA and ANY records with dig. The second command first looks up the primary name server of the zone:
dig any stackoverflow.com @`dig +short SOA stackoverflow.com | cut -d' ' -f1`
dig any example.com @`dig +short SOA example.com | cut -d' ' -f1`