Website Vidya
Linux & ServersStep-by-Step Guide

traceroute Command in Linux: Network Path and Hop Latency Diagnostics

Learn traceroute command in linux with syntax, essential flags, practical terminal examples, real-world sysadmin workflows, security tips, and troubleshooting.

RR
Rajesh RayLead Systems Educator
Published:
10 min read
PDF Cheat Sheet
traceroute Command in Linux: Network Path and Hop Latency Diagnostics
AI Executive SummaryWebsiteVidya AI

10 min read

Learn traceroute command in linux with syntax, essential flags, practical terminal examples, real-world sysadmin workflows, security tips, and troubleshooting.

Key Highlights
  • What traceroute Does and When to Use It
  • Availability and Installation Across Linux Distributions
  • Command Syntax, Arguments, and Exit Status Codes
Grounded in full engineering runbookWebsiteVidya AI Engine

The traceroute command in linux is the industry-standard network diagnostic utility used by systems engineers, network architects, and cloud administrators to map the topological path IP packets traverse across the internet. Whether investigating high application latency, diagnosing packet loss between distributed Kubernetes clusters, or isolating an ISP routing fault, traceroute exposes every intermediate router interface linking your server to a target host.

First created by Van Jacobson in 1988, traceroute operates by exploiting the Time-To-Live (TTL) field in IPv4 headers (or the Hop Limit in IPv6 headers). Every router forwarding an IP packet decrements its TTL by one; when the TTL drops to zero, the router discards the packet and returns an ICMP Time Exceeded error back to the originating host. By dispatching probes with systematically increasing TTL values (1, 2, 3, etc.), traceroute reconstructs the entire router chain hop by hop.

While legacy Unix implementations relied strictly on high-port UDP probes, modern Linux traceroute supports ICMP Echo requests, TCP SYN handshakes, and UDP datagrams. Understanding how to select the right probe method enables engineers to bypass edge firewalls and cloud security groups that silently drop unassigned UDP packets.

Advertisement
traceroute Command in Linux: Network Path and Hop Latency Diagnostics — syntax, flags, and practical terminal workflow diagram
traceroute Command in Linux: Network Path and Hop Latency Diagnostics — command syntax, key options, and production workflow reference.

What traceroute Does and When to Use It

At the transport layer, traceroute dispatches a sequence of probe packets (typically three probes per hop) starting with TTL=1. When the first-hop default gateway receives a probe with TTL=1, it decrements the TTL to 0, drops the datagram, and generates an ICMP Type 11 Code 0 (Time Exceeded in Transit) packet directed back to the source IP. Traceroute records the sender IP of the ICMP message and calculates the round-trip time (RTT) between probe transmission and ICMP arrival.

The utility continues incrementing TTL until the probe reaches the target destination. In default UDP mode, traceroute targets destination ports between 33434 and 33534 (unlikely to be bound by an application). When the destination host receives the datagram, it generates an ICMP Type 3 Code 3 (Port Unreachable) error, indicating to traceroute that the final destination has been reached and concluding the trace.

At the operating system level, traceroute interacts with the Linux kernel networking stack through netlink sockets (AF_NETLINK), raw packet sockets, or standard POSIX resolver APIs. When running traceroute in cloud instances or Kubernetes worker nodes, combining flags such as -I, -T, -U, -p PORT lets you bypass slow reverse DNS lookups and inspect numeric IPv4/IPv6 addresses and socket states directly.

Availability and Installation Across Linux Distributions

The traceroute utility is packaged in traceroute across mainstream Linux distributions. It is pre-installed on standard Ubuntu, Debian, RHEL, Rocky Linux, AlmaLinux, Fedora, and Arch Linux systems, while minimal container images may require manual installation:

Advertisement

Before running administrative tasks or automation scripts, verify whether traceroute is installed and inspect which binary path and version your shell resolves:

type -a traceroute
traceroute --version 2>/dev/null || man -f traceroute

# Illustrative output (reviewed against documentation)
traceroute is /usr/bin/traceroute
traceroute (traceroute)
# Debian / Ubuntu
sudo apt-get update && sudo apt-get install -y traceroute

