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.8traceroute HOSTNAME — Trace the route to a hostname with DNS resolution.
traceroute google.comtraceroute -n HOST — Numeric output only — skip reverse DNS lookups. Much faster.
traceroute -n 8.8.8.8traceroute -q N HOST — Set the number of probe packets per hop (default: 3).
traceroute -q 1 8.8.8.8traceroute -w TIMEOUT HOST — Set the timeout in seconds to wait for a response (default: 5).
traceroute -w 3 8.8.8.8traceroute -m MAX_TTL HOST — Set the maximum number of hops (default: 30).
traceroute -m 20 8.8.8.8traceroute -f FIRST_TTL HOST — Start with a specific TTL value instead of 1.
traceroute -f 5 8.8.8.8Probe Methods
traceroute -I HOST — Use ICMP Echo probes instead of UDP. Often gives better results through firewalls.
sudo traceroute -I 8.8.8.8traceroute -T HOST — Use TCP SYN probes. Good for tracing through firewalls that block UDP/ICMP.
sudo traceroute -T 8.8.8.8traceroute -T -p PORT HOST — Use TCP SYN probes on a specific port.
sudo traceroute -T -p 443 8.8.8.8traceroute -U HOST — Use UDP probes (default method).
traceroute -U 8.8.8.8traceroute -p PORT HOST — Set the destination port for UDP probes (default: 33434).
traceroute -p 53 8.8.8.8Advanced Options
traceroute -s SOURCE HOST — Set the source IP address for outgoing probes.
traceroute -s 10.0.0.5 8.8.8.8traceroute -i INTERFACE HOST — Use a specific network interface.
traceroute -i eth0 8.8.8.8traceroute -z PAUSE HOST — Set the pause between probes in milliseconds.
traceroute -z 50 8.8.8.8traceroute -A HOST — Show AS (Autonomous System) numbers at each hop.
traceroute -A 8.8.8.8traceroute -e HOST — Show ICMP extensions (MPLS labels, etc.).
traceroute -e 8.8.8.8traceroute -6 HOST — Force IPv6 traceroute.
traceroute -6 google.comtraceroute6 HOST — IPv6 traceroute command (alias on many systems).
traceroute6 google.comtracepath (No Root Required)
tracepath HOST — Trace path to host and discover Path MTU. No root required.
tracepath 8.8.8.8tracepath -n HOST — Numeric output only — skip DNS resolution.
tracepath -n 8.8.8.8tracepath -b HOST — Show both hostname and IP address.
tracepath -b 8.8.8.8tracepath -m MAX_HOPS HOST — Set maximum hop count (default: 30).
tracepath -m 20 8.8.8.8tracepath -l PACKET_LEN HOST — Set the initial packet length for MTU discovery.
tracepath -l 1500 8.8.8.8tracepath -p PORT HOST — Set the destination port.
tracepath -p 443 8.8.8.8tracepath -4 HOST — Force IPv4.
tracepath -4 google.comtracepath -6 HOST — Force IPv6.
tracepath -6 google.comReading 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.8sudo traceroute -I -n HOST — ICMP traceroute without DNS — most reliable through firewalls.
sudo traceroute -I -n 8.8.8.8sudo traceroute -T -p 443 -n HOST — TCP traceroute on HTTPS port — works through most firewalls.
sudo traceroute -T -p 443 -n 8.8.8.8traceroute 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
- Traceroute – Wikipedia – background and how it works
- traceroute(8) – manual page – every option at a glance