How to Install Traceroute and Run on Ubuntu 20.04

How to Install Traceroute and Run on Ubuntu 20.04. In this post, we will introduce Traceroute, its working then show you how to run it on Ubuntu 20.04.

When you connect with a website, the data you acquire tends to travel across several devices and channels. It notably includes routers. Have you ever wondered how this movement happens?

The answer is the tool we probably have in our system, called Traceroute. This tool traces the path between your computer and a target destination to provide valuable insights. Have a read and learn about this tool in detail.

So, let’s start the article blog How to Install Traceroute and Run on Ubuntu 20.04.

What is Traceroute?

Traceroute is a network diagnostic tool that tracks real time pathways taken by a packet on an IP network from source to destination. After, it reports the IP addresses of all the routers it pinged in between. This tool also records each hop’s time to make packets during its route to the destination.

Usually, Traceroute uses Internet Control Message Protocol (ICMP) echo packets with variable time to live (TTL) values. Then, it calculates the response time of this hop. Also, Traceroute queries these hops several times to guarantee accuracy. This way, the measurement of that particular hop becomes appropriate. Moreover, Traceroute also uses ICMP messages and TTL fields to function in the IP address header. Operating systems, like Windows and Linux, include these tools as a utility.

Therefore, Traceroute is beneficial for determining the response delays and routing loops in a network pathway across packet switched nodes. With the help of Traceroute, you can locate any point of failure you witness while routing to a specific location.

How Does Traceroute Work?

Well, traceroute uses the field in Internet Protocol (IP) packet headers that do not deal with path or route tracing. Each IP packets have mandatory Time to Live (TTL) values. These values serve as a self destruct mechanism to prevent undesirable packages from circulating across the Internet unnecessarily. Before sending it further down the line, every router in the path must decrement the TTL value by one. Once these values become zero, the routing process comes screeching halt. The last router that processes the packet has to send a “Time to Live exceeded” message, as it is inappropriate for normal data packets.

However, this frustrating error message plays a crucial role in the working of the Traceroute. Actually, traceroute manipulates the TTL field to trigger TTL exceeded messages from each hop along a given path.

  • First, the user invokes the traceroute command and specifies a target host. If the host is defined as a domain name, Traceroute tends to resolve it.
  • Traceroute then sends a data packet to its target. It sets the TTL value to one before sending the packet. The first router in the path decreases its value to 1, which triggers the TTL exceeded messages. It sends back to the host on which the Traceroute program is running.
  • Now Traceroute increases the TTL value to two. The first router again decreases its value to one. However, since it will no longer reduce to zero immediately after heading out of the gate, the packet takes one more hop. When the TTL value hits zero, another TTL exceeded message is generated and sent to the Traceroute.
  • The process repeats with Traceroute increasing its value to one every time until it reaches the destination. The upper limit of packets is 30 hops by default. However, when the command runs, you can specify different values.
  • After the process ends, the Traceroute prints every hops in the path, including the time each hop takes to reach the destination and return. This process is called Round Trip Time.

Traceroute automatically sends three packets to each hop in the path. The same packet will vary related to implementations. It can also change with different flags. However, every class will use the same methodologies.

How to Install and Run Traceroute on Ubuntu 20.04

Install Traceroute

By default, the Traceroute package is available in the Ubuntu default repository. You can install it by running the following command:

				
					apt install traceroute
				
			

After installing Traceroute, you can check its version using the following command:

				
					traceroute --version
				
			

You should get the following output:

				
					Modern traceroute for Linux, version 2.1.0
Copyright (c) 2016  Dmitry Butskoy,   License: GPL v2 or any later
				
			

To get a list of all options that you can use with the Traceroute command, run the following command:

				
					traceroute --help
				
			

You should see the following screen:

How to Run Traceroute On Ubuntu

The basic syntax to use the Traceroute command is shown below:

				
					traceroute [options] host-address [length]
				
			

For example, to see the complete route of the google.com website, run the following command:

				
					traceroute google.com
				
			

