Starting with Nmap
All Nmap commands begin with nmap followed by options and the target specification.
Basic Syntax
bash nmap [Scan Type(s)] [Options] {target specification}
Target Specification
Nmap can scan single IPs, IP ranges, or entire subnets.
| Target Type | Example |
|---|---|
| Single IP | nmap 192.168.1.100 |
| Hostname | nmap testserver.local |
| IP Range | nmap 192.168.1.100-150 |
| CIDR Subnet | nmap 192.168.1.0/24 |
Host Discovery (-sn)
Before port scanning, we check if the host is alive. The -sn (or -sP) option performs a ping scan (only host discovery, no port scan).
bash nmap -sn 192.168.1.0/24
Note: If Nmap detects that an address is likely behind a firewall, it might skip the initial ping check by default. You can force the scan with -Pn (No Ping).