traceroute — Trace the Network Path Hop by Hop

Practical guide to traceroute and tracepath — trace network paths hop by hop, pinpoint latency spikes, and work around firewalls with alternative probes.

traceroute shows you the hop-by-hop path that packets take from your machine to a destination host – and pinpoints where latency or packet loss occurs along the way. It sends probes with incrementally increasing TTL values; each router that discards a packet replies with an ICMP message, revealing its address and round-trip time. This lets you tell at a glance whether a problem lies with your ISP, a transit router, or the destination server itself.

Basic Usage

traceroute HOST — Trace the route to a host using UDP probes (default).

traceroute 8.8.8.8

traceroute HOSTNAME — Trace the route to a hostname with DNS resolution.

traceroute google.com

traceroute -n HOST — Numeric output only — skip reverse DNS lookups. Much faster.

traceroute -n 8.8.8.8

traceroute -q N HOST — Set the number of probe packets per hop (default: 3).

traceroute -q 1 8.8.8.8

traceroute -w TIMEOUT HOST — Set the timeout in seconds to wait for a response (default: 5).

traceroute -w 3 8.8.8.8

traceroute -m MAX_TTL HOST — Set the maximum number of hops (default: 30).

traceroute -m 20 8.8.8.8

traceroute -f FIRST_TTL HOST — Start with a specific TTL value instead of 1.

traceroute -f 5 8.8.8.8

Probe Methods

traceroute -I HOST — Use ICMP Echo probes instead of UDP. Often gives better results through firewalls.

sudo traceroute -I 8.8.8.8

traceroute -T HOST — Use TCP SYN probes. Good for tracing through firewalls that block UDP/ICMP.

sudo traceroute -T 8.8.8.8

traceroute -T -p PORT HOST — Use TCP SYN probes on a specific port.

sudo traceroute -T -p 443 8.8.8.8

traceroute -U HOST — Use UDP probes (default method).

traceroute -U 8.8.8.8

traceroute -p PORT HOST — Set the destination port for UDP probes (default: 33434).

traceroute -p 53 8.8.8.8

Advanced Options

traceroute -s SOURCE HOST — Set the source IP address for outgoing probes.

traceroute -s 10.0.0.5 8.8.8.8

traceroute -i INTERFACE HOST — Use a specific network interface.

traceroute -i eth0 8.8.8.8

traceroute -z PAUSE HOST — Set the pause between probes in milliseconds.

traceroute -z 50 8.8.8.8

traceroute -A HOST — Show AS (Autonomous System) numbers at each hop.

traceroute -A 8.8.8.8

traceroute -e HOST — Show ICMP extensions (MPLS labels, etc.).

traceroute -e 8.8.8.8

traceroute -6 HOST — Force IPv6 traceroute.

traceroute -6 google.com

traceroute6 HOST — IPv6 traceroute command (alias on many systems).

traceroute6 google.com

tracepath (No Root Required)

tracepath HOST — Trace path to host and discover Path MTU. No root required.

tracepath 8.8.8.8

tracepath -n HOST — Numeric output only — skip DNS resolution.

tracepath -n 8.8.8.8

tracepath -b HOST — Show both hostname and IP address.

tracepath -b 8.8.8.8

tracepath -m MAX_HOPS HOST — Set maximum hop count (default: 30).

tracepath -m 20 8.8.8.8

tracepath -l PACKET_LEN HOST — Set the initial packet length for MTU discovery.

tracepath -l 1500 8.8.8.8

tracepath -p PORT HOST — Set the destination port.

tracepath -p 443 8.8.8.8

tracepath -4 HOST — Force IPv4.

tracepath -4 google.com

tracepath -6 HOST — Force IPv6.

tracepath -6 google.com

Reading the Output

1 192.168.1.1 1.234 ms 0.987 ms 1.102 ms — Normal hop: hop number, router IP, and three round-trip times.

5 * * * — No response from this hop. The router may block ICMP/UDP or has no reverse route.

3 10.0.0.1 2.5 ms !N * * — !N = Network unreachable. Other codes: !H (host), !P (protocol), !F (fragmentation needed).

Resume: pmtu 1500 — tracepath output: the discovered Path MTU to the destination.

Common Patterns

traceroute -n -q 1 -w 2 HOST — Fast traceroute: no DNS, one probe per hop, 2 second timeout.

traceroute -n -q 1 -w 2 8.8.8.8

sudo traceroute -I -n HOST — ICMP traceroute without DNS — most reliable through firewalls.

sudo traceroute -I -n 8.8.8.8

sudo traceroute -T -p 443 -n HOST — TCP traceroute on HTTPS port — works through most firewalls.

sudo traceroute -T -p 443 -n 8.8.8.8

traceroute HOST | awk '{print $1, $2}' — Extract hop numbers and IPs only.

traceroute -n 8.8.8.8 | awk '{print $1, $2}'

Conclusion

For most connectivity problems, traceroute -n is the first tool to reach for – you see instantly where the path ends or where latency spikes. If firewalls block UDP probes, switch to -I (ICMP) or -T -p 443 (TCP). For continuous monitoring, mtr supersedes traceroute as a more informative alternative.

Further Reading

  • mtr – combines traceroute and ping for continuous network monitoring
  • ping – check host reachability and measure round-trip time
  • dig – verify DNS resolution when hostnames don't resolve correctly