TExcelTAD
Home › Computer Networking › Network Troubleshooting

Network Troubleshooting

"The network is down" can mean a hundred different things. Good troubleshooters don't guess: they follow a method, test one layer at a time, and let evidence narrow the problem down. This lesson pulls together the tools from the whole course into a repeatable process.

A methodology

  1. Define the problem precisely. Who is affected (one user, a floor, everyone)? What exactly fails (all sites, one app, only large downloads)? Since when? What changed?
  2. Work through the layers, usually bottom-up: link → IP → routing → DNS → transport → application. (Experienced engineers sometimes start in the middle, with ping, and go up or down from there: "divide and conquer".)
  3. Form a hypothesis, test it, and record results. Change one thing at a time.
  4. Fix, verify, and document the cause, so the next person (or future you) is faster.

The toolbox, by layer

Question Tool (Linux / macOS / Windows)
Is the link up? Speed/duplex? ip link, ethtool eth0 / ifconfig / Get-NetAdapter
Do I have an address, mask, gateway? ip addr, ip route / ipconfig /all
Can I reach the gateway? ping 192.168.1.1
Is the gateway's MAC resolved? ip neigh / arp -a
Can I reach the Internet by IP? ping 1.1.1.1
Where does the path break? traceroute, mtr / tracert
Does DNS work? dig, nslookup, resolvectl status
Is the port open? nc -vz host 443, Test-NetConnection host -Port 443
Does the application answer? curl -v, openssl s_client
What's actually on the wire? tcpdump, Wireshark

Bottom-up diagnosis as code

Here is the methodology as a function. It takes the results of the tests above and stops at the first failing layer, which is where to look:

python · try it yourself
CHECKS = [
    ("link",        "link light / ip link shows UP",           "cable, port, Wi-Fi association"),
    ("address",     "has a valid IP (not 169.254.x.x)",        "DHCP server, VLAN, DHCP relay"),
    ("gateway",     "ping default gateway",                     "subnet mask, gateway address, ARP"),
    ("internet_ip", "ping 1.1.1.1",                             "router, NAT, ISP, firewall"),
    ("dns",         "dig example.com returns an address",       "resolver settings, DNS server, firewall on 53"),
    ("port",        "nc -vz server 443 succeeds",               "service not listening, firewall, security group"),
    ("app",         "curl -v returns 200",                      "application logs, TLS certificate, proxy"),
]

def diagnose(results):
    for key, test, causes in CHECKS:
        if not results.get(key, False):
            return f"FAILS at '{key}': {test}  ->  check {causes}"
        print(f"  ok   {key:<11} {test}")
    return "all layers OK: the problem is probably intermittent or user-specific"

cases = {
    "laptop shows 169.254.10.20": {"link": True, "address": False},
    "sites fail, ping 1.1.1.1 works": {"link": True, "address": True, "gateway": True,
                                       "internet_ip": True, "dns": False},
    "only the new API is down": {"link": True, "address": True, "gateway": True,
                                 "internet_ip": True, "dns": True, "port": False},
}
for symptom, results in cases.items():
    print(symptom)
    print("  " + diagnose(results))
laptop shows 169.254.10.20
  ok   link        link light / ip link shows UP
  FAILS at 'address': has a valid IP (not 169.254.x.x)  ->  check DHCP server, VLAN, DHCP relay
sites fail, ping 1.1.1.1 works
  ok   link        link light / ip link shows UP
  ok   address     has a valid IP (not 169.254.x.x)
  ok   gateway     ping default gateway
  ok   internet_ip ping 1.1.1.1
  FAILS at 'dns': dig example.com returns an address  ->  check resolver settings, DNS server, firewall on 53
only the new API is down
  ok   link        link light / ip link shows UP
  ok   address     has a valid IP (not 169.254.x.x)
  ok   gateway     ping default gateway
  ok   internet_ip ping 1.1.1.1
  ok   dns         dig example.com returns an address
  FAILS at 'port': nc -vz server 443 succeeds  ->  check service not listening, firewall, security group

"Websites don't open but ping 1.1.1.1 works" is one of the most common tickets of all, and it's almost always DNS.

Reading ping output

python · try it yourself
import re

ping_output = """\
64 bytes from 10.0.0.1: icmp_seq=1 ttl=64 time=0.84 ms
64 bytes from 10.0.0.1: icmp_seq=2 ttl=64 time=0.91 ms
64 bytes from 10.0.0.1: icmp_seq=4 ttl=64 time=120.5 ms
64 bytes from 10.0.0.1: icmp_seq=5 ttl=64 time=0.88 ms
64 bytes from 10.0.0.1: icmp_seq=7 ttl=64 time=0.95 ms
--- 10.0.0.1 ping statistics ---
8 packets transmitted, 5 received, 37.5% packet loss, time 7010ms
"""

