Security operations

What Is Nmap? The Network Scanner Explained (With Commands)

Nmap maps a network, finds open ports and fingerprints services and operating systems. Here is how it works, the commands to learn first, and the rules for using it safely.

Cysoro Security TeamPublished · 6 min read
SECURITY OPERATIONSWhat is Nmap?The network scanner, explainedHosts, ports, services — mapped in minutes.N22 open · 80 open · 443 open
Quick answer

Nmap, short for Network Mapper, is a free and open-source tool for network discovery and security auditing. It sends specially crafted packets to hosts on a network to find which devices are live, which ports are open, what services and versions are running, and which operating systems they use. System administrators use it for inventory and uptime monitoring, and security teams use it to find exposed services before attackers do.

Key takeaways

  • Nmap is a free, open-source network scanner created by Gordon Lyon and first released in 1997.
  • Its core job is port scanning: finding open ports, services, versions and operating systems on a network.
  • Only scan networks you own or have written permission to test; scanning others without permission can be illegal.

You cannot protect a network you cannot see. Nmap is the tool security teams and system administrators reach for first when they need to find out what is actually running on a network — which devices are live, which ports are open, and what services are listening.

What is Nmap?

Nmap, short for Network Mapper, is a free and open-source utility for network discovery and security auditing. It was created by Gordon Lyon, known as Fyodor, and first released in September 1997.

Nmap uses raw IP packets to determine what hosts are available on a network, what services and versions those hosts offer, what operating systems they run, and what packet filters or firewalls are in use. It was designed to scan large networks rapidly, but works just as well against a single host.

System administrators use it for routine tasks such as network inventory, managing service upgrade schedules and monitoring host or service uptime. Security auditors use it to find exposed services before attackers do. The official Nmap website describes it as flexible, powerful, portable, easy to start with, free and well documented.

How does Nmap work?

Nmap works by sending packets to a target and reading the replies. An open port answers differently from a closed or filtered one, and the details in the reply often reveal the service and its version.

How Nmap builds a picture of your network1. Send packetsNmap sends craftedpackets to eachhost and port2. Read repliesOpen, closed andfiltered ports replyin different ways3. Build the mapHosts, ports,services, versionsand OS guessesThe output is a list of scanned targets with details for each one.
Nmap sends packets, reads the replies and turns them into a network map. Illustration by Cysoro.

At its heart, Nmap is a port scanner. A simple command such as nmap target scans more than 1,000 TCP ports on the target host, according to the Nmap man page. Nmap divides ports into six states: open, closed, filtered, unfiltered, open|filtered and closed|filtered.

Open means an application is listening. Closed means the port is reachable but nothing is listening. Filtered means a firewall or filter is blocking the probe, so Nmap cannot tell whether the port is open or closed.

What can Nmap do?

Nmap does far more than list open ports. Its main jobs are host discovery, port scanning, service and version detection, operating system detection, and scripted checks through the Nmap Scripting Engine.

  • Host discovery: find which devices are live on a network, for example with a ping scan.
  • Port scanning: find open TCP and UDP ports on each host.
  • Service and version detection: identify the application and version behind each open port.
  • OS detection: guess the operating system and version from how the host replies.
  • Scripted checks: run Nmap Scripting Engine scripts to check for vulnerabilities and gather extra detail.
  • Network inventory: record what is on the network so changes stand out later.

The Nmap suite also includes Zenmap, a graphical interface and results viewer, Ncat for data transfer and debugging, Ndiff for comparing scan results, and Nping for packet generation and response analysis.

What are the main Nmap scan types?

Different scan types trade speed, stealth and detail. The table below covers the ones you will use most often.

ScanFlagWhat it doesWhen to use it
Ping scan-snFinds live hosts without port scanningQuick inventory of a network
TCP connect scan-sTCompletes a full TCP connection to each portWhen raw packets are not available
SYN stealth scan-sSSends SYN packets without completing the connectionFaster, quieter default on Linux
UDP scan-sUProbes UDP ports such as DNS and SNMPChecking UDP services
Version detection-sVIdentifies service and version on open portsFinding outdated software
OS detection-OGuesses the operating systemInventory and fingerprinting
Aggressive scan-ACombines OS, version, script and traceroute checksFull picture of one host

The SYN scan is the default when Nmap has the privileges to send raw packets. The TCP connect scan is the fallback when it does not, for example for a non-privileged user on some systems.

What are the most useful Nmap commands?

Learn these commands first. Run them only against your own network or a system you have written permission to test. The freeCodeCamp Nmap tutorial walks through the same core commands with examples.

  • nmap 192.168.1.1 — scan the most common ports on one host.
  • nmap -sn 192.168.1.0/24 — find live hosts on your local network without port scanning.
  • nmap -sV 192.168.1.1 — detect the service and version on each open port.
  • nmap -O 192.168.1.1 — try to identify the operating system.
  • nmap -A 192.168.1.1 — run an aggressive scan with OS, version, script and traceroute checks.
  • nmap -p 80,443 192.168.1.1 — scan only ports 80 and 443.
  • nmap -oN results.txt 192.168.1.0/24 — save the results to a file for later comparison.

Red Hat's guide to inventorying a network with Nmap uses the same pattern: install Nmap with your package manager, run nmap 192.168.0.0/24 for a first look, then use -sn for a host-only sweep. A typical scan report lists each host, its open ports, the service on each port, and the state of each port.

What is the Nmap Scripting Engine (NSE)?

