Skip to content

tracepath command in Linux

The tracepath command in Linux is used to trace the route that packets take from your device to a destination host. It sends packets with increasing Time-To-Live (TTL) values and reports the IP addresses of the routers along the path. This tool is useful for network troubleshooting and understanding the network topology between your device and a remote host.

tracepath Syntax:

Terminal window
tracepath [options] destination

Linux tracepath Options:

OptionDescription
-bUse a flow-based algorithm
-jDo not display the path
-l NUMSet the maximum number of hops
-m NUMSet the initial time-to-live
-nDo not resolve addresses to hostnames
-p PORTUse a specific destination port
-q NUMSet the number of queries
-s NUMSet the source address
-4Use IPv4
-6Use IPv6

tracepath Parameters:

ParameterDescription
destinationThe destination to trace the path to

How to use tracepath command:

Trace the route to a specific domain

Terminal window
tracepath google.com

Traces the route taken to reach the domain “google.com”.

Trace the route to a specific IP address

Terminal window
tracepath 8.8.8.8

Traces the route taken to reach the IP address “8.8.8.8”.

Verbose tracing to a domain

Terminal window
tracepath -n -b -v facebook.com

Performs a verbose tracepath to the domain “facebook.com” without resolving addresses or symbolic names.

Set the maximum number of hops

Terminal window
tracepath -m 15 twitter.com

Traces the route to the domain “twitter.com” with a maximum of 15 hops.

Trace with IPv6

Terminal window
tracepath -6 youtube.com

Traces the IPv6 route to the domain “youtube.com”.

Using UDP protocol to trace

Terminal window
tracepath -u github.com

Traces the route to the domain “github.com” using the UDP protocol.

Display timing information for each hop

Terminal window
tracepath -T 80 linkedin.com

Traces the route to the domain “linkedin.com” and displays timing information for each hop on port 80.

Trace in reverse direction

Terminal window
tracepath -S 192.168.1.1 192.168.2.1

Traces the route from “192.168.1.1” to “192.168.2.1” in the reverse direction.

How do I use tracepath in Linux?

To use the tracepath command in Linux, execute the following command:

Terminal window
tracepath google.com

What is the purpose of tracepath?

The tracepath command is used in Linux to trace the network path to a specific destination, showing the route taken by packets and the number of hops along the way.

Terminal window
tracepath example.com

How can I specify the maximum number of hops in tracepath?

You can limit the number of hops to be displayed in tracepath by using the ‘-m’ option followed by the maximum number of hops.

Terminal window
tracepath -m 20 example.com

How do I perform a DNS lookup before tracing the path with tracepath?

To perform a DNS lookup before tracing the path, use the ‘-n’ option in the tracepath command.

Terminal window
tracepath -n example.com

Can I trace both IPv4 and IPv6 routes with tracepath?

Yes, you can trace both IPv4 and IPv6 routes in tracepath. Use the ‘-4’ option for IPv4 and the ‘-6’ option for IPv6.

Terminal window
tracepath -4 example.com

How can I display the AS (Autonomous System) numbers in the tracepath output?

To display the AS numbers in the tracepath output, use the ‘-l’ option when executing the command.

Terminal window
tracepath -l example.com

Is it possible to set a specific source address for tracepath?

Yes, you can set a specific source address for tracepath using the ‘-s’ option followed by the desired source IP address.

Terminal window
tracepath -s 192.168.1.10 example.com

How can I increase the verbosity of tracepath output?

To increase the verbosity level of tracepath output, use the ‘-v’ option multiple times to display additional information.

Terminal window
tracepath -vv example.com

Applications of the tracepath command

  • Check the path taken by packets to a destination
  • Troubleshoot network connectivity issues
  • Determine the number of hops to a destination
  • Identify network bottlenecks
  • Analyze the routing path to a specific host
  • Discover the round-trip time for packets to reach a destination