17.7. Diagnosing Network Problems
Diagnosis is the chapter's model run in order: link, address, route, neighbor, name, service, path, evidence. Each layer can fail alone, and the failure's location - not its symptom - decides which configuration to touch. Figure 17.4 fixes the order; the four subsections walk it with real captures, ending in deliberately provoked failures that show what the evidence looks like.
Figure 17.4. A conceptual order for turning "the network is broken" into a located fault. Each step's question isolates one layer; a step that passes sends the investigation down the ladder, and the capture at the bottom settles whatever the steps above could not.
17.7.1. Checking Link State, Addresses, Routes, and Neighbors
The four foundation checks take under a minute together, and the practice machine - now carrying three active links - shows each one answering. The brief link inventory first, as john on netlab1:
$ ip -br link show
lo UNKNOWN 00:00:00:00:00:00 <LOOPBACK,UP,LOWER_UP>
eth0 UP 52:54:00:f4:e6:21 <BROADCAST,MULTICAST,UP,LOWER_UP>
eth1 UP 52:54:00:0b:5b:b6 <BROADCAST,MULTICAST,UP,LOWER_UP>
wlan0 UP 02:00:00:00:00:00 <BROADCAST,MULTICAST,UP,LOWER_UP>
wlan1 UP 4a:40:bb:21:10:57 <BROADCAST,MULTICAST,UP,LOWER_UP>
hwsim0 DOWN 12:00:00:00:00:00 <BROADCAST,MULTICAST>
Five links, all UP with carrier except the loopback and hwsim0 -
the software radios' monitor device, DOWN by design. Two facts worth
noticing: wlan0 carries the randomized MAC from Section 17.4.2, and
wlan1 still runs the practice access point. A link in NO-CARRIER
state, or absent entirely (driver not loaded, udev renamed it,
ip link set … down left it administratively down), stops the ladder
right here. Addresses, in the detailed form this time, for eth1:
$ ip addr show eth1
3: eth1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000
link/ether 52:54:00:0b:5b:b6 brd ff:ff:ff:ff:ff:ff
altname enp0s6
altname ens6
altname enx5254000b5bb6
inet 192.168.217.20/24 brd 192.168.217.255 scope global noprefixroute eth1
valid_lft forever preferred_lft forever
inet6 2001:db8:17:1::20/64 scope global noprefixroute
valid_lft forever preferred_lft forever
inet6 fe80::dc1f:7a0a:65cc:6d0d/64 scope link noprefixroute
valid_lft forever preferred_lft forever
The lab-dual configuration from Section 17.5.4, with its broadcast
address shown and forever lifetimes marking both addresses static.
The address check is where an expired SLAAC address, a missing DHCP
lease, or a flush that outlived its owner becomes visible. Routes, in
full, because this machine now has an interesting table:
$ ip route show
default via 192.168.121.1 dev eth0
default via 10.17.0.1 dev wlan0 proto dhcp src 10.17.0.144 metric 600
10.17.0.0/24 dev wlan1 proto kernel scope link src 10.17.0.1
10.17.0.0/24 dev wlan0 proto kernel scope link src 10.17.0.144 metric 600
192.168.121.0/24 dev eth0 proto kernel scope link src 192.168.121.24
192.168.217.0/24 dev eth1 proto kernel scope link src 192.168.217.20 metric 500
198.51.100.0/24 via 192.168.217.2 dev eth1 proto static metric 500
Two default routes, ranked: eth0's carries no metric shown, meaning
metric 0, and the Wi-Fi DHCP gateway sits at 600 - the wireless default
loses to the wired one, and deleting either leaves the other working.
proto dhcp and proto static mark the backends that created their
entries; proto kernel the address-derived ones. This is the table to
read whenever "traffic goes out the wrong interface" is the complaint -
ip route get ADDRESS names the winner for any destination. Warm the
neighbor cache with one ping, then read it:
$ ping -c 1 -W 1 192.168.217.2
PING 192.168.217.2 (192.168.217.2) 56(84) bytes of data.
64 bytes from 192.168.217.2: icmp_seq=1 ttl=64 time=0.519 ms
--- 192.168.217.2 ping statistics ---
1 packets transmitted, 1 received, 0% packet loss, time 0ms
rtt min/avg/max/mdev = 0.519/0.519/0.519/0.000 ms
$ ip neigh show dev eth1
192.168.217.2 lladdr 52:54:00:e7:63:fb REACHABLE
fe80::5054:ff:fee7:63fb lladdr 52:54:00:e7:63:fb router REACHABLE
2001:db8:17:1::2 lladdr 52:54:00:e7:63:fb REACHABLE
One MAC behind three identities - router1's IPv4, its IPv6 global, and
its link-local with the router flag - all REACHABLE, the state only
recent confirmed traffic produces. A gateway stuck at INCOMPLETE or
FAILED here, while the link and address checks passed, is the
signature of a problem below IP: wrong VLAN, MAC filtering, or a
firewall dropping ARP. The four checks have now placed the fault
domain for any connectivity problem on this machine inside or outside
the host - the next three subsections chase it outward.
17.7.2. Separating DNS Failures from Connectivity Failures
"The network is down" divides into two diseases that share a symptom:
the name does not resolve, or the address is not reachable. Treat the
name as the suspect first, because it is the cheaper failure to
confirm. The lab's DNS works, so both sides of the comparison succeed -
the deliberately failing half comes from Section 17.6.4's world, where
corp.example was refused. Start with the resolving name:
$ getent ahosts router1.lab.example
2001:db8:17:1::2 STREAM router1.lab.example
2001:db8:17:1::2 DGRAM
2001:db8:17:1::2 RAW
192.168.217.2 STREAM
192.168.217.2 DGRAM
192.168.217.2 RAW
The name resolves to both families, IPv6 first per the selection rules of Section 17.5.3. Now the same lookup for a name that does not exist in the lab's DNS:
$ getent hosts missing.lab.example
The command prints nothing and exits with status 2 - getent's
"not found" - which in a script is distinguishable from a crash by
$?. Between those two outcomes the name layer is fully described. The
complementary test pins the path layer: reach an address that exists,
then one that does not, with no name involved:
$ ping -c 1 -W 1 192.168.217.2
PING 192.168.217.2 (192.168.217.2) 56(84) bytes of data.
64 bytes from 192.168.217.2: icmp_seq=1 ttl=64 time=0.362 ms
--- 192.168.217.2 ping statistics ---
1 packets transmitted, 1 received, 0% packet loss, time 0ms
rtt min/avg/max/mdev = 0.362/0.362/0.362/0.000 ms
$ ping -c 1 -W 1 192.168.217.99
PING 192.168.217.99 (192.168.217.99) 56(84) bytes of data.
--- 192.168.217.99 ping statistics ---
1 packets transmitted, 0 received, 100% packet loss, time 0ms
The second ping's empty reply section is the honest signature of an
unanswered address: no reply lines, no error - silence, then 100%
loss. The matrix of the two tests names the fault: name fails, IP
works - DNS (Section 17.6); name works, IP fails - routing or the
remote host; both fail - the foundation layers of Section 17.7.1; name
fails and the resolver itself answers - the split-DNS routing of
Section 17.6.4, not connectivity at all. On dual-stack machines the
matrix has one more row per family: ping -4 and ping -6 against
the same name (Section 17.5.4 ran both) separate "IPv6 is broken" from
"the host is down", and resolvectl query NAME adds the server's view
- which upstream answered, and with what.
17.7.3. Inspecting Listening Sockets and Testing Application Ports
When the path layer passes but an application will not answer, the
question becomes whether the service is listening at all - and on which
address. The practice target is a small web server on netlab1. Put its
one page in the workspace first, so the server has something to serve;
create index.html with this content:
<!doctype html>
<title>Network lab</title>
<p>netlab1 serves this page.</p>
Python's standard library includes a small teaching web server; run it as a transient service under john's identity, so the process and its files behave as a user-owned service would. One elevated command:
$ sudo systemd-run --unit=ch17-http --uid=john --gid=john --working-directory=/home/john/debian-handbook/network-basics /usr/bin/python3 -m http.server 8080
Running as unit: ch17-http.service; invocation ID: 763dcf4be8cf4296b760ddb0010dcaf3
The server is now running detached, as john, from the workspace, on
port 8080. Check the listening socket from netlab1 - the -p column
needs root, hence the single elevated form again:
$ sudo ss -ltnp "sport = :8080"
State Recv-Q Send-Q Local Address:Port Peer Address:PortProcess
LISTEN 0 5 0.0.0.0:8080 0.0.0.0:* users:(("python3",pid=6976,fd=3))
ss option |
Description |
|---|---|
-l |
Listening sockets only. |
-t / -u |
TCP / UDP sockets. |
-n |
Numeric addresses and ports, no name resolution. |
-p |
Show the process holding each socket (requires root). |
"sport = :PORT" |
Filter expression: sockets whose source port is PORT - the port a server listens on. |
The row is a complete answer: LISTEN state, backlog 5, bound to
0.0.0.0:8080 - all IPv4 interfaces - and held by python3, PID
6976. A server bound to 127.0.0.1:8080 would show that address
instead, and would be unreachable from other hosts despite listening
perfectly; a missing row means the service is not listening at all.
Test from the outside, which is the only honest test of reachability -
and the host change below is part of that test.
On router1, as an ordinary user:
$ curl -sS -m 3 http://192.168.217.20:8080/
<!doctype html>
<title>Network lab</title>
<p>netlab1 serves this page.</p>
The page itself came back - connection, request, response, and the right file, from a second machine.
curl option |
Description |
|---|---|
-s |
Silent: suppress the progress meter and error messages. |
-S |
Show errors even though -s is set, so failures stay visible. |
-m SECONDS |
Give up on the whole transfer after SECONDS. |
-L |
Follow HTTP redirects to their final destination. |
The one-liner port test answers the same question with no HTTP involved, still on router1:
$ nc -vz 192.168.217.20 8080
192.168.217.20: inverse host lookup failed: Unknown host
(UNKNOWN) [192.168.217.20] 8080 (http-alt) open
nc option |
Description |
|---|---|
-v |
Verbose: print the target address and the result. |
-z |
Connect only: send no data and close immediately. |
-w SECONDS |
Abandon the connection attempt after SECONDS. |
open is the verdict. The first line is noise with a lesson: netcat
tried to reverse-resolve the address, router1's resolver has no PTR
record for it, and the probe proceeded with (UNKNOWN) anyway - a
cosmetic message, not a failure. When this pair of tests disagrees -
listening locally, closed remotely - the gap is a firewall
(Chapter 18), a bind address, or the wrong port.
Stop the practice server; the command is silent:
$ sudo systemctl stop ch17-http.service
17.7.4. Path MTU, Packet Loss, and Packet Captures
The last three faults hide from every check above: links are up,
routes are right, small probes answer - and large transfers hang. The
cause is size. Every hop has a maximum transmission unit, and IPv4
routers that must fragment a too-large packet normally signal it back
with ICMP "fragmentation needed"; paths that block that ICMP make the
sender wait forever. Probe deliberately: a full-sized packet with the
Don't-Fragment bit set, -M do, payload 1472 plus the 28 bytes of
IP and ICMP headers - exactly 1500:
$ ping -M do -s 1472 -c 2 192.168.217.2
PING 192.168.217.2 (192.168.217.2) 1472(1500) bytes of data.
1480 bytes from 192.168.217.2: icmp_seq=1 ttl=64 time=0.420 ms
1480 bytes from 192.168.217.2: icmp_seq=2 ttl=64 time=0.264 ms
--- 192.168.217.2 ping statistics ---
2 packets transmitted, 2 received, 0% packet loss, time 1026ms
rtt min/avg/max/mdev = 0.264/0.342/0.420/0.078 ms
One byte more - 1501 - cannot fit, and the kernel says so locally:
$ ping -M do -s 1473 -c 1 192.168.217.2
PING 192.168.217.2 (192.168.217.2) 1473(1501) bytes of data.
ping: sendmsg: Message too long
--- 192.168.217.2 ping statistics ---
1 packets transmitted, 0 received, +1 errors, 100% packet loss, time 0ms
Message too long from sendmsg is the local interface refusing the
oversized frame - the useful boundary case, because it proves the
probe itself works. The interesting real-world failure is subtler: the
first hop accepts the packet and a later hop cannot, and its ICMP
feedback never arrives. That failure shows up as small-pings-work,
large-transfers-stall, and tracepath diagnoses it by probing with
decreasing sizes:
$ tracepath -n 192.168.217.2
1?: [LOCALHOST] pmtu 1500
1: 192.168.217.2 0.441ms reached
1: 192.168.217.2 0.293ms reached
Resume: pmtu 1500 hops 1 back 1
-n skips name lookups; the resume line reports the discovered path
MTU - 1500 here, with one hop. On a broken path, tracepath reports
the smaller MTU where the stall begins, and the fix is on the tunnel or
link that shrank it - the VPN cases are Chapter 19.
Loss is the other hidden fault, and mtr combines the traceroute and
the ping stream into one report, no root needed:
$ mtr -n -r -c 3 192.168.217.2
Start: 2026-11-21T10:28:14+0000
HOST: netlab1 Loss% Snt Last Avg Best Wrst StDev
1.|-- 192.168.217.2 0.0% 3 0.6 0.5 0.4 0.6 0.1
mtr option |
Description |
|---|---|
-r |
Report mode: print a summary table instead of the live display. |
-c COUNT |
Stop after COUNT rounds of probes. |
-n |
Keep hop addresses numeric instead of resolving names. |
Loss% per hop is
the diagnostic: loss that begins at a hop and persists beyond it
indicts that hop; loss at one hop only, with later hops clean, is
usually ICMP rate-limiting, not real drops. Both statements become
checkable by inducing the fault. router1's practice interface can
drop traffic on demand with the kernel's netem queueing discipline.
Warning: The next command makes router1 drop every packet on its practice interface. It runs on
eth1only - router1's own access path is its separate primary interface, and the disruption is removed two commands later.
On router1, as root:
# tc qdisc add dev eth1 root netem loss 100%
tc form |
Description |
|---|---|
tc qdisc add dev IF root netem loss P% |
Attach netem at the device's root, dropping P% of transmitted packets. |
tc qdisc del dev IF root |
Remove the attached discipline, restoring normal transmission. |
The command is silent. From netlab1, the loss is total:
$ ping -c 3 -W 1 192.168.217.2
PING 192.168.217.2 (192.168.217.2) 56(84) bytes of data.
--- 192.168.217.2 ping statistics ---
3 packets transmitted, 0 received, 100% packet loss, time 2040ms
No reply lines, no error - the packets left netlab1 and never came
back, which from the client is indistinguishable from a dead host.
An mtr report at this moment would show 100% at the first hop.
Remove the discipline - still on router1, as root:
# tc qdisc del dev eth1 root
Also silent. The recovery check, back on netlab1:
$ ping -c 2 -W 1 192.168.217.2
PING 192.168.217.2 (192.168.217.2) 56(84) bytes of data.
64 bytes from 192.168.217.2: icmp_seq=1 ttl=64 time=0.355 ms
64 bytes from 192.168.217.2: icmp_seq=2 ttl=64 time=0.312 ms
--- 192.168.217.2 ping statistics ---
2 packets transmitted, 2 received, 0% packet loss, time 1014ms
rtt min/avg/max/mdev = 0.312/0.333/0.355/0.021 ms
The induced fault is gone, and the two-command pattern - break it, watch the signature, fix it, watch recovery - is the cheapest way to learn what real failures look like before meeting them unsupervised.
When every layer checks out and the application still misbehaves, the
answer is in the packets themselves. tcpdump records what actually
crosses an interface; capturing to a file in the workspace keeps the
evidence and keeps it out of system directories. Run it as a transient
service so the capture proceeds in the background, from netlab1 with
one elevated command:
$ sudo systemd-run --unit=ch17-tcpdump --collect /usr/bin/tcpdump -i eth1 -nn -c 4 icmp -w /home/john/debian-handbook/network-basics/icmp.pcap
Running as unit: ch17-tcpdump.service; invocation ID: 64633873af0d42e98ceb51c21cce2697
tcpdump option |
Description |
|---|---|
-i IFACE |
Capture on one interface. |
-n |
Do not resolve host names; given twice, also skip port names. |
-c COUNT |
Stop after COUNT captured packets. |
-w FILE |
Write raw packets to FILE instead of printing them. |
-r FILE |
Read a saved capture back, with the same display options. |
The filter word icmp is a capture expression: only ICMP packets. The
capture runs detached; generate traffic for it to see, on netlab1:
$ ping -c 3 -W 1 192.168.217.2
PING 192.168.217.2 (192.168.217.2) 56(84) bytes of data.
64 bytes from 192.168.217.2: icmp_seq=1 ttl=64 time=0.502 ms
64 bytes from 192.168.217.2: icmp_seq=2 ttl=64 time=0.362 ms
64 bytes from 192.168.217.2: icmp_seq=3 ttl=64 time=0.352 ms
--- 192.168.217.2 ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 2044ms
rtt min/avg/max/mdev = 0.352/0.405/0.502/0.068 ms
Four packets later the capture stops itself (-c 4), and reading it
back prints the evidence:
$ sudo tcpdump -nn -r /home/john/debian-handbook/network-basics/icmp.pcap
reading from file /home/john/debian-handbook/network-basics/icmp.pcap, link-type EN10MB (Ethernet), snapshot length 262144
10:28:38.159517 IP 192.168.217.20 > 192.168.217.2: ICMP echo request, id 19, seq 1, length 64
10:28:38.160010 IP 192.168.217.2 > 192.168.217.20: ICMP echo reply, id 19, seq 1, length 64
10:28:39.179053 IP 192.168.217.20 > 192.168.217.2: ICMP echo request, id 19, seq 2, length 64
10:28:39.179396 IP 192.168.217.2 > 192.168.217.20: ICMP echo reply, id 19, seq 2, length 64
The banner line is the file's metadata; then request/reply pairs, half a
millisecond apart, with matching IDs and sequence numbers - a healthy
exchange in its entirety. The same tool settles the unhealthy
questions: requests with no replies name the direction of loss; an ARP
or Neighbor Solicitation storm names a link-layer problem; a DHCP
exchange that stops at DISCOVER names a server or relay failure
(Chapter 22 captures one); and a TCP handshake that
completes but immediately resets moves the fault past the network and
into the application. Remove the capture file when it has served its
purpose - sudo rm /home/john/debian-handbook/network-basics/icmp.pcap
- since it was written by root into john's workspace.
The chapter's practice state ends here. Take down the wireless profile, with one elevated command:
$ sudo nmcli connection down LabWifi
Connection 'LabWifi' successfully deactivated (D-Bus active path: /org/freedesktop/NetworkManager/ActiveConnection/6)
The practice radios exist only while the mac80211_hwsim module is
loaded, so they disappear at the next reboot; the wireless profile
remains saved on disk and can be removed with nmcli connection delete
once it is no longer wanted. The machines keep their primary interfaces,
their DNS, and their SSH paths - the property every exercise in this
chapter preserved on purpose. What sits between those paths and the
wider network is the subject of the next chapter: packet filtering and
firewalls, where the same disciplined-change pattern of Section 17.2.4
becomes a remote rollout with a timed rollback.