Back to course

Nmap Basic Syntax and Host Discovery

Cyber Security Mastery: From Zero to Hero

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 TypeExample
Single IPnmap 192.168.1.100
Hostnamenmap testserver.local
IP Rangenmap 192.168.1.100-150
CIDR Subnetnmap 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).