Using Traceroute for Linux Network Troubleshooting
The traceroute command in Linux is an essential
diagnostic utility used to map the journey packets take from a local
system to a remote destination host. This article covers how
traceroute functions, why it is vital for identifying
latency and connection failures, the interpretation of its output, and
the most common command-line options used during network
troubleshooting.
What is the Traceroute Command?
traceroute tracks the route that data packets travel
across an Internet Protocol (IP) network. When communication between a
Linux host and a destination server fails or experiences severe
degradation, traceroute identifies the exact path
traversed, displaying every intermediary router (or "hop") along with
the round-trip transit time for each.
How Traceroute Works
The utility operates by manipulating the Time-to-Live (TTL) field in the IP header of network packets:
- Initial Probe:
traceroutesends packets with a TTL value set to 1. The first router that encounters the packet decrements the TTL to 0, drops the packet, and returns anICMP Time Exceededmessage back to the sender. This identifies the first hop. - Incrementing TTL: The tool systematically increases the TTL value by 1 for each subsequent set of packets (TTL = 2, TTL = 3, etc.), mapping each consecutive router along the route.
- Completion: The process continues until the packets reach the destination host or exceed the maximum hop limit (default is typically 30 hops).
By default, the Linux implementation of traceroute sends
UDP packets to high-numbered, unassigned ports, though it can also be
configured to use ICMP or TCP probes.
Primary Use Cases in Network Troubleshooting
Network administrators rely on traceroute to diagnose
several specific failure modes:
- Pinpointing Packet Loss and Outages: If packets
fail to progress beyond a certain hop,
traceroutereveals the last responsive router. This indicates whether the failure resides within the local network, an upstream Internet Service Provider (ISP), or the remote infrastructure. - Locating Latency Bottlenecks:
traceroutemeasures and displays three round-trip times (RTT) for each hop. A sudden, sustained jump in millisecond response times between two consecutive hops highlights where network congestion or suboptimal routing is occurring. - Detecting Routing Loops: If routing tables are
misconfigured, a packet may bounce endlessly between two routers until
the TTL expires.
traceroutedisplays this behavior as alternating hops repeating in a cycle. - Bypassing Firewall Restrictions: Firewalls often
block default UDP trace packets.
tracerouteallows switching to ICMP Echo or TCP SYN packets to verify whether traffic is actively dropped by network policies rather than broken routing.
Basic Syntax and Common Options
The general syntax is straightforward:
traceroute [options] <destination_host_or_ip>Key options for troubleshooting include:
-n(Numeric Output): Disables DNS reverse lookups, showing only IP addresses. This speeds up the trace and prevents slow DNS responses from skewing the results.traceroute -n example.com-I(ICMP Echo): Uses ICMP Echo requests instead of UDP datagrams. This mimics traditionalpingbehavior and often passes through firewalls that drop UDP traffic.traceroute -I example.com-T(TCP SYN): Employs TCP SYN packets (defaulting to port 80). This is useful for troubleshooting web servers that block both UDP and ICMP traffic.traceroute -T -p 443 example.com-m <value>(Max Hops): Specifies the maximum number of hops to query before terminating the trace (default is 30).traceroute -m 20 example.com
Understanding the Output
A standard traceroute output displays a row for each hop
containing:
- Hop Number: The sequential index of the router along the path.
- Hostname and IP: The network identifier of the
router (or only IP if
-nis used). - RTT Times: Three round-trip latency values, measuring the time taken for each probe sent to that hop.
If a hop displays asterisks (* * *), it means the router
did not reply with an ICMP Time Exceeded message within the
timeout period. This is often benign, resulting from routers configured
to ignore low-priority ICMP generation, provided that subsequent hops
continue to respond normally. However, if asterisks persist continuously
until the trace times out, traffic is being dropped entirely at that
point in the route.