Easier to read with cream paper, a tint, more contrast or larger text? Choose your colours and text, once, for every page.

Free lesson

Finding where a connection fails

After this lesson: I can use ping and traceroute output to find where a connection fails.

55 min lessonNo commands

The warehouse cannot reach the shop

A ticket comes in from the warehouse: "The order system will not load." The office upstairs says it works fine.

Is the problem the warehouse laptop, its router, the internet, or the server? Guessing wastes hours. Two small tools, ping and traceroute, show you where the trail goes cold.

By the end of this lesson

Note

I can use ping and traceroute output to find where a connection fails.

Key words

WordWhat it meansExample
pinga tool that asks a device to answer back
Latencyhow long a reply takes, in milliseconds18 ms
Packet lossthe share of messages that never come back
traceroutea tool that lists every router on the way
Hopone router a message passes through
Timeoutgiving up after waiting too long for a reply

The cells students fill in are left blank in this preview.

ping asks one device to answer

ping sends a small message and waits for an answer. Each line of output is one reply, with the time it took.

The summary at the end says how many were sent and received. A time under about 50 ms is normal inside one country. Some loss, or times that jump about, suggest a busy or poor link. Below is real output from a laptop.

Real output from ping

Code: bash
$ ping -c 4 shop.example.com
PING shop.example.com (203.0.113.10): 56 data bytes
64 bytes from 203.0.113.10: icmp_seq=0 ttl=54 time=18.4 ms
64 bytes from 203.0.113.10: icmp_seq=1 ttl=54 time=17.9 ms
Request timeout for icmp_seq 2
64 bytes from 203.0.113.10: icmp_seq=3 ttl=54 time=19.1 ms

--- shop.example.com ping statistics ---
4 packets transmitted, 3 packets received, 25.0% packet loss
round-trip min/avg/max = 17.9/18.5/19.1 ms

Worked example: working out packet loss

SentReceivedLostLoss
4400 in 100
43125 in 100
105550 in 100
404100 in 100: no replies at all

The cells students fill in are left blank in this preview.

traceroute shows each step

traceroute lists every hop between you and the server, with a time for each.

Hop 1 is your own gateway. The middle hops belong to internet providers. The last hop should be the server. A * means that hop gave no answer before the timeout. The table below is real output from the warehouse laptop.

Real output: traceroute shop.example.com

HopAddressTimeWho it is
1192.168.1.12 msWarehouse router
2198.51.100.19 msInternet provider
3* * *no answerA router that ignores traceroute
4198.51.100.6521 msInternet provider
5* * *no answerUnknown
6* * *no answerUnknown

The cells students fill in are left blank in this preview.

A common mistake

Warning

Many people think a * * * line means the network is broken there. Many routers are set not to answer traceroute, yet still pass traffic on. Hop 3 is fine because hop 4 answers after it. Only stars that never stop, like hops 5 and 6, point at a fault.

Try it: read a saved traceroute

Code: bash
# A colleague pasted their traceroute into a ticket. Save it as a file.
printf "1 192.168.1.1 2 ms\n2 198.51.100.1 9 ms\n3 * * *\n4 198.51.100.65 21 ms\n5 * * *\n6 * * *\n" > trace.txt

# Which hops gave no answer?
grep "\*" trace.txt

# Which was the last hop that answered?
grep "ms" trace.txt | tail -n 1

# Change tail -n 1 to tail -n 2, then press Run.

Work outwards, one step at a time

Test from the near end to the far end. If the gateway does not answer, the fault is in the building. If the gateway answers but a public address does not, look at the internet link. If addresses work but names do not, look at DNS. If everything answers but the page does not, look at the server or the port.

Write down what you tested. That note is what makes a good ticket update.

Worked example: the warehouse ticket

TestResultWhat it tells you
ping 192.168.1.1Replies, 2 msThe laptop and router are fine
ping 198.51.100.1Replies, 9 msThe internet link is up
ping shop.example.comName found, 100 in 100 lostDNS works; the server does not reply
traceroute shop.example.comStops after hop 4The fault is near the server, not the warehouse

The cells students fill in are left blank in this preview.

Teaching a class? Set this module for your students with a teacher guide, marked assignments and a lab for every student.