The Traceroute command in Linux: track the package route

What is traceroute?

Traceroute is a network diagnostic tool that shows the route that IP packages follow from source to a specific destination. In each jump, the command sends packages with a growing TTL (Time to Live) value and records the ICMP response »Time Exceeded» which return the intermediate routers. In this way, you can identify at which point excessive latency, loss of packages or even a connection cut occurs. Although its operation is based on ICMP, many distributions also offer variants that use UDP or TCP, allowing it to adapt to firewalls that block certain types of traffic. Knowing traceroute is essential for system managers, network engineers and any user who needs to solve connectivity problems.

Traceroute installation in Linux

In most modern distributions, traceroute is already pre-installed, but if it is missing, its installation is simple. In Debian / Ubuntu based systems, just runsudo apt update && sudo apt install traceroute. In Red Hat, CentOS or Fedora, the corresponding command issudo dnf install traceroute(in more recent versions) orsudo yum install traceroutein old versions. In Arch Linux, it is usedsudo pacman -S traceroute. After installation, the availability can be verified by runningtraceroute --version, which will show the version number and the supported options. Some distributions also offer the packagetraceroute6to work exclusively with IPv6.

Basic syntax and simple use

The simplest format of the command istraceroute destinowheredestinocan be an IP address or a resolble domain name by DNS. For example,traceroute 8.8.8.8will show the route to Google's public DNS server. When running, the output is composed of numbered lines representing each jump; each line includes the jump number, the IP address of the responding router and, optionally, the host name if it can be solved, followed by three response times measured in milliseconds (by default, three probes are sent by jump). If one of those times shows an asterisk (*), indicates that no response was received within the expected waiting time.

Interpretation of the exit

Analyzing the traceroute output allows you to detect network problems quickly. A progressive increase in response times indicates congestion or less capacity links in this segment. If several consecutive asterisks appear in the same jump, it may mean that the router is configured to not respond to the time-exceeded ICMP packages, or that there is a filter that discards them. A jump that shows a very high time followed by a sharp improvement in the next can point to a punctual problem, such as an overloaded link or a change of route. In addition, the emergence of private IP addresses on the track (e.g. 10.x.x.x or 192.168.x.x) suggests that traffic is going through an internal network before going on the Internet, which is normal in corporate environments.

Useful Traceroute Options

  • -n: avoids DNS name resolution, showing only IP addresses and accelerating the execution.
  • -I: forces the use of ICMP ECHO packages instead of the default value (UDP in many implementations).
  • -T: uses TCP SYN packages that are useful for removing firewalls that block ICMP or UDP.
  • -f valor: establece el TTL inicial, permitiendo omitir los primeros saltos conocidos.
  • -m valor: define el número máximo de saltos (TTL máximo) que el comando intentará alcanzar.
  • -q numero: ajusta la cantidad de sondas enviadas por salto (por defecto 3).
  • -w tiempo: establece el tiempo de espera en segundos para cada respuesta.

Practical examples

Suppose we want to diagnose connectivity to an internal web serverintranet.empresa.local. We can run:

traceroute -n intranet.empresa.local

This will show the route without trying to solve names, which is useful if the internal DNS is not available. If we suspect that a firewall blocks the UDP packages, we can switch to TCP:

traceroute -T -p 443 intranet.empresa.local

Here we specify port 443 (HTTPS) so that the TCP SYN probes are directed to the web service, increasing the probability of getting answers. In another scenario, if we want to limit the trace to a maximum of 15 jumps and wait half a second per response, we use:

traceroute -m 15 -w 0.5 google.com

Finally, to get only IP addresses and speed up the test on a high latency network, we combine-nand-q 1:

traceroute -n -q 1 203.0.113.10

Limitations and considerations

Although traceroute is very versatile, it has certain limitations that must be taken into account. First, it depends on intermediate routers sending ICMP messages »Time Exceeded»; if a device is configured to rule out those messages, the trace will show asterisks and it will not be possible to identify that jump. Second, the presence of load balancing or asymmetric routes can make the probes follow different paths in each attempt, which generates a confused output with multiple directions for the same jump number. Finally, traceroute does not measure the bandwidth or the loss of packages directly; for these metrics, tools such aspingwith adjusted intervals,mtroriperf. Despite these limitations, it remains one of the first lines of diagnosis when problems of routing or latency are suspected.

Conclusion

The Linux traceroute command is an essential tool for any professional working with networks. Its ability to show the course of the packages and the response times in each jump allows to quickly identify congestion points, routing failures or wrong firewalls configurations. Knowing your basic syntax, the most common options and how to interpret the output gives you a significant advantage by solving connectivity incidents. Whether you are managing a server, managing a corporate infrastructure or simply curious about how your traffic reaches a remote destination, traceroute provides you with the visibility to make informed decisions and keep the network running in an optimal way.

This work is under aCreative Commons License Attribution 4.0 International for Francesc Roig francesc @ vivaldi.net.

EnglishenEnglishEnglish