Traceroute is a network diagnostic tool that is used to display the route that network packages take from sender t receiver as well as the time it takes for the network packages to travel from one network node to the other. This command is used to test the IP route of the destination server or host in order to resolve network issues. It mainly provides the connectivity status but also points the issue precisely as well as its occurrence which makes the system administrators trace out the issue more quickly and fix it.
This article had brought you six commands that might be useful in Linux to trace the network connection status along with practical examples related to it.
Check Connection Status Using Traceroute
As we discussed earlier traceroute checks the connection status of the specific host. In this scenario, we will be doing connection testing of the Google DNS server let’s see how the output will be. You should execute the command in the following way.
$ traceroute google.com
As you can see in the above example my first route gateway is at 192.168.233.2 which is provided by VM itself for your case it might be different. The other ‘*’ field in the output can have many scenarios to get output like that. It usually states that the required field is unable to fetch or there may be reverse DNS lookup failure to packets not hitting the target route.
Determining the maximum number of hops
When the packet is passed through one network segment to another then it determines as hops. The default hops value is set to 30 but you can customize the number of hops for the packets to reach the destination using the -m option along with the number of hops. As you can see I have determined 8 hops max for the packets.
$ traceroute -m 8 google.com
Determine the number of queries per Hop
The traceroute command sends 3 packets to 3 round trip routes as per hops which is the default for the command. But you can set the number of probs to be sent to routes per-hop using the -q option. The probs are the number of IP packets that we sent to routes. You can configure the number of probs to be sent to routes in the following way.
$ traceroute -q 4 facebook.com
Adjust Start value of TTL
The TTL refers to the Time to Live which determines the duration data can live in an IP network. When the command is executed the traceroute sends the packets of data with a TTL value of one to the destination server. Then the first route from where data passes will decrease the TTL value by one until it’s zero and the IP packets will be discarded along with the TTL exceeded response message. Usually, TTL prevents data packets from traveling endlessly around the internet. When TTL is discarded it give RTT values for hope one and so on with increasing hop number. This process will continue until it reaches the destination or exceeds the hop limit.
So you can adjust the TTL value from where the user wants to start the utility with. Initially, the TTL value is one which means its starts off with the first route that outputs as hop one. You can set the TTL value that determines from which route the packets transfer start using the -f option. In the following example, let’s compare with initial TTL value and custom TTL value.
$ traceroute -m 6 facebook.com
$ traceroute -f 4 facebook.com
Response Wait Time Configuration
After packets data send to the routes the traceroute waits to receive a response from it which can be adjusted according to your requirement. In order to do so pass -w option to the command along with the time in second. In the following example, I have determined the wait time for 1s so after one second the command will display * if the response was not received from the route.
$ traceroute -w 1 google.com
Specific Gateway Route
You can use the -g option to the command to route the packets only from the specific gateway. In the following example, I have specified the 192.168.233.2 IP as the routing gateway for the packets.
$ traceroute -g 192.168.233.2 facebook.com
Conclusion
These are the six traceroute commands in Linux with a practical example that might be useful to trace out the network issue. Thank you for taking your time to completely read this article I hope this article might be useful to you.