Master Linux Traceroute: Install, Use, and Advanced Options Explained
Learn how to install the traceroute utility on Debian/Ubuntu and CentOS/RHEL systems, understand its basic command syntax, explore common and advanced options, and see practical examples for network path tracing, while noting important considerations and usage tips.
In Linux,
tracerouteis a network diagnostic tool that determines the route packets take from your computer to a target host such as a website or remote server.
If the tool is not installed, you can add it via the package manager.
Debian/Ubuntu and derivatives
<code>sudo apt-get update
sudo apt-get install traceroute</code>CentOS/RHEL and derivatives
<code>sudo yum install traceroute</code>On newer versions you may need to use
dnfinstead of
yum:
<code>sudo dnf install traceroute</code>Basic command format
<code>traceroute [options]... [target host]</code>Basic usage example
Trace the route to
example.com:
<code>traceroute example.com</code>Common options
-n: Do not perform DNS lookups, show IP addresses only.
-w: Set the timeout in seconds.
-p: Specify the destination port (default 33434).
-m: Set the maximum number of hops (default 30).
-s: Set the source port number.
-I: Use ICMP packets.
-4or
-6: Force IPv4 or IPv6.
-q: Set the number of probe packets per hop (default 3).
-T: Use TCP packets.
-A: Use all protocols (UDP, TCP, ICMP).
Advanced options
-P proto: Choose protocol (tcp, udp, icmp, ip).
-S srcaddr: Set source address.
-g gateway: Specify a gateway to skip.
-N: Use NTP mode for time queries.
-F: Set the “Don’t Fragment” flag to control MTU.
Examples
Disable DNS lookup:
<code>traceroute -n example.com</code>Use ICMP protocol:
<code>traceroute -I example.com</code>Set maximum hops to 20:
<code>traceroute -m 20 example.com</code>Use TCP protocol:
<code>traceroute -T example.com</code>Use all protocols:
<code>traceroute -A example.com</code>Send 5 probe packets:
<code>traceroute -q 5 example.com</code>Set timeout to 10 seconds:
<code>traceroute -w 10 example.com</code>Notes
Some network devices may block traceroute packets, resulting in incomplete or inaccurate paths.
When using traceroute, comply with network policies and legal regulations to avoid misuse.
On certain Linux distributions,
traceroutemay require root privileges.
tracerouteis an essential tool for network troubleshooting and performance analysis, helping identify where latency or packet loss occurs.
Raymond Ops
Linux ops automation, cloud-native, Kubernetes, SRE, DevOps, Python, Golang and related tech discussions.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.