How to Use Traceroute Command on Linux (Examples)

How to Use the Traceroute Command on Linux (Examples). When you’re working with a network, it is at times hard to tell what’s going on.

You might be trying to figure out why your computer is having trouble connecting to the internet and be unable to figure out why. Or maybe you’re trying to troubleshoot a problem on your home network and can’t seem to find the problem.

All in all, Traceroute is one of the oldest and most widely used tools for tracing a route through the Internet. The tool has been around since the early days of ARPANET and has been used in countless environments to troubleshoot network problems.

First of all, Traceroute is a command line tool that prints out the path taken by packets while they travel across an IP network. It it then used to troubleshoot network connectivity problems, track down hosts, identify routing protocols, and more.

In this article, you learn about the traceroute command. What is it, and how does it work? Additionally, you learn how to use it in various ways on the Linux operating system.

Let’s start with article How to Use the Traceroute Command on Linux (Examples).

What is Traceroute Command

Traceroute is a command line network diagnostic tool that allows you to trace the route of a packet through an internet link. It’s especially useful if you’ve got a problem with your connection, and want to see what’s going on.

It lets you know your Internet connection. Hence, used to determine if the network is working properly and to see how long it takes to reach a remote site.

Also, traceroute uses the IP addresses of each router in the path between you and the target server or host to trace the packet’s path from your computer to its destination. It also helps to diagnose other problems with your Internet connection, such as congestion, packet loss, or packet loss rate.

Therefore, traceroute is a comprehensive command that lets you find out just about everything about the path your connection took from one endpoint to another.

You can see how many hops away from each other all of your systems are, which routers are involved in the connection between them, and even if they’ve changed their IP addresses along the way.

Traceroute even gives you information about whether or not your connection has been cut off at any point along its path, allowing you to figure out what went wrong.

How Does Traceroute Command Works

Accordingly, traceroute follows the path packets from an IP network take on their way to a certain host. It provides you with information about your system’s IP address, router, DNS server, and gateway.

The traceroute command works by sending packets of data to the IP address of each hop in your path.

Each packet has a header that includes an IP header, a UDP header, and a TCP header. The three headers contain different types of information about the packet, including its source address, destination address, and protocol type.

This IP header contains a parameter called time to live (TTL). TTL is an eight-bit integer in the header. Despite its name, it is actually a counter. Routers decrease the TTL counter when packets arrive. The packet’s router decrements the TTL value to zero if it approaches one. Because it timed out, the packet is discarded.

Image Source: www.hackingarticles.in 

When the packet times out, the router elicits an ICMP TIME EXCEED response from each router along the path to the host. This helps to map the routers in the network and record the round trip time.

This output gives an insight into the router state, response time, network congestion, and network outage. This makes troubleshooting the network a lot easier.

Follow this post to learn how to use the traceroute command with different examples on the Linux operating system.

How to Use Traceroute Command on Linux (Examples)

Install Traceroute Utility on Linux

If you do not have Traceroute Utility already installed on your Linux system, you can install it by running the following command:

				
					sudo apt-get install traceroute
				
			

Basic Syntax of the Traceroute Command

The basic syntax of the traceroute command is as follows:

				
					traceroute [options] host_Address
				
			

Where Host Address is the website/destination/server name, or IP address, that is the destination address.

For example, run the following example to simply run Traceroute on the Google site:

				
					traceroute google.com
				
			

The Output of the Traceroute Command

Before diving into what and how to configure the traceroute command for your benefit, you need to understand its output and what it depicts.

On the first line, you’ll see the destination hostname and IP address, the number of hops the traceroute command will try, and the maximum packet size.

The subsequent lines contain the specifics of how the user interacted with each router they came across. As a result, we see that the traceroute command not only provides the IP addresses of the intermediate routers but also provides three different round trip timings for that specific router.

This is because the traceroute command sends three packets to each router by default.

The “*” sign indicates a packet loss or the lack of a response from the router at that hop for the application. The network may be down, there may be network congestion from heavy traffic, or the firewall may be dropping traffic, which all contribute to packet loss.

The error message for a significant packet loss is “destination is not reached” on the traceroute.

Following are a few examples of how you can customize and use the traceroute.

Use ICMP and TCP SYN Packets in Traceroute

Altogether, traceroute uses UDP packets by default, but you can also use ICMP echo for probing the network, as Windows does.

To use ICMP in traceroute, use the traceroute command with the -I option in the command prompt.

				
					traceroute -I google.com
				
			

Similarly, you can use TCP SYN in traceroute with the -T option.

				
					sudo traceroute -T google.com
				
			

Customize the TTL and Maximum Number of Hops 

You can use traceroute for targeted investigation of your network. What it means is that you see the output from the 7 or 8 routers and skip the first 6 or 7 routers because they are clear or working fine.

You can do this by specifying the TTL in the command with the -f option.

				
					traceroute -f 5 google.com
				
			

Alternatively, use the maximum number of hops to limit the investigation to a few routers with the -m option.

				
					traceroute -m 5 google.com
				
			

Specify the Response Wait Time and Number of Queries for a hop

The default response wait time is set to 5 seconds, but it can be configured under special conditions.

If you wish to customize the response wait time, run the traceroute command with the -w option.

				
					traceroute -w 7.0 google.com
				
			

Similarly, traceroute sends and records the response time three times by default per packet. You can set the number of queries with the -q option.

				
					traceroute -q 5 google.com
				
			

You can see the extra response wait time as a result of extra queries. 

More About Traceroute

Alternatively, you learn more about the traceroute command and its options by running the following help command.

				
					traceroute –help
				
			

That’s it on different uses and options of How to Use the Traceroute Command on Linux (Examples).

How to Use Traceroute Command on Linux (Examples) Conclusion

Finally, traceroute is a wonderful command for diagnosing and troubleshooting networks. It lets you know the state of your Internet connection. It’s used to determine if the network is working properly and to see how long it takes to reach a remote site.

For example, if you’re trying to watch videos and they’re not streaming properly, it might be because the video itself is too big (or the server isn’t working at all). Traceroute tells you where that problem lies.

Explore our Linux section to learn more.

Avatar for Sobia Arshad
Sobia Arshad

Information Security professional with 4+ years of experience. I am interested in learning about new technologies and loves working with all kinds of infrastructures.

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