When you attempt to connect to a remote server or a website, your data does not travel in a straight, unbroken line. Instead, the data packets “hop” across dozens of intermediate routers, switches, and internet service providers before reaching their final destination. If a connection is failing or incredibly slow, a basic ping command will only tell you that the destination is unreachable; it will not tell you exactly where on the internet the connection failed.
To diagnose the exact point of failure, Linux administrators rely on the traceroute command.
How Traceroute Works
The traceroute utility works by manipulating the Time To Live (TTL) value of data packets. It sends a packet with a TTL of 1, which expires at the very first router it hits. That router sends an ICMP “Time Exceeded” message back to your machine, allowing traceroute to record its IP address. The command then sends a packet with a TTL of 2, hitting the second router, and continues this process until the final destination is reached.
Basic Usage: Tracing a Path
To trace the path from your Linux machine to a remote server or website, simply type the command followed by the domain name or IP address:
traceroute google.com
The terminal will output a numbered list. Each number represents a “hop” (a router). Next to the number, you will see the hostname or IP address of the router, followed by three latency measurements in milliseconds (ms). traceroute tests each router three times to provide an accurate average response time.
How to Read the Output and Find Problems
Reading the output is relatively straightforward once you understand what to look for:
- Asterisks ( * * * ): If a row only displays asterisks instead of latency times, it means that specific router is configured to drop or ignore ICMP requests for security reasons. This is completely normal and does not necessarily indicate a failure, especially if the subsequent hops continue successfully.
- Latency Spikes: Look at the millisecond response times. If hops 1 through 5 are returning in 20ms, but hop 6 suddenly jumps to 450ms, you have found a bottleneck. The router at hop 6 is heavily congested or physically distant (such as an undersea cable crossing).
- Dead Ends: If the trace reaches hop 8 and then every subsequent hop displays only asterisks ( * * * ) until the maximum limit of 30 hops is reached, the connection died at hop 8. The router at hop 8 is either offline, blocking your traffic, or misconfigured.
If you prefer a more dynamic, real-time interface, consider installing the mtr command, which combines the functionality of ping and traceroute into a continuously updating dashboard.