Linux Commands

How to Run Traceroute in Linux

Traceroute is a tool in Linux that allows you to investigate the routes of network packets. It can help you in identifying the limiting factor of network packet journeys. Traceroute is also useful for troubleshooting sluggish network connections. This guide shows you how to run traceroute in Linux.

About traceroute

Traceroute works by sending packets of data to the target computer, server, or website and recording any intermediate steps through which the packets travel. The output of a traceroute command will be the IP addresses and domain names through which the packets pass. These entries also show how long it takes for the packets to reach each destination. This may explain why some websites may take longer to load than others, as the number of traffic hops can vary.

Traceroute is also useful for mapping local networks. Insight into the topology and connections of the local network is found when running the tool.

Note that while using traceroute, some devices may not interact well. This could be due to routers being bugged, ISPs rate-limiting ICMP messages, devices configured not to send ICMP packets (to prevent distributed DoS attacks), etc. Some networks are also configured to block traceroute requests.

Installing traceroute

Traceroute is a powerful tool that is available for all Linux distros. Provided below is a short list of the commands to install traceroute on various distributions.

For Debian/Ubuntu and derivatives:

$ sudo apt install traceroute -y

For Fedora and derivatives:

$ sudo dnf install traceroute

For openSUSE, SUSE Linux, and derivatives:

$ sudo zypper in traceroute

For Arch Linux and derivatives:

$ sudo pacman -S traceroute

Using traceroute

The following sections show you how to use traceroute on your Linux system.

Basic Usage

The primary method for using traceroute is quite simple. All traceroute requires is the destination to perform the probing. The destination can be either a domain or an IP address.

$ traceroute

$ traceroute

If a network is configured to block the traceroute signal, then this probe will be denoted with asterisks.

IPv4 or IPv6

By default, traceroute will use the default Internet Protocol with which your system is configured. To manually set the IP version, follow the procedure below.

To tell traceroute to use IPv4, use the “-4” flag:

$ traceroute -4

To tell traceroute to use IPv6, use the “-6” flag:

$ traceroute -6

Testing Ports

If there is a need to test a specific port, the port can be specified using the “-p” flag. For UDP tracing, traceroute will start with the given value and increase with each probe. For ICMP tracing, the value will determine the initial ICMP sequence value. For TCP and others, this will be the constant destination port to connect.

$ traceroute -p <port>

Hiding Device Names

In some situations, the device names in the output may make the output look messy. For more clarity, you can hide the device names from the output. To do so, use the “-n” (no mapping) flag:

$ traceroute -n

Traceroute Timeout Limit

By default, traceroute waits for 5 seconds to receive a response. In certain situations, you may want to change the waiting time to be greater or less than 5 seconds. To do so, use the “-w” flag. Note that the time value is a floating-point number.

$ traceroute -w 6.0

Probing Methods

There are multiple methods that you can use to probe the remote address. To specify traceroute to use ICMP echo, use the “-I” flag:

$ traceroute -I

To use TCP SYN for probing, use the “-T” flag:

$ sudo traceroute -T

Setting the Maximum Number of Hops

By default, traceroute will track 30 hops. Traceroute offers the ability to manually set the number of hops to track.

Use the “-m” flag with the number of hops:

$ traceroute -I -m 10

Specifying the Interface

If there are multiple network interfaces connected to the computer, then it may help to specify the network interface to use for sending packets. To specify the network interface, use the “-i” flag:

$ sudo traceroute -i enp0s3

Defining the Number of Queries for a Hop

To define the number of queries for a hop, specify this number using the “-q” flag:

$ traceroute -I -q 4

Routing Packets through a Gateway

To route packets through a certain gateway, use the “-g” option, followed by the gateway:

$ traceroute -I -g

Traceroute Help Page

The above demonstrations are just some of the common usages of traceroute, and there are even more features for you to use. To get quick help, open the traceroute help page with the following command:

$ traceroute --help

For a fuller, more in-depth guide on all the available traceroute options, check out the man page with the following command:

$ man traceroute


Traceroute is a powerful tool used for network diagnostics, and there are tons of options it supports. Mastering traceroute may require some time and practice. When using this tool, you will often employ the methods described in this article.

There are more tools like traceroute out there. If you are looking to work with a similar tool in GUI, then check out Zenmap to scan a network. Zenmap is a GUI front-end for another popular network scanner called Nmap.

Happy computing!

About the author

Sidratul Muntaha

Student of CSE. I love Linux and playing with tech and gadgets. I use both Ubuntu and Linux Mint.