Nmap Basics and Port Specifications
What you'll learn: How to use nmap's fundamental syntax to specify targets and control which ports to scan.
Understanding Nmap Command Structure
Nmap (Network Mapper) is the industry-standard tool for port scanning. At its core, every nmap command follows a simple pattern: you tell it what to scan (targets), where to look (ports), and how to scan (scan type).
Think of nmap like a security guard checking doors in a building. You need to tell the guard which building (target), which floors to check (port ranges), and whether to knock politely or try the handle (scan type).
Basic Syntax
The simplest nmap command structure:
nmap [scan_type] [options] [port_specification] target
Target specification:
- Single IP:
nmap 192.168.1.10 - Hostname:
nmap example.com - IP range:
nmap 192.168.1.1-50 - CIDR notation:
nmap 192.168.1.0/24
Port Specifications
By default, nmap scans the 1,000 most common ports. You can control this:
- Specific port:
-p 80 - Multiple ports:
-p 22,80,443 - Port range:
-p 1-1000 - All ports:
-p-(same as-p 1-65535) - Top ports:
--top-ports 100
Selecting Scan Types
Recall the scan techniques you've learned:
-sT= TCP Connect scan-sS= SYN scan (requires root/admin)-sU= UDP scan
Example combining it all: nmap -sS -p 1-1024 192.168.1.0/24
Key Takeaway: Nmap requires three pieces: target specification (what to scan), port specification (where to look), and scan type selection (how to probe) — mastering this syntax gives you precise control over reconnaissance scope.