Network Troubleshooting Commands - CodeSwordsman

A full troubleshooting toolkit for connectivity, DNS, port usage, routing and packet capture, with practical ss, lsof, dig and tcpdump combinations for timeouts and refused connections.

iproute2 / iputils / bind-utils / tcpdumpUpdated 2026-10-3021 commands

Connectivity

Send 4 ICMP packets to check reachability and latency; failure is not proof of downtime

ping -c 4 example.com

Many hosts and firewalls drop ICMP by default; confirm with port tests.

Show the hop-by-hop path to find where packets start dropping

traceroute -n example.com

Continuous probing with per-hop loss summary, better than traceroute for link quality

mtr -rw -c 20 example.com

Quick check whether a target port accepts connections

telnet 10.0.0.12 3306

Port probe with timeout; succeeded means the TCP handshake completed

nc -vz -w 3 10.0.0.12 3306

DNS Resolution

Print the resolved records only for a fast answer check

dig +short api.example.com

Query a public resolver to compare with local results and spot cache issues

dig @8.8.8.8 api.example.com +short

Walk from the root to find authoritative gaps or stale caches

dig +trace api.example.com

Inspect local DNS settings; container failures often trace back to nameserver here

cat /etc/resolv.conf

Ports & Connections

List all listening TCP/UDP ports with processes to verify the service is bound

ss -tunlp

Summarize connections by state to spot TIME-WAIT buildup or backlog

ss -s

Show established connections to a specific target to verify pool size

ss -tn state established dst 10.0.0.12:3306

Find the process holding a port, useful for port conflicts

lsof -i:8080 -P -n

Fallback for systems without ss; output semantics are similar

netstat -anp | grep 8080

Capture & Analysis

Capture 50 packets on port 8080; -nn skips name resolution for speed

sudo tcpdump -i any -nn port 8080 -c 50

Save full packets to pcap for Wireshark analysis of handshakes and retransmits

sudo tcpdump -i eth0 -s 0 -w /tmp/app.pcap host 10.0.0.12

Read a pcap in ASCII to confirm whether HTTP requests arrived

sudo tcpdump -r /tmp/app.pcap -nn -A | less

Request with timeouts and verbose timings to isolate DNS, connect, TLS or response slowness

curl -v --connect-timeout 3 --max-time 10 https://api.example.com/health

Routing & Interfaces

Show which interface and gateway will be used for a destination

ip route get 8.8.8.8

Inspect the ARP table for same-subnet reachability and IP conflicts

ip neigh

Check link speed, duplex and state to rule out physical layer issues

ethtool eth0 | head -20

This website uses cookies to ensure you get the best experience on our website. Privacy Policy.