traceroute

2024-06-08

Understanding traceroute

traceroute is a command-line utility that reveals the path packets take to reach a destination host. It achieves this by sending packets with increasing Time To Live (TTL) values. Each router along the path decrements the TTL; when it reaches zero, the router sends an ICMP “Time exceeded” message back to the sender. traceroute uses these responses to identify the routers along the path.

Basic Usage:

The most basic usage is straightforward:

traceroute google.com

This command will trace the route to google.com. The output will display a list of hops, their IP addresses, and the round-trip time (RTT) for each hop. You’ll see something like this (results will vary based on your network):

traceroute to google.com (172.217.160.142), 30 hops max, 60 byte packets
 1  <your router's IP>    (your router's name if configured)    0.504 ms    0.492 ms    0.488 ms
 2  <ISP router 1 IP>   <ISP router 1 name if configured>    1.234 ms    1.123 ms    1.012 ms
 3  ... and so on ...
 30 * * *

An asterisk (*) indicates a hop that didn’t respond.

Advanced Options:

traceroute offers many useful options:

Example using Multiple Options:

traceroute -f 5 -m 20 -q 5 -I www.example.org

Introducing mtr – An Enhanced traceroute

mtr (my traceroute) combines the functionalities of traceroute and ping. It provides a more user-friendly output, displaying hop information, packet loss, and RTT statistics in a table format. This makes it easier to identify problematic hops.

Basic mtr Usage:

mtr google.com

The output is dynamic, constantly updating as it sends probes. You’ll see columns for hop number, hostname, IP address, loss percentage, and RTT statistics (minimum, average, maximum, and standard deviation). This offers a far richer and more insightful view of network performance than traceroute alone.

mtr Options:

mtr also supports a range of options, including:

Example using mtr options:

mtr -c 10 -r 2 -w 80 google.com

This will send 10 probes, display a report every 2 seconds, and use a report width of 80 characters.

These commands are indispensable tools for diagnosing network connectivity problems. Their ability to pinpoint specific hops causing delays or packet loss is essential for troubleshooting network issues effectively. Mastering their usage enhances your ability to resolve network-related challenges within a Linux environment.