SkillPilotAI

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

OSToolProbe types
Windowstracert.exe (built in)ICMP echo only
Linuxtraceroute packageUDP (default), ICMP, TCP, UDPLITE, DCCP, raw
Linuxtracepath (iputils)UDP, no root, also finds path MTU
macOS/usr/sbin/traceroute + traceroute6UDP (default), TCP, ICMP, GRE, any protocol

39.2 How it works

TTL 1, 2, 3, 4: every router reveals its address
  1. 1.Probe with TTL 1: Router 1 makes TTL 0, drops it, sends ICMP Time Exceeded -> hop 1

  2. 2.Probe with TTL 2: dropped at Router 2 -> hop 2

  3. 3.Probe with TTL 3: dropped at Router 3 -> hop 3

  4. 4.Probe with TTL 4 reaches the server on a high UDP port with no app listening

  5. 5.Server replies ICMP Port Unreachable -> trace stops

  6. 6.3 probes per hop by default, so each line shows 3 times

39.3 Windows tracert

Terminal
tracert /?tracert -d -h 15 -w 1000 8.8.8.8
Output
$ 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.
OptionMeaning
-dNo name lookup (fast)
-h 15Max hops (default 30)
-w 1000Wait per reply in ms (default 4000)
-j host-listLoose source route (IPv4 only)
-RRound-trip path (IPv6 only)
-S addrSource address (IPv6 only)
-4 / -6Force 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.
Terminal
traceroute -n 192.168.59.194traceroute -n -f 2 -m 3 192.168.59.194traceroute -n -q 1 192.168.59.194 1400
Output
$ 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 ms

39.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.
Terminal
traceroute -n -w 1 192.168.59.194traceroute -n -q 1 -w 1 -z 0.5 \  192.168.59.194
Output
$ 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 ms

39.6 Probe methods: getting through a firewall

TCP SYN probe through a firewall
  1. 1.Router 3's firewall drops UDP and ICMP echo to the server but allows TCP

  2. 2.Default UDP probes pass Router 1 and 2, get blocked at Router 3: stars from hop 4

  3. 3.-I (ICMP) stalls the same way

  4. 4.-T -p 443 sends a TCP SYN to port 443; it passes the firewall

  5. 5.Server replies SYN-ACK: hop 4 appears, an app is listening on 443

Terminal
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
Output
$ 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
MethodOptionProbeRoot?
default-M defaultUDP 33434+No
icmp-IICMP echoYes
tcp-T (tcptraceroute, lft)TCP SYN half-open, port 80Yes
tcpconn-M tcpconn -p 443Full connect()No
udp-UFixed UDP port 53No
udplite-ULUDPLITE port 53No
dccp-DDCCP Request, port 33434Yes
raw-P 47Raw IP protocolYes
  • -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.
Terminal
traceroute -n -q 1 -F 192.168.59.194 1500traceroute -n --mtu 192.168.59.194tracepath -n 192.168.59.194
Output
$ 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 4
Output
tracepath 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 Z

39.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).
ToolTrailing size argument means
Linux traceroutepacket_len: whole packet (60 IPv4, 80 IPv6)
macOS traceroutepacketsize: datagram length (default 40)
macOS traceroute6datalen: payload bytes (default 12)
Windows tracertNo 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.