Skip to content
Tutorials Center
My learning

Topics

Lesson 7 of 36 ยท Scanning Basics

Nmap Port States Explained

Understand the six Nmap port states (open, closed, filtered, unfiltered, open|filtered, closed|filtered), what each reply means, and how to interpret them.

Every port Nmap reports has a state. Six states exist, and mixing them up leads to wrong conclusions: "closed" and "filtered" are not the same thing, and "open|filtered" is not a bug but an honest "I cannot tell". This lesson defines each state, shows which replies produce it, and gives you a small program that classifies probes.

The packet exchanges are described in words and diagrams, and the Python editors model them with plain strings. No real scanning happens in your browser.

The six states

The three main states

open A service accepts connections.
closed Reachable, but no service listens.
filtered Something blocks the probes.

Most results are one of these.

1 / 2

open

An application is actively accepting connections (TCP) or datagrams (UDP) on this port. For a TCP SYN scan, the proof is a SYN-ACK. Open ports are where the attack surface is, and also where useful services live. Finding them is the main point of most scans.

closed

The host answered, and the answer says "nothing is listening here". For TCP this is a RST packet; for UDP an ICMP "port unreachable". Closed ports are not useless to a scanner: they prove the host is alive, and they help with OS detection. They may become open later, which is why a closed port is still reported when you ask (-v, --open shows only open ones).

filtered

Nmap cannot tell whether the port is open because something blocks the probes: a packet filter, a firewall rule, a router. The giveaway is usually silence after retries, or an ICMP error of type 3 with codes such as 13 (communication administratively prohibited). Filtered ports are slow to scan because Nmap waits and retransmits. The reason (no-response, admin-prohibited) tells you which behavior it saw.

unfiltered

The port is reachable (a probe got through), but Nmap cannot tell whether it is open or closed. Only the ACK scan (-sA) produces this state, because it deals with firewall rules rather than ports (ACK, Window and Maimon Scans).

open|filtered

Nmap cannot decide between open and filtered because an open port gives no reply to the probe and a filtered one gives none either. This is common for UDP, and for the NULL, FIN and Xmas scans (UDP Scanning, Null, FIN and Xmas Scans).

closed|filtered

Used only by the idle scan (-sI), when Nmap cannot decide between closed and filtered.

Which reply produces which state

Scan Reply State
SYN / connect SYN+ACK (connection made) open
SYN / connect RST closed
SYN / connect no reply after retries, or ICMP unreachable filtered
UDP UDP data back open
UDP no reply after retries open|filtered
UDP ICMP port unreachable (type 3, code 3) closed
UDP other ICMP unreachable filtered
NULL / FIN / Xmas RST closed
NULL / FIN / Xmas no reply open|filtered
ACK RST unfiltered
ACK no reply / ICMP unreachable filtered

Why "closed" and "filtered" matter to a defender

A closed port means the machine itself answered. A filtered port means a device in between swallowed the probe. In an audit those two tell different stories: a server with 997 closed ports probably has no firewall in front of it (the OS answers everything), while 997 filtered ports tell you a firewall is dropping traffic to ports that have no business being reachable, which is usually the better posture. Seeing closed where you expected filtered may mean a firewall rule is missing.

flowchart TD
  P["Probe sent"] --> R{"Reply?"}
  R -- "SYN+ACK" --> O["open"]
  R -- "RST" --> C["closed"]
  R -- "ICMP unreachable (admin)" --> F["filtered"]
  R -- "nothing after retries" --> F

Figure: classifying the result of a TCP SYN probe.

A stand-in: classify TCP SYN replies

This function turns what the scanner saw into a state and a reason, mirroring the table. It handles the TCP SYN case and a few ICMP codes.

Python Classify TCP SYN results

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

A stand-in: summarize like "Not shown"

Nmap groups the most common state behind "Not shown". This stand-in computes that line from a list of states, then lists the others.

Python Summarize states like Nmap does

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

Practical advice

  • Treat open as "something is listening and reachable from where I scanned". It might still be unreachable from elsewhere.
  • Scan from more than one position (inside and outside the firewall) and compare; the difference shows what the firewall hides.
  • open|filtered and filtered are not failures; they are information. Follow up with version detection or a different scan type.
  • Reasons (--reason) show exactly how a state was decided. See Verbosity and Reasons.

Check your understanding

Quick check ยท 4 questions

of 4 answered You scored / 4 ยท perfect!

  1. 1. A SYN scan gets a RST reply from a port. What is its state?

    RST means the host answered and nothing listens on that port.
  2. 2. A UDP port sends no reply after retries. Which state does Nmap report?

    Open UDP ports are often silent, and filtered ones are too, so Nmap cannot tell them apart.
  3. 3. Which scan can produce the unfiltered state?

    The ACK scan only tests whether packets reach the port, so it can say 'unfiltered' but never 'open'.
  4. 4. A server shows 997 filtered ports and 3 open ports. What does this most likely indicate?

    Mass silence on unused ports with a few open ones is the pattern of a restrictive firewall.

Summary

  • Six states: open, closed, filtered, unfiltered, open|filtered, closed|filtered.
  • Open = accepts; closed = host replied "nothing here"; filtered = something blocks the probe.
  • UDP and flag scans often yield open|filtered because silence is ambiguous.
  • Closed versus filtered tells you whether a firewall stands in the way.
  • Use reasons and multiple vantage points to interpret results.

Next: Choosing Ports