Network troubleshooting: follow the packet
Test from DNS to the application, compare refused and timed-out connections, and capture packets at a known boundary.
By the end of this lesson you'll be able to
0 of 3 completeVerified lab: two temporary Nginx containers and an Alpine client produced a successful HTTP response, a
refused connection, a firewall-drop timeout, and a real tcpdump capture. The output is saved in the lab folder.
The script removes its containers and Docker network on exit.
Cloud lab: none. No AWS resources were created.
When a page stops loading, restarting the service is the first reaction. It can hide the evidence without fixing the path. A disciplined check follows the request from name lookup to the listening process, and stops where the first check fails. A packet capture confirms what crossed one interface. In this lesson, you will compare common TCP errors and use a short capture to narrow the fault.
A layer-by-layer method
Write down the source, destination, port, protocol, and time. Then test in order:
- DNS: does the client resolve the intended name?
- Route: does the machine have a next hop for that address?
- TCP: does the destination port accept a connection?
- TLS and HTTP: is the certificate valid, and what status does the server return?
- Application: do logs show the request and its dependency calls?
Each check proves only that boundary. A successful DNS lookup does not prove the route works. A successful TCP connection does not prove the application can serve the request.
Packet capture with tcpdump
tcpdump prints packets seen on one interface. Choose the interface and filter narrowly:
tcpdump -i eth0 -nn -c 4 'tcp port 80'
-i selects an interface, -nn keeps addresses and ports numeric, and -c stops after a packet count. A client
capture can show a SYN leaving. A server capture can show whether it arrived and whether a reply left. A capture
does not reveal packets on interfaces you did not inspect, and payloads may contain sensitive data. Avoid writing
captures to shared locations.
Real broken scenarios
The lab produced different responses for a closed port and a dropped port:
$ nc -zvw 2 server 8081 (closed port) nc: connect to server (172.19.0.2) port 8081 (tcp) failed: Connection refused $ nc -zvw 2 server 8082 (firewall drop) nc: connect to server (172.19.0.2) port 8082 (tcp) timed out: Operation in progress
Refused means something returned a reset; check the listener, bind address, or an explicit reject rule. A timeout means no answer arrived by the deadline; check routes and silent drops. Neither message alone identifies the exact device. Compare captures at both ends before changing firewall rules.
Find the first failing boundary
Run the disposable lab: make one working HTTP request, compare a closed port with a filtered port, then capture the TCP handshake. The cleanup trap removes every container and network.
A real HTTP response, distinct TCP errors, and a four-packet captureReveal one safe solution
bash devops-academy-tools/networking-lab/12-capture.sh
Read the output from top to bottom. Notice that the closed port resets quickly, while the firewall drop returns no answer before the timeout.
Try it yourself
0 of 4 steps doneRun each task in your own account or terminal, then tick it off.
Quick check
A TCP connection is refused immediately. What should you check first?
Official reading for this lesson
Or get every quiz answer right and it completes itself.
Something unclear, wrong or out of date in this lesson? Tell me, and I'll fix it.