tracepath – Trace the routing information of the destination host

The tracepath command is a Linux utility used to trace the route that packets take from the local host to a destination host. It is similar to the traceroute command, but with a slightly different output format.

Overview

The basic syntax for the tracepath command is as follows:

tracepath [options] destination

Where destination is the IP address or hostname of the target host. By default, tracepath will send packets with a Time-to-Live (TTL) value of 1 and increment the TTL value by 1 until the target host is reached or the maximum number of hops is reached.

The output of the tracepath command includes the IP addresses and hostnames of each hop along the way, as well as the round-trip time (RTT) for each hop. The output is similar to the following:

 1:  localhost.localdomain                          0.027ms pmtu 1500
 1:  192.168.1.1                                     1.245ms 
 2:  10.0.0.1                                         2.345ms 
 3:  203.0.113.1                                     3.456ms 
 4:  203.0.113.2                                     4.567ms 
 5:  203.0.113.3                                     5.678ms 
 6:  203.0.113.4                                     6.789ms 
 7:  203.0.113.5                                     7.890ms 
 8:  203.0.113.6                                     8.901ms 
 9:  203.0.113.7                                     9.012ms 
10:  destination                                      10.123ms reached

In this example, the packets first travel to the local router (192.168.1.1), then through several other routers before reaching the destination host.

Examples

To trace the route to the example.com domain:

tracepath example.com

To specify a maximum number of hops:

tracepath -m 10 example.com

To use a specific network interface:

tracepath -i eth0 example.com

Options

The following table lists the available options for the tracepath command:

Option Description
-4 Force the use of IPv4
-6 Force the use of IPv6
-b Print both hostname and IP address
-d Enable debugging output
-f Start the trace with a specific TTL value
-i Use a specific network interface
-m Set the maximum number of hops
-n Do not resolve hostnames
-p Use a specific source port
-q Set the number of probes per hop
-r Bypass the normal routing tables
-s Set the size of the packets
-t Set the type of service (TOS) field

Troubleshooting tips

If you are having trouble running the tracepath command, try the following:

  • Ensure that the target host is reachable and responding to ICMP packets.
  • Check that you have permission to use the tracepath command (i.e. you are running as root or have the necessary permissions).
  • Try using the traceroute command instead, as it may provide more detailed output or work better with certain network configurations.

Notes

  • The tracepath command may not be installed on all Linux distributions by default. Check your distribution’s documentation for information on how to install it.
  • Some network configurations may block ICMP packets, which can result in incomplete or inaccurate output from the tracepath command.