skip to content

How does hping3's traceroute mode, sending a TCP SYN to an allowed port, map the path through a filter that drops ICMP echo?

level: middleimportance: should knowfreq 14%

answer

  1. TTL climbs one hop at a time
  2. the probe looks like real traffic
  3. routers answer with time exceeded
  4. only advances when an answer arrives
  5. the last hop answers differently

basics

~20 s

With --traceroute hping3 starts at TTL 1 and raises it each time a router returns an ICMP time-exceeded, so a TCP probe to an allowed port can map hops where echo is dropped. A hop that stays silent stalls it.

solid answer

~40 s

`--traceroute` (`-T`) implies `--ttl 1` and `--bind`. hping3 sends the probe, and when a router returns an ICMP time-exceeded it prints `hop=N`, a line `TTL 0 during transit from ip=...` and the hop's round-trip time, then raises the TTL by one. Using `-S -p 443` makes the probe the same kind of packet the filter already allows, so it travels where an echo request would be dropped, and the destination ends the trace with `flags=SA` or `flags=RA`. `--tr-stop` exits at the first reply that is not a time-exceeded. It depends on routers returning time-exceeded: if one does not, hping3 keeps sending at that TTL and prints nothing, so a silent hop stalls the trace.

code

bash · 2 lines
bash
# TCP SYN path trace to an allowed port; stop at the first non-time-exceeded reply
hping3 -S -p 443 --traceroute --tr-stop 192.0.2.10

go deeper

for a junior

Recall that --traceroute starts at TTL 1 and raises it as routers report time-exceeded, and that you can choose TCP and a port.

for a middle

Explain the hop lines, how the destination ends the trace, and what --tr-stop, --tr-keep-ttl and --ttl change.

for a senior

Know that a silent hop stalls hping3 rather than being skipped, and that the trace also depends on time-exceeded replies surviving the return path.

for a principal

Decide when a path map from one source zone is enough evidence for a change, and when you need maps from several zones.

## What the mode does `-T` / `--traceroute` turns hping3 into a path mapper. According to the manual page it increases the TTL for each ICMP "time to live 0 during transit" it receives, and it **implies `--bind` and `--ttl 1`**. The first probe therefore expires at the first router, which returns a time-exceeded message naming itself; hping3 prints that hop and sends the next probe with the TTL one higher. Because you choose the protocol, the probe can be a TCP SYN to a port the filter already permits, for example `-S -p 443`. A path or a firewall that drops ICMP echo requests often still passes TCP to that port, and the probe is the same kind of packet as the production traffic you care about, so it meets the same rules. ## What the output means - `hop=3 TTL 0 during transit from ip=198.51.100.1` names the device that answered for the current TTL, and a following `hoprtt=` value is the round trip to it. - A reply from the destination itself ends the useful part of the trace: `flags=SA` if the port is open, `flags=RA` if a reset answered. - An ICMP unreachable, such as a `Packet filtered` line, tells you a device on the way refused the probe. - hping3 prints a hop once, even if the same router answers again, unless `--tr-keep-ttl` is set. ## Options that change it | Option | Effect | |---|---| | `--ttl N` | Overrides the starting TTL of 1 | | `--tr-stop` | Exits at the first reply that is not an ICMP time-exceeded, like classic traceroute | | `--tr-keep-ttl` | Holds the TTL fixed, so you watch one hop's address and round trip over time | | `--tr-no-rtt` | Hides round-trip times and skips computing them | | `-z` / `--bind` | Lets Ctrl+Z raise or lower the TTL by hand | ## The limit: a silent hop stalls the trace The TTL goes up only when a time-exceeded message arrives. The source's `log_traceroute` function is the only place the TTL is incremented. If a router at hop 5 never answers, because it does not send ICMP errors or because its answer is filtered on the way back, hping3 does not skip it; it keeps sending probes at TTL 5 and prints nothing new. The way past it is to raise the TTL yourself with Ctrl+Z (traceroute mode binds it) or to restart with `--ttl` set higher. This differs from the host tools that print a row of asterisks and carry on, and it is worth knowing before you read a quiet terminal as "the trace finished". ## Reading the result as evidence 1. The list of hops is what answered, not necessarily every device: some routers never return time-exceeded. 2. A path that works with a TCP probe to 443 and fails with echo shows that the filter treats the two differently, which is exactly what a rule test wants to establish. 3. The trace depends on the return path too. A filter that blocks time-exceeded inbound will hide hops that are really there. 4. Run it from the source zone the rule applies to, and treat the result as valid for that source and that port only. 5. Record the TTL at which the trace stopped advancing: a stall at hop 5 is itself a finding, either that router sends no time-exceeded or its reply is filtered. ## What it looks like to the defender A defender sees a short run of TCP SYNs from one source to one destination and port, with the TTL value rising by one each time, one probe a second by default. Routers on the way log or send time-exceeded replies; a firewall sees only the probes whose TTL is high enough to reach it. That is a recognisable pattern in a log, so tell the log owners the source address and window in advance. ## Rules of engagement Map only paths inside your written scope, from a source address known to the people watching, and use `--tr-stop` so the run ends when the destination answers. Plain host traceroute, and what a path-diagnostic report looks like in general, is a different skill from this single-rule, filter-aware use.

  • Why can a TCP trace work through a filter that drops ICMP echo?
    The filter matches on the packet it sees. A SYN to a permitted port is the kind of traffic the rule already allows, so it passes, and routers still return time-exceeded for the expiring probes. The trace still fails if time-exceeded replies are filtered on the way back.
  • What does --tr-keep-ttl do and when is it useful?
    It stops hping3 raising the TTL, so every probe expires at the same hop. Use it to watch one device's address and round-trip time over several probes, for example to see whether a hop's latency changes during a change window, instead of mapping the whole path.

  • hping3 traceroute prints a row of asterisks for silent hops and carries on
  • A TCP traceroute needs the destination port to be open
  • The hops listed are every router on the path
  • Dropping ICMP echo at the filter always hides the path from TCP probes
  • The TTL rises on a timer, so the trace always ends by itself