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.
|Linux||traceroute domainname.com or traceroute 188.8.131.52|
|macOS||traceroute domainname.com or traceroute 184.108.40.206|
|Windows||tracert domainname.com or tracert 220.127.116.11|
There are small differences between the traceroute command on Linux, macOS, and Windows.
Traceroute/Tracert command syntax
|Linux||traceroute [options] host_Address [pathlength]|
|macOS||traceroute [options] host [packetsize]|
|Windows||tracert [-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 traceroute||What does it do?||Is it on Linux?||Is it on macOS?||Is it on Windows?|
|-d||With this option, you stop the addresses to hostnames resolving.||No||No||Yes|
|-d –debug||This command enables debugging on Linux.||Yes||No||No|
|-h maximum_hops||Define, the maximum amount of hops for the request.||No||No||Yes|
|-m max_ttl||The TTL in traceroute means maximum amount of hops.||Yes||Yes||No|
|-j host-list||Only for IPv4 – loose source route along host-list.||No||No||Yes|
|-w timeout||Maximum waiting time for each of the replies.||No||No||Yes|
|-w waittime –wait=waittime||Maximum waiting time for each of the replies.||Yes||Yes||No|
|-I –icmp||Use the ICMP echo for the requests.||Yes||No||No|
|-R||Tracert, but for IPv6 only.||No||No||Yes|
|-S srcaddr||IPv6 only – source address.||No||No||Yes|
|-4||Use only IPv4 addresses||Yes||Yes||Yes|
|-6||Use only IPv6 addresses||Yes||Yes||Yes|
|-p port||Define the port for the query.||No||Yes||No|
|-F||Don’t allow packet fragmentation||Yes||Yes||No|
|-n||Stop the resolving of the IP addresses.||Yes||Yes||No|
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
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.
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.