What is the Traceroute command, and how to use it?

The Traceroute command is a network tool that helps you see the complete route of a query and identify problematic spots on the networks, such as slow or not responsive routers. You can use it through the Terminal with a simple “traceroute + domain name” command.

It is light, fast, and does the job it was designed for. The great thing is that you can find it on the most popular OSes. 

What is the Traceroute command?

The Traceroute command is a simple software with a CLI interface that serves to show you each hop of a query from your computer to the destination – IP address or domain name. It races the route of a probe and gives back the result. 

The query will travel through the internet, hoping from a router to another and finally reaching the destination. At each of the hops, your computer will send packets and get answers for them. That way, you will get statistics about each of the points, from your device to the destination.

The statistic can show you:

  • If there is a problem reaching the destination and where it is.
  • Show you a slow point/router that might be possible to upgrade.
  • See the precise points that the query takes.
  • Get the addresses of the routers on the way to the destination.

Sometimes, if the time between two routers is too long, this could indicate a problem with the second route. Other times, it can just be natural because of a considerable distance between the two routers. The second could be on another continent.

How to use the Traceroute command?

On Linux and macOS, you can use the combination between “traceroute + domain name/IP address” through the Terminal application. If you are a Windows user, open the Command Prompt and use “tracert + domain name/IP address”.

In both cases, you will get the statistics about each hop and the total time it took for the query to reach the final destination.

Linuxtraceroute domainname.com or traceroute 1.2.3.4
macOStraceroute domainname.com or traceroute 1.2.3.4
Windowstracert domainname.com or tracert 1.2.3.4

There are small differences between the traceroute command on Linux, macOS, and Windows.

Traceroute/Tracert command syntax

Linuxtraceroute [options] host_Address [pathlength]
macOStraceroute [options] host [packetsize]
Windowstracert [-d] [-h maximum_hops] [-j host-list] [-w timeout] [-R] [-S srcaddr] [-4] [-6] target_name

Traceroute command options

There are slightly different options to perform more specific Traceroute commands on Linux, macOS, and Windows. The first two OSes are quite similar, but on Windows, there are more differences. Use this comparison table to see when the options match and when they don’t.

Having the options with the command will give you greater control for detecting problems and more chances to pinpoint the problem. You can use IPv4 or IPv6, choose the port, or adjust the maximum time to wait or the maximum amount of hops. 

Option for tracerouteWhat does it do?Is it on Linux?Is it on macOS?Is it on Windows?
-dWith this option, you stop the addresses to hostnames resolving.NoNoYes
-d –debugThis command enables debugging on Linux.YesNoNo
-h maximum_hopsDefine, the maximum amount of hops for the request.NoNoYes
-m max_ttlThe TTL in traceroute means maximum amount of hops. YesYesNo
-j host-listOnly for IPv4 –  loose source route along host-list. NoNoYes
-w timeoutMaximum waiting time for each of the replies. NoNoYes
-w waittime –wait=waittimeMaximum waiting time for each of the replies. YesYesNo
-I –icmpUse the ICMP echo for the requests. YesNoNo
-RTracert, but for IPv6 only. NoNoYes
-S srcaddrIPv6 only – source address. NoNoYes
-4Use only IPv4 addressesYesYesYes
-6Use only IPv6 addressesYesYesYes
-p portDefine the port for the query.NoYesNo
-FDon’t allow packet fragmentationYesYesNo
-nStop the resolving of the IP addresses.YesYesNo

Traceroute vs Ping

While you can use both the commands, Traceroute and Ping, to check general connectivity to a destination, these commands serve different purposes.

Both will show you a similar time for the final destination.

The Traceroute not only pings the last point but each one on the way. That helps you pinpoint a problematic router or indicate where you need a new DNS server to shorten the time of response.

Alterative to the Traceroute command

There are several alternatives to the traceroute command, which are open-source and free too.

MTR command on Linux and macOS

mtr domainname.com

It will give you a bit better idea about the lost packets (percentage).  

Dig command on Linux and macOS

dig +trace www.yourdomain.com

It will show you the route to the domain name.

Open Visual Traceroute (for Linux, macOS, and Windows)

You can use this software to visualize better the route of a query. You will have a map and a Gantt graph.

You can try them or stick to the already included Traceroute or Tracert command on your OS. It is a personal choice. Additional software might add extra information, but sometimes a quick answer from a CLI software is all that you need. 

Conclusion

The Traceroute command or its Windows equivalent Tracert command are useful network diagnostic tools that will help you indicate a problematic spot on the network. Later, with the data you get, you can make a decision and fix the problem if it is in your hands. If it is not currently, you can think about DNS and setting up a point of presence that could facilitate the domain resolving and lower the latency. The speed is very important, and you should not leave it to the change. Actively reduce the latency in any way you can.

Leave a Reply

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