Andres Diaz

andres@diaz:~$ whoami

Andres Diaz

Defect Reproduction Engineer at Filevine

andresdiaztech@gmail.com

LinkedIn GitHub Blog



andres@diaz:~/notes$ cat nmap-flags.md

cd ..

Nmap (Network Mapper)

Oct 22, 2026 · Reference

Goal

A running list of the Nmap (Network Mapper) flags I use, the common scan types and what the port states mean. Nmap scans a host for open ports and figures out what is running on them.

Related: Ports · TCP and UDP

Flags I use most

These answer different questions, so they are not an either/or. -T4 just rides along on any scan for speed.

FlagWhat it does / question it answersWhen to use it
-sn"Which hosts are alive?" Host discovery only, no port scan.Sweeping a whole range to find targets. Skip it on a single IP I already know is up.
(no -p)"What is open?" Scans the top 1000 ports.A fast first look. Catches most things.
-p-"What is open?" Scans all 65535 ports.When I want to be thorough and not miss a service on an odd high port. Slower.
-p 80,443Scan only the ports I list, for example 80 (HTTP) and 443 (HTTPS).Once I know which ports to focus on.
-sV"What service and version is on each open port?"Always, once there are open ports. The versions are my leads.
-sCRuns the default scripts for extra detail.Together with -sV. -sC -sV is the standard enumeration combo.
-sSSYN scan, the "stealth" or half-open scan.The normal TCP (Transmission Control Protocol) scan, and already the default with sudo, so I rarely type it.
-sTTCP (Transmission Control Protocol) connect scan, finishes the full connection.The default when I am not root (without sudo).
-sU"What UDP (User Datagram Protocol) ports are open?"Checking UDP. Slow, so I stick to the common ports.
-O"What operating system is it?"When I want OS (Operating System) detection.
-AEverything at once: version, OS, default scripts and traceroute.One command when I want the full picture.
-PnSkip host discovery, treat the host as up.When the host blocks pings.
--top-ports 100The 100 most common ports.A middle ground between the top 1000 and all 65535.
--script <name>Run a specific NSE (Nmap Scripting Engine) script.Targeted checks on a service.
-T0 to -T5Speed, not a scan type. Higher is faster.Add to any scan. T4 is a good default, T5 can miss things.
-oA <name>Save the results to files.So I can reread them later without scanning again.
-vShow more detail while it runs.When I want to watch progress.
-iL <file>Read the list of targets from a file.Many targets at once.

Run nmap -h or man nmap for the full list.

Scan types and the stealth scan

The stealth scan (-sS) is a half-finished version of the TCP (Transmission Control Protocol) handshake. Nmap sends SYN, an open port answers SYN-ACK, and instead of finishing the connection Nmap sends RST (reset) to drop it. Because it never completes the connection, it is quieter in the logs, which is why it is called stealthy. It is not invisible: a network with good security (an IDS, Intrusion Detection System) can still spot it. It is Nmap's default scan when run with sudo.

Port states

StateWhat it means
openSomething is listening on the port.
closedNothing is listening, but the host replied.
filteredA firewall is dropping the probe, so no reply comes back.
open|filteredOnly on UDP (User Datagram Protocol) and a few scan types. No reply came back, so Nmap can't tell open from filtered.

Scans I've run

sudo nmap -sn 192.168.12.0/24           # find live hosts on the network
sudo nmap -T4 -p- -A <target>           # full TCP scan: all ports, versions, OS and scripts
sudo nmap -sU -T4 <target>              # UDP scan, top 1000 ports
sudo nmap -T4 -p- -A -oA scan <target>  # same full scan, saved to files