Cheat sheets

Cheat sheet

nmap cheat sheet

Scanning on one page: nmap's host discovery, port scans and service detection, then nping.

nmap

Scans a device or a network for open ports and live hosts, and tells open, closed and filtered apart.

nmap -Pn -p 22,53,80,443 10.0.2.10
Checks four common ports on 10.0.2.10 and reports each as open, closed or filtered.
nmap -sn 10.0.1.0/24
Finds which addresses on 10.0.1.0/24 answer, without scanning ports.
nmap -sn --reason 10.0.2.0/24
Finds the live hosts and says why each counts as up: an ARP reply on your own network, a ping reply or a TCP reset across a router.
nmap -sU -p 53,67 10.0.1.2
Checks two UDP ports, DNS and DHCP, on the router.
nmap 10.0.2.10
Scans the 1000 most common TCP ports and lists the open ones.
nmap -p- 10.0.2.10
Scans all 65535 TCP ports, finding services on unusual ports.
nmap -F 10.0.2.0/24
Scans only the 100 most common ports on every address of the network: a fast first look.
nmap --top-ports 20 --open 10.0.2.0/24
Scans the 20 most common ports and shows only the hosts and ports that are open.
nmap -sV -p 22,80,443 10.0.2.10
Asks each open port what answers on it and prints the program and version.
nmap -O 10.0.2.10
Guesses the operating system from how its TCP/IP stack answers (needs root).
nmap -A 10.0.2.10
Runs version detection, OS detection, the default scripts and traceroute together.
nmap -sT -p 22,80 10.0.2.10
Makes full TCP connections, the scan you get without root; as root nmap sends half-open SYN probes (-sS).
nmap --script ssl-cert -p 443 bank.lab
Prints the server's certificate: its name, issuer and dates.
nmap -T4 -oA office-scan 10.0.1.0/24
Scans faster and saves the results in normal, XML and grepable files named office-scan.

Every nmap option, with real output

nping

Builds and sends packets or frames by hand, with any source address, and shows what comes back.

nping --tcp -p 80 -c 3 10.0.1.20
Sends three TCP SYNs to port 80 and prints each reply, with its flags.
nping --arp -c1 --send-eth -e eth0 --source-mac 02:00:00:00:00:01 10.0.1.250
Sends one ARP request from a made-up MAC address, which every switch on the way learns.
nping --udp -p 53 -S 10.0.2.13 -c 30 --rate 30 10.0.1.10
Sends thirty DNS queries that forge a victim's source address, so the replies land on the victim.

Every nping option, with real output

Learn it on real machines.

Every lab is a small network of real Linux machines in your browser. Sign in with Google or email to start.

Start this lab