# RHEL / Rocky / AlmaLinux / Fedora
sudo dnf install -y traceroute

# Arch Linux
sudo pacman -S --noconfirm traceroute

# Alpine Linux
sudo apk add --no-cache traceroute

Command Syntax, Arguments, and Exit Status Codes

traceroute [OPTIONS] HOST [PACKET_LEN]

The traceroute syntax follows: traceroute [OPTIONS] HOST [PACKET_LEN]. The HOST argument can be a domain name or an IPv4/IPv6 address. An optional PACKET_LEN parameter overrides the default packet size (typically 60 bytes for IPv4).

Essential command options control the transport protocol and timing: -I selects ICMP Echo probes (identical to Windows tracert), -T selects TCP SYN probes (ideal for testing web servers behind firewalls), -n suppresses reverse DNS lookups, -m specifies the maximum hop limit (default 30), and -w configures the response wait timeout in seconds.

  • 0 — Successful trace execution; target destination reached or maximum hop limit reached cleanly.
  • 1 — Operational error; host cannot be resolved, network interface down, or invalid parameters.
  • 2 — Command-line syntax error or unsupported probe method selected.

Important Options and Flags Reference

Option / FlagLong Form / ArgumentTechnical Behavior and Purpose
-I--icmpUses ICMP ECHO requests as probe packets instead of default UDP datagrams.
-T--tcpUses TCP SYN packets as probes (defaults to destination port 80; overrides with -p).
-U--udpUses UDP datagrams to a specific fixed port (rather than incrementing ephemeral ports).
-p PORT--port=PORTSpecifies the destination port number for UDP or TCP probes (e.g., -p 443).
-n-nDisables reverse DNS resolution of intermediate router IP addresses, accelerating output.
-m MAX--max-hops=MAXSets the maximum number of router hops to probe before aborting (default: 30).
-w SECS--wait=SECSConfigures the timeout interval in seconds to wait for a response from each hop (default: 5.0).
-q N--queries=NSets the number of probe packets dispatched per hop (default: 3 probes per hop).
-F--dont-fragmentSets the Don't Fragment (DF) bit on outgoing IP packets to test Path MTU Discovery.

In modern cloud environments (AWS, Google Cloud, Azure), default UDP traceroute probes are frequently blocked by intermediate firewalls and security groups, causing the trace to degenerate into a series of asterisks (* * *). Switching to TCP SYN probes directed at an open service port (for example, sudo traceroute -T -p 443 -n example.com) passes through stateful firewalls cleanly and accurately maps the complete cloud network route.

Advertisement

Always include the -n flag when diagnosing live network incidents. Suppressing reverse DNS lookups prevents slow or timed-out PTR queries from stalling your trace, reducing execution time from several minutes to just a few seconds.

When combining short flags on the command line, POSIX and GNU utilities allow clustering boolean flags behind a single hyphen, provided any option taking an argument appears last. In automated shell scripts, using long-form GNU options where portable makes self-documenting code that is easier to audit during peer review.

Practical Basic and Advanced Usage Examples

1. Execute a Standard UDP Trace to a Remote Domain

Perform a standard network route trace to identify intermediate router hops and latency across public networks.

traceroute example.com

# Illustrative output (reviewed against documentation)
traceroute to example.com (93.184.216.34), 30 hops max, 60 byte packets
 1  gateway (192.0.2.1)  0.842 ms  0.710 ms  0.695 ms
 2  core-rtr-01.isp.net (198.51.100.254)  4.210 ms  4.112 ms  4.090 ms
 3  edge01.datacenter.net (203.0.113.1)  12.450 ms  12.390 ms  12.510 ms
 4  93.184.216.34 (93.184.216.34)  14.210 ms  14.180 ms  14.240 ms

The output lists each router hop, displaying the reverse DNS hostname, numeric IP address, and three latency measurements representing round-trip times for each probe.

2. Fast Numeric Trace Bypassing Reverse DNS

Accelerate traceroute execution by disabling reverse DNS lookups, outputting raw numerical IP addresses.

traceroute -n example.com

