Traceroute Command: Principles, Options, Usage Examples, and Troubleshooting Cases
This article explains the traceroute command’s working principle, details its many options, provides practical usage examples, and presents two real‑world troubleshooting cases that illustrate how traceroute can locate misconfigurations, asymmetric paths, and routing loops in Linux networks.
Traceroute Principles and Functions
Traceroute is a common Linux network diagnostic command that tracks the path of packets from the source host to the destination host, helping identify latency and packet loss.
It works by sending packets with an initial TTL of 1, incrementing the TTL for each subsequent probe, and receiving ICMP Time Exceeded messages from each router along the route until the destination is reached.
The command is used to test the route taken by data packets and to verify network reachability and locate faults.
Command Syntax
The basic syntax is:
traceroute [options] [host]Option Descriptions
Various options control the behavior of traceroute, such as:
-d # use socket-level debugging
-f # set initial TTL
-F # set "don't fragment" flag
-g # specify loose source routing gateways (up to 8)
-i # specify network interface
-I # use ICMP echo instead of UDP
-m # set maximum TTL
-n # show numeric IP addresses only
-p # set destination UDP port
-r # bypass normal routing table
-s # set source IP address
-t # set TOS value
-v # verbose output
-w # set timeout per probe
-x # enable/disable packet checksum verificationDetailed Usage Examples
Configure Wait Time
Change default wait time (3 seconds) to 1 second:
traceroute -w 1 google.comChange Number of Probes per Hop
Send 4 probes per hop instead of the default 3:
traceroute -q 4 google.comSet Maximum Hop Count
Limit the maximum number of hops to 4:
traceroute -m 4 google.comSpecify Starting TTL
Begin tracing from TTL 5:
traceroute -f 5 google.comAdd Source IP Address
Use a specific source IP:
traceroute -s 192.168.1.7 google.comDisable Hostname Resolution
Show only numeric IP addresses:
traceroute -n google.comSpecify Gateway
Route probes through a specific gateway:
traceroute -g 192.168.1.7 google.comChange Destination Port
Set a custom UDP destination port:
traceroute -p 29879 google.comSet Packet Length
Default packet size is 60 bytes; you can specify a different size after the host:
traceroute google.comDisable Packet Fragmentation
Prevent probes from being fragmented:
traceroute -F google.comTroubleshooting Cases
Case ①: Locate Misconfigured Network Segment
A campus network shows poor performance when host 4.0.0.2 accesses server 5.0.0.2. Ping results reveal alternating short and long response times, indicating two different paths. Traceroute from Router C to Router A identifies the discrepancy at hop 6, pointing to a static routing issue between Router B and Router A. The static routes lack priority, causing load‑sharing instead of primary/backup behavior. Adjusting route metrics or deploying a dynamic protocol resolves the problem.
Case ②: Detect a Routing Loop
Three routers with static routes cause a loop, preventing ping from reaching host 4.0.0.2. Traceroute from Router A shows repeated hops between Router A and Router B, confirming a loop. The static route on Router B mistakenly points to Router A instead of the correct next hop. Correcting the route eliminates the loop.
Recommendations
Traceroute quickly reveals latency issues, asymmetric paths, and routing loops, making it indispensable for network operations and troubleshooting in complex environments.
Selected Java Interview Questions
A professional Java tech channel sharing common knowledge to help developers fill gaps. Follow us!
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.