SkillPilotAI

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

QuestionWhat 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
Hop by hop: how far does the packet get?
  1. 1.Answers: since morning, no website opens anywhere in the office

  2. 2.Laptop 192.168.1.10 -> switch: OK

  3. 3.Switch -> router 192.168.1.1: OK

  4. 4.Router -> ISP: dropped

  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

MethodStarts atBest whenDownside
Bottom-upL1: cable, link light, then IP, port, appYou doubt the hardware or a cableSlow in a big network
Top-downL7: browser error, curl output, then downA user complains about one appMany steps if the cable is the issue
Divide and conquerL3 (middle): ping the gatewayGeneral case, fastest splitNeeds a good first guess of the middle
Divide and conquer decision
  1. 1.Ping the gateway 192.168.1.1 from the laptop

  2. 2.Reply OK: cable, switch and IP are fine

  3. 3.-> problem is beyond the gateway: check upper layers or the ISP side

  4. 4.Ping fails: problem is local (cable/Wi-Fi, switch, laptop IP settings)

  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

LayerWhat you checkWindowsLinux
L1 PhysicalLink light, interface up/downGet-NetAdapterip link
L2 Data linkWas the neighbour's MAC found?arp -aip neigh
L3 NetworkIP, path, routesipconfig, ping, tracert, route printip addr, ping, traceroute, ip route
L4 TransportIs the port open / listening?Test-NetConnection -Portnc -zv, ss -lnt
DNSDoes the name resolve correctly?nslookupdig, nslookup, getent hosts
L7 ApplicationThe whole HTTP conversationcurl -vcurl -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

PowerShell
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
Output
$ 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.
Terminal
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/
Output
$ 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

Terminal
# 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
Output
$ 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

Terminal
# 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
Output
$ 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

Terminal
# 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
Output
$ 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

Terminal
# 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/
Output
$ 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.
FaultSymptomTool that caught itFix
1 Interface downcurl (7), ping Network unreachableip link: state DOWNip link set eth0 up
2 Wrong IPping Network unreachableip addr: 192.168.37.10/24del wrong, add 192.168.73.10/24
3 Service stoppedping OK, Connection refusednc -zv + netstat -lntStart httpd on 8080
4 Wrong hosts entryTimeout to 192.168.73.30curl -v + getent hostsCorrect 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.