# Illustrative output (reviewed against documentation)
traceroute to example.com (93.184.216.34), 30 hops max, 60 byte packets
 1  192.0.2.1  0.712 ms  0.690 ms  0.680 ms
 2  198.51.100.254  3.840 ms  3.810 ms  3.790 ms
 3  203.0.113.1  11.910 ms  11.880 ms  11.950 ms
 4  93.184.216.34  13.820 ms  13.790 ms  13.810 ms

Disabling DNS resolution eliminates timeout delays caused by unresponsive in-addr.arpa nameservers along the transit path.

3. Perform ICMP Echo Traceroute (Windows tracert Behavior)

Use ICMP Echo requests instead of UDP datagrams, which is often permitted through corporate firewalls.

sudo traceroute -I example.com

# Illustrative output (reviewed against documentation)
traceroute to example.com (93.184.216.34), 30 hops max, 60 byte packets
 1  192.0.2.1  0.650 ms  0.620 ms  0.610 ms
 2  198.51.100.254  3.510 ms  3.490 ms  3.480 ms
 3  203.0.113.1  11.200 ms  11.180 ms  11.150 ms
 4  93.184.216.34  13.100 ms  13.080 ms  13.050 ms

The -I option switches from UDP to standard ICMP Echo requests, mimicking the behavior of the Microsoft Windows tracert utility.

4. Bypass Firewalls Using TCP SYN Probes on HTTPS Port 443

Trace the network path to a web server that filters ICMP and UDP by sending TCP SYN packets to port 443.

sudo traceroute -T -p 443 -n example.com

# Illustrative output (reviewed against documentation)
traceroute to example.com (93.184.216.34), 30 hops max, 60 byte packets
 1  192.0.2.1  0.580 ms  0.550 ms  0.540 ms
 2  198.51.100.254  3.420 ms  3.390 ms  3.410 ms
 3  203.0.113.1  10.950 ms  10.910 ms  10.880 ms
 4  93.184.216.34  12.850 ms  12.820 ms  12.800 ms

TCP SYN probes establish standard TCP handshakes at the destination, allowing the trace to penetrate stateful firewalls that drop UDP traffic.

5. Limit Maximum Hops and Configure Custom Timeout

Restrict the trace to a local network segment by capping maximum hops at 10 and setting a 1-second timeout.

traceroute -m 10 -w 1 192.168.1.100

# Illustrative output (reviewed against documentation)
traceroute to 192.168.1.100 (192.168.1.100), 10 hops max, 60 byte packets
 1  gateway (192.168.1.1)  0.420 ms  0.390 ms  0.380 ms
 2  192.168.1.100 (192.168.1.100)  1.210 ms  1.180 ms  1.150 ms

Setting -m 10 stops scanning after 10 hops, preventing wasted time probing unreachable internet routes.

6. Specify Outgoing Network Interface for Multi-Homed Hosts

Force traceroute to send probe packets out of a specific network device on a multi-homed server or VPN client.

traceroute -i eth1 -n 198.51.100.25

# Illustrative output (reviewed against documentation)
traceroute to 198.51.100.25 (198.51.100.25), 30 hops max, 60 byte packets
 1  10.10.0.1  0.920 ms  0.890 ms  0.880 ms
 2  198.51.100.25  14.500 ms  14.480 ms  14.450 ms

The -i eth1 flag overrides standard kernel routing lookup, dispatching probes directly through the eth1 interface.

Real-World Workflows, Pipelines, and Shell Automation

Network Latency Bottleneck and Packet Loss Diagnosis Pipeline

Isolate whether connection lag is caused by local network equipment, an intermediate ISP transit provider, or the remote server infrastructure.

#!/usr/bin/env bash
set -euo pipefail

TARGET="example.com"
REPORT="/tmp/traceroute_diagnostic.txt"

echo "=== Running Multi-Protocol Route Diagnostics for: ${TARGET} ==="

echo "--- 1. Testing Default Fast Numeric Trace ---"
traceroute -n -w 2 "${TARGET}" | tee "${REPORT}"

