What does Nmap's -Pn option change in a scan of a /22, and why is it an expensive fix for hosts that read as down?
answer
- Discovery stage disappears
- Every address is assumed alive
- Reason shown is user-set
- Cost scales with the address count
- Fix the probes before this
basics
~20 s-Pn skips host discovery and treats every address as up, so the requested scans run against all 1,024 addresses of a /22, empty ones included. It costs time and noise and fills the report with phantom hosts; fix the probe set first.
solid answer
~40 s`-Pn` (called `-P0` or `-PN` in older releases) skips host discovery and treats every target as up, so port scanning, version detection and OS detection are attempted against every address the scope expands to: 1,024 for a /22, empty ones included. Dead addresses cost timeouts and retries, and the reference guide notes default timing is used, which may mean slower scans. Non-local addresses are labelled up with the reason `user-set`, so the report can no longer separate a live host from an unanswered address and the inventory gains phantom entries. On a local Ethernet segment ARP still runs unless `--disable-arp-ping` is given. Use it for hosts you have shown to exist and to filter every probe; otherwise choose better probes.
go deeper
Know that -Pn skips discovery and treats every address as up, and that it is a different thing from -sn.
Explain the cost in probes and time for a /22 and what the user-set reason means in the report.
Refuse -Pn as a blanket fix: diagnose with --reason, widen the probes, change the vantage point, and use -Pn only on proved hosts with the reason noted.
Set the organisation's rule on when a discovery-skipping scan is permitted against production, since it widens what is touched beyond the live hosts.
## What -Pn does Normally Nmap uses its discovery stage to decide which targets are alive, so that heavy work such as port scanning, version detection or OS detection runs only against hosts found up. `-Pn` removes that stage. Nmap behaves as if every target address were up and attempts the requested functions against all of them. Older releases called the option `-P0` or `-PN`. It is not the same as `-sn`: `-sn` keeps discovery and drops the port scan, while `-Pn` drops discovery and keeps everything else. ## What it costs For a /22 the scope expands to 1,024 addresses. With a default port scan covering the 1,000 most common TCP ports, that is on the order of a million port probes before retries, most of them to addresses where nothing lives. - **Time.** An address that never answers costs timeouts and retries, and the reference guide notes default timing parameters are used, which may result in slower scans. - **Report quality.** Every non-local address reads as up, empty ones included, and carries the reason `user-set`, which records that Nmap assumed it up rather than saw it answer. - **Noise.** A defender sees one source touching every address, dark space included, across many ports, which is a far louder signature than a four-probe sweep. - **Production impact.** The assessment now sends port probes to every address in the range, including ones nobody expects to be touched, which is a scope and change-control matter as well as a speed one. ## A worked comparison Suppose 20 of the /22's 1,024 addresses are live. With discovery first, Nmap finds those 20 and port-scans only them. With `-Pn` it scans all 1,024, about fifty times as many hosts, and 1,004 of them are empty. The extra work buys nothing for the 20 live hosts, and it does so against addresses nobody expected to be touched, which is a change-control issue on production networks. ## What it does not change - On a local Ethernet segment ARP still runs, because Nmap needs MAC addresses to scan further; `--disable-arp-ping` turns that off. - `-Pn` does not make a filtered host answerable. It only changes whether Nmap tries. ## When it is right 1. A single device you have already proved is live that drops every discovery probe. 2. A short, explicit target list, so the extra cost is trivial. 3. `-Pn -sn` together, which skips discovery and the port scan but lets NSE scripts run. ## Better first moves - read `--reason` on known-live hosts to see which probe types are answered - widen the probe set (`-PS`, `-PA`, `-PU`, `-PE`, `-PP`, `-PM`) to match what the network passes - run from a vantage point inside the segment - ignore resets from a firewall that answers for empty addresses with `--discovery-ignore-rst` (since 7.90) Reports built from `-Pn` runs also need care downstream: a tool that ingests every `up` host as an asset will record the 1,004 empty addresses as hosts. Treat a `-Pn` result as a list of what was tried, not what exists.
- Which combination skips discovery and the port scan but still lets NSE host scripts run?`-Pn -sn` together. The reference guide gives this combination: discovery is skipped, no port scan runs, and the scripting engine can still run host scripts. Without `-sn`, `-Pn` leaves the port scan in place for every address.
- Why does -Pn look noisier to a firewall administrator reading the logs?Without discovery, every address in the range, including unoccupied ones, receives port probes from the same source. The log shows one source touching a thousand addresses across many ports, where a discovery sweep shows a handful of probes per address.
- -Pn is a quieter, faster form of ping scan
- -Pn only skips ICMP and still confirms hosts over TCP
- Using -Pn on every run is a harmless safe default
- Hosts reported under -Pn have been confirmed alive
- -Pn and -sn do the same thing
Assumes Nmap 7.991; --discovery-ignore-rst has been available since Nmap 7.90, and -Pn replaced the older names -P0 and -PN.