How to Use the traceroute Command on Linux

How to Use the traceroute Command on Linux

This guide is about How to Use the traceroute Command on Linux. So read this free guide, How to Use the traceroute Command on Linux. If you have query related to same article you may contact us.

How to Use the traceroute Command on Linux – Guide

The traceroute command in Linux prints the route a packet takes to reach the host. This command is useful when you want to know something about the route and all the hops that a packet takes. The image below shows how to use traceroute command to reach google host (172.217.26.206) from local machine and also print details of all hops it visits in between.

The first column corresponds to the hop count. The second column represents the address of that hop and after that you see it three times in milliseconds separated by spaces. The traceroute command sends three packets to the hop, and each time refers to the time the packet takes to reach the hop.

How does traceroute work?

  • Knowing how traceroute works makes it much easier to understand the results. The more complicated the path a network packet must take to reach its destination, the more difficult it is to identify where delays might be occurring.
  • A small organization’s local area network (LAN) can be relatively simple. It will likely have at least a server and a router or two. Complexity increases in a wide area network (WAN) that communicates between different locations or over the Internet. Your network packet reaches (and is forwarded and routed by) a lot of hardware, such as routers and gateways.
  • Metadata headers in data packets describe their length, where they come from, where they are going, the protocol used, and so on. The protocol specification defines the header. If you can identify the protocol, you can determine the start and end of each field in the header and read the metadata.
  • Traceroute uses the TCP/IP family of protocols and sends User Datagram Protocol packets. The header contains the Time to Live (TTL) field, which contains an 8-bit integer value. Despite what the name might suggest, it’s a count, not a duration.
  • A packet travels from its source to its destination through a router. Each time the packet arrives at a router, it decrements the TTL counter. If the TTL value reaches one, the router receiving the packet decreases the value and realizes that it is now zero. The packet is then dropped and not forwarded to the next hop in its journey because it “timed out”.
  • The router sends an Internet Message Control Protocol (ICMP) timeout message back to the source of the packet to let it know that the packet has timed out. The Time Exceeded message contains the original header and the first 64 bits of data from the original packet. This is defined on page six of Request for Comments 792.
  • So if traceroute sends a packet but sets the TTL value to one, the packet will only reach the first router before being dropped. It will receive an ICMP timeout message from the router and will be able to record the time it took for the round trip.
  • It then repeats the exercise with TTL set to 2, which will fail after two jumps. traceroute increases the TTL to three and tries again. This process repeats until the destination is reached or the maximum number of hops (30 by default) is tested.
  • Installing traceroute

  • traceroute has already been installed on Fedora 31, but must be installed on Manjaro 18.1 and Ubuntu 18.04. To install traceroute in Manjaro, use the following command:
  • sudo pacman -Sy traceroute
  • To install traceroute on Ubuntu, use the following command:
  • sudo apt-get install traceroute
  • Using traceroute

  • As we covered above, the purpose of traceroute is to get a response from the router on every hop from the computer to the destination. Some may keep their mouths shut and reveal nothing, while others are likely to spill the beans unscrupulously.
  • As an example, we will do a traceroute to the Blarney Castle website in Ireland, home of the famous Blarney Stone. Legend has it that if you kiss the Blarney Stone, you will be blessed with the “gift of conversation”. Let’s hope the routers we meet along the way are suitably chatty.
  • We type the following command:
  • traceroute www.blarneycastle.ie
  • The first line gives us the following information:
  • The destination and its IP address.
  • The number of hops traceroute will attempt before giving up.
  • The size of the UDP packets we are sending.
  • All other lines contain information about one of the hops. Before we delve into the details, though, we can see that there are 11 hops between our computer and the Blarney Castle website. Hop 11 also tells us that we have arrived at our destination.

  • The format of each jump line is as follows:
  • The device name or, if the device does not identify itself, the IP address.
  • The IP address.
  • The round-trip time for each of the three tests. If there is an asterisk here, it means there was no response for this test. If the device does not respond, you will see three asterisks and no device name or IP address.
  • Hide device names

  • As we’ve seen, sometimes including device names leads to a cluttered display. To make viewing the data easier, you can use the -n (no mapping) option.
  • To do this with our example, we type the following:
  • traceroute -n blarneycastle.ie
  • This makes it easier to choose large numbers for round-trip times that could indicate a bottleneck.
  • Setting traceroute timeout value

  • Perhaps if we extend the default timeout period (five seconds) we will get more responses. To do this, we’ll use the -w (timeout) option to change it to seven seconds. (Note that this is a floating point number.)
  • We type the following command:
  • traceroute -w 7.0 blarneycastle.ie
  • Setting the number of tests

  • By default, traceroute sends three UDP packets for each hop. We can use the -q (number of queries) option to adjust this up or down.
  • Speed ​​up up In the traceroute test, we type the following to reduce the number of UDP probe packets we send to one:
  • traceroute -q 1 blarneycastle.ie
  • Final note

    I hope you like the guide How to Use the traceroute Command on Linux. In case if you have any query regards this article you may ask us. Also, please share your love by sharing this article with your friends.

    We will be happy to hear your thoughts

    Leave a reply

    How to Guides, Best Lists, Top 10 and Tech News - Compsmag
    Logo