Trace route to a host using the TRACEPATH command in Linux

Home > Search > Linux commands
  by

The tracepath command is an alternative to the traceroute command.

The tracepath command without any options will display the usage of the tracepath command. The tracepath command followed by a hostname or IPv4 address can be used to trace the route an IPv4 packet takes from the client machine to the target machine. The tracepath6 command followed by the hostname or IPv6 address can be used to trace the route an IPv6 packet takes from the client machines to the target machine. In this example, the IPv4 route is traced to www.example.com.

[root@server1 ~]# tracepath www.example.com
 1?: [LOCALHOST]                                         pmtu 1500
 1:  r1.software.eng.us                                    1.864ms 
 1:  r1.software.eng.us                                    2.368ms 
 2:  142.254.152.73                                       23.145ms 
 3:  ae9.applwibp02h.midwest.rr.com                       17.043ms 
 4:  be72.gnfdwibb01r.midwest.rr.com                      26.595ms 
 5:  bu-ether16.chcgildt87w-bcr00.tbone.rr.com            29.266ms 
 6:  0.ae9.pr1.chi10.tbone.rr.com                         25.727ms 
 7:  192.229.225.135                                      22.647ms
 8:  93.184.216.34                                        29.476ms

 

The tracepath command displays the hops a packet takes from the source device to the destination device. A hop is the transmission of a packet from router "a" to router "b" to router "c" and so on. The hop count is not incremented when a packet traverses a switch or end-point. Also, a hop is not counted when the packet enters the first router in the path. Sometimes this is referred to as hop 0.  A hop is counted when a packet exits a router.  Thus when a packet exits a router and enters the next router, a hop is counted. Also, a hop is counted when a packet exits a router on it's way to the destination device.

 


Only display IP addresses

The -n option can be used to only display IP addresses, and to not display hostnames. This will also greatly reduce the time it takes to complete the trace.

[root@server1 ~]# tracepath -n www.example.com
 1?: [LOCALHOST]                                         pmtu 1500
 1:  192.168.0.1                                           1.375ms 
 1:  192.168.0.1                                           2.029ms 
 2:  142.254.152.73                                       15.642ms 
 3:  65.31.112.238                                        18.135ms 
 4:  65.31.112.178                                        26.219ms 
 5:  66.109.6.204                                         28.014ms 
 6:  66.109.9.197                                         27.024ms 
 7:  192.229.225.135                                      29.256ms
 8:  93.184.216.34                                        21.754ms

 


Both hostname and IP address

The -b option can be used to display both the hostname and IP address.

[root@server1 ~]# tracepath www.example.com
 1?: [LOCALHOST]                                              pmtu 1500
 1:  r1.software.eng.us                                        1.864ms 
 1:  r1.software.eng.us                                        2.368ms 
 2:  142.254.152.73                                           23.145ms 
 3:  ae9.applwibp02h.midwest.rr.com(65.31.112.238)            17.043ms 
 4:  be72.gnfdwibb01r.midwest.rr.com(65.31.112.178)           26.595ms 
 5:  bu-ether16.chcgildt87w-bcr00.tbone.rr.com(66.109.6.204)  29.266ms 
 6:  0.ae9.pr1.chi10.tbone.rr.com(66.109.9.197)               25.727ms 
 7:  192.229.225.135                                          22.647ms
 8:  93.184.216.34                                            29.476ms

 


Unreachable host

If consecutive sets of no reply are displayed, this means the packet cannot hop to the next device.

[root@server1 ~]# traceroute -n www.example.com
1 192.168.0.1 0.366 ms 0.322 ms 0.333 ms
2 142.254.152.73 11.161 ms 11.188 ms 11.075 ms
3 24.164.240.217 30.611 ms 30.653 ms 30.675 ms
4 65.31.112.238 18.770 ms 18.763 ms 18.762 ms
5 no reply
6 no reply
7 no reply
8 no reply
9 no reply
10 no reply
11 no reply
. . .

 

In this example, the packet was unable to hop from device 4 to device 5. Device 5 could be a firewall, a router, a switch, or an end point. The tracepath command can confirm that the packet cannot hop from device 4 to device 5. However, the tracepath command cannot identify why the packet cannot hop from device 4 to device 5.

 



Add a Comment




We will never share your name or email with anyone. Enter your email if you would like to be notified when we respond to your comment.




Please enter in the box below so that we can be sure you are a human.




Comments