Troubleshooting method: layer by layer
Troubleshooting is a method, not a guess: first ask the right questions, then test the network layer by layer with the right tool until you find the exact place where it breaks. Restarting the router or changing DNS at random sometimes works, but nobody learns the real cause.
273.1 Why is it used?
- Story: a user says "the website is not opening" and a new engineer starts guessing: restart the router, change DNS.
- Sometimes it gets fixed, sometimes not, and the actual reason is never found.
- A method finds the faulty layer quickly and gives a fix you can explain and repeat.
273.2 First, 4 right questions
| Question | What to find out |
|---|---|
| What exactly fails? | One site or all? Which error is on the screen? |
| Since when? | Time and pattern |
| Who else is affected? | One user, one floor or everyone? |
| What changed? | Update, cable, config, password: many problems start right after a change |
- Step 1
1.Answers: since morning, no website opens anywhere in the office
- Step 2
2.Laptop 192.168.1.10 -> switch: OK
- Step 3
3.Switch -> router 192.168.1.1: OK
- Step 4
4.Router -> ISP: dropped
- Step 5
5.Conclusion: the problem is between the router and the ISP; no need to check the rest
273.3 Methods: bottom-up, top-down, divide and conquer
| Method | Starts at | Best when | Downside |
|---|---|---|---|
| Bottom-up | L1: cable, link light, then IP, port, app | You doubt the hardware or a cable | Slow in a big network |
| Top-down | L7: browser error, curl output, then down | A user complains about one app | Many steps if the cable is the issue |
| Divide and conquer | L3 (middle): ping the gateway | General case, fastest split | Needs a good first guess of the middle |
- Step 1
1.Ping the gateway 192.168.1.1 from the laptop
- Step 2
2.Reply OK: cable, switch and IP are fine
- Step 3
3.-> problem is beyond the gateway: check upper layers or the ISP side
- Step 4
4.Ping fails: problem is local (cable/Wi-Fi, switch, laptop IP settings)
- Step 5
5.-> check lower layers; do not blame the ISP or DNS server
Same logic as the Cisco troubleshooting guide: middle test passes -> go up, fails -> go down
273.4 Layer -> symptom -> tool
| Layer | What you check | Windows | Linux |
|---|---|---|---|
| L1 Physical | Link light, interface up/down | Get-NetAdapter | ip link |
| L2 Data link | Was the neighbour's MAC found? | arp -a | ip neigh |
| L3 Network | IP, path, routes | ipconfig, ping, tracert, route print | ip addr, ping, traceroute, ip route |
| L4 Transport | Is the port open / listening? | Test-NetConnection -Port | nc -zv, ss -lnt |
| DNS | Does the name resolve correctly? | nslookup | dig, nslookup, getent hosts |
| L7 Application | The whole HTTP conversation | curl -v | curl -v |
273.5 Two golden rules
- Write down every step and its result, so the team knows what has already been checked.
- Change one thing at a time, then test: change three settings together and you never know which one fixed it.
273.6 Practical 1: a quick layer check on Windows
ping -n 2 127.0.0.1ping -n 2 8.8.8.8Test-NetConnection 8.8.8.8 -Port 53 ` -InformationLevel Quietnslookup example.com 8.8.8.8$ ping -n 2 127.0.0.1Reply from 127.0.0.1: bytes=32 time=1ms TTL=128Reply from 127.0.0.1: bytes=32 time<1ms TTL=128 Packets: Sent = 2, Received = 2, Lost = 0 (0% loss),$ ping -n 2 8.8.8.8Reply from 8.8.8.8: bytes=32 time=19ms TTL=118Reply from 8.8.8.8: bytes=32 time=19ms TTL=118 Packets: Sent = 2, Received = 2, Lost = 0 (0% loss),$ Test-NetConnection 8.8.8.8 -Port 53 -InformationLevel QuietTrue$ nslookup example.com 8.8.8.8Server: dns.googleAddress: 8.8.8.8Name: example.comAddresses: 2606:4700:90c5:72db:f2ef:0:ef6b:ff98 172.66.147.243 104.20.23.154- Loopback 127.0.0.1 OK = the PC's own TCP/IP stack works.
- 8.8.8.8 in 19 ms = layer 3 is OK up to the internet.
- Port 53 test prints True (L4) and nslookup resolves example.com (DNS).
273.7 Practical 2: the Docker lab baseline
- Isolated lab: client 192.168.73.10, web server 192.168.73.20 on port 8080.
- Record a healthy baseline first; after every fault compare with it.
ip link show eth0ping -c 2 -W 1 192.168.73.20nc -zv -w 2 192.168.73.20 8080curl -s http://web.lab.local:8080/$ ip link show eth02: eth0@if148: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP$ ping -c 2 -W 1 192.168.73.2064 bytes from 192.168.73.20: icmp_seq=1 ttl=64 time=0.172 ms64 bytes from 192.168.73.20: icmp_seq=2 ttl=64 time=0.092 ms2 packets transmitted, 2 received, 0% packet loss, time 1009ms$ nc -zv -w 2 192.168.73.20 8080Connection to 192.168.73.20 8080 port [tcp/http-alt] succeeded!$ curl -s http://web.lab.local:8080/Hello from web (SiteA lab)273.8 Fault 1 (L1/L2): interface down
# fault 1: eth0 is down on the clientcurl -sS --connect-timeout 3 \ http://web.lab.local:8080/ip link show eth0ping -c 2 -W 1 192.168.73.20# fixip link set eth0 upping -c 2 -W 1 192.168.73.20$ curl -sS --connect-timeout 3 http://web.lab.local:8080/curl: (7) Failed to connect to web.lab.local port 8080 after 0 ms: Couldn't connect to server$ ip link show eth02: eth0@if148: <BROADCAST,MULTICAST> mtu 1500 qdisc noqueue state DOWN$ ping -c 2 -W 1 192.168.73.20ping: connect: Network unreachable$ ip link set eth0 up$ ip link show eth02: eth0@if148: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP$ ping -c 2 -W 1 192.168.73.2064 bytes from 192.168.73.20: icmp_seq=1 ttl=64 time=0.305 ms64 bytes from 192.168.73.20: icmp_seq=2 ttl=64 time=0.117 ms- curl only says it could not connect, so go bottom-up: state DOWN and the UP flag is missing.
273.9 Fault 2 (L3): wrong IP / subnet
# fault 2: wrong IP on the clientip -4 addr show eth0ping -c 2 -W 1 192.168.73.20# fix: put the correct address backip addr del 192.168.37.10/24 dev eth0ip addr add 192.168.73.10/24 dev eth0ping -c 2 -W 1 192.168.73.20$ ip -4 addr show eth02: eth0@if148: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP inet 192.168.37.10/24 scope global eth0$ ping -c 2 -W 1 192.168.73.20ping: connect: Network unreachable$ ip addr del 192.168.37.10/24 dev eth0$ ip addr add 192.168.73.10/24 dev eth0$ ip -4 addr show eth0 inet 192.168.73.10/24 scope global eth0$ ping -c 2 -W 1 192.168.73.2064 bytes from 192.168.73.20: icmp_seq=1 ttl=64 time=0.195 ms2 packets transmitted, 2 received, 0% packet loss, time 1012ms- Interface is UP, but 192.168.37.10/24 is a different network from 192.168.73.0/24, so there is no route to the server.
273.10 Fault 3 (L4): service stopped
# fault 3: web service stoppedping -c 2 -W 1 192.168.73.20nc -zv -w 2 192.168.73.20 8080netstat -lnt # on web# fix: start httpd again (on web)httpd -f -p 8080 -h /wwwnc -zv -w 2 192.168.73.20 8080$ ping -c 2 -W 1 192.168.73.2064 bytes from 192.168.73.20: icmp_seq=1 ttl=64 time=0.111 ms64 bytes from 192.168.73.20: icmp_seq=2 ttl=64 time=0.130 ms2 packets transmitted, 2 received, 0% packet loss, time 1021ms$ nc -zv -w 2 192.168.73.20 8080nc: connect to 192.168.73.20 port 8080 (tcp) failed: Connection refused[web]$ netstat -lntProto Recv-Q Send-Q Local Address Foreign Address Statetcp 0 0 127.0.0.11:45155 0.0.0.0:* LISTEN[web]$ httpd -f -p 8080 -h /www[web]$ netstat -lnttcp 0 0 127.0.0.11:45155 0.0.0.0:* LISTENtcp 0 0 :::8080 :::* LISTEN$ nc -zv -w 2 192.168.73.20 8080Connection to 192.168.73.20 8080 port [tcp/http-alt] succeeded!- Ping works, so L1-L3 are fine; Connection refused + no LISTEN on 8080 = L4, the service is not running.
273.11 Fault 4 (DNS / hosts): wrong address
# fault 4: wrong hosts entry on the clientcurl -v --connect-timeout 3 \ http://web.lab.local:8080/getent hosts web.lab.local# fix: 192.168.73.20 web.lab.localgetent hosts web.lab.localcurl -v http://web.lab.local:8080/$ curl -v --connect-timeout 3 http://web.lab.local:8080/* Host web.lab.local:8080 was resolved.* IPv4: 192.168.73.30* Trying 192.168.73.30:8080...* Failed to connect to web.lab.local port 8080 after 3002 ms: Timeout was reachedcurl: (28) Failed to connect to web.lab.local port 8080 after 3002 ms: Timeout was reached$ getent hosts web.lab.local192.168.73.30 web.lab.local web.lab.local$ getent hosts web.lab.local192.168.73.20 web.lab.local web.lab.local$ curl -v http://web.lab.local:8080/* IPv4: 192.168.73.20* Connected to web.lab.local (192.168.73.20) port 8080> GET / HTTP/1.1< HTTP/1.1 200 OKHello from web (SiteA lab)- nc to the IP is fine, but the name resolves to 192.168.73.30 instead of .20: a wrong hosts file entry.
- If the same mistake sits on a DNS server, catch it with nslookup or dig.
| Fault | Symptom | Tool that caught it | Fix |
|---|---|---|---|
| 1 Interface down | curl (7), ping Network unreachable | ip link: state DOWN | ip link set eth0 up |
| 2 Wrong IP | ping Network unreachable | ip addr: 192.168.37.10/24 | del wrong, add 192.168.73.10/24 |
| 3 Service stopped | ping OK, Connection refused | nc -zv + netstat -lnt | Start httpd on 8080 |
| 4 Wrong hosts entry | Timeout to 192.168.73.30 | curl -v + getent hosts | Correct the entry to .20 |
273.12 Common mistakes
- Myth: ping fails = server down. Many servers and firewalls block ICMP; also run a port test and curl.
- Ping OK but port refused: the problem is L4/application, no service listening, not the network.
- Changing several settings at once and not writing anything down.
- Blaming the ISP or DNS when even the gateway ping fails.
273.13 Interview tips
- Define the problem first: what fails, since when, who is affected, what changed.
- Choose a method: bottom-up for hardware doubt, top-down for an app complaint, otherwise divide and conquer with a gateway ping.
- Name the right tool per layer: ip link, ping, nc, nslookup/dig, curl -v.
- End with: one change at a time and document every step.