The Nmap Scripting Engine lets Nmap run scripts that go beyond a basic port scan. Scripts can check for known vulnerabilities, brute-force weak logins, gather extra service details and test for misconfigurations.

Scripts live in the Nmap scripts directory on your system, and you run them with the --script flag, for example nmap --script vuln 192.168.1.1 to run the vulnerability-checking scripts. The Nmap project ships hundreds of scripts, and the community adds more.

Use NSE carefully: some scripts are intrusive and can crash fragile services or trigger alerts. Run them first in a lab or against a test system, and never run brute-force scripts against a system you do not own.

How do you read Nmap results?

A scan report starts with the host name and address, then lists the interesting ports in a table. Each row shows the port number and protocol, its state, and the service Nmap detected.

$ nmap -sV 192.168.1.10PORT STATE SERVICE VERSION22/tcp open ssh OpenSSH 9.680/tcp open http Apache 2.4443/tcp open https Apache 2.43306/tcp filtered mysqlAsk: should each open port be reachable?Example output for a test host on a private network. Illustration by Cysoro.
Example Nmap output: open ports, services and versions, plus one filtered port. Illustration by Cysoro.

Ask three questions about every open port: should this service be running, should it be reachable from this network, and is the version up to date. An open port is not automatically a problem — a web server needs port 443 open — but an unexpected open port is a finding worth investigating.

Nmap itself is legal to own and use. Scanning a network you do not own or do not have permission to test can be illegal, can breach your employer's rules, and can trigger alerts at your internet provider or hosting company.

  • Scan only what you own or have written permission to test, such as a lab network or a client engagement.
  • Get permission in writing before scanning a client's or employer's network.
  • Start in a lab: scan your home network or a virtual machine first.
  • Be gentle: aggressive scans and brute-force scripts can disrupt fragile services.
  • Keep records: save scan output so you can show what you scanned and when.

If you find an unexpected open port on your own network, check what service is behind it before you close it. Our guide to securing your Wi-Fi covers the home-network checks that pair well with a first Nmap scan.

What are the alternatives to Nmap?

Nmap is the standard for command-line scanning, but other tools fit different jobs. Masscan is faster for scanning the whole internet, while commercial vulnerability scanners add reporting and remediation tracking.

  • Masscan: very fast port scanning for large ranges, with less detail per host than Nmap.
  • Angry IP Scanner: a simpler graphical scanner for a quick look at a small network.
  • OpenVAS: an open-source vulnerability scanner that builds on port scanning with vulnerability checks.
  • Commercial scanners: tools such as Tenable Nessus add scheduled scans, reports and compliance mapping.

For most small teams, Nmap plus a regular schedule — scan after every change, and at least monthly — covers the basics. You can check the public-facing side of the same problem with our free SSL checker.

The bottom line

Nmap is a free, open-source network scanner that shows you what is really on your network: live hosts, open ports, services, versions and operating systems. Learn the ping scan, the version scan and the aggressive scan first, and run them regularly on networks you own.

Start on your home network, save your results, and investigate every port you did not expect to find open. You can check your public services the same way with the free SSL checker.

Frequently asked questions

What is Nmap used for?

Nmap is used for network discovery and security auditing. It finds live hosts, open ports, running services and operating systems, and helps administrators with network inventory, upgrade planning and uptime monitoring.

Is Nmap free?

Yes. Nmap is free and open source, with full source code available under its license. Official binary packages are available for Linux, Windows and macOS from nmap.org.

Is Nmap legal?

Nmap itself is legal, but scanning a network you do not own or do not have permission to test can be illegal or breach your employer's or provider's rules. Only scan your own networks or systems you have written permission to test.

What is the difference between Nmap and Zenmap?

Nmap is the command-line scanner. Zenmap is the graphical interface and results viewer that ships with the Nmap suite, for people who prefer a visual view of scan results.

What does nmap 192.168.1.1 do?

It runs a default scan of that host, checking the most common TCP ports and reporting which are open, closed or filtered, along with any service information it can detect.

What is the Nmap Scripting Engine?

The Nmap Scripting Engine, or NSE, lets Nmap run scripts that do more than a basic port scan, such as checking for known vulnerabilities, brute-forcing weak logins and gathering extra service details.

How long does an Nmap scan take?

A scan of one host usually takes seconds to a minute. Scanning a large network, or using slow stealth or version-detection options, can take much longer.

Do I need Nmap if I have a firewall?

Yes, for different reasons. A firewall blocks unwanted traffic; Nmap shows you what is actually reachable from the network, so you can check the firewall is doing its job.

Sources

  1. Nmap.org — Nmap: the Network Mapper - Free Security Scanner
  2. Nmap Reference Guide — Nmap network security scanner man page
  3. freeCodeCamp — What is Nmap and How to Use it
  4. Red Hat — Running a quick NMAP scan to inventory my network
Written & fact-checked byCysoro Security Team

The engineers and analysts who build Cysoro's domain scanner, email-authentication checks and free security tools. We test what we write about every day — SPF, DKIM, DMARC, certificates, look-alike domains and phishing — and check each guide against the relevant standards, government guidance and vendor documentation.

  • Email authentication
  • Phishing & BEC
  • Domain & DNS security
  • Small-business security

Checked against the official Nmap website and reference guide, the Nmap man page, and Red Hat's Nmap inventory guide.

How we write and fact-check →

Free tools for this topic

No account needed.

See where your domain stands

Free for up to 3 domains. No card, no installs.

Start free