echo "--- 2. Checking for Firewall Filtering (TCP Port 443) ---"
if grep -q "* * *" "${REPORT}"; then
  echo "Asterisks detected in UDP trace. Re-testing with TCP SYN on port 443..."
  sudo traceroute -T -p 443 -n -w 2 "${TARGET}" | tee -a "${REPORT}"
fi

echo "--- 3. Analyzing Latency Jump Across Hops ---"
awk '
  $1 ~ /^[0-9]+$/ {
    hop = $1;
    ip = $2;
    lat = $(NF-1);
    if (lat ~ /^[0-9.]+$/) {
      if (lat > 50) {
        printf "HIGH LATENCY ALERT: Hop %s (%s) reported %s ms\n", hop, ip, lat;
      }
    }
  }
' "${REPORT}"

# Illustrative output (reviewed against documentation)
=== Running Multi-Protocol Route Diagnostics for: example.com ===
--- 1. Testing Default Fast Numeric Trace ---
traceroute to example.com (93.184.216.34), 30 hops max, 60 byte packets
 1  192.0.2.1  0.710 ms  0.680 ms  0.670 ms
 2  198.51.100.254  3.840 ms  3.810 ms  3.790 ms
 3  203.0.113.1  78.910 ms  79.120 ms  78.850 ms
 4  93.184.216.34  82.410 ms  82.150 ms  82.200 ms
--- 3. Analyzing Latency Jump Across Hops ---
HIGH LATENCY ALERT: Hop 3 (203.0.113.1) reported 78.910 ms
HIGH LATENCY ALERT: Hop 4 (93.184.216.34) reported 82.410 ms

This production bash script automates route diagnostics, retries with TCP SYN if UDP packets are dropped, and parses latency jumps to pinpoint the exact upstream hop introducing network delay.

Multi-Cloud Ingress Path Comparison Workflow

Compare network transit paths and hop counts from a central monitoring host to AWS, GCP, and Azure public IP endpoints.

#!/usr/bin/env bash
set -euo pipefail

declare -A CLOUD_ENDPOINTS=(
  ["AWS"]="52.95.110.1"
  ["GCP"]="34.102.136.180"
  ["Azure"]="20.190.159.0"
)

echo "=== Comparing Cloud Provider Ingress Routing Paths ==="
for cloud in "${!CLOUD_ENDPOINTS[@]}"; do
  ip="${CLOUD_ENDPOINTS[$cloud]}"
  echo "--- Probing ${cloud} (${ip}) ---"
  HOPS=$(traceroute -n -m 20 -q 1 "${ip}" | awk 'END {print $1}')
  FINAL_LATENCY=$(traceroute -n -m 20 -q 1 "${ip}" | awk 'END {print $(NF-1), $NF}')
  printf "Provider: %-6s | Total Hops: %-3s | Final Latency: %s\n" "${cloud}" "${HOPS}" "${FINAL_LATENCY}"
done

# Illustrative output (reviewed against documentation)
=== Comparing Cloud Provider Ingress Routing Paths ===
--- Probing AWS (52.95.110.1) ---
Provider: AWS    | Total Hops: 8   | Final Latency: 14.210 ms
--- Probing GCP (34.102.136.180) ---
Provider: GCP    | Total Hops: 6   | Final Latency: 9.850 ms
--- Probing Azure (20.190.159.0) ---
Provider: Azure  | Total Hops: 9   | Final Latency: 16.420 ms

The script surveys routing topologies across three major hyperscalers, reporting total intermediate hops and round-trip times to aid in multi-cloud deployment decisions.

Pipelines, Redirection, Quoting, and Shell Expansion

When embedding traceroute inside shell pipelines (|), conditional chains (&& and ||), or command substitutions ($(...)), the calling shell performs tilde expansion, variable interpolation, and globbing before invoking the binary. Always wrap paths, patterns, and variables in quotes so whitespace and wildcard characters (*, ?) are not expanded prematurely, and use set -euo pipefail in unattended scripts.

Permissions, Security Implications, and Safe Execution

