skip to content

Which ports does an Nmap scan cover when no -p option is given, and how do -p-, -F, --top-ports and -p U:53,T:80 change that?

level: juniorimportance: should knowfreq 33%

answer

  1. default is a ranked list
  2. frequency from nmap-services
  3. -p- is the full range
  4. protocol prefixes need both scan types

basics

~20 s

With no -p option Nmap scans the 1,000 most common ports per protocol, ranked by nmap-services frequency. -p- covers 1-65535, -F cuts to 100, --top-ports n picks the n most common, and T: or U: prefixes choose TCP or UDP ports.

solid answer

~30 s

With no `-p`, Nmap scans the **1,000 most common ports** per protocol, ranked by the frequency data in `nmap-services`. `-F` reduces that to 100, `--top-ports n` takes the n highest-ranked, and `-p-` means ports 1 to 65535. A range may omit either end, and `-p U:53,T:80` selects UDP 53 and TCP 80, though scanning both protocols still needs `-sU` plus a TCP scan type such as `-sS`. The default is a speed choice, so a service on an unusual port such as 8443 can be missed from an inventory unless the port list is widened.

code

bash · 3 lines
bash
# Inside the signed scope: full TCP range on one server, then a short agreed UDP list.
nmap -sS -p- --reason web01.example.internal
nmap -sU -p U:53,123 --reason web01.example.internal

go deeper

for a junior

Know that the default is the 1,000 most common ports, and that -p- covers all 65,535.

for a middle

Explain the frequency ranking in nmap-services, -F, --top-ports, protocol prefixes and why UDP needs -sU.

for a senior

Pick a port list for an inventory, a hardened-host audit and a production change window, and say what each cannot prove.

for a principal

Set a policy for default port lists across an organisation's recurring scans, including how unusual-port services enter the inventory.

## The default list is a ranking, not a standard Nmap needs to decide which ports to probe. Without `-p`, it scans the **1,000 most common ports for each scanned protocol**. "Most common" is not a guess: `nmap-services` carries a frequency for every port (in the pinned file 80/tcp ranks highest, with 23, 443, 21 and 22 behind it), and Nmap takes the highest-ranked entries. The port order is randomised by default, with some commonly reachable ports moved to the front for efficiency; `-r` scans in sorted order instead. The practical consequence: **what is not on the list is not scanned**. An inventory that reports "nothing else open" after a default scan has only said that nothing else answered among the top 1,000. ## Selecting ports | Form | What it scans | |---|---| | (no `-p`) | The 1,000 most common ports per protocol | | `-F` | The most common 100 ports (when no frequency data exists, only ports named in the services file) | | `--top-ports n` | The n highest-frequency ports in `nmap-services`, after `--exclude-ports` | | `--port-ratio r` | Every port with a frequency ratio above r (0.0 to 1.0) | | `-p-` | Ports 1 to 65535: an omitted start or end of a range means 1 or 65535 | | `-p 1-1023` | An explicit range | | `-p 22,443,8443` | Individual ports | | `-p U:53,T:80` | Protocol-prefixed lists; the prefix lasts until the next one | | `-p ftp,http*` | Ports by service name, with `*` and `?` wildcards (quote it for the shell) | | `--exclude-ports` | Ports never scanned, discovery phase included | Port zero is scanned only when written explicitly. ## Protocol prefixes need the matching scan type A `T:` or `U:` prefix only chooses a port list. To scan TCP and UDP in one run, Nmap needs `-sU` and at least one TCP scan type such as `-sS`. With a prefix missing, the number is added to every protocol list in the run. ## A worked example An inventory run with the default list reports three open web ports on a host. The application team then mentions an internal admin service on 18080. It is not in the 1,000 most common ports, so it was never probed and the report is silent about it, neither open nor closed. Rerunning with an explicit list that includes 18080, or with `-p-`, answers the question. The lesson is to write the port list into the report so a reader can see what the silence covers. ## Choosing a list for an authorised assessment 1. **Inventory of a known estate.** Start with the default for breadth, then add the ports your own application list says should exist (an application on 8443 or 9200 is not necessarily in the top 1,000). 2. **Audit of a single hardened host.** Use `-p-` for the full TCP range, because the question is "what is listening anywhere", and accept the longer scan. 3. **Change window on production.** Prefer an explicit list agreed in the scope document, so the scan's footprint is the one the owner approved. Scanning all 65,535 ports against a host that silently drops most of them is slow, since each dropped probe is retried. Pacing options belong to the timing material; here the point is only that a wider list costs time. ## Reading the output when many ports share a state A default scan prints a collapsed line such as "Not shown: 995 closed ports". That line stands for ports that all got the same state; only the exceptions get their own rows. With `--reason`, the collapsed line also names the reason in parentheses. ## Defender's side A wide port list is visible in the receiving firewall's log as a sequence of probes to many different destination ports from one source in a short span. A narrow, agreed list produces a short, predictable pattern, which is easier to reconcile with the change ticket. Sharing the list with the SOC before the scan is part of the rules of engagement. ## Common mistakes - Reporting "no other ports open" after a default scan. - Assuming `-p U:53` alone scans both protocols. - Assuming `-F` means "only well-known ports". - Forgetting that UDP and TCP have separate states for the same number.

  • Why can a default scan miss a service the owners say exists?
    The default list is the 1,000 highest-frequency ports from nmap-services. A service on an uncommon port is simply not probed. Add the port explicitly, use --top-ports with a larger n, or use -p- when the audit needs a full answer.
  • What does --exclude-ports do that leaving a port out of the list does not?
    It names ports that are never scanned under any scan type, discovery phase included. That suits ports the scope document puts off limits, because the exclusion holds even when other options change which probes are sent.

  • The default scan checks all 65,535 ports.
  • -F means well-known ports only.
  • -p U:53 scans both UDP and TCP port 53.
  • A clean default scan proves nothing else is open.
  • Port order is fixed ascending unless you say otherwise.