Operations 13 min read

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.

Selected Java Interview Questions
Selected Java Interview Questions
Selected Java Interview Questions
Traceroute Command: Principles, Options, Usage Examples, and Troubleshooting Cases

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 verification

Detailed Usage Examples

Configure Wait Time

Change default wait time (3 seconds) to 1 second:

traceroute -w 1 google.com

Change Number of Probes per Hop

Send 4 probes per hop instead of the default 3:

traceroute -q 4 google.com

Set Maximum Hop Count

Limit the maximum number of hops to 4:

traceroute -m 4 google.com

Specify Starting TTL

Begin tracing from TTL 5:

traceroute -f 5 google.com

Add Source IP Address

Use a specific source IP:

traceroute -s 192.168.1.7 google.com

Disable Hostname Resolution

Show only numeric IP addresses:

traceroute -n google.com

Specify Gateway

Route probes through a specific gateway:

traceroute -g 192.168.1.7 google.com

Change Destination Port

Set a custom UDP destination port:

traceroute -p 29879 google.com

Set Packet Length

Default packet size is 60 bytes; you can specify a different size after the host:

traceroute google.com

Disable Packet Fragmentation

Prevent probes from being fragmented:

traceroute -F google.com

Troubleshooting 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.

operationsnetwork troubleshootingtracerouteLinuxDiagnostics
Selected Java Interview Questions
Written by

Selected Java Interview Questions

A professional Java tech channel sharing common knowledge to help developers fill gaps. Follow us!

0 followers
Reader feedback

How this landed with the community

login Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.