Nmap
Executive Summary
Nmap is used for host discovery, port scanning, service detection, script scanning, and network mapping.
Use this cheatsheet for quick scan syntax during enumeration and validation.
Basic Scans
Scan a single host:
Scan multiple hosts:
Scan a subnet:
Scan from a file:
Host Discovery
Ping scan:
Treat host as alive:
ARP discovery on local network:
Port Scanning
Top 1000 TCP ports:
Specific ports:
Port range:
All TCP ports:
Fast all-port scan:
UDP scan:
Top UDP ports:
Scan Types
TCP SYN scan:
TCP connect scan:
UDP scan:
Null scan:
FIN scan:
Xmas scan:
Service and Version Detection
Service detection:
Default scripts and service detection:
Aggressive scan:
Version intensity:
NSE Scripts
Run default scripts:
Run specific script:
Run script category:
Run scripts against specific port:
List local scripts:
Search scripts:
Timing and Performance
Timing templates:
Minimum packet rate:
Limit retries:
Scan faster with no DNS:
Output
Normal output:
Grepable output:
XML output:
All formats:
Firewall and Evasion Options
Disable host discovery:
Fragment packets:
Use decoys:
Spoof source port:
Append random data:
Common Service Scans
SMB:
FTP:
HTTP:
DNS:
SNMP:
RDP:
Practical Workflow
| Step | Command |
|---|---|
| Discover hosts | nmap -sn SUBNET |
| Scan all TCP ports | nmap -p- --min-rate 1000 TARGET_IP |
| Scan found ports | nmap -sC -sV -p PORTS TARGET_IP |
| Run service scripts | nmap --script CATEGORY -p PORT TARGET_IP |
| Save output | nmap -oA scan TARGET_IP |
Notes
- Use
-Pnwhen ICMP is blocked. - Use
-nto skip DNS and speed up scans. - UDP scans are slower and often require root.
- Raw packet scans may fail through proxies or tunnels.
- Always save scan output for comparison and reporting.