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

  1. Physical layer - Cable connected? Link light on?
  2. Data link - Interface up? MAC address visible?
  3. Network - IP configured? Can ping gateway?
  4. Transport - Port open? Service listening?
  5. 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 root
  • tracepath - No root required
  • mtr - 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):

FlagMeaning
-tTCP
-uUDP
-lListening
-nNumeric (no DNS)
-pShow 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 -nP

ip

Interface and route management on Linux.

  • ip addr - Show IP addresses
  • ip route - Show routing table
  • ip neigh - Show ARP table
  • ip 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.1
  • tcp.port == 443
  • http.request
  • dns
  • tcp.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

  1. Check interface status
  2. Check IP configuration
  3. Check default route
  4. Ping gateway
  5. Ping external IP (e.g., 8.8.8.8)
  6. Test DNS resolution
  7. Check listening services
  8. Check firewall rules

Common Issues and Solutions

SymptomLikely CauseCheck
No link lightCable/port issuePhysical connection
No IP addressDHCP failureDHCP client, server
Can’t ping gatewayIP config, gateway downRoutes, ARP
Can ping IP, not DNSDNS misconfigurationResolver config, dig
Connection refusedService not running, bound only to 127.0.0.1, or firewall REJECTss -tlnp (Linux) / lsof, service status, firewall rules
Connection timeoutFirewall dropping (DROP), routing blackholeFirewall rules, tcpdump, mtr
Small packets work, large transfers stallMTU mismatch / Path MTU Discovery (PMTUD) blackholeping -M do -s 1472 <host> (Linux) / ping -D -s 1472 <host> (macOS)
Slow connectionCongestion, packet lossmtr, iperf3
Intermittent issuesFlapping, duplex mismatchethtool, dmesg

See Also

  • OSI Model — Layer-by-layer mental model for triage
  • TCP — Retransmissions, window issues, and TIME_WAIT diagnostics
  • DNS — dig/nslookup and common resolution failures
  • Firewalls — Diagnosing rules that drop or reset traffic
  • Routing — Routing-table issues, asymmetric paths, blackholes

References