skip to content

Why do filtered ports dominate an Nmap scan's duration, and what do --max-retries and --host-timeout give up to shorten it?

level: middleimportance: should knowfreq 24%

answer

  1. silence means wait, then ask again
  2. default allows ten retransmissions
  3. capping retries loses some ports
  4. a timed-out host reports nothing
  5. the timer started counting later in 7.92

basics

~20 s

A port that never answers makes Nmap wait out a timeout and retransmit, up to ten times by default. --max-retries cuts the retries and risks missed ports; --host-timeout abandons a slow host entirely, with no port table, OS or version results for it.

solid answer

~40 s

A reply tells Nmap the answer at once; silence does not. For a silent port Nmap waits out the timeout and retransmits, with a default cap of ten retransmissions, so a firewall that drops quietly makes every port expensive. `--max-retries` caps that cycle: lower is faster, but a lost probe is no longer retried, so ports can be missed (0 suits only informal surveys). `--host-timeout` abandons a host after a set time, such as `30m`: nothing is printed for it, no port table, no OS and no version results. Giving up early on ports is usually better than letting the host timeout expire and losing everything for that host.

go deeper

for a junior

Recall that an unanswered port makes Nmap wait and retry, and that a host timeout skips the host.

for a middle

Explain the default of ten retransmissions, what -T4 and -T5 do to it, and what a timed-out host's output looks like in plain and XML formats.

for a senior

Combine a low retry cap with a host timeout deliberately, then rescan the timed-out hosts so a skipped host is never mistaken for a clean one.

for a principal

Decide how an assessment standard treats unmeasured hosts: a required rescan, a stated coverage figure, and no clean claim on a partial scan.

## Why silence is slow When a port answers, Nmap knows at once: a reset or an ICMP error from a closed port, a SYN/ACK from an open one. When nothing comes back, there are two explanations Nmap cannot tell apart yet: the port is filtered, or the probe or its reply was lost, or the host is rate-limiting its answers. Nmap resolves the doubt the only way it can, by waiting out its timeout and sending the probe again. That cycle repeats up to the **retransmission cap**. - With no `-T` template the cap is **ten retransmissions**, up to eleven probes to one port. - On a reliable network with hosts that do not rate-limit, Nmap usually needs only one retransmission, so most scans never reach the cap. - `-T4` lowers the cap to 6 and `-T5` to 2. - Closed ports are cheap, because they answer; filtered ports are expensive, because they do not. A UDP scan has the same shape, since open and filtered ports rarely respond, but how its answers are read belongs to the scan-technique material. ## --max-retries `--max-retries N` caps the retransmissions per probe. The reference guide notes that dropping the value to three, say, usually changes little on a reliable network and substantially speeds scans of slow or rate-limited hosts. The price is real: Nmap gives up on ports sooner, and a probe that was only lost, not filtered, is not repeated. `--max-retries 0` removes retransmission altogether and is recommended only for informal surveys where occasional missed ports and hosts are acceptable. ## --host-timeout `--host-timeout time` sets the longest Nmap will spend on one host (a bare number is seconds; `ms`, `s`, `m` and `h` are accepted). The slowest few percent of hosts can consume most of a scan's time, so the option cuts them off. What a cut-off host looks like matters when reading a report: 1. **The host is skipped.** No port table, OS detection or version detection results are printed for it. 2. **Plain output** carries a line saying the host was skipped due to the host timeout. 3. **XML output** writes the `host` element with `timedout="true"`. 4. **`-T5` sets it for you** at 15 minutes; `--host-timeout 0` means no timeout and overrides that. 5. **Other hosts keep scanning** while one is being timed, so the wait is not a pure loss. ## What changed in 7.92 Release 7.92 (2021-08-07) stopped counting the host-discovery phase against the host timeout, since Nmap may wait a long time between probes to a target while it works on others, and added `--host-timeout 0` as the way to disable the timeout. In 7.991, the host timeout therefore excludes the host-discovery phase. ## Choosing between the two | Goal | Reach for | Cost | |---|---|---| | Finish a quick survey | `--max-retries` low | Missed ports and hosts | | Bound the worst hosts | `--host-timeout` | Nothing at all reported for slow hosts | | Keep both accuracy and bounds | Both, with the first scan's timed-out hosts rescanned | A second pass | The reference guide also lists other levers for slow scans: scan more hosts in parallel, check the popular ports first, or scan from behind the firewall so ports answer rather than disappear. ## A worked reading Take a scan of 198.51.100.0/24 run with `--host-timeout 30m`. Three hosts end with the skip line and `timedout="true"`; the rest have port tables. The three sit behind the strictest firewall, where almost every port is silent and so spends the full retry cycle. The sensible follow-up is to scan those three alone, with a narrower port list, a lower retry cap or a longer timeout, in a separate run. Reporting the /24 as covered would be wrong: three hosts have no result at all. ## Common mistakes - Treating a long scan as a stuck one and killing it, instead of reading its progress (`--stats-every`) and bounding it. - Setting `--max-retries 0` for an audit, so that every lost probe becomes a missed port. - Forgetting that `-T5` sets a 15-minute host timeout and will silently drop the slowest hosts. ## Reading the result A report with timed-out hosts is not a clean report. Search the output for the skip line (or `timedout="true"` in XML), list those hosts, and rescan them with more time. A host with no row is unmeasured, not safe.

  • A scan finishes, and one host has no port table at all. How do you tell a timed-out host from a host with no open ports?
    Look for the skip line in plain output or `timedout="true"` on that host's XML element. A host with no open ports still has a port summary of closed or filtered ports. A timed-out host has neither, so it needs a rescan with a longer or no `--host-timeout`.
  • Why can scanning from inside the firewall be quicker than from outside it?
    Behind the firewall, closed ports answer with a reset or an ICMP error instead of disappearing, so Nmap does not wait out a timeout and retransmit on each one. From outside, a quiet drop leaves every blocked port to run the full retry cycle.

  • A host that hits --host-timeout still shows the ports finished so far
  • Lowering --max-retries costs nothing because lost probes are rare
  • Filtered ports are fast because the firewall answers at once
  • --host-timeout 0 enables a default timeout of 15 minutes
  • A host with no report row was scanned and found clean

Assumes Nmap 7.991; the 7.92 change to what the host timeout counts is from the 7.92 release notes of 2021-08-07.