Sub topic 13
Using layers to narrow down network problems
This chapter assumes you know the four TCP/IP layers (link, internet, transport, application) and their OSI counterparts. It also assumes you can read a basic packet capture and run commands in a terminal.
Why layers help with faults
A network fault has many possible causes. The layered model lets you test one layer at a time and rule out whole groups of causes. A layer can only work if the layers below it work. A web page that loads proves that every lower layer is fine. A page that fails tells you little until you find the lowest layer that is broken.
There are two common strategies:
- Bottom-up: start at the link layer and move up until a test fails. This suits a new machine or a "nothing works" report.
- Top-down: start with the failing application and move down. This suits "one site is broken but others work."
A bottom-up checklist
Each step uses one tool and answers one question.
# Link layer: is the interface up, and does it have a carrier?
ip link show
# Link layer: has the gateway's MAC address been resolved (ARP)?
ip neigh show
# Internet layer: can we reach the default gateway, then a remote IP?
ping -c 3 192.0.2.1
ping -c 3 198.51.100.7
# Transport layer: does the server accept a TCP connection on port 443?
nc -zv example.com 443
# Application layer: DNS first, then the HTTP exchange itself
dig +short example.com
curl -v https://example.com/Replace the addresses with ones from your own network. Pinging an IP address, not a name, keeps DNS out of the internet-layer test.
Reading symptoms
| Symptom | Likely layer | Typical causes |
|---|---|---|
| Interface shows no carrier | Link | Unplugged cable, switch port down, Wi-Fi not associated |
| Gateway ARP entry is `FAILED` or `INCOMPLETE` | Link | Wrong VLAN, gateway down |
| Ping to gateway works, ping to remote IP times out | Internet | Missing route, wrong gateway, upstream outage |
| Ping by IP works, ping by name fails | Application (DNS) | Wrong resolver, DNS outage |
| `nc` reports "Connection refused" | Transport | Nothing listening on that port |
| `nc` hangs until timeout | Transport or below | Firewall silently dropping packets |
| TCP connects, `curl` shows a certificate error | Application (TLS) | Expired certificate, name mismatch |
| TCP connects, HTTP returns 500 | Application | Server-side bug |
"Refused" and "timed out" mean different things. A refusal means a TCP reset came back, so the host was reached and the port was closed. A timeout means no answer came back at all.
Confirming with a capture
When a tool's message is ambiguous, capture the traffic and see which layer's headers appear.
sudo tcpdump -nn -c 10 'host 198.51.100.7 and tcp port 443'What you see tells you where the problem is:
- Only
SYNpackets leaving, with no reply: the problem is a drop in the path or a firewall. - A
SYNfollowed byRST, ACK: the server is reachable and nothing is listening. - A completed handshake followed by a TLS alert: the problem is at the application layer.
Limits of the method
Layers blur in practice, as the previous chapters showed.
- ARP and ICMP do not fit one layer cleanly. A failed ping may be an ICMP filter and not a broken route, so confirm with a TCP test.
- A TLS failure can look like a transport fault, because the connection drops during the handshake.
- A faulty network card can corrupt frames and cause problems that look like higher-layer faults, such as slow transfers.
Exercise
A user reports that https://intranet.example loads for colleagues but not for them. ping 203.0.113.20 (the server's IP) succeeds, dig +short intranet.example returns nothing, and nc -zv 203.0.113.20 443 succeeds. Which layer is at fault, and what do you check next?
Show answer
The application layer, specifically DNS. The link, internet, and transport layers all work, since ping and the TCP connection to port 443 succeed. The name lookup fails, so check which resolver the user's machine uses, for example in /etc/resolv.conf, and compare it with a colleague's machine.