Programster's Blog

Tutorials focusing on Linux, programming, and open-source

Nmap Cheatsheet

Scan A Single Host For Common Ports

nmap $IP_ADDRESS

Scan A Single Host For All Ports

nmap -p- $IP_ADDRESS

Scan for a single port on a range of IP addresses.

PORT_NUMBER=22
nmap -p $PORT_NUMBER 192.168.1.*

If you want to scan all IPs from 192.168.0.0 to 192.168.2.255, you could use a - like so:

nmap -p 80 192.168.0-2.*

Check UDP Port

If you need to check if a UDP port is open you need to provide the -sU option like so:

nmap -sU -p $PORT $IP

References

Last updated: 16th May 2025
First published: 28th December 2020

This blog is created by Stuart Page

I'm a freelance web developer and technology consultant based in Surrey, UK, with over 10 years experience in web development, DevOps, Linux Administration, and IT solutions.

Need support with your infrastructure or web services?

Get in touch