skip to content

Why does Nmap 7.991 OS detection want one open and one closed TCP port, and what does --osscan-limit do when a host lacks them?

level: middleimportance: must knowfreq 33%

answer

  1. Probes need something to aim at
  2. Two different kinds of target port
  3. Missing port, weaker evidence
  4. A warning, not an abort
  5. An option that skips the host

basics

~20 s

Some probe sets need a listening TCP port and others a closed one, so without both Nmap has fewer tests to compare. It still runs and warns that results may be unreliable; with --osscan-limit it skips that host instead.

solid answer

~40 s

OS detection aims its sequence, ECN and T2 to T4 probes at an open TCP port and its T5 to T7 probes at a closed one, so a host lacking either yields fewer tests and a weaker match. By default Nmap still runs and prints `Warning: OSScan results may be unreliable because we could not find at least 1 open and 1 closed port`. With `--osscan-limit` it skips a host that has no open TCP port, or neither a closed nor an unfiltered one, and `-v` prints a skip line. The option only matters with `-O` or `-A` and saves time on big `-Pn` sweeps, at the price of no OS data for the skipped hosts.

code

bash · 4 lines
bash
# Inventory audit of one lab range inside the signed scope.
# -O needs raw-packet privilege; --osscan-limit skips hosts without an open
# and a closed (or unfiltered) TCP port; -v prints one skip line per host.
sudo nmap -O --osscan-limit -v 192.0.2.0/28

go deeper

for a junior

Recall that OS detection works best with at least one open and one closed TCP port, and that --osscan-limit skips hosts without them.

for a middle

Explain which probe sets use the open port and which the closed one, what the default warning says, and what the skip rule counts, including the unfiltered stand-in.

for a senior

Show how to report it: tell skipped hosts apart from weak-condition hosts, and say what a firewalled host's thin fingerprint does and does not tell you.

for a principal

Weigh coverage against probe load across a large estate: when skipping hosts is acceptable, and what status values the asset record needs.

## The rule in one paragraph Nmap's OS detection compares a fingerprint made of several probe sets, and those probes need somewhere to land. A listening TCP port answers a SYN with a SYN-ACK, which exposes the stack's initial sequence numbers, options and window. A closed TCP port answers with a reset, which exposes a different slice of behaviour. The reference guide puts it plainly: OS detection is far more effective if at least one open and one closed TCP port are found. It does not say the scan cannot run without them. ## Which probes use which port | Probe set | Aimed at | Why that target | |---|---|---| | Six SEQ probes (with OPS, WIN, T1) | an open TCP port | a SYN-ACK reveals sequence numbers, options, windows | | ECN | an open TCP port | tests the answer to a congestion-notification SYN | | T2 to T4 | an open TCP port | probes with no flags, an odd flag mix and a bare ACK, which stacks answer or ignore differently | | T5 to T7 | a closed TCP port | how a closed port resets | | U1 | a closed UDP port | the ICMP port-unreachable reply and what it echoes | | IE | the host | two ICMP echo requests; no port needed | ## What happens without them - **Default behaviour.** Nmap runs the rest of the probes anyway. Tests with no response are empty, fewer tests can be compared, and several reference entries may tie. The report carries the warning about not finding an open and a closed port. - **Guesses appear by themselves.** When no perfect match exists and the fingerprint was taken under non-ideal conditions, Nmap prints its near-matches without being asked and ends with `No exact OS matches for host (test conditions non-ideal)`. - **A stand-in for closed.** In the 7.991 source, an unfiltered TCP port, one that answered but whose state could not be decided, is accepted when no closed port was found. - **No UDP answer.** If no closed UDP port answers and no UDP scan ran, Nmap does not offer the fingerprint for submission and suggests a combined SYN and UDP scan. ## --osscan-limit 1. Nmap checks each host after port scanning. 2. If it has no open TCP port, or has neither a closed nor an unfiltered one, the host is skipped. 3. With `-v`, Nmap prints `Skipping OS Scan against <host> due to absence of open (or perhaps closed) ports`. The option matters only when `-O` or `-A` is given. Its saving is largest on `-Pn` scans of many addresses, where most targets show nothing open and each would otherwise cost several probe rounds. Its price is that a skipped host gets no OS data at all, not even a weak guess. ## --max-os-tries When no perfect match appears, Nmap repeats detection. The default is five tries when conditions are favourable for a submittable fingerprint and two otherwise; a lower value such as 1 speeds the scan up but gives up the retries that might have identified the host. This is a speed against completeness choice, not an accuracy control. ## A worked reading Take a documentation range, 192.0.2.0/28, scanned inside a signed scope with `-O`. Three hosts show how the rule bites: 1. Host .10 shows an open TCP port and a closed one. All probe sets have a target, and the verdict is as good as the database allows. 2. Host .11 shows one open port and every other port filtered, so no closed or unfiltered port exists. Detection runs, the unreliable-results warning appears, and the guess list may be printed with `test conditions non-ideal`. 3. Host .12 shows nothing open. Without the option it costs several rounds of probes for almost no information; with `--osscan-limit` it is skipped and, under `-v`, named. The inventory should carry three different statuses for these three, not one column of OS names. ## Reading the report as a defender - A host that exposes one open port because a firewall drops everything else produces a thinner fingerprint. The missing closed port limits the measurement; it is not evidence about the operating system. - Store the warning with the result. An inventory should distinguish "OS detection not attempted" (skipped by `--osscan-limit`), "attempted, weak conditions" and "attempted, ideal conditions". - A rule set that filters probes is doing its normal job; the assessor adjusts the confidence it assigns, not the rule set. - On large ranges `--osscan-limit` also keeps the assessor's own footprint smaller, which helps when the scan must not disturb production. - All of this assumes written authorisation for the targets: the extra probe rounds are traffic the owner must expect.

  • Nmap's source accepts an unfiltered port when no closed port exists; when does that arise?
    A port is unfiltered when a probe such as an ACK scan got a reset back but cannot say whether the port is open or closed. For OS detection the reset is the useful behaviour, so Nmap 7.991 uses such a port as the closed-port target if none is known closed, and --osscan-limit also lets the host through.
  • What does --max-os-tries change, and what is its default?
    It caps how many times Nmap repeats OS detection after a failed match. The default is five tries when conditions are favourable for fingerprint submission and two when they are not. Lowering it to 1 speeds the scan but removes retries that might have found a match; raising it is rarely useful outside building fingerprints.
  • Does --osscan-limit apply to a scan run without -O?
    No. It only matters when OS detection is requested with -O or -A. Without either, Nmap sends no OS probes at all, so there is nothing to limit. Used alone it is simply ignored.

  • Nmap refuses to run -O unless an open and a closed port exist.
  • --osscan-limit makes OS detection more accurate.
  • Closed ports are useless to OS detection; only open ports matter.
  • --osscan-limit is on by default.
  • A host that shows only filtered ports gets a reliable match anyway.

Assumes Nmap 7.991: the open and closed port advice, the warning text and the --osscan-limit skip rule are those of the 7.991 reference guide and source.