What is Traceroute command?

Traceroute command explained

Traceroute is a built-in command with a command-line interface that you can use through the Terminal application. It serves as a diagnostic tool most commonly used to trace a route from the computer, sending the traceroute request to a hostname or IP address. It will send the query and get back a result, showing the query’s route and statistics about time and packets lost. 

You can find Traceroute on Linux (almost all distros), macOS, Windows (there it is called tracert), and even Android (though you will need extra installation). 

The software’s benefits are that it is free, easy to use, and serves well its purpose of tracing the route to a target.  

How does traceroute work?

When you are using the traceroute, your device will send packets of data starting from your IP address, going through various hops, and reaching its target – hostname or IP address. The software will use packets with a short TTL (time to live) value and listen for the ICMP replays. The probes continue until a message “port unreachable (ICMP) or rest (TCP), which will indicate host. 

As a result, you will see TTLs, addresses of the hops, and round time per probe, and extra data if you used some of the options.   

If you need more detailed information about the Traceroute command we recommend you this article – Traceroute command and its options

Traceroute syntax Linux

To get to the syntax on Linux, you will need to write the following in the Terminal: 

$traceroute –help

traceroute [options] host_Address [pathlength]

You will also see all the options for the traceroute command on Linux. They will help you perform better probes and get richer results. 

Traceroute Linux options

This is a complete list of Traceroute options on Linux. Use it on Debian, Ubuntu, CentOS, or whatever distro you have.

Option/flagDescription
-d –debugThis will allow socket level debugging in case that the kernel supports it.
-4Only use IPv4. Yhe default will give results for IPv4 and IPv6 both. 
-6Only use IPv6.
-TSpecify only TCP for the probes.
-ISpecify only ICMP ECHO for the probes.
-FForbid packet’s fragmentation. 
-f first_ttlSet, TTL value for starting (default is 1).
-g gatewaySay through which gateway you want the query to pass. 
-i interfaceDecide which interface to use for traceroute. 
-m max_ttlSet the maximum hop number (default is 30).
-N squeriesSet the number of queries send simultaneously (default is 16).
-nDon’t map the IP addresses to the hostnames.
-p portChoose the port for probing.
-t tosType of service and precedence value. 
-w waittimeThe waiting time for probes (default is 5 seconds).
-q nqueriesThe number of packets per hop (default is 3 seconds). 
-rSend directly to a host, bypassing the normal routing table. 
-s source_addrAlternative source address. 
-z sendwaitThe minimum interval, between sending of packets (default is 0). 
-eSee the ICMP extensions. 
-VSee the version and exit. 
-UUDP for the probes. 
-ULUDPLITE for the probes. 
-P protocolChoose the protocol for the probes. 

Suggested article: How to use the MTR command?

Traceroute syntax for macOS and Windows?

Here we are focused on Linux-only, but not to be bad with the rest of the readers, we will tell you how to use traceroute on macOS and Windows. 

  • macOS

Use the Terminal. Traceroute exists, and it is very similar. The syntax for macOS is:

traceroute [options] host [packetsize]

To see all the options, you can write:

Traceroute –help

  • Windows 10

On Windows, the Traceroute command has a slightly different name – tracert. The functionality is very similar. 

The tracert sytax is: 

 tracert [-d] [-h maximum_hops] [-j host-list] [-w timeout] [-R] [-S srcaddr] [-4] [-6] target_name

It shows all the available options like –R for roundtrip, -S srcaddr source address, -4 for IPv4, and -6 for IPv6.  

Conclusion

Traceroute is an easy to use, fast, and small command that you can easily use, no matter your Linux distro. Use it to monitor your servers or other network diagnostics.

Article Writter By

Tux

Write a Comment

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