The traceroute command is a powerful network diagnostic tool used to trace the path that packets take from your system to a destination host. It provides valuable insights into the network infrastructure between two points, showing each hop along the route and measuring the round-trip time for packets to reach each hop. This information is crucial for network administrators and users troubleshooting connectivity issues, analyzing network performance, or simply understanding the topology of the internet.
Unlike the simpler ping command which only tests if a destination is reachable, traceroute reveals the entire journey of packets through the network, making it an essential tool for comprehensive network diagnostics.
Traceroute operates by sending packets with incrementally increasing Time-To-Live (TTL) values:
It begins by sending a packet with a TTL of 1
When this packet reaches the first router, the TTL is decremented to 0
The router discards the packet and sends back an ICMP "Time Exceeded" message
Traceroute records this router's address and the time taken
The process repeats with TTL values of 2, 3, and so on until the destination is reached
The final result is a list of all routers (hops) along the path to the destination
By default, traceroute sends UDP packets on Linux (while Windows' tracert uses ICMP Echo requests). However, modern versions of traceroute can use different protocols based on the options specified.
This command traces the route to google.com, displaying each hop along the path with its IP address, hostname (if available), and round-trip times for packets.
traceroute to google.com (142.250.190.78), 30 hops max, 60 byte packets 1 _gateway (192.168.1.1) 3.171 ms 3.142 ms 3.114 ms 2 96.120.42.133 (96.120.42.133) 12.132 ms 12.104 ms 12.077 ms 3 96.110.156.185 (96.110.156.185) 13.450 ms 13.422 ms 13.394 ms 4 68.85.118.13 (68.85.118.13) 13.366 ms 13.339 ms 13.311 ms 5 68.86.102.121 (68.86.102.121) 13.283 ms 13.256 ms 13.228 ms 6 68.86.93.5 (68.86.93.5) 13.200 ms 13.173 ms 13.145 ms 7 * * * 8 142.251.60.219 (142.251.60.219) 13.089 ms 13.062 ms 13.034 ms 9 142.250.190.78 (142.250.190.78) 13.006 ms 12.979 ms 12.951 ms
Each line represents a hop along the route:
The first column is the hop number
The second column shows the hostname and IP address of the router
The last three columns show the round-trip time for three separate probe packets
An asterisk (*) indicates that the probe timed out (no response was received within the timeout period).
The traceroute command is an essential tool for network diagnostics, providing valuable insights into the path that packets take across networks. By understanding how to use traceroute and interpret its output, network administrators and users can effectively troubleshoot connectivity issues, analyze network performance, and gain a deeper understanding of network topology.
While traceroute has some limitations, particularly with modern networks that may block or rate-limit ICMP or UDP traffic, it remains one of the most useful tools for network diagnostics. Combined with other networking tools like ping, mtr, and tcpdump, traceroute forms a comprehensive toolkit for network analysis and troubleshooting.
Test Your Knowledge
Take a quiz to reinforce what you've learned
Exam Preparation
Access short and long answer questions for written exams