Skip to content

What is traceroute Linux command?

The traceroute command in Linux allows users to trace the route that packets take to reach a specified destination, providing valuable insight into network connectivity and potential issues. By showing each hop along the path to the destination, including any delays or failures, traceroute helps pinpoint connection problems and aids in troubleshooting network performance issues.

traceroute Syntax:

Terminal window
traceroute [options] host

traceroute Options:

OptionDescription
-nDo not resolve hostnames
-m max_hopsSet the maximum number of hops
-f first_ttlSet the initial time-to-live value
-q nqueriesSet the number of queries to send per hop
-p portSet the destination port number
-t tosSet the Type of Service field in the IP header
-w waittimeSet the number of seconds to wait for a response
-IUse ICMP ECHO for tracerouting
-UUse UDP to tunnel the traceroute

Parameters:

ParameterDescription
hostThe destination host to trace the route to

traceroute Command Usage Examples:

Traceroute to a Domain Name

Terminal window
traceroute google.com

Traces the route that packets take to reach the domain name “google.com”.

Traceroute with Maximum Hops

Terminal window
traceroute -m 15 yahoo.com

Limits the number of hops to 15 when tracing the route to the domain name “yahoo.com”.

Traceroute Using IPv6

Terminal window
traceroute -6 facebook.com

Performs a traceroute using IPv6 to trace the route to the domain name “facebook.com”.

Traceroute with No DNS Lookup

Terminal window
traceroute -n reddit.com

Initiates a traceroute without performing DNS lookup for the domain name “reddit.com”.

Traceroute with Packet Size Modification

Terminal window
traceroute -q 5 amazon.com

Sets the query packets per hop to 5 when tracing the route to the domain name “amazon.com”.

How do I use traceroute in Linux?

To use the traceroute command in bash, execute the following command:

Terminal window
traceroute www.example.com

What is the purpose of traceroute in Linux?

Traceroute is used to trace the route that packets take to reach a destination host on an IP network.

How can I specify the number of hops for the traceroute command?

You can specify the maximum number of hops for the traceroute command using the -m flag followed by the maximum number of hops.

Terminal window
traceroute -m 20 www.example.com

How can I make traceroute to resolve IPs to hostnames?

To make traceroute resolve IP addresses to hostnames, use the -n flag to disable hostname resolution.

Terminal window
traceroute -n www.example.com

Can I use traceroute with IPv6 addresses?

Yes, you can use traceroute with IPv6 addresses by specifying the -6 option in the command.

Terminal window
traceroute -6 www.example.com

How do I perform a traceroute using TCP packets instead of UDP in Linux?

To perform a traceroute using TCP packets instead of UDP in Linux, use the -T flag in the traceroute command.

Terminal window
traceroute -T www.example.com

How can I increase the timeout for each probe in the traceroute command?

You can increase the timeout for each probe in the traceroute command using the -w flag followed by the timeout value in milliseconds.

Terminal window
traceroute -w 500 www.example.com

Applications of the traceroute command

  • Identifying the route taken by packets to reach a destination
  • Diagnosing network connectivity issues
  • Troubleshooting slow network connections
  • Analyzing network latency and performance
  • Mapping out networks and understanding their structure
  • Identifying potential bottlenecks or points of failure in a network