Security tools · Lesson 13 of 14
Nmap: scan your own network
A beginner’s Nmap guide: what port scanning is, when it’s legal, how to scan your own lab, and how to read open, closed and filtered results.
⏱ 18 min🎯 Beginner🧪 Hands-on practice🎬 Video
By the end, you’ll be able to…
- Explain what a port scan does and why defenders use it
- Run safe Nmap scans against your own machine and lab
- Read Nmap output and decide what to do about open ports
Key words
- Port scan
- Checking which ports on a device accept connections.
- Open
- A program is listening on that port and answered.
- Closed
- The device answered, but nothing is listening on that port.
- Filtered
- No clear answer, usually because a firewall dropped the probe.
- Service detection
- Asking an open port what software and version is behind it (-sV).
- Attack surface
- Everything about a system that someone could try to interact with.
What Nmap is for
Nmap (“Network Mapper”) is a free, open-source tool that discovers devices on a network and checks which ports they have open. Defenders use it to answer a simple but vital question: what am I actually exposing? You can’t protect a service you don’t know is running.
Install
- Windows / macOS: installers on the official download page.
- Ubuntu / Debian:
sudo apt install nmap - Kali: already installed.
Scan 1: your own computer
nmap localhost
This checks the 1,000 most common ports on your own machine. Typical output:
Nmap scan report for localhost (127.0.0.1)
Host is up (0.00010s latency).
Not shown: 997 closed tcp ports (reset)
PORT STATE SERVICE
22/tcp open ssh
631/tcp open ipp
5432/tcp open postgresql
Do you recognise each one? Here: SSH (remote login), IPP (printing), PostgreSQL (a database). If you don’t use one, that’s a service worth turning off.
Scan 2: what software is listening?
nmap -sV localhost
-sV asks each open port what software and version it’s running. Outdated versions are worth updating.
Scan 3: find devices in your lab
If your VMs are on a host-only network such as 192.168.56.0/24:
nmap -sn 192.168.56.0/24 # -sn = just find which hosts are up, no port scan
nmap 192.168.56.101 # then scan one VM you own
The /24 means “all 256 addresses from 192.168.56.0 to 192.168.56.255”. Only use ranges that are entirely yours.
Reading port states
| State | Means | What to do |
|---|---|---|
| open | Something is listening and answered | Do you need it? Is it updated? Is it limited by a firewall? |
| closed | Reachable, but nothing is listening | Usually fine |
| filtered | A firewall is probably dropping probes | Often expected and good |
From scan to defence
A scan is only useful if it leads to action:
- List each open port and the service behind it.
- Ask: does this need to be reachable, and from where?
- Turn off what isn’t needed (
systemctl disable --now <service>), update what is, and use a firewall to limit who can reach it. - Scan again to confirm your change worked.
That loop of discover, decide, fix, verify is real defensive work.
🧪 Hands-on
Practice
Read this Nmap scan of a lab VM and answer the questions.
🎬 Watch
Video: Nmap Tutorial to Find Network Vulnerabilities
Video by NetworkChuck, hosted on YouTube. It loads only when you press play.
✅ Check yourself
Quick quiz
🔗 Go further
Trustworthy resources
- Nmap reference guide The official manual.
- Nmap download Official installers for every OS.
- scanme.nmap.org Read the rules before scanning this test host.
- Nmap source code Open source on GitHub.