Nmap (Network Mapper) is one of the most powerful network scanning tools used in cybersecurity and ethical hacking. In this Nmap tutorial for beginners, you will learn how to scan networks, detect open ports, identify running services, analyze security vulnerabilities, and interpret Nmap's output like a professional.
⚠️ Legal Notice: Only scan networks, devices, or websites that you own or have explicit written permission to test. Scanning systems without authorization may violate the Computer Fraud and Abuse Act (in the US), the Computer Misuse Act (in the UK), and similar laws in other countries — even when using default or "safe" scan types. Always get permission first.
On this page:
Nmap is a free and open-source network scanning tool used to discover hosts and services on a computer network. It is widely used for network auditing, penetration testing, and security assessments.
With Nmap, you can identify live systems, detect open ports, determine running services, and even guess operating systems used by devices. First released in 1997, Nmap has grown into one of the most trusted tools in the cybersecurity industry, used by network administrators, security researchers, and IT teams around the world to keep their infrastructure visible and accounted for.
Nmap plays a critical role in cybersecurity by helping professionals understand network exposure and detect potential entry points for attackers.
The examples below use private network addresses (192.168.x.x) and IANA's reserved documentation domain, which are safe to reference for learning purposes. When practicing yourself, only run these against your own devices or a lab environment you control.
nmap 192.168.1.1
This command scans a single device and shows open ports.
nmap 192.168.1.1-100
Scans multiple devices in a network.
nmap example.com
Finds open ports and services running on a domain. Note: example.com is a domain reserved by IANA specifically for documentation and testing — never run this against a live website you don't own or have permission to test.
nmap -sV 192.168.1.1
Shows versions of services running on open ports.
nmap -p 80,443 192.168.1.1
Limits the scan to specific ports instead of the default top 1,000 — useful when you already know which services you want to check.
nmap -p- 192.168.1.1
A full port scan is slower but more thorough than the default scan, which only checks the most common ports.
After running an Nmap scan, the results show important details such as:
A "filtered" state usually means a firewall is blocking Nmap's probes, while "closed" means the port is reachable but nothing is listening on it. Understanding this distinction helps you tell the difference between a genuinely secured system and one that's simply not running a service on that port.
Nmap Scan Output Example:
The scans below (OS detection, aggressive scan, and stealth scan) are more invasive and, in the case of stealth scanning, specifically designed to evade detection. Only run these against systems you own or a lab environment set up for practice — never against third-party networks or websites.
nmap -O 192.168.1.1
nmap -A 192.168.1.1
nmap -sS 192.168.1.1
Nmap includes a built-in scripting engine that extends its functionality with community-written scripts, covering everything from service detection to configuration auditing. Scripts are grouped into categories such as default, discovery, safe, and vuln. Beginners should stick to scripts labeled "safe" when testing on any system, since some categories are intentionally more aggressive.
Nmap lets you control how fast a scan runs using timing templates, numbered T0 (slowest, most stealthy) to T5 (fastest, most aggressive). Slower scans are less likely to trigger intrusion detection systems but take longer to complete.
| Template | Speed | Typical Use |
|---|---|---|
| -T0 | Paranoid | Extremely slow, avoids detection |
| -T1 | Sneaky | Slow, IDS evasion |
| -T2 | Polite | Reduces load on the network |
| -T3 | Normal | Default speed |
| -T4 | Aggressive | Faster, assumes a stable network |
| -T5 | Insane | Fastest, may sacrifice accuracy |
Example: nmap -T4 192.168.1.1
For real audits, you'll usually want to save your scan results rather than just reading them in the terminal. Nmap supports several output formats:
-oN scan.txt — normal, human-readable output-oX scan.xml — XML output, useful for feeding into other tools-oG scan.gnmap — "grepable" format, easy to search with command-line tools-oA scan — saves all three formats at once using the same base filenameExample: nmap -oA my_scan 192.168.1.1
Nmap shows up constantly in real cybersecurity work. A few common scenarios:
| Tool | Primary Use | Best For |
|---|---|---|
| Nmap | Port and network scanning | General-purpose network discovery and auditing |
| Masscan | High-speed port scanning | Scanning very large IP ranges quickly |
| Nessus | Vulnerability scanning | In-depth vulnerability identification and reporting |
| Zenmap | GUI for Nmap | Beginners who prefer a visual interface over the command line |
Many security professionals use Nmap alongside these other tools rather than instead of them — Nmap for initial discovery, then a dedicated vulnerability scanner for deeper analysis.
Nmap is one of the first tools used during penetration testing. It helps ethical hackers map the network, identify targets, and plan further testing — always within the scope of an agreed, authorized engagement.
By understanding open ports and services, security professionals can detect weaknesses before attackers exploit them.
Yes, Nmap itself is completely legal software. What matters is what you scan — scanning systems you don't own or don't have permission to test can be illegal, regardless of which tool you use.
Yes, Nmap is free and open-source, available for Windows, Linux, and macOS.
No. While Nmap is commonly associated with Linux distributions like Kali Linux, it runs natively on Windows and macOS as well.
No. Nmap is primarily a discovery and mapping tool. For in-depth vulnerability detection, it's typically paired with a dedicated vulnerability scanner like Nessus or OpenVAS.
Zenmap is the official graphical interface for Nmap. It runs the same scanning engine underneath but presents results visually, which can be easier for beginners than reading raw terminal output.
Nmap is an essential tool for anyone interested in networking or cybersecurity. Whether you are a beginner or a professional, learning Nmap can significantly improve your ability to analyze and secure networks — always with proper authorization.