Course contents · Lesson 19 of 22

Ping and Traceroute: Network Troubleshooting Basics

Troubleshooting Toolkit · Lesson 19 of 22 · 11 min Hands-on

Wi-Fi says connected, yet no page loads. Is the fault in your laptop, your router, your provider or the far end? This lesson shows how ping and traceroute answer that, how to read their output, and why a failed ping proves less than it seems.

How ping works: echo request and reply

Ping uses ICMP, the protocol for short status notes between routers and hosts from lesson 12. It sends an echo request, the target's operating system answers with an echo reply, and ping times the round trip (lesson 5).

ping -c 4 1.1.1.1 sends four requests, one per second, to Cloudflare's public DNS resolver. Without -c, Linux and macOS keep pinging until you press Ctrl+C; Windows sends four, and -n sets its count. Linux prints something like this (TTL and times are illustrative; macOS words the summary differently and counts from 0):

PING 1.1.1.1 (1.1.1.1) 56(84) bytes of data.
64 bytes from 1.1.1.1: icmp_seq=1 ttl=57 time=11.5 ms
64 bytes from 1.1.1.1: icmp_seq=2 ttl=57 time=11.2 ms
64 bytes from 1.1.1.1: icmp_seq=3 ttl=57 time=12.0 ms
64 bytes from 1.1.1.1: icmp_seq=4 ttl=57 time=11.4 ms

--- 1.1.1.1 ping statistics ---
4 packets transmitted, 4 received, 0% packet loss, time 3005ms
rtt min/avg/max/mdev = 11.214/11.548/12.041/0.306 ms

icmp_seq numbers the requests, so a gap means a lost reply. time is the round trip in milliseconds (ms). ttl is what was left of the reply's TTL, the hop counter from lesson 1, when it reached you.

Hosts start packets at a fixed TTL, often 64 on Linux and macOS and 128 on Windows, and each router on the way back lowers it by one. So ttl=57 hints at a host about seven routers away, if it started at 64: a guess, not a count.

Packet loss is the share of requests that got no reply. The last line gives the fastest, average and slowest round trip, then mdev, how far the times typically stray from the average: a quick measure of jitter, the variation in delay from one packet to the next.

Reading ping results: healthy, slow or lossy

Healthy means 0% loss and steady times, as in the sample. Fast depends on distance: your home router answers in a few milliseconds, a server on the other side of the world in 150 ms or more, since light in fibre covers about 200 km per millisecond (lesson 1).

Times far above that baseline, or swinging ones such as 12, 90, 15 and 240 ms (illustrative), point to congestion, a busy link where packets wait in queues, or to weak Wi-Fi. A large mdev is the sign of jitter, which makes video calls stutter.

Loss means packets were dropped, by full queues on a congested link or by a bad link such as weak Wi-Fi or a damaged cable. Busy hosts may also limit how many pings they answer, so slight loss while pages load normally can be harmless.

How traceroute works: one more hop each time

As lesson 12 explained, each router lowers a packet's TTL by one, and the router that takes it to zero discards it and sends back an ICMP "time exceeded" message from its own address, a rule traceroute exploits.

It sends probes, test packets: three with a TTL of 1, three with 2, and so on. In the diagram, each probe gets one hop further, and the router where it runs out reveals itself by replying; the last probe reaches the destination.

Step-by-step diagram with five columns: you, Router 1, Router 2, Router 3 and example.com. Probe 1 leaves with TTL=1; Router 1 lowers it to 0, discards it and replies with time exceeded. Probe 2 leaves with TTL=2; Router 1 leaves 1, Router 2 takes it to 0 and replies with time exceeded. Probe 3 leaves with TTL=3; it has 2 left after Router 1 and 1 after Router 2, and Router 3 discards it and replies. Probe 4 leaves with TTL=4, passes all three routers and arrives at example.com, which replies, so the destination is reached. A box says each reply's sender becomes one line of the trace: 1 Router 1, 2 Router 2, 3 Router 3, 4 example.com. One probe per TTL is shown; traceroute sends three
Each probe goes one hop further, and the router where it runs out names itself.

On Linux and macOS the probes are UDP packets to unlikely ports, starting at 33434. Nothing listens there, so the destination answers ICMP "port unreachable", meaning "arrived". Windows' tracert sends echo requests instead and stops at the echo reply. Both give up after 30 hops by default (macOS after 64).

Reading a trace: jumps, stars and silent routers

Each line is one hop: its number, the router's name if DNS has one, its address, then three round-trip times, one per probe. Here is an illustrative traceroute example.com from a Linux laptop on home Wi-Fi; the diagram after it marks up this trace and the earlier ping.