seqs = [int(s) for s in re.findall(r"icmp_seq=(\d+)", ping_output)]
times = [float(t) for t in re.findall(r"time=([\d.]+) ms", ping_output)]
sent = int(re.search(r"(\d+) packets transmitted", ping_output).group(1))

missing = sorted(set(range(1, sent + 1)) - set(seqs))
print("missing replies:", missing)
print(f"loss: {100 * (sent - len(seqs)) / sent:.1f}%")
print(f"median RTT {sorted(times)[len(times) // 2]} ms, worst {max(times)} ms")
spikes = [s for s, t in zip(seqs, times) if t > 10 * min(times)]
print("latency spikes at seq:", spikes)
missing replies: [3, 6, 8]
loss: 37.5%
median RTT 0.91 ms, worst 120.5 ms
latency spikes at seq: [4]

Loss and spikes to a gateway on the local LAN point to layer 1/2: a bad cable, Wi-Fi interference, or an overloaded switch port.

Finding the bad hop in a traceroute

A latency jump that persists for all later hops shows where the delay is added. A jump at one hop only, with normal values after it, is usually just a router that answers ICMP slowly (it deprioritises traffic addressed to itself) and is harmless:

python · try it yourself
trace = """\
 1  192.168.1.1     1.1 ms
 2  100.64.0.1      8.9 ms
 3  203.0.113.9     9.6 ms
 4  198.51.100.30  95.0 ms
 5  198.51.100.77  11.2 ms
 6  192.0.2.140    84.3 ms
 7  192.0.2.141    85.1 ms
 8  93.184.215.14  86.0 ms
"""

hops = []
for line in trace.splitlines():
    num, ip, ms, _ = line.split()
    hops.append((int(num), ip, float(ms)))

for i in range(1, len(hops)):
    num, ip, ms = hops[i]
    jump = ms - hops[i - 1][2]
    if jump > 30:
        later = [h[2] for h in hops[i + 1:]]
        persists = bool(later) and min(later) > hops[i - 1][2] + 30
        verdict = "persists to the destination: real delay starts here" if persists else \
                  "later hops are fast again: just slow ICMP replies, ignore"
        print(f"hop {num} ({ip}) +{jump:.1f} ms -> {verdict}")
hop 4 (198.51.100.30) +85.4 ms -> later hops are fast again: just slow ICMP replies, ignore
hop 6 (192.0.2.140) +73.1 ms -> persists to the destination: real delay starts here

Hop 6's jump of about 73 ms carries through to the destination, so the extra latency is introduced between hops 5 and 6: often an intercontinental link, or congestion at a peering point.

Classic problems and their signatures

Symptom Likely cause Confirm with
Address 169.254.x.x DHCP failed ip addr, DHCP server logs
Can ping by IP, not by name DNS dig, resolvectl status
Small pages load, big downloads/VPN hang MTU / blocked ICMP "fragmentation needed" ping -M do -s 1472 host
Works for some hosts on the subnet, not others wrong subnet mask on one side, duplicate IP ip addr, arping
"Connection refused" nothing listening on that port ss -tlnp on the server
"Connection timed out" firewall dropping, routing, host down traceroute -T -p 443, firewall logs
Slow, with retransmissions in captures packet loss, duplex mismatch, Wi-Fi mtr, ethtool, Wireshark "TCP Analysis"
Certificate errors expired cert, wrong name, missing intermediate openssl s_client -showcerts
bash
ping -M do -s 1472 -c 2 10.20.0.15

Sample output (through a VPN with a smaller MTU):

text
PING 10.20.0.15 (10.20.0.15) 1472(1500) bytes of data.
ping: local error: message too long, mtu=1420
ping: local error: message too long, mtu=1420

-M do sets the Don't Fragment bit and -s 1472 makes a 1500-byte packet (1472 + 8 + 20), which tells you exactly what fits.

Tip: When you're stuck, capture packets on both ends. If the client's SYN appears in a capture on the server, the network is fine and the problem is on the server; if it never arrives, follow the path in between.

Test yourself

A user can ping 8.8.8.8 but can't open any website by name. What do you check first?

  1. The Ethernet cable
  2. DNS resolution
  3. The web server's TLS certificate
  4. The switch's MAC table

In a traceroute, one hop shows 150 ms but every later hop is back to 20 ms. What does that mean?

  1. The link after that hop is congested
  2. That router just answers ICMP slowly; it's probably harmless
  3. The destination is down
  4. There's a routing loop

What does 'Connection refused' (as opposed to 'timed out') tell you?

  1. A firewall silently dropped the SYN
  2. The host answered with a RST: nothing is listening on that port
  3. DNS failed
  4. The cable is unplugged