Sub topic 8
Tracing the Path with tracert and traceroute
This chapter assumes you can read basic ping output, know that routers forward packets between networks, and understand that ICMP carries the echo request and reply messages ping uses. It builds on the TTL idea from the previous chapter and shows how a path-tracing tool turns that field into a map of routers.
What a trace tells you that ping does not
Ping answers one question: does a reply come back from the destination, and how long did it take? It says nothing about where a failure sits. If a ping to a remote server times out, the fault could be on your own LAN, at your ISP, or near the server.
A path tracer lists each router that forwards your packet, in order, with the round-trip time to each one. You can see where latency jumps or where replies stop.
- Windows calls the tool
tracert. - Linux and macOS call it
traceroute.
How it works: TTL and Time Exceeded
Every IP packet carries a Time To Live (TTL) field. In IPv6 the same field is named hop limit. Each router that forwards the packet subtracts 1. If a router would reduce the value to 0, it discards the packet. It then sends an ICMP Time Exceeded message back to the packet's source. That message carries the router's own IP address as its source.
A trace uses this on purpose:
- Send a probe with TTL 1. The first router drops it and returns Time Exceeded. You now know hop 1.
- Send a probe with TTL 2. The second router drops it and returns Time Exceeded. You now know hop 2.
- Keep increasing the TTL by 1.
- Stop when the destination itself answers, or when the maximum hop count is reached.
Most tools send three probes per TTL value. That is why each line of output shows three times.
The final reply differs by tool. Windows tracert sends ICMP echo requests, so the destination answers with an echo reply. Linux and macOS traceroute sends UDP datagrams to a high, unlikely-to-be-used port by default. The destination answers with ICMP Port Unreachable, which the tool treats as "arrived".
Running tracert on Windows
tracert example.com
tracert -d -h 20 example.com-dskips reverse DNS lookups for each hop. Without it,tracerttries to turn every router address into a name, which slows the output and can stall on addresses with no name.-h 20caps the maximum number of hops at 20. The default is 30.
Running traceroute on Linux and macOS
traceroute example.com
traceroute -n example.com
sudo traceroute -I example.com-nskips name lookups, liketracert -d.-Isends ICMP echo probes instead of UDP, matching what Windows does. On Linux this typically needs root. ICMP is useful when a firewall blocks the high UDP ports but allows ping.
Reading the output
A typical result looks like this. The addresses are documentation examples.
Tracing route to example.com [93.184.216.34]
over a maximum of 30 hops:
1 <1 ms <1 ms <1 ms 192.168.1.1
2 8 ms 7 ms 9 ms 10.20.0.1
3 12 ms 11 ms 12 ms 203.0.113.5
4 * * * Request timed out.
5 35 ms 34 ms 36 ms 198.51.100.9
6 36 ms 35 ms 35 ms 93.184.216.34
Trace complete.Each line has the hop number, three round-trip times, and the router address (or name if lookups are on).
| Element | Meaning |
|---|---|
| Hop number | The TTL value that produced this line. Hop 1 is usually your default gateway. |
| Three times | Round-trip time for each of the three probes, in milliseconds. |
| `<1 ms` | The reply came back faster than the timer could measure. |
| `*` | No reply arrived for that probe within the timeout. |
| Address or name | The router that sent the Time Exceeded message. |
Hop 1 is worth checking against your ipconfig output. It should match your default gateway. If it does not, the trace is not leaving through the gateway you expect.
Locating a problem
You are looking for a pattern, not a single number. Three patterns matter most.
Latency that jumps and stays high
In the example, the time rises from about 12 ms at hop 3 to about 35 ms at hop 5. The step happens between those hops, and every later hop stays high. Long links such as a transcontinental or submarine cable cause this, and it is usually normal. A large jump that persists is a real delay on or just after that link. A jump at one hop that disappears at the next is almost always not a real problem (see below).
Trace stops partway
If every line from some hop onward shows * * * and the trace never reaches the destination, the packets are being lost or filtered from that point. The fault is usually at or just beyond the last hop that answered. A trace that ends with Request timed out until the hop limit is reached is the typical sign.
Compare this with a single * * * line in the middle, followed by normal hops, as at hop 4 above. The probes passed through that router fine. The router simply did not send a Time Exceeded reply, or the reply was filtered or rate limited. This is not a fault.
Error replies
Sometimes a hop answers with an error instead of a time. Destination net unreachable or Destination host unreachable means a router has no route to the target and is telling you so. The address shown is the router that gave up. That is a precise location for the routing problem.
Why the path can look odd
- Different routes per probe. Routers may spread traffic over several equal-cost paths. The three probes of one hop can then come from different routers, so a line may list more than one address.
- Asymmetric return paths. Replies need not return along the route the probes took. The times you see combine the outward and return legs, which can differ.
- Changing paths. Run the same trace later and you may see different routers.
- Private addresses inside the path. Addresses such as 10.x.x.x can appear at carrier hops. That alone is not a problem.
- Name hints. With lookups on, router names often include city or interface codes. This helps you see where the path moves geographically, but names can be wrong or stale.
Common errors
- Reading
*as always meaning failure. A single starred hop followed by normal hops is not a fault. - Judging by one run. Run the trace more than once, and compare with ping to the destination.
- Forgetting the protocol difference. A trace that stops on Linux (UDP) might complete with
-I(ICMP), and the reverse can happen too. - Waiting on slow DNS. If the trace seems to hang between lines, rerun it with
-dor-n. - Assuming a complete trace proves the service works. Reaching the destination with ICMP says nothing about whether a web server on that host accepts connections.
A short workflow
- Run
ipconfigand note the default gateway. - Ping the gateway and a remote IP address. If those work but a name fails, the problem is DNS and a trace will not help.
- If the remote IP fails or is slow, run
tracert -dto that IP. - Check that hop 1 is your gateway.
- Find the last hop that answered, and any hop after which latency stays high.
- Repeat once or twice, then report that hop address to your ISP or network team.
Exercise
A trace to a server shows hops 1 to 6 with normal times, then hop 7 reads * * *, and hops 8 to 12 respond normally, ending at the server. A colleague says hop 7 is broken. Is that conclusion justified, and why? Then say what you would conclude if hops 7 to 30 were all * * *.
Show answer
The conclusion is not justified. Traffic clearly passed through hop 7, because hops 8 to 12 and the server answered. Router 7 forwards packets but does not return Time Exceeded messages, either because it is configured to drop them or because it rate limits them. If hops 7 to 30 were all * * *, the packets stop being answered from that point, so the fault (or a filter) is at or just beyond hop 6, the last hop that responded. You would then check whether the destination answers a ping or a trace using the other protocol (-I on Linux, or tracert versus UDP traceroute) before reporting.
Exercise
Why does traceroute on Linux, by default, end when it receives an ICMP Port Unreachable message, even though that message looks like an error?
Show answer
By default it sends UDP probes to a high port that is unlikely to have a listener. When a probe reaches the destination host, the host has nothing listening and returns Port Unreachable. Only the destination sends this message for the probe, so the tool knows the final hop was reached and stops.