traceroute to example.com (203.0.113.7), 30 hops max, 60 byte packets
 1  192.168.1.1 (192.168.1.1)  1.912 ms  1.804 ms  1.776 ms
 2  10.20.0.1 (10.20.0.1)  9.321 ms  9.287 ms  9.244 ms
 3  * * *
 4  198.51.100.9 (198.51.100.9)  61.207 ms  60.884 ms  61.032 ms
 5  198.51.100.14 (198.51.100.14)  13.115 ms  12.998 ms  13.042 ms
 6  198.51.100.42 (198.51.100.42)  148.226 ms  148.190 ms  148.163 ms
 7  203.0.113.7 (203.0.113.7)  150.733 ms  150.711 ms  150.690 ms
Annotated output. Top, ping -c 4 1.1.1.1 on Linux: four replies with icmp_seq 1 to 4, ttl=57 and times of 11.5, 11.2, 12.0 and 11.4 ms, then 4 packets transmitted, 4 received, 0% packet loss, and rtt min/avg/max/mdev = 11.214/11.548/12.041/0.306 ms. Labels say icmp_seq is the request number and a gap means a lost reply; ttl is the reply's TTL left when it arrived; time is the round trip in ms; packet loss counts requests with no reply; mdev shows how much times vary, a measure of jitter. Bottom, traceroute example.com with columns hop, router name and address, and three round trips. Hop 1, 192.168.1.1, is often your home router. Hop 3 shows * * *: no reply, but the path goes on. Hop 4, at about 61 ms, is slow to answer while hop 5 is back at 13 ms. Hop 6 jumps to about 148 ms and the time stays high: a long link. Hop 7, 203.0.113.7, is the destination. All values are illustrative
Read the columns, then find the jump that later hops keep.

Look for a jump that stays. From hop 5 to hop 6 the time leaps from 13 to 148 ms, and hop 7 keeps it: a long link, such as an undersea cable, or a congested one. Hop 4's 61 ms does not last, so router 4 forwards quickly but answers probes slowly, a low-priority job.

A line of * * * means no probe got an answer within a few seconds. Hop 4 answered, so traffic does pass hop 3; that router stayed silent, perhaps because it is set not to send "time exceeded", limits its ICMP messages, or sits behind a firewall.

Each time also includes the trip back, which may take another path, so one slow line is a hint, not proof. Stars to the last line mean the destination ignores the probes, not that it is down.

Limits: a failed ping is not proof the host is down

Networks are free to filter ICMP. A cloud security group drops ping unless a rule allows it (lesson 13), and many servers and office firewalls ignore echo requests, so a site can serve pages while every ping goes unanswered.

And a reply proves only that the machine answers, not that a program listens on your port (lesson 2). Use ping to test the path step by step, from your device outwards, as the flowchart shows; lesson 12's try-it finds your address and your default gateway, usually your home router.

Flowchart. Start: a ping to a site fails. Step 1, ping your own IP address, for example 192.168.1.5; no reply means your device: Wi-Fi off, cable out or no address. If it replies, step 2, ping the default gateway, for example 192.168.1.1; no reply means your local network: the Wi-Fi link or home router. If it replies, step 3, ping a public IP address, 1.1.1.1; no reply means the break is beyond your router: the ISP link, an outage, or a network that blocks ping. If it replies, step 4, ping a name, example.com; a name error with no address means DNS, covered in lesson 20. If ping shows an address, the network and DNS work; with still no replies, test the site's port next. A note says no reply is not proof a host is down, because many hosts and firewalls drop ping
Each step that replies clears one more stretch of the path.

The first step that fails marks the break. If, on Linux, ping example.com prints Temporary failure in name resolution or Name or service not known instead of a PING line with an address, DNS failed (lesson 20 debugs it). If the address appears but no replies follow, the host may just ignore ping: test its port with curl (lesson 21).

Check yourself

Your home router answers pings with 0% loss, but pings to 1.1.1.1 lose 30%. Where is the problem most likely?

Beyond your router, on your provider's link or further. Your device and local network passed, so the loss starts after the gateway.

A trace shows hop 5 at 80 ms, but hops 6 to 10 are all near 20 ms. Is hop 5 slowing your traffic?

No. Later probes pass through hop 5 too, so a slow link there would raise every later time; router 5 is just slow to answer probes.

ping shop.example.com shows 100% packet loss, yet the site loads in your browser. What does that tell you?

The host or its firewall ignores ping. The loaded page proves the path and the web port work; ping only tests ICMP.