| Key Takeaways |
|
|
|
|
|
Nmap (short for Network Mapper) is a free network scanning tool that discovers hosts and services on a network by sending packets and analyzing the responses. Security teams use it to find live hosts, scan open ports, identify the services and versions running on them, and fingerprint operating systems. It runs on Linux, Windows, and macOS.
Gordon Lyon, who writes under the alias Fyodor, released the first version in 1997. Nmap has since become a standard tool on both sides of security work: penetration testers and red teams use it to map a target’s attack surface, while defenders and incident responders use it to inventory their own networks, catch unauthorized devices, and spot exposed services before an attacker does.
This guide covers what Nmap does and how to use Nmap, from running your first scan and learning the key commands to reading scan results on Windows and macOS.
What is Nmap?
Nmap is a free network scanning and host-discovery tool. What does Nmap do? Point it at a single host or an entire network, and it reports which systems are live, which ports are open, what services and versions they run, and each system’s likely operating system. It works on Linux, Windows, and macOS.
First released in 1997, Nmap is still actively maintained. The current stable version is 7.991, released August 6, 2026, and recent releases have kept pace with modern environments: updated operating-system and service fingerprints, newer TLS and post-quantum cipher support in its scripts, an updated Npcap packet-capture driver on Windows, and the ability to scan over VPN virtual adapters.
Most of what makes Nmap useful has been stable for years:
- Nmap Scripting Engine (NSE). Run or write scripts that automate tasks like vulnerability checks, service enumeration, and authentication testing.
- Service and version detection. Probe open ports to identify the likely application and version behind them.
- OS detection. Fingerprint a host’s operating system from how its network stack responds.
- Flexible timing. Dial a scan between slow-and-quiet and fast-and-aggressive with the -T0 through -T5 options.
- Multiple output formats. Save results as normal text (-oN), XML (-oX), or grepable output (-oG) for reporting or feeding into other tools.
What is Nmap Used For?
So what is Nmap used for? At its simplest, Nmap turns an unknown network into an inventory. In a single scan, it tells you which systems are live, which ports are open, what services they run, and what operating system each is on. That inventory is the starting point for a security audit, a vulnerability check, or simply confirming no rogue device has appeared on the network.
Here is where an Nmap scan helps a security team:
- Assess network security. Scan open ports and services to find the entry points an attacker would probe first.
- Detect unauthorized devices. Run regular scans to catch new or rogue devices that should not be on the network.
- Troubleshoot connectivity. Pinpoint the status of hosts and services when something breaks.
- Inventory assets. Build a current list of the devices and services running across the network.
- Scan for vulnerabilities. Pair Nmap with NSE scripts and vulnerability databases to flag known weaknesses before attackers exploit them.
Nmap maps what you point it at, which means it only covers the assets you already know to scan. That is its natural limit: systems outside the range you hand it, such as forgotten subdomains or unmanaged cloud instances, stay invisible to a routine internal scan.
Knowing that boundary is part of using Nmap well, and it is why network inventory and external asset discovery usually run as two separate jobs.
Key Features of Nmap
Nmap packs several capabilities into one command-line tool. These are the features that do the most work in a typical scan:
- Multiple scan types. Nmap offers different ways to probe a target, from the fast, quiet SYN scan (-sS) to UDP scans (-sU) for services like DNS and SNMP, and ACK scans (-sA) for mapping firewall rules. Each one trades speed, stealth, and detail differently, so security teams can match the scan to the job.
- Nmap Scripting Engine (NSE). NSE runs small scripts that extend Nmap well past basic scanning, with more than 600 maintained scripts for vulnerability checks, service brute-forcing, and enumeration. You can also write your own.
- Service and version detection. Nmap probes open ports (-sV) to name the exact application and version behind each one. That is what turns “port 443 is open” into “nginx 1.24 is running here,” which is the detail security teams need to spot outdated or vulnerable software.
- OS detection. Nmap fingerprints a host’s operating system (-O) from how its network stack responds to crafted probes, then matches that behavior against its fingerprint database to estimate the OS and version.
- Zenmap (the GUI). Zenmap is Nmap’s official graphical interface. It builds and saves scan profiles, compares results across scans, and renders network topology visually, which helps when reporting findings to a less technical audience.
How Nmap Works: A Technical Overview
Nmap interacts with Internet Protocol (IP) packets to probe network devices, send crafted requests, and analyze their responses. This packet-level interaction lets the tool extract detailed information about hosts, services, and potential vulnerabilities on a network. Depending on the options used, a scan can include five main activities:
Host Discovery
Nmap first finds which devices in the target range are online, a step called host discovery. It narrows the scan to live systems, helps build a network inventory, scopes a penetration test, and flags unauthorized devices.
Port Scanning
Once it finds active devices, Nmap scans ports to identify which ones are open. It helps security teams detect misconfigurations, unnecessary services, and potential attack vectors.
Service Detection
Once the Nmap scan determines that a port is open, it also identifies the service running on it and its version. It queries the open port, checks how it responds, and compares it with its built-in service database.
OS Fingerprinting
Nmap can estimate a device’s operating system (OS) by analyzing its responses to various network probes. Different OS types handle network requests in unique ways.
It compares these patterns against its OS fingerprint database to estimate the system type and version, and sometimes the device type, such as a router or printer.
Script Execution
Nmap also includes a scripting engine that automates tasks like:
- Detecting known vulnerabilities in services
- Enumerating user accounts and configurations
- Testing services for weak or default credentials
- Gathering network information, like DNS records and TLS/SSL certificates
Common Nmap Scanning Techniques
Nmap provides several scanning techniques, each suited to a different goal: speed, stealth, firewall mapping, or a particular protocol. The table below covers the most commonly used ones and the flag that runs each.
| Scan technique | Flag | What it does |
| TCP Connect scan | -sT | Completes the full three-way handshake (SYN, SYN-ACK, ACK). Reliable, but easy to log. The default when Nmap runs without admin rights. |
| SYN scan | -sS | Sends a SYN but never finishes the handshake, so it is faster and less conspicuous in application logs than a Connect scan, though firewalls and monitoring tools can still detect it. Needs root or admin privileges, and is the default when Nmap has them. |
| UDP scan | -sU | Checks UDP ports used by services like DNS, SNMP, and DHCP. Slower than TCP scans, and often returns open|filtered when a service does not respond, but TCP-only scans miss these ports entirely. |
| ACK scan | -sA | Maps firewall rulesets by distinguishing filtered from unfiltered ports. It doesn’t determine whether a port is open or closed, so it helps you understand a firewall before choosing another scan. |
Service and version detection
Service and version detection attempts to identify the application and version number behind an open port, not just that the port is open. Nmap sends a series of probes to the port, reads the responses, and matches them against its service-fingerprint database to return something like “OpenSSH 9.6” rather than just “port 22 open.”
When Nmap detects SSL/TLS on a port, its version probes negotiate the encrypted connection to identify the service running over it, which is how it fingerprints encrypted services such as HTTPS and IMAPS.
The flag is -sV, and version detection is most useful paired with a port scan: knowing the exact version running is what lets a security team match a service against known vulnerabilities.
Basic Nmap commands
These commands cover the everyday tasks, enough to run a useful scan from a standing start:
| Command | What it does |
| nmap <target> | Scans the 1,000 most common ports on a single host. |
| nmap 192.168.1.0/24 | Scans an entire subnet using CIDR notation. |
| nmap -sn <target> | Ping sweep: finds live hosts without scanning ports. |
| nmap -p 80,443 <target> | Scans only the named ports. |
| nmap -p- <target> | Scans all 65,535 ports. |
| nmap -F <target> | Fast scan of the top 100 ports. |
| nmap -Pn <target> | Skips host discovery and treats the host as online, useful when a firewall blocks ping. |
Advanced Nmap commands
These go deeper, combining detection, scripting, and output control:
| Command | What it does |
| nmap -sV <target> | Detects service and version on open ports. |
| nmap -O <target> | Attempts OS detection. |
| nmap -A <target> | Aggressive scan: OS detection, version detection, default scripts, and traceroute in one pass. |
| nmap -sC <target> | Runs the default set of NSE scripts. |
| nmap –script=<name> <target> | Runs a specific NSE script or category. |
| nmap -T4 <target> | Sets a faster timing template (T0 is slowest and quietest, T5 the fastest). |
| nmap -oN output.txt <target> | Saves results to a file (see output formats below). |
Using Nmap for network security audits
For a security audit, Nmap’s stages combine into a single picture of what is exposed. A typical audit scan runs host discovery, port scanning, service and version detection, and OS fingerprinting together, often with the aggressive flag:
nmap -A -T4 <target>
That one command surfaces unauthorized devices, open ports that should be closed, services running outdated versions, and misconfigured hosts. Pairing it with NSE vulnerability scripts (–script=vuln) adds a check for known weaknesses against the versions Nmap finds. For a documented audit, saving the output to a file (covered in the next section) gives a record to compare against future scans.
Best practices for using Nmap effectively
A few habits make Nmap scans faster, safer, and more useful:
- Get authorization first. Only scan systems you own or have written permission to test.
- Define the scan’s goal before running it. A quick host sweep and a full vulnerability audit call for very different scans.
- Match the scan type to the target. Use lighter, slower scans on fragile or production systems to avoid disruption.
- Automate repeat work with NSE scripts rather than re-running manual steps.
- Keep Nmap updated so scans use the latest OS and service fingerprints.
How to Run Nmap on Windows
Running Nmap on Windows takes just a few steps. This section covers how to use Nmap on Windows end to end: installing it, running your first scan, and the commands security teams should know. The official installer sets up the scanner, its packet-capture driver, and the Zenmap graphical interface in one step, so you don’t need to configure anything manually before the first scan.
Installing Nmap on Windows
The official Windows installer is available at nmap.org. It bundles everything Nmap needs, including Npcap, the driver that lets Nmap capture and send raw packets on Windows.
- Download the installer. Go to the official Nmap download page and get the latest stable self-installer, named nmap-<version>-setup.exe (currently nmap-7.991-setup.exe).
- Run the installer. Open the file and follow the prompts. By default, it installs Nmap, Npcap, and the extra tools (Zenmap, Ncat, Nping, and Ndiff). Keep Npcap checked: Nmap needs it for raw-packet features like SYN scanning and OS detection. Without it, Nmap can still run a basic TCP connect scan, but with reduced capabilities.
- Keep the default options. The installer adds Nmap to your system PATH, which is what lets you run nmap from any command window. There is no need to change this unless you have a specific reason to.
- Finish and confirm. Once the installer completes, open Command Prompt, PowerShell, or Windows Terminal and run nmap –version. If it prints a version number, Nmap is installed and ready.
System requirements are modest: Nmap supports Windows 7 and later, and Windows Server 2008 and later.
Running Your First Nmap Scan
Nmap runs from the command line on Windows, just as it does on Linux and macOS. Open Command Prompt, PowerShell, or Windows Terminal and type a command.
A good first target is scanme.nmap.org, a host the Nmap Project maintains and authorizes for public test scans (within reason, a few scans a day, not heavy or brute-force testing):
nmap scanme.nmap.org
This runs a default scan of the 1,000 most common ports and reports which are open, along with the service likely running on each. To scan a machine on your own network, use its IP address instead:
nmap 192.168.1.1
Only scan hosts you own or have permission to test. Unauthorized scanning can breach acceptable-use policies or the law.
Common Nmap Commands on Windows
The commands are identical to those on Linux and macOS, since Nmap uses the same syntax across platforms. One difference: scan types that send raw packets, such as the SYN scan (-sS) and OS detection (-O), need Npcap, which the installer already set up. A few to start with:
| Command | What it does |
| nmap <target> | Scans the 1,000 most common ports on a host. |
| nmap -sV <target> | Detects the service and version on open ports. |
| nmap -A <target> | Aggressive scan: OS detection, version detection, scripts, and traceroute. |
| nmap -p- <target> | Scans all 65,535 ports. |
| nmap -oN results.txt <target> | Saves the output to a text file. |
Zenmap, the graphical version installed alongside Nmap, offers the same scans through a visual interface if you prefer not to work from the command line. It is a useful way to build and save scan profiles and to view results without memorizing flags.
How to Run Nmap on MacOS
Nmap runs on macOS as a command-line tool, and you can install it in two common ways before you learn how to use it: the Homebrew package manager or the official installer package from nmap.org. Both give you the same nmap command in the Terminal, but the right choice depends mostly on your Mac’s chip and whether you want the graphical interface.
| Homebrew | Official .dmg installer | |
| Best for | Apple Silicon Macs (M1 and later) | Intel Macs, or wanting the GUI |
| Chip | Native on both Intel and Apple Silicon | Built for Intel; runs on Apple Silicon through Rosetta |
| Includes Zenmap (GUI)? | No, command-line only | Yes |
| Updating | One command (brew upgrade nmap) | Manual: download and reinstall the new .dmg |
| Needs setup first? | Requires Homebrew installed | Nothing; self-contained installer |
Most Macs sold since late 2020 run Apple Silicon, so Homebrew is the common choice today. The official installer is useful on Intel Macs and for anyone who wants Zenmap bundled in.
Installing Nmap on macOS
Option 1: Homebrew. If you have the Homebrew package manager installed, one command installs Nmap and handles the rest:
brew install nmap
To confirm it worked, run nmap –version. If you do not have Homebrew yet, install it first from brew.sh, then run the command above.
Option 2: The official installer. nmap.org provides a macOS disk image named nmap-<version>.dmg (currently nmap-7.991.dmg). Download it, open the disk image, and run the installer package inside. macOS may warn that the package is from an unidentified developer; if so, right-click the installer, choose Open, and confirm. You will be asked for your password, since Nmap installs into a system directory. This route installs both Nmap and the Zenmap graphical interface.
Running Your First Nmap Scan
Open the Terminal app and type an Nmap command. A good first target is scanme.nmap.org, a host the Nmap Project maintains and authorizes for public test scans (keep it to a few scans a day, and no heavy or brute-force testing):
nmap scanme.nmap.org
This runs a default scan of the 1,000 most common ports and reports which are open. To scan a device on your own network, use its IP address instead:
nmap 192.168.1.1
Some scan types need elevated privileges on macOS. The SYN scan (-sS) and OS detection (-O) send raw packets, which requires running the command with sudo:
sudo nmap -sS 192.168.1.1
Only scan hosts you own or have permission to test. Unauthorized scanning can breach acceptable-use policies or the law.
Common Nmap Commands on macOS
The commands are the same across macOS, Linux, and Windows because Nmap uses the same syntax everywhere. The main macOS-specific habit is prefixing raw-packet scans with sudo. A few to start with:
| Command | What it does |
| nmap <target> | Scans the 1,000 most common ports on a host. |
| nmap -sV <target> | Detects the service and version on open ports. |
| sudo nmap -sS <target> | Stealth SYN scan (needs sudo for raw packets). |
| sudo nmap -O <target> | Detects the operating system (needs sudo). |
| nmap -oN results.txt <target> | Saves the output to a text file. |
Understanding Nmap Scan Results
A scan is only useful if you can read what it returns. Nmap reports each port it checks with three pieces of information: the port number, its state, and the service likely behind it. The state matters most because it tells you whether a port is reachable, blocked, or genuinely exposed.
Open, closed, and filtered ports
Most scan results come down to three outcomes, and each means something different for security:
- Open. An application is actively accepting connections on the port. Open ports are important because each one runs a service and can be a potential entry point worth checking.
- Closed. The port is reachable, but nothing is listening on it. It responds to Nmap, so the host is up and the port is accessible; there is just no service there right now.
- Filtered. Nmap cannot tell whether the port is open because something, usually a firewall, is blocking its probes from reaching the port. A wall of filtered ports often means a firewall is doing its job.
The practical read: open ports are your attack surface, closed ports confirm the host is responding, and filtered ports point to filtering in front of the host.
Port states and their meaning
Nmap recognizes six port states. The three above are the most common; the other three appear when Nmap can narrow the result down but not fully resolve it:
| State | What it means |
| open | An application is actively accepting connections on the port. |
| closed | The port is reachable and responding, but no application is listening. |
| filtered | A firewall or filter is blocking probes, so Nmap cannot determine the state. |
| unfiltered | The port is reachable, but Nmap cannot tell whether it is open or closed. |
| open|filtered | Nmap cannot tell whether the port is open or filtered. |
| closed|filtered | Nmap cannot tell whether the port is closed or filtered. |
The combined states (open|filtered, closed|filtered) show up most often in UDP scans and some stealth scans, where a lack of response is ambiguous by design.
Service and version information
Beyond the state, Nmap reports which service is likely running on each open port. By default, it guesses from the port number, since well-known ports map to common services (port 22 to SSH, port 80 to HTTP). That guess is only a convention, though, and anyone can run a different service on any port.
Adding version detection (-sV) replaces the guess with evidence. Nmap probes the port directly and reports the application and version it detects, turning “port 80 is open” into “Apache httpd 2.4.58 is running here.” That detail makes the result actionable: security teams can check a known version against known vulnerabilities, something a port number alone can’t do.
Interpreting Nmap output
A default scan prints a short report per host. Here is what a typical result looks like:
Nmap scan report for scanme.nmap.org (45.33.32.156)
Host is up (0.045s latency).
Not shown: 997 closed ports
PORT STATE SERVICE
22/tcp open ssh
80/tcp open http
443/tcp open https
Nmap done: 1 IP address (1 host up) scanned in 1.32 seconds
Reading it top to bottom:
- Nmap scan report for… names the host scanned, with its resolved IP address.
- Host is up (latency) confirms the host responded, and how quickly.
- Not shown accounts for the ports Nmap checked but did not list individually. In this example, that is 997 closed ports, folded into one line so the report stays focused on what is open.
- The PORT / STATE / SERVICE columns list each notable port: its number and protocol, its state, and the service behind it. Running with -sV adds a VERSION column with the detected software and version.
- Nmap done closes with a summary: how many hosts were scanned and how long it took.
Nmap Output Formats and Reporting
By default, Nmap prints results to the screen in a human-readable format. For anything beyond a quick look, it can also write results to a file in several formats, each suited to a different job: reading, sharing, parsing, or feeding into another tool. Security teams can set the format with an output flag and a filename.
| Flag | Format | Best for |
| -oN | Normal | A plain-text copy of the on-screen report, for reading or sharing. |
| -oX | XML | Machine-readable output for other tools and scripts to parse. |
| -oG | Grepable | A one-line-per-host format for quick filtering with grep or awk. |
| -oA | All of the above | Saves normal, XML, and grepable files at once from one base name. |
For example, this saves the scan as a plain-text file:
nmap -oN scan.txt scanme.nmap.org
And this writes all three formats at once, producing scan.nmap, scan.xml, and scan.gnmap:
nmap -oA scan scanme.nmap.org
Which format to use. For reading or handing a result to a colleague, normal output (-oN) is enough. For anything automated, XML (-oX) is the right choice: Nmap’s maintainers recommend it for programmatic use, and standard XML parsers exist for every common language, which is why reporting tools, vulnerability scanners, and custom scripts consume it.
Spreadsheet applications can import Nmap XML directly as well. Grepable output (-oG) is handy for a fast command-line filter, but it is officially deprecated, so XML is the better long-term choice for parsing.
Saving output matters for reporting. A stored scan becomes a record you can compare against a later one to spot new open ports or services, attach to an audit, or pull into a larger assessment. For a documented security review, running with -oA keeps every format on hand without rescanning.
How Group-IB Turns Nmap Data Into a Defense Plan
An Nmap scan shows what is exposed on your network, but it doesn’t tell you what to do about it, especially for external-facing assets a routine internal scan never reaches. Attackers look for those systems first, and they use the same reconnaissance tools defenders do.
In Group-IB’s investigation of the RansomHub ransomware group, attackers used Nmap alongside Angry IP Scanner and PowerShell to map a victim’s network before reaching the domain controller.
That is where scanning stops and intelligence begins. Nmap shows what you can see from inside; Group-IB’s platform and analysts extend that view to the full external attack surface and tie each finding to active threats:
- Attack Surface Management discovers and ranks exposed assets by real-world risk, so remediation starts with what attackers are most likely to reach.
- Red Teaming tests those exposures the way an adversary would, confirming which gaps are genuinely exploitable before someone else finds out.
This work is backed by scale. According to Group-IB’s High-Tech Crime Trends 2025 report, the company contributed to eight law enforcement operations across more than 60 countries in 2024, supporting the arrest of 1,221 cybercriminals and the dismantling of over 207,000 malicious infrastructures.
Talk to Group-IB to turn your scan results into a prioritized plan for closing the exposures that matter most.





