Linux Traceroute Command Tutorial With Examples – POFTUT

Linux Traceroute Command Tutorial With Examples

The network is an important part of the system administration. Because without a network the server has nothing to do. While administrating Linux servers troubleshooting network is very important. When a network problem occurs in a Linux server first step is checking network services and the route information. Network services can be checked with systemctl or similar commands. Network routes can be checked with different tools but the most popular and straightforward tool is traceroute . We will look at usage examples of traceroute in this tutorial.

About

Networking is a stand-alone profession done by its professionals. But some simple tools need to know by system administrators. Traceroute mainly uses ICMP packets. ICMP is a protocol mainly developed for network troubleshooting and information sharing. ICMP packets are transmitted between network-capable devices to share information about network traffic. ICMP packets have TTL value. TTL is time to live where holds information about hop count. Generally, all network devices are one hop and as an example when ICMP packets send to poftut.com 

Syntax

The syntax of the traceroute is like below.

Help

Help about traceroute commands can get like below.

Help

Help

Find Route To The Host, IP Address, Website

As we stated before traceroute will find the route to the given destination like host, IP address, website, etc. In this example, we will route to the site named but the destination can be an IP address or hostname in a local area network.

LEARN MORE  DHCP Reservation For Windows Server 2012, Windows Server 2008 and Benefits

Find Route To The Host, IP Address, Website

Find Route To The Host, IP Address, Website

This example provides information about the route. There are 18 hops to the destination. Which is shown in the first column. In the second column, the hop names are provided. and in the other columns, the operation metrics are provided. If we look to the example we see that * * * lines. Those are used to inform that these hops do not provide information about themselves.

Show IP Address Do Not Resolve Host Name

In the previous example, the hosts are expressed with their hostnames. Hostnames give more clues about the host. But the disadvantage of the hostname is that it should be resolved. As we know all operation is done with IP addresses but the IP addresses are expressed with their hostnames by using DNS. This will slow the trace operation. The -n option can be used to disable hostname resolution.

Show IP Address Do Not Resolve Host name

Show IP Address Do Not Resolve Hostname

Set Response Time

By tracing the path the ICMP packet transmission will occur. We will send the ICMP packet to the destination hop and we will wait for the answer. Sometimes this answer can come back late or never came back. This will slow our network trace operation. We can set time for the response and make our network trace operation faster. In the example, we set a timeout for the trace 1 second with -w option.

Set Response Time

Set Response Time

Set Number Of Queries Per-Hop

We send ICMP packets to the hop and this hop sends back responses. We call this round trip as a query. Traceroute by default makes 3 queries for each hop. This is a changeable property. This can be changed with -q parameter. In the following example, we set the query count as 1 for each hop.

LEARN MORE  Linux ping Command Tutorial With Examples

Set Number Of Queries Per Hop

Set Number Of Queries Per-Hop

 Set TTL For ICMP

We have previously talked about the TTL value. By default, this TTL value is set as 30. This means that we can only reach up to 30 hops. Because in each hop this TTL value is incremented and after hop number 30 the TTL will be 0 and the packet will not be transmitted to the next hop. In this example, we will set TTL number 8 which will only reach the first 8 hops.

 Set TTL For ICMP

Set TTL For ICMP

Set Start TTL

By default, the traceroute command will show all hops starting from 1 to the last hop. In some situations, we only need only some part of the hops starting from the n’th hop. This can be set with the -f option. In this example, we will start from hop number 10.

Set Start TTL

Set Start TTL

Print Autonomous System (AS) Numbers

The Internet is a very big public network. There are a lot of parties that provide connections for each other in a mesh topology. These parties are generally ISP’s or big companies and those are called in internet terminology as Autonomous Systems. All AS’s have their unique identifiers called AS numbers. While hoping in different AS’s their AS numbers can be printed with -A option.

Print Autonomous System (AS) Numbers

Print Autonomous System (AS) Numbers

We can see the AS numbers like [AS9121] after the IP address of hop.

LEARN MORE  nslookup Commands Tutorial with Examples

Specify Source Interface

In enterprise environments, Linux systems generally have multiple interfaces for high availability. Multiple interfaces mean multiple paths to the destination. Linux has default routes which mean primary interfaces for out of network destinations. This is used by default but we can specify another interface with the -i option. But first, we will list available interfaces with the ip command.

Specify Source Interface

List Interfaces

Now we will specify the network device name. But keep in mind that these options require root privileges which can be provided with sudo command.

Specify Source Interface

Specify Source Interface

Specify Gateway

IP packets are firstly redirected to the host where it’s specified in the network configuration of the source system. This first hop/host is called a gateway. By default, this gateway is used by traceroute. We can change this gateway information with the -g option. In this example, we will set IP address 192.168.122.1 as gateway address.

Leave a Reply

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

Enjoy this blog? Please spread the word :)