You will get the following output:

				
					traceroute to google.com (216.58.203.14), 30 hops max, 60 byte packets
 1  _gateway (192.168.32.213)  4.277 ms  6.348 ms  6.623 ms
 2  * * *
 3  56.14.132.245 (56.14.132.245)  57.956 ms 56.14.132.253 (56.14.132.253)  57.639 ms 56.14.133.13 (56.14.133.13)  57.253 ms
 4  172.17.184.232 (172.17.184.232)  62.807 ms  62.562 ms  74.712 ms
 5  172.17.185.2 (172.17.185.2)  74.695 ms 172.17.185.3 (172.17.185.3)  74.677 ms 172.17.185.2 (172.17.185.2)  74.932 ms
 6  192.168.168.10 (192.168.168.10)  74.644 ms 192.168.168.2 (192.168.168.2)  66.717 ms  66.880 ms
 7  * * *
 8  * * *
 9  * * *
10  * * *
11  142.250.238.196 (142.250.238.196)  358.876 ms 108.170.248.209 (108.170.248.209)  158.028 ms *
12  142.250.235.8 (142.250.235.8)  460.099 ms 142.250.208.222 (142.250.208.222)  460.071 ms 108.170.248.195 (108.170.248.195)  460.000 ms
13  bom12s04-in-f14.1e100.net (216.58.203.14)  55.560 ms 108.170.248.210 (108.170.248.210)  62.419 ms hkg12s09-in-f14.1e100.net (216.58.203.14)  63.228 ms

				
			

The above output shows the following information:

  • The IP address of the specified website.
  • Number of Hops: Shows the time the traceroute will try to reach the destination.
  • Number of packets per Hop.
  • The size of packets you are sending.

If you want to trace the path without resolving each hop IP address, run the following command:

				
					traceroute -d google.com
				
			

You should see the following output:

				
					traceroute to google.com (142.250.183.142), 30 hops max, 60 byte packets
 1  _gateway (192.168.32.213)  2.273 ms  2.351 ms  2.614 ms
 2  * * *
 3  56.14.132.245 (56.14.132.245)  219.958 ms 56.14.133.9 (56.14.133.9)  219.937 ms 56.14.132.237 (56.14.132.237)  220.183 ms
 4  172.17.184.229 (172.17.184.229)  219.695 ms  218.895 ms  219.239 ms
 5  172.17.185.2 (172.17.185.2)  219.832 ms  226.633 ms  226.927 ms
 6  192.168.168.12 (192.168.168.12)  226.350 ms  1308.578 ms 192.168.168.10 (192.168.168.10)  1308.795 ms
 7  * * *
 8  * * *
 9  74.125.32.0 (74.125.32.0)  1340.838 ms * 74.125.51.166 (74.125.51.166)  1343.542 ms
				
			

Define Number of Probes

By default, the Traceroute command will passed 16 probes simultaneously. You can customize the number of probes to 5 using the N option:

				
					traceroute -N 5 google.com
				
			

You should see the following output:

				
					traceroute to google.com (172.217.27.206), 30 hops max, 60 byte packets
 1  _gateway (192.168.32.213)  3.134 ms  3.155 ms  3.197 ms
 2  * * *
 3  56.14.132.249 (56.14.132.249)  38.496 ms 56.14.132.225 (56.14.132.225)  38.168 ms 56.14.132.233 (56.14.132.233)  39.190 ms
 4  172.17.184.229 (172.17.184.229)  38.831 ms  39.980 ms  39.777 ms
 5  172.17.185.3 (172.17.185.3)  40.838 ms 172.17.185.2 (172.17.185.2)  40.614 ms  39.666 ms
 6  192.168.168.14 (192.168.168.14)  479.916 ms 192.168.168.12 (192.168.168.12)  439.863 ms 192.168.168.14 (192.168.168.14)  538.679 ms

				
			

Limit the Number of Hops

By default, the Traceroute command will check the website for only 30 hops. You can set this value to 5 using the -m option:

				
					traceroute -m 5 google.com
				
			

You should see the following output:

				
					traceroute to google.com (172.217.27.206), 5 hops max, 60 byte packets
 1  _gateway (192.168.32.213)  2.750 ms  2.635 ms  2.815 ms
 2  * * *
 3  56.14.133.13 (56.14.133.13)  67.194 ms 56.14.133.5 (56.14.133.5)  67.162 ms 56.14.132.245 (56.14.132.245)  67.129 ms
 4  172.17.184.229 (172.17.184.229)  66.739 ms  66.708 ms  67.037 ms
 5  172.17.185.2 (172.17.185.2)  67.006 ms 172.17.185.3 (172.17.185.3)  66.976 ms  67.181 ms

				
			

