tracert / traceroute / tracepath
These tools list every router between your PC and a destination with the response time of each hop, using the TTL trick. They show where a path stops, which probe type gets through a firewall and what the path MTU is.
39.1 Where they run
| OS | Tool | Probe types |
|---|---|---|
| Windows | tracert.exe (built in) | ICMP echo only |
| Linux | traceroute package | UDP (default), ICMP, TCP, UDPLITE, DCCP, raw |
| Linux | tracepath (iputils) | UDP, no root, also finds path MTU |
| macOS | /usr/sbin/traceroute + traceroute6 | UDP (default), TCP, ICMP, GRE, any protocol |
39.2 How it works
- Step 1
1.Probe with TTL 1: Router 1 makes TTL 0, drops it, sends ICMP Time Exceeded -> hop 1
- Step 2
2.Probe with TTL 2: dropped at Router 2 -> hop 2
- Step 3
3.Probe with TTL 3: dropped at Router 3 -> hop 3
- Step 4
4.Probe with TTL 4 reaches the server on a high UDP port with no app listening
- Step 5
5.Server replies ICMP Port Unreachable -> trace stops
- Step 6
6.3 probes per hop by default, so each line shows 3 times
39.3 Windows tracert
tracert /?tracert -d -h 15 -w 1000 8.8.8.8$ tracert /?Usage: tracert [-d] [-h maximum_hops] [-j host-list] [-w timeout] [-R] [-S srcaddr] [-4] [-6] target_name -d Do not resolve addresses to hostnames. -h maximum_hops Maximum number of hops to search for target. -w timeout Wait timeout milliseconds for each reply.$ tracert -d -h 15 -w 1000 8.8.8.8Tracing route to 8.8.8.8 over a maximum of 15 hops * office hops hidden * 6 109 ms * * 72.14.243.0 7 22 ms 20 ms 19 ms 142.251.193.131 8 20 ms 19 ms 21 ms 142.251.49.115 9 20 ms 24 ms 29 ms 8.8.8.8Trace complete.| Option | Meaning |
|---|---|
| -d | No name lookup (fast) |
| -h 15 | Max hops (default 30) |
| -w 1000 | Wait per reply in ms (default 4000) |
| -j host-list | Loose source route (IPv4 only) |
| -R | Round-trip path (IPv6 only) |
| -S addr | Source address (IPv6 only) |
| -4 / -6 | Force IPv4 / IPv6 |
39.4 Linux traceroute: general, hop control and timing
- Lab: three routers between PC and server 192.168.59.194, built in a Docker container.
- -n no DNS; -f first TTL; -m max TTL (30); -q probes per hop (3); trailing number = packet length (60 IPv4, 80 IPv6).
- -N probes in parallel (16); -N 1 gives fewer stars on rate-limited routers.
- -w max wait seconds (5); -z pause between probes. traceroute6 = traceroute -6.
traceroute -n 192.168.59.194traceroute -n -f 2 -m 3 192.168.59.194traceroute -n -q 1 192.168.59.194 1400$ traceroute -n 192.168.59.194traceroute to 192.168.59.194 (192.168.59.194), 30 hops max, 60 byte packets 1 192.168.59.1 0.260 ms 0.018 ms 0.009 ms 2 192.168.59.66 0.085 ms 0.016 ms 0.015 ms 3 192.168.59.130 10.731 ms 0.052 ms 0.021 ms 4 192.168.59.194 0.129 ms 0.031 ms 0.023 ms$ traceroute -n -f 2 -m 3 192.168.59.194traceroute to 192.168.59.194 (192.168.59.194), 3 hops max, 60 byte packets 2 192.168.59.66 0.326 ms 0.256 ms 0.216 ms 3 192.168.59.130 0.187 ms 0.135 ms 0.092 ms$ traceroute -n -q 1 192.168.59.194 1400traceroute to 192.168.59.194 (192.168.59.194), 30 hops max, 1400 byte packets 1 192.168.59.1 14.736 ms 2 192.168.59.66 14.687 ms 3 192.168.59.130 14.633 ms 4 192.168.59.194 14.584 ms39.5 What three stars really mean
- In the lab Router 2 is set not to send Time Exceeded.
- Hop 2 shows * * * but hops 3 and 4 reply: the path is not broken, that router just stays silent.
- Marks after a time: !H host, !N network, !P protocol unreachable, !F fragmentation needed, !X admin prohibited.
traceroute -n -w 1 192.168.59.194traceroute -n -q 1 -w 1 -z 0.5 \ 192.168.59.194$ traceroute -n -w 1 192.168.59.194traceroute to 192.168.59.194 (192.168.59.194), 30 hops max, 60 byte packets 1 192.168.59.1 0.785 ms 0.721 ms 0.682 ms 2 * * * 3 192.168.59.130 0.530 ms 0.480 ms 0.444 ms 4 192.168.59.194 0.404 ms 0.348 ms 0.304 ms$ traceroute -n -q 1 -w 1 -z 0.5 192.168.59.194 1 192.168.59.1 0.071 ms 2 * 3 192.168.59.130 0.072 ms 4 192.168.59.194 0.080 ms39.6 Probe methods: getting through a firewall
- Step 1
1.Router 3's firewall drops UDP and ICMP echo to the server but allows TCP
- Step 2
2.Default UDP probes pass Router 1 and 2, get blocked at Router 3: stars from hop 4
- Step 3
3.-I (ICMP) stalls the same way
- Step 4
4.-T -p 443 sends a TCP SYN to port 443; it passes the firewall
- Step 5
5.Server replies SYN-ACK: hop 4 appears, an app is listening on 443
traceroute -n -m 6 -w 1 192.168.59.194traceroute -n -I -m 6 -w 1 \ 192.168.59.194traceroute -n -T -O info -p 443 \ 192.168.59.194$ traceroute -n -m 6 -w 1 192.168.59.194 1 192.168.59.1 0.658 ms 0.600 ms 0.574 ms 2 192.168.59.66 0.508 ms 0.451 ms 0.414 ms 3 192.168.59.130 0.378 ms 0.287 ms 0.243 ms 4 * * * 5 * * * 6 * * *$ traceroute -n -I -m 6 -w 1 192.168.59.194 1 192.168.59.1 0.061 ms 0.017 ms 0.013 ms 2 192.168.59.66 2.209 ms 0.048 ms 0.015 ms 3 192.168.59.130 0.096 ms 0.023 ms 0.015 ms 4 * * * 5 * * * 6 * * *$ traceroute -n -T -O info -p 443 192.168.59.194 1 192.168.59.1 2.364 ms 2.370 ms 3.800 ms 2 192.168.59.66 4.063 ms 4.535 ms 4.571 ms 3 192.168.59.130 4.612 ms 4.849 ms 4.884 ms 4 192.168.59.194 <syn,ack,mss=1460,sack,timestamps,window_scaling> 4.961 ms 4.857 ms 4.767 ms| Method | Option | Probe | Root? |
|---|---|---|---|
| default | -M default | UDP 33434+ | No |
| icmp | -I | ICMP echo | Yes |
| tcp | -T (tcptraceroute, lft) | TCP SYN half-open, port 80 | Yes |
| tcpconn | -M tcpconn -p 443 | Full connect() | No |
| udp | -U | Fixed UDP port 53 | No |
| udplite | -UL | UDPLITE port 53 | No |
| dccp | -D | DCCP Request, port 33434 | Yes |
| raw | -P 47 | Raw IP protocol | Yes |
- -p: base port for UDP, sequence for ICMP, fixed port for TCP and others.
- -O method options: tcp flags (syn, ack, fin...), -T -O ack tests stateless filters, -O mss=1460 detects MSS clamping, -O info shows final reply flags; icmp -O dgram needs no root.
- Interface/header: -i iface, -s source, -r bypass routing, -t TOS, -F DF, --mtu, --fwmark, --sport; extra output: -e MPLS labels, -A AS numbers, --back reverse hops.
39.7 Path MTU: traceroute --mtu and tracepath
- Lab: the Router 2 - Router 3 link has MTU 1400.
- -F with a 1500-byte packet: hop 3 shows !F-1400.
- --mtu discovers it alone and prints F=1400 at hop 3.
- tracepath gives the same without root: Resume: pmtu 1400 hops 4.
traceroute -n -q 1 -F 192.168.59.194 1500traceroute -n --mtu 192.168.59.194tracepath -n 192.168.59.194$ traceroute -n -q 1 -F 192.168.59.194 1500traceroute to 192.168.59.194 (192.168.59.194), 30 hops max, 1500 byte packets 1 192.168.59.1 0.725 ms 2 192.168.59.66 0.653 ms 3 192.168.59.66 0.599 ms !F-1400$ traceroute -n --mtu 192.168.59.194 1 192.168.59.1 0.130 ms F=1500 0.157 ms 1.799 ms 2 192.168.59.66 0.052 ms 0.017 ms 0.021 ms 3 192.168.59.130 0.322 ms F=1400 0.054 ms 0.025 ms 4 192.168.59.194 0.045 ms 0.038 ms 0.031 ms$ tracepath -n 192.168.59.194 1?: [LOCALHOST] pmtu 1500 1: 192.168.59.1 0.075ms 2: 192.168.59.66 0.037ms 3: 192.168.59.66 0.024ms pmtu 1400 3: 192.168.59.130 0.029ms 4: 192.168.59.194 0.041ms reached Resume: pmtu 1400 hops 4 back 4tracepath 8.8.8.8 trace + path MTU-4 / -6 IPv4 / IPv6 only-n numeric IPs only-b names + IPs both-l 1500 initial packet length-m 20 max hops (30)-p 33434 initial UDP portoutput: 1? = TTL guess, pmtu N, asymm Nreached, Resume: pmtu X hops Y back Z39.8 macOS traceroute and traceroute6
- Basics like Linux: -f/-M first TTL, -m max TTL, -q, -w, -z (pause in ms), -n; -S prints a summary of unanswered probes.
- -P UDP|TCP|GRE|ICMP picks the protocol (-I = ICMP); -e fixed destination port for firewall evasion.
- -E detects ECN bleaching; -a AS numbers, -A custom whois server.
- traceroute6: -I ICMPv6, -T TCP, hop limit up to 255; trailing number = datalen (payload, default 12, ignored for TCP).
| Tool | Trailing size argument means |
|---|---|
| Linux traceroute | packet_len: whole packet (60 IPv4, 80 IPv6) |
| macOS traceroute | packetsize: datagram length (default 40) |
| macOS traceroute6 | datalen: payload bytes (default 12) |
| Windows tracert | No size option |
39.9 Common mistakes
- Reading * * * at one hop as 'network down there' when later hops reply: that router just doesn't send Time Exceeded or rate-limits it.
- Thinking a high time at a middle hop (e.g. 109 ms at hop 6) means a slow router: routers give their own ICMP replies low priority. A real delay jumps at one hop and stays high to the destination.
- Giving up when UDP/ICMP traces stall at a firewall: try -T -p 443.
- Expecting tracert to use UDP like Linux: it is ICMP only.
39.10 Interview tips
- How traceroute works: TTL starts at 1, +1 each round; each router replies ICMP Time Exceeded (address + RTT); destination replies Port Unreachable (UDP) or Echo Reply (ICMP).
- Behind a firewall use TCP SYN probes: traceroute -T -p 443.
- Windows tracert = ICMP; Linux traceroute default = UDP 33434+.
- tracepath / traceroute --mtu find the path MTU hop by hop.