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.

# Usage

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

1
2
3
4
traceroute [options]

traceroute domain
traceroute ip-address

Examples:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
traceroute citizix.com
traceroute 192.168.101.10</code></pre>

root@frhb64566ds:~# traceroute www.citizix.com
traceroute to www.citizix.com (172.67.197.111), 30 hops max, 60 byte packets
  1  vlan130vrrpmlag06.ikoula.com (178.170.10.252)  0.185 ms  0.136 ms  0.134 ms
  2  be3.rc1.ikdc2.ikoula.com (213.246.32.128)  0.600 ms  0.422 ms be3.rc2.ikdc2.ikoula.com (213.246.32.142)  0.601 ms
  3  be2.rc1.ikdc2.ikoula.com (213.246.32.132)  2.734 ms  2.661 ms  2.645 ms
  4  et-t1.core15.rb.ikoula.com (213.246.32.135)  3.121 ms cloudflare.par.franceix.net (37.49.237.49)  3.578 ms et-t1.core15.rb.ikoula.com (213.246.32.135)  3.067 ms
  5  cloudflare.par.franceix.net (37.49.237.49)  3.801 ms 172.67.197.111 (172.67.197.111)  2.983 ms  2.973 ms

# Installation

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:

1
2
3
4
5
$ 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:

1
sudo yum install traceroute -y

Verify that the command is installed successfully

1
2
3
4
5
6
7
8
9
$ which traceroute

/usr/bin/traceroute

$ traceroute 10.2.11.8

traceroute to 10.2.11.8 (10.2.11.8), 30 hops max, 60 byte packets
1  ip-10-2-10-8.ap-southeast-1.compute.internal (10.2.10.8)  168.745 ms  168.707 ms  168.679 ms
2  ip-10-2-11-8.ap-southeast-1.compute.internal (10.2.11.8)  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

1
sudo apt install -y traceroute

Verify that the command is installed successfully using traceroute google.com:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
root@frhb64566ds:~# which traceroute

/usr/sbin/traceroute

root@frhb64566ds:~# traceroute google.com

traceroute to google.com (216.58.215.46), 30 hops max, 60 byte packets
  1  vlan130vrrpmlag06.ikoula.com (178.170.10.252)  0.156 ms  0.106 ms  0.124 ms
  2  be3.rc1.ikdc2.ikoula.com (213.246.32.128)  0.561 ms  0.529 ms  0.476 ms
  3  be2.rc2.ikdc2.ikoula.com (213.246.32.133)  3.101 ms et-t2.core14.ikdc1.ikoula.com (213.246.32.141)  2.722 ms  2.761 ms
  4  eth-trunk3.core16.ikdc1.ikoula.com (213.246.32.57)  1.490 ms  1.705 ms et-t2.core14.ikdc1.ikoula.com (213.246.32.141)  2.635 ms
  5  core11.th2.Eth-Trunk4.ikoula.com (213.246.50.194)  3.479 ms  3.629 ms  3.572 ms
  6  core11.th2.Eth-Trunk4.ikoula.com (213.246.50.194)  3.802 ms  3.544 ms  3.405 ms
  7  195.42.144.100 (195.42.144.100)  3.296 ms 108.170.245.1 (108.170.245.1)  4.827 ms 108.170.244.193 (108.170.244.193)  3.265 ms
  8  108.170.244.193 (108.170.244.193)  3.243 ms  3.837 ms 108.170.245.1 (108.170.245.1)  4.511 ms
  9  72.14.237.93 (72.14.237.93)  4.113 ms  4.027 ms par21s17-in-f14.1e100.net (216.58.215.46)  3.897 ms

# Archlinux

Coming soon

# Fedora

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:

1
traceroute -n www.citizix.com

Output:

1
2
3
4
5
6
7
8
$ traceroute -n www.citizix.com

traceroute to www.citizix.com (104.21.82.63), 30 hops max, 60 byte packets
  1  178.170.10.252  0.143 ms  0.114 ms  0.102 ms
  2  213.246.32.128  0.645 ms  0.581 ms  0.542 ms
  3  213.246.32.135  3.339 ms  3.290 ms  3.224 ms
  4  213.246.32.135  3.160 ms 37.49.237.49  4.059 ms 213.246.32.135  3.281 ms
  5  104.21.82.63  3.602 ms  3.589 ms 37.49.237.49  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.

