How to Install and Use Traceroute in Linux

In this guide we will learn how to install and use traceroute in the following linux distributions: Centos, Ubuntu, Debian, Fedora and Archlinux.

Traceroute is a computer network diagnostic commands for displaying possible routes (paths) and measuring transit delays of packets across an Internet Protocol (IP) network. The history of the route is recorded as the round-trip times of the packets received from each successive host (remote node) in the route (path); the sum of the mean times in each hop is a measure of the total time spent to establish the connection. It also shows you how systems are connected to each other, letting you see how your ISP connects to the Internet as well as how the target system is connected. Traceroute proceeds unless all (usually three) sent packets are lost more than twice; then the connection is lost and the route cannot be evaluated.

When you connect to a remote machine (IP) or domain, your traffic always go through different network machines such as routers and switches. It is the work of these routers and switches to control how your activity gets to its destination.


The traceroute commands can be used by typing these in your terminal:

traceroute [options]

traceroute domain
traceroute ip-address


root@frhb64566ds:~# traceroute
traceroute to (, 30 hops max, 60 byte packets
 1 (  0.185 ms  0.136 ms  0.134 ms
 2 (  0.600 ms  0.422 ms (  0.601 ms
 3 (  2.734 ms  2.661 ms  2.645 ms
 4 (  3.121 ms (  3.578 ms (  3.067 ms
 5 (  3.801 ms (  2.983 ms  2.973 ms


The traceroute and tracert commands are not usually installed by default. This guide will show you how to install it in these Linux distributions: Centos, Ubuntu, Debian, Fedora, Archlinux.

Centos 7

Centos 7 uses yum to manage its packages. We will use yum to install traceroute in centos 7.

Lets first check which package provides the traceroute command using yum whatprovides:

$ sudo yum whatprovides traceroute
3:traceroute-2.0.22-2.el7.x86_64 : Traces the route taken by packets over an IPv4/IPv6 network
Repo        : base
3:traceroute-2.0.22-2.el7.x86_64 : Traces the route taken by packets over an IPv4/IPv6 network
Repo        : @base

From the above output, we can see that its provided by traceroute, you don’t have to specify the version details unless you are looking for a specific version. Lets install it with this command:

sudo yum install traceroute -y

Verify that the command is installed successfully

 $ which traceroute

$ traceroute
traceroute to (, 30 hops max, 60 byte packets
 1  ip-10-2-10-8.ap-southeast-1.compute.internal (  168.745 ms  168.707 ms  168.679 ms
 2  ip-10-2-11-8.ap-southeast-1.compute.internal (  168.815 ms  168.785 ms  168.747 ms

Ubuntu & Debian

Ubuntu and Debian uses apt command to manage its packages. Use the following command to install traceroute

sudo apt install -y traceroute

Verify that the command is installed successfully using traceroute

root@frhb64566ds:~# which traceroute

root@frhb64566ds:~# traceroute
traceroute to (, 30 hops max, 60 byte packets
 1 (  0.156 ms  0.106 ms  0.124 ms
 2 (  0.561 ms  0.529 ms  0.476 ms
 3 (  3.101 ms (  2.722 ms  2.761 ms
 4 (  1.490 ms  1.705 ms (  2.635 ms
 5 (  3.479 ms  3.629 ms  3.572 ms
 6 (  3.802 ms  3.544 ms  3.405 ms
 7 (  3.296 ms (  4.827 ms (  3.265 ms
 8 (  3.243 ms  3.837 ms (  4.511 ms
 9 (  4.113 ms  4.027 ms (  3.897 ms


Coming soon


Coming soon

Command usage beyond basic

Disable IP address and host name mapping

If you want to disable the mapping of the IPs to the hostnames, you can use the flag -n like in this example:

traceroute -n


# traceroute -n
traceroute to (, 30 hops max, 60 byte packets
 1  0.143 ms  0.114 ms  0.102 ms
 2  0.645 ms  0.581 ms  0.542 ms
 3  3.339 ms  3.290 ms  3.224 ms
 4  3.160 ms  4.059 ms  3.281 ms
 5  3.602 ms  3.589 ms  3.734 ms

Configure Response Wait Time

At whatever point traceroute issues a test, it wait for the response from the switch for some time span called “Response Wait Time”. The ‘-w’ option set the time (in seconds) to wait for a response to a probe. Default wait time is 5.0 sec.

Use this command to reduce wait time to 1.0 sec.

traceroute -w 1.0


$ traceroute -w 1.0
traceroute to (, 30 hops max, 60 byte packets
 1 (  0.194 ms  0.128 ms  0.124 ms
 2 (  0.623 ms (  0.752 ms  0.633 ms
 3 (  2.906 ms  2.720 ms  2.665 ms
 4 (  9.047 ms (  3.277 ms  3.406 ms
 5 (  3.680 ms (  3.025 ms  3.735 ms

## Configure Number of Queries per Hop
`traceroute` utility sends 3 packets per hop to provide 3 round trip times.  Use the `q` to change this config. The value given should always be an integer.

traceroute -q 5</code></pre>
<pre><code>$ traceroute -q 5
traceroute to (, 30 hops max, 60 byte packets
 1 (  0.147 ms  0.102 ms  0.098 ms  0.096 ms  0.106 ms  0.101 ms
 2 (  0.639 ms (  0.653 ms (  0.490 ms (  0.501 ms (  0.431 ms  0.361 ms
 3 (  3.050 ms  3.001 ms  3.056 ms (  2.741 ms (  3.306 ms  3.232 ms
 4  * (  3.597 ms (  3.082 ms * (  3.742 ms (  3.149 ms
 5  * (  3.636 ms *  2.940 ms * *</code></pre>
<h2>Configure the TTL value to start with</h2>
<p>The default ttl set for <code>traceroute</code> is 1. Change this value with the flag <code>-f</code></p>
<pre><code class="language-bash">traceroute -f 4</code></pre>
<pre><code class="language-bash">$ traceroute -f 4
traceroute to (, 30 hops max, 60 byte packets
 4 (  3.842 ms (  3.002 ms (  9.145 ms
 5 (  6.766 ms (  6.994 ms (  4.871 ms

# Other Options

To check on other &#x60;traceroute&#x60; command, use any of these options:
- Use manpages
man traceroute
  • Use `–help` option traceroute –help


# traceroute --help
  traceroute [ -46dFITnreAUDV ] [ -f first_ttl ] [ -g gate,... ] [ -i device ] [ -m max_ttl ] [ -N squeries ] [ -p port ] [ -t tos ] [ -l flow_label ] [ -w MAX,HERE,NEAR ] [ -q nqueries ] [ -s src_addr ] [ -z sendwait ] [ --fwmark=num ] host [ packetlen ]
  -4                          Use IPv4
  -6                          Use IPv6
  -d  --debug                 Enable socket level debugging
  -F  --dont-fragment         Do not fragment packets
  -f first_ttl  --first=first_ttl
                              Start from the first_ttl hop (instead from 1)
  -g gate,...  --gateway=gate,...
                              Route packets through the specified gateway
                              (maximum 8 for IPv4 and 127 for IPv6)
  -I  --icmp                  Use ICMP ECHO for tracerouting
  -T  --tcp                   Use TCP SYN for tracerouting (default port is 80)
  -i device  --interface=device
                              Specify a network interface to operate with
  -m max_ttl  --max-hops=max_ttl
                              Set the max number of hops (max TTL to be
                              reached). Default is 30
  -N squeries  --sim-queries=squeries
                              Set the number of probes to be tried
                              simultaneously (default is 16)
  -n                          Do not resolve IP addresses to their domain names
  -p port  --port=port        Set the destination port to use. It is either
                              initial udp port value for "default" method
                              (incremented by each probe, default is 33434), or
                              initial seq for "icmp" (incremented as well,
                              default from 1), or some constant destination
                              port for other methods (with default of 80 for
                              "tcp", 53 for "udp", etc.)
  -t tos  --tos=tos           Set the TOS (IPv4 type of service) or TC (IPv6
                              traffic class) value for outgoing packets
  -l flow_label  --flowlabel=flow_label
                              Use specified flow_label for IPv6 packets
                              Wait for a probe no more than HERE (default 3)
                              times longer than a response from the same hop,
                              or no more than NEAR (default 10) times than some
                              next hop, or MAX (default 5.0) seconds (float
                              point values allowed too)
  -q nqueries  --queries=nqueries
                              Set the number of probes per each hop. Default is
  -r                          Bypass the normal routing and send directly to a
                              host on an attached network
  -s src_addr  --source=src_addr
                              Use source src_addr for outgoing packets
  -z sendwait  --sendwait=sendwait
                              Minimal time interval between probes (default 0).
                              If the value is more than 10, then it specifies a
                              number in milliseconds, else it is a number of
                              seconds (float point values allowed too)
  -e  --extensions            Show ICMP extensions (if present), including MPLS
  -A  --as-path-lookups       Perform AS path lookups in routing registries and
                              print results directly after the corresponding
  -M name  --module=name      Use specified module (either builtin or external)
                              for traceroute operations. Most methods have
                              their shortcuts (<code>-I&#039; means -M icmp' etc.)
  -O OPTS,...  --options=OPTS,...
                              Use module-specific option OPTS for the
                              traceroute module. Several OPTS allowed,
                              separated by comma. If OPTS is "help", print info
                              about available options
  --sport=num                 Use source port num for outgoing packets. Implies
                              `-N 1'
  --fwmark=num                Set firewall mark for outgoing packets
  -U  --udp                   Use UDP to particular port for tracerouting
                              (instead of increasing the port per each probe),
                              default port is 53
  -UL                         Use UDPLITE for tracerouting (default dest port
                              is 53)
  -D  --dccp                  Use DCCP Request for tracerouting (default port
                              is 33434)
  -P prot  --protocol=prot    Use raw packet of protocol prot for tracerouting
  --mtu                       Discover MTU along the path being traced. Implies
                              `-F -N 1'
  --back                      Guess the number of hops in the backward path and
                              print if it differs
  -V  --version               Print version info and exit
  --help                      Read this help and exit

+     host          The host to traceroute to
      packetlen     The full packet length (default is the length of an IP
                    header plus 40). Can be ignored or increased to a minimal
                    allowed value</code>
comments powered by Disqus
Built with Hugo
Theme Stack designed by Jimmy