Linux Traceroute Command Tutorial With Examples

RSS
EMAIL
FACEBOOK
FACEBOOK
GOOGLE
GOOGLE
https://www.poftut.com/linux-traceroute-command-tutorial-examples/
PINTEREST
PINTEREST
INSTAGRAM

Network is important part of the system administration. Because without a network the server have 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 systemcl or similar commands. Network routes can be checked with different tools but the most popular and straightforward tool is traceroute . We will look 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 is one hop and as an example when a ICMP packets send to poftut.com 

Syntax

Syntax of traceroute is like below.

Help

Help about traceroute commands can be 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 poftut.com but the destination can be a IP address or hostname in a local area network.

This example provide 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 this hops do not provide information about themselves.

LEARN MORE  Vi/Vim Show Line Numbers

Show IP Address Do Not Resolve Host Name

In the previous example the hosts are expressed with their host names. Host names gives more clue about the host. But the disadvantage of the host name is that it should be resolved. As we know all operation is done with IP addresses but the IP addresses are expressed with their host names by using DNS. This will slow the trace operation. The -n option can be used to disable host name 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 ICMP packet to the destination hop and we will wait for the answer. Sometimes this answer can came 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 more faster. In the example we set 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 send back responses. We call this round trip as query. Traceroute by default makes 3 query for each hop. This is changeable property. This can be changed with -q parameter. In the following example we set query count as 1 for each hop.

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 hop. Because in each hop this TTL value is incremented and after hop number 30 the TTL will be 0 and the packet will not transmitted to the next hop. In this example we will set TTL number 8 which will only reach to the first 8 hops.

LEARN MORE  How To Make Samba Server Secure?

 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 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

Internet is very big public network. There are a lot of parties those provides connections for each other in a mesh topology. This parties are generally ISP’s or big companies and those are called in internet terminology as Autonomous Systems. All AS’s have their unique identifier 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 IP address of hop.

Specify Source Interface

In enterprise environments Linux systems generally have multiple interfaces for high availability. Multiple interfaces means multiple paths to the destination. Linux have default routes which means primary interfaces for out of network destination. This is used by default but we can specify an other interfaces 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 this options requires root privileges which can be provided with sudo command.

LEARN MORE  Linux ls Command Tutorial With Examples

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 source system. This first hop/host is called as 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.

RSS
EMAIL
FACEBOOK
FACEBOOK
GOOGLE
GOOGLE
https://www.poftut.com/linux-traceroute-command-tutorial-examples/
PINTEREST
PINTEREST
INSTAGRAM

You may also like...

Leave a Reply

Your email address will not be published.

Enjoy this blog? Please spread the word :)