Limit the Number of Probes

By default, the Traceroute command shows three probes at every Hop. You can change this value to 2 using the -q option:

				
					traceroute -q 2 google.com
				
			

Hide Device Names

The Traceroute command also allows us to hide the device name to make it easier to see the data. You can do it using the -n option

				
					traceroute -n google.com
				
			

You should see the following output:

				
					traceroute to google.com (142.250.183.142), 30 hops max, 60 byte packets
 1  192.168.32.213  38.755 ms  36.079 ms  36.220 ms
 2  * * *
 3  56.14.132.249  124.227 ms 56.14.132.245  124.058 ms 56.14.132.233  129.031 ms
 4  172.17.184.229  128.385 ms  128.718 ms  128.699 ms
 5  172.17.185.3  134.329 ms  133.886 ms 172.17.185.2  133.622 ms
 6  192.168.168.10  138.274 ms  102.884 ms  103.156 ms
 7  * * *
 8  * * *
 9  74.125.51.62  102.100 ms *  98.206 ms
10  * * *
11  108.170.248.177  99.058 ms 142.250.214.100  72.280 ms 209.85.255.206  72.388 ms
12  108.170.248.170  70.010 ms 216.239.57.188  84.832 ms 108.170.248.178  84.752 ms
13  142.250.214.111  81.108 ms 142.250.183.142  63.196 ms 142.250.214.111  72.126 ms

				
			

Define Initial TTL Value

You can set the initial value of TTL to skip some hops. If we set it to five, the first test will attempt to get to hop five and skip hops one through four.

To set the initial TTL value to 15, run the following command:

				
					traceroute -f 15 google.com
				
			

You should see the following output:

				
					traceroute to google.com (142.250.183.142), 30 hops max, 60 byte packets
15  bom07s31-in-f14.1e100.net (142.250.183.142)  198.816 ms  192.093 ms 142.250.214.111 (142.250.214.111)  192.010 ms

				
			

Increase Hope Response Rate

You can use the -w option to increase the response rate that each Hop must wait to show the result.

				
					traceroute -w 6.5 google.com
				
			

You should see the following output:

				
					traceroute to google.com (172.217.27.206), 30 hops max, 60 byte packets
 1  _gateway (192.168.32.213)  7.418 ms  4.893 ms  5.042 ms
 2  * * *
 3  56.14.132.225 (56.14.132.225)  56.568 ms 56.14.133.1 (56.14.133.1)  56.410 ms 56.14.132.225 (56.14.132.225)  56.626 ms
 4  172.17.184.229 (172.17.184.229)  56.026 ms  56.357 ms  55.991 ms
 5  172.17.185.3 (172.17.185.3)  56.461 ms 172.17.185.2 (172.17.185.2)  56.442 ms  56.286 ms
 6  192.168.168.10 (192.168.168.10)  56.406 ms 192.168.168.14 (192.168.168.14)  45.208 ms 192.168.168.10 (192.168.168.10)  45.694 ms
 7  * * *

				
			

Set Pause Time Between Probes

The default time is 0ms. However, you can use the -z option to define your own time:

				
					traceroute -z 0.5 google.com
				
			

Define Specific Interface for Traceroute

You can use the -i option to specify the interface through which traceroute should send packets. By default, the interface is selected according to the routing table.

				
					traceroute -i eth0 google.com
				
			

Thank you for reading How to Install Traceroute and Run on Ubuntu 20.04. It is time to conclude.

How to Install Traceroute and Run on Ubuntu 20.04 Conclusion

In this post, we showed you how to install and run Traceroute on Ubuntu 20.04. The Traceroute command is very a useful tool for system or network admins to diagnose the network related problems. The Traceroute command shows you which part of the path is the problem to identify the website issue. You can also use Traceroute to see the amount of latency at each stop.

Have a look at more Ubuntu content in our blog over here

Avatar for Hitesh Jethva
Hitesh Jethva

I am a fan of open source technology and have more than 10 years of experience working with Linux and Open Source technologies. I am one of the Linux technical writers for Cloud Infrastructure Services.

0 0 votes
Article Rating
Subscribe
Notify of
0 Comments
Most Voted
Newest Oldest
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x