
traceroute Command in Linux
The traceroute command in Linux traces the path packets take to reach a network host. It shows each hop (router) along the route and measures the round-trip time to each. This command is helpful in diagnosing issues when a website fails to load or a server is unreachable. It is also useful for spotting where network problems or slow connections are happening.
Table of Contents
Here is a comprehensive guide to the options available with the traceroute command −
- Installation of traceroute Command
- Syntax of traceroute Command
- traceroute Command Options
- Examples of traceroute Command in Linux
Installation of traceroute Command
By default, the traceroute command may not be installed on Linux. To install it on Ubuntu, Kali Linux, Raspberry Pi OS, Debian, and other Debian-based distributions, use the following command −
sudo apt install traceroute
To install it on Arch Linux, use the command below −
sudo pacman -S traceroute
To install traceroute on Fedora, use the following command −
sudo dnf install traceroute
To verify the installation of the traceroute command, check its version −
traceroute -V

Syntax of traceroute Command
The syntax of the Linux traceroute command is as follows −
traceroute [options] [host]
In the above syntax, the [options] argument is used to specify optional flags or settings that modify how the command works. The [host] argument is the destination IP address or domain name that the command traces the path to.
traceroute Command Options
The options for the traceroute command in Linux are listed below −
Short Option | Long Option | Description |
---|---|---|
-4 / -6 | Force IPv4 or IPv6 usage | |
-I | --icmp | Use ICMP ECHO for probes |
-T | --tcp | Use TCP SYN for probes |
-d | --debug | Enable socket-level debugging |
-F | --dont-fragment | Prevent packet fragmentation |
-f | --first | Set initial TTL (default 1) |
-g | --gateway | Route through specified gateway(s) |
-i | --interface | Use the specified network interface |
-m | --max-hops | Max hops (TTL), default is 30 |
-N | --sim-queries | Send probes in parallel (default 16) |
-n | Skip hostname lookup, show IPs only | |
-p | --port | Set destination/source port for probes |
-t | --tos | Set Type of Service or Traffic Control |
-l | --flowlabel | Set flow label for IPv6 |
-w | --wait | Set probe response wait time |
-q | --queries | Probes per hop (default 3) |
-r | Bypass the routing table, send direct | |
-s | --source | Use an alternative source address |
-z | --sendwait | Set a delay between sending probes |
-e | --extensions | Show ICMP extensions |
-A | --as-path-lookups | Show AS path info |
-V | --version | Print version info and exit |
--sport | Set source port | |
--fwmark | Set the firewall mark | |
-M | --module | Use the specified tracing method |
-O | --options | Set method-specific options |
-U | --udp | Use UDP with fixed port (default 53) |
-UL | Use UDPLITE (default port 53) | |
-D | --dccp | Use DCCP for probes |
-P | --protocol | Use a raw packet with the given protocol |
--mtu | Detect MTU along the path | |
--back | Show guessed reverse path hops | |
--help | Print help info and exit |
Examples of traceroute Command in Linux
This section demonstrates how to use the traceroute command in Linux with examples −
Tracing Route of a Host
To trace the route of a host, use the traceroute command followed by the hostname −
traceroute google.com

Skipping DNS Lookup
To skip the DNS lookup and make the route tracing quicker, use the -n option −
traceroute -n google.com

Setting the Maximum Number of Hops
To set the maximum number of hops, use the -m or --max-hops option −
traceroute -m 5 google.com

Changing Number of Probes
The default number of probes per hop is 3. To change the number of probes, use the -q or --queries option −
traceroute -q 5 google.com

Using ICMP Echo
By default, traceroute uses UDP (User Datagram Protocol) packets. To use ICMP echo, use -I or --icmp option −
sudo traceroute -I google.com

Note: On systems like macOS or BSD, the traceroute uses ICMP by default.
Using TCP SYN Packets
By default, traceroute uses UDP (User Datagram Protocol) packets in Linux. To use TCP SYN packets, use -T or --tcp option −
sudo traceroute -T google.com

Note: The use of TCP SYN (-T) requires root privileges.
Sending a Probe to a Port
To send a probe to a destination port, use -p or --port option −
traceroute -p 443 google.com

Setting Delay for Response
To wait for a specific number of seconds after each response, use the -w or --wait option.
traceroute -w 5 google.com
Detecting MTU
To detect the Maximum Transmission Unit (MTU) size on each hop along the route, use the --mtu option with the traceroute command −
traceroute --mtu google.com

Displaying Usage Help
To display the usage help of the traceroute command, use the --help option −
traceroute --help
Conclusion
The traceroute command in Linux helps track the path network packets take to reach a specific destination, making it useful for diagnosing connectivity issues. This tutorial explained how to install traceroute on various Linux distributions, described its syntax, detailed its available options, and provided practical usage examples.