Get free ebooK with 50 must do coding Question for Product Based Companies solved
Fill the details & get ebook over email
Thank You!
We have sent the Ebook on 50 Must Do Coding Questions for Product Based Companies Solved over your email. All the best!

Traceroute Command in Linux with Examples

Last Updated on November 21, 2023 by Abhishek Sharma

Traceroute is a powerful and essential network diagnostic tool that allows users to trace the route that packets take to reach a destination host. It provides valuable insights into the network topology, helping identify potential issues such as network congestion or routing problems. In this article, we’ll delve into the details of the traceroute command in Linux, exploring its functionality and providing examples to demonstrate its usage.

What is Traceroute Command in Linux?

Traceroute works by sending a series of packets toward the target host, incrementally increasing the time-to-live (TTL) value for each packet. As a packet traverses each router or hop, the TTL value decreases. When the TTL reaches zero, the router discards the packet and sends an "Time Exceeded" ICMP (Internet Control Message Protocol) message back to the source. Traceroute collects these ICMP messages to construct a map of the network path.

Syntax of Traceroute Command in Linux:

The basic syntax of the traceroute command is straightforward:

traceroute [options] target_host

Here, target_host is the destination you want to trace the route to. Let’s explore some common options and examples.

Examples of Traceroute Command in Linux

Below are some examples of Traceroute Command in Linux:
Example 1: Simple Traceroute


This command traces the route to Google’s servers. It displays the list of routers (hops) along with their response times.

Example 2: Specify Maximum Hops

traceroute -m 15

Here, the -m option sets the maximum number of hops to 15. This can be useful to limit the number of hops displayed, especially when tracing long paths.

Example 3: Use ICMP Echo Requests

traceroute -I

The -I option sends ICMP echo requests instead of UDP packets. This is useful when dealing with firewalls that might block UDP packets.

Example 4: Use UDP Packets

traceroute -U

The -U option uses UDP packets instead of the default ICMP. Some systems might block ICMP, making UDP a viable alternative.

Example 5: Display Hop Addresses

traceroute -n

The -n option prevents traceroute from performing reverse DNS lookups. This speeds up the process, as DNS resolution can sometimes introduce delays.

Example 6: Bypass Firewall Restrictions

traceroute -T

The -T option uses TCP SYN packets, which can be useful in scenarios where ICMP and UDP packets are blocked by firewalls.

Example 7: Save Output to a File

traceroute > trace_output.txt

Redirect the output to a file for later analysis or sharing with others.

Traceroute is a valuable tool for diagnosing network issues and understanding the path that data takes to reach its destination. By experimenting with different options and understanding the output, users can gain insights into the structure and performance of the networks they are interacting with. The examples provided should serve as a solid foundation for using traceroute effectively in Linux.

Frequently Asked Questions (FAQs) about Traceroute Command in Linux:

Here are some of the FAQs related to Traceroute Command in Linux:

Q1: What is the purpose of the traceroute command?
A: Traceroute is a network diagnostic tool used to trace the route that packets take from the source to a destination host. It helps identify network issues and provides insights into the network topology.

Q2: How does traceroute work?
A: Traceroute works by sending packets toward the target host with incrementally increasing time-to-live (TTL) values. Each router along the path decreases the TTL, and when TTL reaches zero, the router discards the packet and sends an "Time Exceeded" ICMP message back. Traceroute collects these messages to build a map of the network path.

Q3: What information does traceroute provide?
A: Traceroute provides a list of routers (hops) along with their response times. This information helps in identifying the network path, potential bottlenecks, and routing issues.

Q4: How can I limit the number of hops displayed in traceroute?
A: You can limit the number of hops using the -m option. For example, traceroute -m 15 sets the maximum number of hops to 15.

Q5: Why use ICMP Echo Requests or UDP packets with traceroute?
A: Using ICMP Echo Requests (-I option) or UDP packets (-U option) provides flexibility in dealing with network configurations. Some systems may block ICMP, so using UDP can be an alternative.

Leave a Reply

Your email address will not be published. Required fields are marked *