Reference notes.
A systematic approach to diagnosing network issues using command-line tools. Work from the bottom of the stack upwards (this workflow uses a practical 5-layer TCP/IP view, collapsing OSI Model Layers 5–7 into Application).
Troubleshooting Methodology
- Physical layer - Cable connected? Link light on?
- Data link - Interface up? MAC address visible?
- Network - IP configured? Can ping gateway?
- Transport - Port open? Service listening?
- Application - Service responding? Correct response?
Essential Tools
ping
Test basic connectivity with ICMP echo requests.
No response? Check: IP config, gateway, firewall rules, ICMP blocked.
traceroute / tracepath / mtr
Show the path packets take to a destination, with latency at each hop.
traceroute- Traditional, may need roottracepath- No root requiredmtr- Combined ping + traceroute, best for diagnosing packet loss
* * * in output indicates filtered/dropped packets at that hop.
ss / netstat / lsof
View socket statistics — listening ports and established connections. On Linux, prefer ss (netstat from net-tools is deprecated).
Linux (ss -tulnp):
| Flag | Meaning |
|---|---|
-t | TCP |
-u | UDP |
-l | Listening |
-n | Numeric (no DNS) |
-p | Show owning process (may require sudo) |
macOS / BSD: BSD netstat uses different flags (e.g., netstat -anv -p tcp) and does not accept Linux’s -tulnp. Use lsof to map listening ports to processes:
sudo lsof -iTCP -sTCP:LISTEN -nPip
Interface and route management on Linux.
ip addr- Show IP addressesip route- Show routing tableip neigh- Show ARP tableip link- Show interface status
tcpdump
Capture and analyse packets on an interface. Filter by host, port, protocol. Save to .pcap for analysis in Wireshark.
Wireshark
GUI packet analysis. Useful filters:
ip.addr == 192.168.1.1tcp.port == 443http.requestdnstcp.analysis.retransmission
nmap
Port scanning and host discovery.
- Quick scan:
nmap <host> - Service detection:
nmap -sV <host> - Ping sweep:
nmap -sn <subnet>
nc (netcat)
Test TCP/UDP connectivity. Check if ports are open, send/receive data.
dig / nslookup
DNS queries. See DNS for detailed usage.
curl
HTTP testing — check responses, headers, timing, and TLS handshakes. Supports HTTP/3 via --http3 (with fallback) or --http3-only (strict), provided curl is built with QUIC support (such as ngtcp2, quiche, or OpenSSL QUIC).
iperf3
Bandwidth testing between two endpoints. Run server on one end, client on the other.
termshark
TUI (terminal UI) alternative to Wireshark. Useful for packet analysis on remote servers without a GUI. Built on tshark.
Quick Diagnostics Checklist
- Check interface status
- Check IP configuration
- Check default route
- Ping gateway
- Ping external IP (e.g., 8.8.8.8)
- Test DNS resolution
- Check listening services
- Check firewall rules
Common Issues and Solutions
| Symptom | Likely Cause | Check |
|---|---|---|
| No link light | Cable/port issue | Physical connection |
| No IP address | DHCP failure | DHCP client, server |
| Can’t ping gateway | IP config, gateway down | Routes, ARP |
| Can ping IP, not DNS | DNS misconfiguration | Resolver config, dig |
| Connection refused | Service not running, bound only to 127.0.0.1, or firewall REJECT | ss -tlnp (Linux) / lsof, service status, firewall rules |
| Connection timeout | Firewall dropping (DROP), routing blackhole | Firewall rules, tcpdump, mtr |
| Small packets work, large transfers stall | MTU mismatch / Path MTU Discovery (PMTUD) blackhole | ping -M do -s 1472 <host> (Linux) / ping -D -s 1472 <host> (macOS) |
| Slow connection | Congestion, packet loss | mtr, iperf3 |
| Intermittent issues | Flapping, duplex mismatch | ethtool, dmesg |