Using ICMP Echo (-I) or TCP SYN (-T) probing methods requires root privileges or the CAP_NET_RAW capability. Unprivileged users can execute standard UDP traceroute, but if local outbound UDP is blocked by a host firewall, sudo elevation is necessary to utilize TCP/ICMP probe options.

Security-conscious network engineers frequently configure internet-facing edge routers with Control Plane Policing (CoPP) or ICMP rate limits. When a router's CPU is busy forwarding transit traffic, it may deprioritize generating ICMP Time Exceeded packets, causing artificially inflated latency readings or asterisks on individual hops that do not impact actual transit traffic throughput.

GNU/Linux, BSD, and BusyBox Implementation Differences

Modern Linux distributions provide Dmitry Butskoy's modern traceroute implementation (version 2.1+). On BSD systems (FreeBSD, OpenBSD) and macOS, the native traceroute command supports different flags (e.g., using -I for ICMP, but lacking -T for TCP SYN unless installed via third-party packages).

Microsoft Windows includes tracert, which defaults to ICMP Echo requests rather than UDP datagrams. When migrating scripts between Linux and Windows, keep in mind that Linux traceroute requires the -I option to match native Windows tracert behavior.

Troubleshooting Common Errors and Diagnostics

Line of asterisks (* * *) across hops

Root Cause: Intermediate routers or firewalls along the network path are configured to silently drop probe packets or suppress ICMP Time Exceeded generation.

Resolution: Switch to TCP SYN probing on an allowed web port (sudo traceroute -T -p 443 host) or ICMP probing (-I).

sudo traceroute -T -p 443 -n example.com

traceroute: sendto: Operation not permitted

Root Cause: Local host firewall rules (iptables/nftables) or SELinux policies are blocking outgoing raw socket packets.

Resolution: Verify local outbound firewall policies or inspect system logs for dropped raw packets.

sudo iptables -L OUTPUT -n -v

traceroute: -T: requires root privileges

Root Cause: TCP SYN packet construction requires creating raw network sockets, which is restricted to administrative users.

Resolution: Rerun traceroute using sudo or grant the CAP_NET_RAW capability to the traceroute binary.

sudo traceroute -T -p 443 example.com

Authoritative References and Official Documentation

Frequently Asked Questions

Quick answers to common questions and configurations

4 FAQs
Those specific intermediate routers are configured for security or performance to discard UDP probes or rate-limit ICMP Time Exceeded messages. If subsequent hops respond normally, packets are forwarding successfully and the asterisks do not indicate a network outage.
Historically, Van Jacobson designed traceroute around UDP so it could run without requiring root privileges on Unix systems, whereas ICMP generation required raw socket access. In contrast, Windows tracert was developed later and defaulted to ICMP Echo.
traceroute performs a single sequential trace across all hops. mtr (My Traceroute) combines traceroute and ping into an interactive real-time utility that continuously probes all hops, reporting packet loss percentages and running latency statistics over time.
Use traceroute with the -6 option (e.g., traceroute -6 2606:4700:4700::1111) or invoke the dedicated traceroute6 command.
RR
Written byVerified Author

Rajesh Ray

I’m Rajesh Rai, a full-stack developer, Linux administrator, and technology enthusiast passionate about making complex technology easier to understand and use.

SPAM-FREE MODERATED DISCOURSE

Join the Conversation & Perspective

Have thoughts, counterpoints, or reflections on this story? Engage directly with fellow readers and editorial contributors.

AT
MP
JV
+2

No comments on this guide yet. Be the first to share your thoughts or ask a question!

Recommended Reading10 Guides

Related Technical Guides

Tested runbooks, server administration walkthroughs, and troubleshooting guides

Featured Infrastructure PartnerUp to 75% OFF + 3 Months Free

Supercharge Your Linux & Cloud Workloads with Hostinger

Deploy high-speed NVMe KVM VPS, Docker containers, and LiteSpeed-accelerated WordPress servers in under 60 seconds with full root access, dedicated IPv4, and 24/7 technical support.

Pure NVMe SSD StorageFull Root Access & SSHFree Domain & Unlimited SSL99.9% Uptime SLA
Plans from$2.99/mo
Claim Hostinger DealAffiliate link • Special discount applied at checkout