1
traceroute -w 1.0 www.citizix.com

Output:

1
2
3
4
5
6
7
$ traceroute -w 1.0 www.citizix.com
traceroute to www.citizix.com (104.21.82.63), 30 hops max, 60 byte packets
  1  vlan130vrrpmlag06.ikoula.com (178.170.10.252)  0.194 ms  0.128 ms  0.124 ms
  2  be3.rc2.ikdc2.ikoula.com (213.246.32.142)  0.623 ms be3.rc1.ikdc2.ikoula.com (213.246.32.128)  0.752 ms  0.633 ms
  3  be2.rc1.ikdc2.ikoula.com (213.246.32.132)  2.906 ms  2.720 ms  2.665 ms
  4  cloudflare.par.franceix.net (37.49.237.49)  9.047 ms et-t1.core15.rb.ikoula.com (213.246.32.135)  3.277 ms  3.406 ms
  5  cloudflare.par.franceix.net (37.49.237.49)  3.680 ms 104.21.82.63 (104.21.82.63)  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.

Example:

1
    traceroute -q 5 citizix.com

Output:

1
2
3
4
5
6
7
$ traceroute -q 5 citizix.com
    traceroute to citizix.com (104.21.82.63), 30 hops max, 60 byte packets
     1  vlan130vrrpmlag06.ikoula.com (178.170.10.252)  0.147 ms  0.102 ms  0.098 ms  0.096 ms  0.106 ms  0.101 ms
     2  be3.rc2.ikdc2.ikoula.com (213.246.32.142)  0.639 ms be3.rc1.ikdc2.ikoula.com (213.246.32.128)  0.653 ms be3.rc2.ikdc2.ikoula.com (213.246.32.142)  0.490 ms be3.rc1.ikdc2.ikoula.com (213.246.32.128)  0.501 ms be3.rc2.ikdc2.ikoula.com (213.246.32.142)  0.431 ms  0.361 ms
     3  et-t1.core15.rb.ikoula.com (213.246.32.135)  3.050 ms  3.001 ms  3.056 ms be2.rc1.ikdc2.ikoula.com (213.246.32.132)  2.741 ms et-t1.core15.rb.ikoula.com (213.246.32.135)  3.306 ms  3.232 ms
     4  * cloudflare.par.franceix.net (37.49.237.49)  3.597 ms et-t1.core15.rb.ikoula.com (213.246.32.135)  3.082 ms * cloudflare.par.franceix.net (37.49.237.49)  3.742 ms et-t1.core15.rb.ikoula.com (213.246.32.135)  3.149 ms
     5  * 104.21.82.63 (104.21.82.63)  3.636 ms *  2.940 ms * *

# Configure the TTL value to start with

The default ttl set for traceroute is 1. Change this value with the flag -f

Example:

1
traceroute -f 4 citizix.com

Output:

1
2
3
4
$ traceroute -f 4 citizix.com
traceroute to citizix.com (104.21.82.63), 30 hops max, 60 byte packets
  4  cloudflare.par.franceix.net (37.49.237.49)  3.842 ms et-t1.core15.rb.ikoula.com (213.246.32.135)  3.002 ms cloudflare.par.franceix.net (37.49.237.49)  9.145 ms
  5  cloudflare.par.franceix.net (37.49.237.49)  6.766 ms 104.21.82.63 (104.21.82.63)  6.994 ms cloudflare.par.franceix.net (37.49.237.49)  4.871 ms

# Other Options

To check on other traceroute command, use any of these options:

  • Use manpages
1
man traceroute
  • Use --help option
1
traceroute --help

Output:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
$ traceroute --help

Usage:
  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 ]
Options:
  -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
  -w MAX,HERE,NEAR  --wait=MAX,HERE,NEAR
                              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
                              3
  -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
                              addresses
  -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

Arguments:
+     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
Citizix Ltd
Built with Hugo
Theme Stack designed by Jimmy