Drill: Basic Port Scanning with nmap¶
Goal¶
Use nmap to perform basic port scans and service detection to verify what is actually listening and reachable.
Setup¶
- Linux system with nmap installed (
apt install nmaporyum install nmap) - Permission to scan the target host (never scan systems you do not own or have authorization for)
Commands¶
Quick scan of common ports:
Scan specific ports:
Scan a port range:
Service version detection:
TCP SYN scan (fast, default with root):
TCP connect scan (no root needed):
Scan a subnet for live hosts:
Show reason for port state:
Output in all formats:
What to Look For¶
openmeans a service is accepting connectionsfilteredmeans a firewall is silently dropping packets (no RST, no response)closedmeans the port responded with RST (host is up but nothing is listening)- Service version info from
-sVconfirms what software is running
Common Mistakes¶
- Scanning without authorization (legal and ethical implications)
- Using
-sSwithout root and getting TCP connect scan instead without realizing it - Scanning all 65535 ports over WAN (very slow; use targeted port lists)
- Not using
--reasonand guessing why a port is shown as filtered vs closed