Host discovery
nmap -sn <net>/24
Ping scan only, no port scan
Formerly -sP. Lists the hosts that answered.
nmap -Pn <host>
Skip discovery, assume host is up
Use when hosts block ping and show as down.
nmap -PS<ports> <host>
Discover with TCP SYN probes
Default port is 80.
nmap -PA<ports> <host>
Discover with TCP ACK probes
nmap -PU<ports> <host>
Discover with UDP probes
nmap -PE <host>
Discover with ICMP echo
nmap -PR <net>/24
ARP discovery on local LAN
Used automatically for hosts on the local Ethernet.
nmap -n <host>
Never resolve DNS names
Faster; -R forces resolution for every host.
nmap --traceroute <host>
Trace route after the scan
Scan types
nmap -sS <host>
TCP SYN (half-open) scan
Default when run as root: fast and rarely logged by apps.
nmap -sT <host>
TCP connect scan
Default without root; completes every handshake.
nmap -sU <host>
UDP scan
Slow; combine with --top-ports to keep it practical.
nmap -sA <host>
ACK scan to map firewall rules
Reports only filtered or unfiltered.
nmap -sN <host>
TCP NULL scan (no flags)
nmap -sF <host>
TCP FIN scan
nmap -sX <host>
TCP Xmas scan (FIN, PSH, URG)
nmap -sW <host>
TCP window scan
nmap -sO <host>
Scan IP protocols, not ports
nmap -sI <zombie> <host>
Idle scan via a zombie host
Detection
nmap -sV <host>
Detect service versions
nmap -O <host>
Detect the operating system
Needs root; works best with an open and a closed port.
nmap -A <host>
OS, versions, scripts, traceroute
Noisy: it is the aggressive all-in-one option.
nmap -sV --version-intensity <0-9> <host>
Set version probe depth
Default is 7.
nmap -sV --version-light <host>
Quick version detection
Same as intensity 2.
nmap -sV --version-all <host>
Try every version probe
nmap -O --osscan-guess <host>
Guess OS more aggressively
nmap -O --osscan-limit <host>
Only try OS on promising hosts
Scripts (NSE)
nmap -sC <host>
Run default scripts
Equals --script=default.
nmap --script <name> <host>
Run a named script
nmap --script <category> <host>
Run a category (safe, vuln...)
nmap --script "http-*" <host>
Run scripts by wildcard
nmap --script "default and safe" <host>
Combine selections with and/or/not
nmap --script-args <k>=<v> <host>
Pass arguments to scripts
nmap --script-help <script>
Describe a script or category
nmap --script-updatedb
Rebuild the script index
nmap --script-trace <host>
Show script network traffic
nmap -T4 <host>
Faster scan on a reliable network
Templates run -T0 paranoid to -T5 insane; default is -T3.
nmap -T2 <host>
Polite: slow, light on the target
nmap --min-rate <pps> <host>
Send at least this many packets/s
nmap --max-rate <pps> <host>
Cap the send rate
nmap --max-retries <n> <host>
Fewer retransmissions
nmap --host-timeout <time> <host>
Give up on slow hosts
Time takes units, e.g. 30m or 90s.
nmap --scan-delay <time> <host>
Wait between probes
Output
nmap -v <host>
More verbose, repeat for more
nmap --open <host>
Show only open ports
nmap -oN <file> <host>
Save normal output
nmap -oX <file> <host>
Save XML output
nmap -oA <base> <host>
Save normal, XML and grepable
nmap -oG <file> <host>
Save grepable output
Deprecated; prefer XML for parsing.
nmap --reason <host>
Explain each port state
nmap --packet-trace <host>
Show every packet sent and received
nmap --append-output -oN <file> <host>
Append instead of overwrite
nmap --resume <file>
Resume an interrupted scan
Takes a previous -oN or -oG file and no other arguments.
nmap -oX - <host>
Write XML to stdout