The Basic Scan
Just knocks on the top 1,000 most common doors.
nmap 192.168.1.1
The essential guide to scanning and mapping networks.
Learn how to discover hosts and services on a computer network, building a map of things most people can't see.
Nmap is a free tool that helps you find computers, phones, and servers on a network. It shows you what doors are open on those devices and what software is running behind them.
Imagine an IP address is a large office building. Nmap is a security guard. The guard walks up to the building and knocks on every single door (port) to see if anyone answers.
After knocking, the guard writes a list. The list says which doors are open, which are locked, and who answered the open doors. This is exactly what Nmap does for computer networks.
You plug a new printer into your network but don't know its address. Nmap can scan the whole network and find it for you.
You want to make sure your computer doesn't have open doors that hackers can walk through. Nmap shows you your open doors.
A company needs a list of every computer running in their office. Nmap builds this list automatically.
Every command is built using three simple parts: The tool, the options (flags), and the target.
This tells the computer to start the Nmap program.
The flags. These tell Nmap how to act. Here we ask it to check the version (-sV) and only check door number 80 (-p 80).
The target. This is the exact address of the computer you want to check.
You will often see commands start with sudo nmap. Why? Some of Nmap's best tricks (like
silent knocking or guessing the operating system) require deep access to your computer's network
card.
Typing sudo is like pulling out a master key. It tells your computer, "I am the boss,
let Nmap do advanced stuff." If a scan isn't working right, you probably forgot sudo.
Before Nmap knocks on 1,000 doors, it checks if the building is even there. If a computer is turned off, there's no point checking its doors. Nmap uses a "Ping Sweep" to shout "Is anyone awake?" to an entire network.
The "No Port Scan" flag
The -sn flag tells Nmap: "Just tell me which computers are turned on. Don't
bother checking any of their doors." This is incredibly fast. You can find every device
on your home Wi-Fi in less than 3 seconds.
If an IP address is a building, a port is a specific room inside that building. A computer has 65,535 possible ports. Some rooms are used for specific jobs.
By default, Nmap only checks the top 1,000 most common doors to save time. But you can tell it exactly which ones you care about.
A short list. Only check door 80 and door 443. Nothing else.
A range. Check every single door starting from 1 up to 100.
All of them. The magic dash tells Nmap to check all 65,535 doors. This takes a long time!
When Nmap knocks on a port, it usually gets one of three answers back.
The door is open, and a program is actively listening on this port. Anyone can connect to it.
Nmap knocked, and the computer said "I am here, but there is no program running on this port right now."
Nmap knocked, but heard nothing back. A firewall (a security shield) is blocking Nmap's messages from reaching the port.
Computers send messages in two main ways. Nmap needs to know which way you want to check.
Nmap Flag: -sT or -sS (Default)
TCP is like calling someone on the phone. You dial, they answer "Hello", you say "Hello back", and then you start talking. It guarantees the message arrived. Most of the internet (websites, emails) uses TCP.
Nmap Flag: -sU
UDP is like throwing a postcard in a mailbox. You hope it gets there, but you never get a receipt. It's very fast, used for live video games and video calls. Scanning UDP is much slower because Nmap has to wait a long time to see if the postcard was ignored.
Nmap walks up, knocks, waits for the door to open, steps inside, says "Hello", and then leaves. It completes a full connection. It is highly accurate, but it is very loud. The computer will write down in its logbook that you visited.
Nmap knocks. As soon as the door starts to open, Nmap runs away before stepping inside. It found out the door was open, but because it didn't complete the greeting, many computers won't write it down in their logbook. This is the default scan.
Knowing a port is open is good. Knowing exactly what software is using that port is better.
The Version flag
When you use -sV, Nmap doesn't just check if the door is open. It yells into the
room and asks, "What is your name and what version are you?"
The OS flag (Capital letter O)
Every operating system (Windows, Mac, Linux) answers network messages in a slightly different way—like an accent. Nmap can listen to these "accents" and guess what operating system the target is running.
Sometimes you are in a rush. Sometimes you want to go very slowly so security alarms
don't go off. You can control Nmap's speed from 0 to 5 using the -T flag.
If you don't want the target computer to know you are the one knocking, you can use decoys.
The -D flag tells Nmap to send fake knocks from other IP addresses at the exact same
time you knock. To the target's security guard, it looks like 3 different people knocked at once.
They won't know which one was actually you.
Nmap has mini-programs inside it called scripts. These scripts can do complicated jobs automatically.
Runs a collection of the most safe and common scripts. It checks for obvious weak spots.
Tells Nmap to run specific scripts that check if the computer has known security holes (vulnerabilities).
If typing commands into a black terminal window feels intimidating, you can use Zenmap.
Zenmap is the official visual version of Nmap. It has buttons, drop-down menus, and even draws a cool spider-web map of all the devices on your network. It does the exact same thing as the terminal, just with a mouse.
When Nmap finishes, it prints a report. Here is how to read a basic scan report.
| PORT | STATE | SERVICE | VERSION |
|---|---|---|---|
| 22/tcp | open | ssh | OpenSSH 8.2p1 |
| 80/tcp | open | http | Apache httpd 2.4.41 |
| 443/tcp | filtered | https |
If you scan 500 computers, the results will scroll off your screen faster than you can read them. Always save your output to a file.
Normal. Saves the text exactly how it looks on your screen.
Greppable. Puts all the data into neat rows so other computer tools can search it easily.
All Formats. The best option. Saves a Normal file, a Greppable file, and an XML file all at once.
-T5 over a weak Wi-Fi signal will
drop packets and Nmap will tell you doors are closed when they are actually open.sudo: Wondering why your OS detection (-O)
gave you an error? You forgot to run it as an admin.Just knocks on the top 1,000 most common doors.
nmap 192.168.1.1
Checks versions (-sV), runs safe scripts (-sC), and guesses the OS (-O). Also called the Aggressive scan (-A).
nmap -A 192.168.1.1
Finds every single device turned on in a typical home or small office network.
nmap 192.168.1.0/24
Only knocks on one single door instead of all of them (saves time).
nmap -p 443 192.168.1.1
Never, ever scan a network or an IP address that you do not own, or do not have written permission to scan.
Using Nmap to check your own home router or your own servers is a great way to learn security. Scanning someone else's server without asking looks like a digital break-in to security teams and is illegal in many places.
Master more skills with other tutorials from the Security series.