How To Use traceroute Command in Linux such as Ubuntu

The “traceroute” command tracks the path of network packets from the source to the destination. It is used to identify issues with network connectivity and detect packet loss or delay.

The traceroute command provides insights into the number of routers between the internet source and IP and each router’s RTT or round-trip time. Here’s how the traceroute command works: it first sends the ICMP internet control message protocol packets or hops, and then the routers receive these packets along the network path.

That’s why you can use the traceroute command for network troubleshooting to find how data packets travel from the source to the specific IP address. However, it is essential to get in-depth information about the traceroute command. Therefore, this blog has every possible detail about how to use the traceroute command in Linux.

While traceroute comes as the pre-installed utility in many Linux distros, you can install it with the specific commands:

Operating System

Command


Debian/Ubuntu

sudo apt install traceroute

Fedora/RHEL/Almalinux/Rocky/Oracle Linux

sudo dnf install traceroute

Arch Linux

sudo pacman -Sy traceroute

openSUSE

sudo zypper install traceroute

Checking whether Traceroute is installed or not:

You can also check the currently installed version of the traceroute command:

traceroute --version
check the installed version of the traceroute

Traceroute command usage

Here is the basic syntax of the traceroute command you can use:

traceroute <options> <host_IP>

In the above command, replace <host_IP> with the IP address of your destination device and <options> with the additional options of the command.

Let’s start with a simple example to check the connectivity between the system and the website. For example, let’s track the packets between the host and How2Shout:

traceroute www.how2shout.com

With the above result, you can evaluate the packets from How2Shout’s server at a specific time. You can use the following options of the traceroute command to get crisper results:

check the connectivity using Traceroute command linux

The -n Option

It disables the hostname lookup and then displays the IP address.

traceroute -n www.how2shout.com

Sometimes, the traceroute command shows asterisks (*) instead of a hop. This is because those hops do not respond to the 3 queries sent.

disables the hostname lookup and then displays the IP address traceroute

The -m Option

If you want to display the N number of hops, you can use the -m option.

traceroute -m N www.how2shout.com

Here, N represents the number of hops, so please replace it with the number of hops you want to display:

traceroute -m 5 www.how2shout.com
want to display the N number of hops

The -I Option

You can use the -I option to use ICMP ECHO and check each hop’s RTT accurately:

traceroute -nI www.how2shout.com

This command sends ICMP packets to the destination to obtain RTT with improved accuracy.

ICMP ECHO and check each hops

The IPv4 and IPv6 Options

You can use the -4 option to use an IPv4 connection during the execution of the traceroute command.

traceroute -4 how2shout.com
Pv4 connection during the execution of the traceroute

Similarly, use the -6 option to use an IPv6 connection in the traceroute command operation:

traceroute -6 how2shout.com
IPv6 connection in the traceroute command

The -T Option

The -T option is useful when you want to identify if a particular port or TCP blocks the protocol. It specifies the traceroute command to use TCP for the process:

traceroute -T www.how2shout.com
traceroute command to use TCP

The -q Option

If the load balancing has inaccurate paths, please refer to queries using the -q option. With the -q option, you can increase the amount of packets sent per hop. For instance, let’s send 10 queries per hop:

traceroute -q 5 www.how2shout.com
amount of packets sent per hop

The -p Option

If you want to check the connectivity on the specific port, then you can use the -p option with the traceroute command:

traceroute -p 8080 www.how2shout.com

In the above command, 8080 is the port.

check the connectivity on the specific port

Save Traceroute Results

If you want the traceroute to save the traceroute result, then you can run the following command by which the system will save the output in the data.txt file:

traceroute how2shout.com > data.txt
Save Traceroute Results

The –help Option

You can check the help page of the traceroute command to go deeper into its additional options.

traceroute --help
traceroute help

A Quick Summary

Traceroute is a versatile command-line utility that helps network administrators track and diagnose network-related problems. It displays network routes, which ensures efficient data transmission. Therefore, this blog demonstrates the use of the traceroute command and its options with appropriate examples.

Other Articles:

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.