traceroute – trace packet route to host

traceroute command
traceroute command

traceroute shows the path packets take to reach a network host, displaying each hop along the way.

Synopsis

traceroute [OPTIONS] HOST

Examples

Basic traceroute

$ traceroute google.com
traceroute to google.com (142.250.187.206), 30 hops max
 1  router (192.168.1.1)  1.234 ms  1.123 ms  1.012 ms
 2  isp-gateway (10.0.0.1)  5.678 ms  5.432 ms  5.321 ms
 3  core-router (203.0.113.1)  12.345 ms  11.234 ms  10.123 ms
 ...
10  google.com (142.250.187.206)  15.678 ms  14.567 ms  13.456 ms

Use ICMP (requires root)

$ sudo traceroute -I google.com

Use TCP

$ sudo traceroute -T -p 443 google.com

Numeric only (no DNS)

$ traceroute -n google.com

Set max hops

$ traceroute -m 15 google.com

Understanding Output

 3  core-router (203.0.113.1)  12.345 ms  11.234 ms  10.123 ms
 │  │                         │
 │  │                         └─ Round-trip times (3 probes)
 │  └─ IP address (and hostname)
 └─ Hop number
  • * * *: No response (firewall, timeout)
  • !H: Host unreachable
  • !N: Network unreachable

mtr: Better Alternative

mtr combines ping and traceroute:

$ mtr google.com

Common Options

OptionDescription
-nNo DNS resolution
-IUse ICMP (like ping)
-TUse TCP
-p PORTDestination port
-m NMax hops
-w NWait time

Tips

  • Asterisks are common: Many routers don’t respond to traceroute
  • Use mtr for live view: Better for diagnosing intermittent issues
  • TCP for firewalled hosts: -T -p 80 or -T -p 443
  • macOS: Uses UDP by default (like Linux)

See Also

  • ping — Test connectivity
  • mtr — Combined traceroute and ping
  • nslookup — DNS lookup

Tutorials