traceroute Command in Linux

Topics Covered

Overview

The traceroute command in Linux is used to track the route taken by a packet through an IP network. It is used to identify network connectivity issues and locate where the packet is lost or delayed. It is a useful tool for network troubleshooting and debugging.

Linux traceroute Command Syntax

The syntax for the traceroute command is as follows:

Where:

  • options: Specifies the different options available for the traceroute command.
  • host: Specifies the host name or IP address for which the route is to be traced.

traceroute Command Options:

  • -n: Displays IP addresses instead of hostnames.
  • -w: Sets the timeout for receiving a response.
  • -q: Sets the number of queries per hop.
  • -m: Sets the maximum number of hops to be searched.

Example Usages

  • Traces the route to the host google.com:

    Output:

    Explanation: This command traces the route to the host google.com and displays the IP addresses of each hop in the route.

  • Traces the route to the host github.com and sets the maximum number of hops to be searched as 10:

    Output:

    Explanation: This command traces the route to the host github.com and sets the maximum number of hops to be searched as 10, and stops tracing after 10 hops.

Tips

  • Use the -n option to display IP addresses instead of hostnames. This can be useful for debugging purposes.

  • Use the -w option to set the timeout for receiving a response. This can help to reduce the time taken for tracing the route.

  • Use the -q option to set the number of queries per hop. This can help to reduce the number of packets sent during the tracing process.

  • Use the -m option to set the maximum number of hops to be searched. This can help to limit the amount of network traffic generated during the tracing process.

Advanced Use Cases of traceroute Command in Linux

  • Traces the route to the host example.com and displays the time taken for each hop in milliseconds.:

    Output:

    Explanation: This command traces the route to the host example.com and displays the time taken for each hop in milliseconds. The -n option is used to display IP addresses instead of hostnames, and the time taken for each hop is displayed in milliseconds.

  • Traces the route to the host yahoo.com and sets the timeout for receiving a response as 1 second.:

    Output:

    Explanation: This command traces the route to the host yahoo.com and sets the timeout for receiving a response as 1 second. This can help to reduce the time taken for tracing the route.

  • Traces the route to the host facebook.com and sets the number of queries per hop as 2.:

    Output:

    Explanation: This command traces the route to the host facebook.com and sets the number of queries per hop as 2. This can help to reduce the number of packets sent during the tracing process.

Conclusion

  • The traceroute command in Linux is a useful tool for network troubleshooting and debugging.

  • It can be used to track the route taken by a packet through an IP network and identify network connectivity issues.

  • The -n, -w, -q, and -m options can be used to customize the traceroute command and improve its functionality.