Last Updated: May 1, 2025
Connectivity Testing
ping -c 4 hostSend 4 ICMP echo requests — test basic reachability
ping -i 0.2 hostFlood ping with 0.2s interval (careful!)
mtr hostMy Traceroute — continuous ping + traceroute, best diagnostic
traceroute hostTrace packet path with TTL increments (UDP by default)
traceroute -T hostUse TCP SYN instead of UDP (gets through firewalls)
tracepath hostLike traceroute but discovers MTU along the path
arp -aShow ARP table (IP → MAC address mappings)
ip neighModern replacement for arp — show neighbor table
Port & Connection Diagnostics
ss -tlnpList all listening TCP ports with process names
ss -tanShow all TCP connections (listening + established)
ss -sSummary statistics: total sockets by type/state
netstat -tlnpLegacy: show listening TCP ports (ss is faster)
netstat -iNetwork interface statistics (errors, drops)
lsof -i :80List processes using port 80
nmap -p 1-1000 hostScan first 1000 ports on a host
nmap -sV hostService/version detection on open ports
Packet Capture (tcpdump)
tcpdump -i eth0Capture all traffic on interface eth0
tcpdump -i any port 80Capture HTTP traffic on any interface
tcpdump -i eth0 host 192.168.1.100Only traffic to/from specific host
tcpdump -i eth0 -w capture.pcapWrite packets to .pcap file for Wireshark
tcpdump -r capture.pcapRead packets from capture file
tcpdump -i eth0 'tcp[tcpflags] & (tcp-syn|tcp-fin) != 0'TCP SYN/FIN flags only
tcpdump -i eth0 -A port 80Show HTTP payload in ASCII
DNS & HTTP Diagnostics
dig +trace example.comTrace full DNS delegation from root
nslookup example.comSimple DNS lookup (interactive mode available)
host example.comQuick DNS lookup with concise output
curl -v https://example.com 2>&1 | grep -E '^(> |< )'Show HTTP request/response headers only
nc -zv host 443Test if TCP port is open (netcat zero-I/O mode)
tcptraceroute host 80Trace path to a specific TCP port
Pro Tip: Troubleshoot from bottom up: Physical → Data Link (ARP) → Network (ping/IP) → Transport (port check) → Application. Also: mtr combines ping + traceroute in one tool — use it!