GO KALI FREE

Nmap

Information Gathering

Beginnermedium risk

Learn how to use Nmap, the free open-source network scanner: run your first port scan, discover live hosts, detect services and operating systems, and check for vulnerabilities with NSE scripts — a beginner tutorial for Kali Linux.

Authorized scope leads to host discovery, port-state observations, service probes and corroboration; nonresponse is not proof of an offline host.
Network discovery: evidence, not guaranteesConceptual Nmap learning workflow, not a mandatory internal execution sequence. Discovery may be skipped; observations depend on vantage point and scan method.Original conceptual diagram. On narrow screens, scroll the figure to read the labels.

Installation

sudo apt update && sudo apt install nmap -y

Basic Syntax

nmap [Scan Type] [Options] {target specification}

Quick Facts

Full Name
Network Mapper
License
GNU GPL v2
Author
Gordon Lyon (Fyodor)
Written In
C, C++, Python, Lua
Platforms
Linux, Windows, macOS, Termux
Category
Network Scanner
First Release
1997
Scripting Engine
NSE (Nmap Scripting Engine)

Tool Overview

To use Nmap, install it with sudo apt install nmap, then run nmap <target> to scan the top 1,000 ports on a host you own or have written permission to test. Add -sn to find live hosts on a subnet, -sV to identify the services on open ports, -O to detect the operating system, and --script vuln to check for known vulnerabilities. Save every scan with -oA so you can review and share the results.

Learning how to use Nmap follows one loop: install it, confirm it with nmap --version, pick an authorized target, discover live hosts, scan ports, detect services and the operating system, run NSE scripts for vulnerabilities, then save and review the results. Install on Kali or Debian with sudo apt install nmap, on Fedora with sudo dnf install nmap, on macOS with brew install nmap, on Arch with sudo pacman -S nmap, or on Windows with the installer from nmap.org.

Your first scan can run against your own machine. The command nmap -sT -p 22,80,443 127.0.0.1 checks three ports on localhost and returns a scan report for localhost (127.0.0.1): host is up, then a PORT, STATE and SERVICE table showing 22/tcp open ssh, 80/tcp closed http and 443/tcp closed https. It proves port 22 is listening while 80 and 443 are reachable but have nothing listening — and it ran in 0.06 seconds.

Read every port state together with the target, the protocol and the scan type. An open port accepts connections and is part of the attack surface. A closed port is reachable but has no service listening — it still tells an attacker the host is alive. A filtered port means a firewall or packet filter is silently dropping probes, so Nmap cannot decide whether the port is open or closed. Unfiltered means the port answered but this scan type cannot determine open versus closed. For UDP, open|filtered is the usual answer because UDP has no handshake; confirm it with an application-aware probe such as -sV, or ask the service owner.

Nmap (Network Mapper) is a free, open-source utility for network discovery and security auditing. It uses raw IP packets to identify active hosts, open ports, running services, and operating systems across any TCP/IP network.

Created by Gordon Lyon in 1997, Nmap has become the industry-standard tool for network reconnaissance. Security professionals, system administrators, and penetration testers rely on it for asset discovery, vulnerability assessment, and compliance verification.

The Nmap Scripting Engine (NSE) extends core scanning with over 700 Lua scripts for automated vulnerability detection, brute-force testing, and service enumeration. Combined with Zenmap, its graphical interface, Nmap serves both beginners and advanced users.

Quick Reference Commands

Verified quick-reference commands for Nmap
CommandPurpose
nmap <target>Scan the default 1,000 common ports.
nmap -sn <target>Discover live hosts without a port scan.
nmap -p 80,443 <target>Scan selected TCP ports.
nmap -p- <target>Scan TCP ports 1 through 65535.Full-port scans can create substantial traffic.
nmap -sV <target>Probe open ports for service and version information.
nmap -A <target>Enable OS detection, version detection, default scripts, and traceroute.Aggressive scans are intrusive and require explicit authorization.
Nmap Reference Guide

Common Commands

nmap 192.168.1.1Basic scan of a single IP address
nmap -sV 192.168.1.1Probe open ports to determine service/version info
nmap -sn 192.168.1.0/24Ping scan - disable port scan (discover active hosts)
nmap -p 80,443 192.168.1.1Scan specific ports (80 and 443)
nmap -sS 192.168.1.1TCP SYN scan (stealth scan)
nmap -sT 192.168.1.1TCP connect scan
nmap -sU 192.168.1.1UDP scan
nmap -p- 192.168.1.1Scan all 65535 ports
nmap -O 192.168.1.1Enable OS detection
nmap -A 192.168.1.1Aggressive scan (OS, version, script scanning, traceroute)
nmap -sS -sV -O -p- -T4 192.168.1.1Comprehensive fast scan (SYN, version, OS, all ports, T4 timing)
nmap --script vuln 192.168.1.1Run all vulnerability scanning scripts
nmap --script=http-enum 192.168.1.1Enumerate common web application directories and files
nmap --script=smb-vuln* 192.168.1.1Run all SMB vulnerability scripts
nmap -sV --script=banner 192.168.1.1Grab banners for detected services
nmap -sS -Pn -n --disable-arp-ping 192.168.1.1Stealth scan, treat host as online, no DNS, disable ARP ping
nmap -sS -f 192.168.1.1SYN scan with fragmented IP packets (firewall bypass)
nmap -D RND:10 192.168.1.1Scan with 10 random decoys to obfuscate source IP
nmap --source-port 53 192.168.1.1Spoof source port as 53 (DNS) to bypass rules
nmap -sI zombie_ip 192.168.1.1Idle scan using a zombie host (blind scan)
nmap --script=default,safe 192.168.1.1Run default and safe category scripts
nmap -oA scan_results 192.168.1.1Output results in all major formats (normal, XML, greppable)
nmap -iL targets.txt -oN output.txtRead targets from file and save normal output
nmap --script "http-* and not http-brute" 192.168.1.1Run HTTP scripts except brute force ones
nmap -sV -O -p 1-1000 192.168.1.1Scan the first 1000 ports with service detection and OS fingerprinting
nmap -F 192.168.1.1Fast scan of the 100 most common ports
nmap -sC 192.168.1.1Run the default NSE script set
nmap -sL 192.168.1.0/24List targets without sending any probes
nmap -sA 192.168.1.1ACK scan to map which ports a firewall filters
nmap --open 192.168.1.1Show only ports that are open
nmap -6 2001:db8::1Scan an IPv6 target
nmap --script ssl-enum-ciphers -p 443 192.168.1.1List the TLS ciphers a server accepts
nmap -n 192.168.1.0/24Skip reverse DNS lookups to speed up the scan
nmap -v 192.168.1.1Verbose output showing scan progress
nmap -sS -T4 -p- 192.168.1.100Fast full TCP SYN scan all ports

Step-by-Step Guide

  1. 1Confirm Nmap is installed: nmap --version (on Kali or Debian install it with sudo apt update && sudo apt install nmap -y; Fedora: sudo dnf install nmap -y; macOS: brew install nmap; Windows: installer from nmap.org)
  2. 2Pick a target you own or have written permission to test — your lab host, e.g. 192.168.1.1, or scanme.nmap.org
  3. 3Run your first scan: nmap 192.168.1.1 (scans the top 1,000 TCP ports)
  4. 4Read the output table: PORT, STATE and SERVICE — open means a service accepts connections, closed means reachable with nothing listening, filtered means a firewall drops the probe
  5. 5Find live hosts on a subnet first: nmap -sn 192.168.1.0/24
  6. 6Identify what runs on open ports: nmap -sV 192.168.1.1
  7. 7Detect the operating system: sudo nmap -O 192.168.1.1 (or -A for the full aggressive scan)
  8. 8Check for known vulnerabilities: nmap --script vuln 192.168.1.1
  9. 9When it matters, scan every port: nmap -p- -T4 192.168.1.1
  10. 10Save the results in all formats: nmap -sV -oA scan_results 192.168.1.1

Warnings

Use Cases

Host Discovery

Identify active devices on any network segment. Find live hosts before deeper scanning.

Port Scanning

Map open ports on target systems. Detect TCP/UDP services accepting connections.

Service Detection

Fingerprint running services and version numbers. Identify outdated software.

OS Detection

Determine operating system through TCP/IP stack fingerprinting.

Vulnerability Scanning

Run NSE scripts to detect known CVEs and misconfigurations.

Network Mapping

Visualize entire network topologies. Document infrastructure layout.

Firewall Enumeration

Identify firewall rules and packet filtering behavior using different scan types and response analysis.

SSL/TLS Assessment

Evaluate encryption configurations, certificate validity, and supported cipher suites on web servers.

Default Credential Detection

Test common default usernames and passwords on discovered services using NSE brute-force scripts.

DNS Enumeration

Discover DNS records, zone transfers, and subdomains associated with target domains.

Network Inventory

Build a comprehensive asset database of all devices, operating systems, and services across the infrastructure.

Shadow IT Detection

Find unauthorized devices and services connected to the network that bypass official IT management.

Key Features

People Also Ask

What is the difference between Nmap SYN scan and TCP connect scan?

A SYN scan (-sS) sends SYN packets without completing the TCP handshake, making it faster and stealthier — it is the default when running as root. A TCP connect scan (-sT) completes the full three-way handshake using the OS connect() call, which is more reliable but slower and fully logged by the target. Use -sS for stealthy authorized engagements; use -sT only when -sS is unavailable (non-root).

How long does a full Nmap port scan take?

A default scan of the top 1000 ports on a single host completes in 1-5 seconds. A full port scan (-p-) covering all 65535 ports takes 2-10 minutes per host depending on the timing template (-T0 through -T5) and network conditions. Aggressive timing (-T5) is faster but more likely to miss ports or trigger IDS alerts.

Can Nmap detect operating systems?

Yes. Use nmap -O [target] for OS detection. Nmap analyzes TCP/IP stack responses, TCP window sizes, IP ID sequences, and other fingerprinting techniques to determine the target's operating system and version with high accuracy. OS detection requires at least one open and one closed port on the target.

What is the Nmap Scripting Engine (NSE)?

NSE is a Lua-based framework that extends Nmap's scanning capabilities with over 700 scripts. Scripts automate vulnerability detection (vuln category), brute-force testing (brute category), network discovery (discovery category), and more. Run scripts with nmap --script [category or script name] [target]. Categories include auth, broadcast, brute, default, discovery, dos, exploit, external, fuzzer, intrusive, malware, safe, version, and vuln.

Is Nmap legal to use?

Nmap itself is legal software. However, scanning networks or systems without explicit written permission from the owner is illegal in most jurisdictions. Unauthorized scanning violates laws like the CFAA (US), Computer Misuse Act (UK), and similar legislation worldwide. Always obtain proper authorization before performing any network scans.

Does Nmap work on firewalled networks?

Yes, but with limitations. Nmap can use fragmentation (-f), decoys (-D), source port spoofing (--source-port), and idle scans (-sI) to bypass some firewall rules. However, stateful firewalls that track connections will block many evasion techniques. Use nmap -sN (Null scan) or -sF (FIN scan) to bypass stateless packet filters.

What is the difference between -sS and -sT?

nmap -sS (SYN scan) sends SYN packets without completing the TCP handshake — it is faster, stealthier, and the default scan when running as root. nmap -sT (TCP connect scan) completes the full three-way handshake using the OS connect() call, making it more reliable but slower and fully logged by the target. Use -sS for stealth; use -sT only when -sS is unavailable (non-root).

Can Nmap scan IPv6 addresses?

Yes. Use nmap -6 [target] to scan IPv6 addresses. Nmap supports IPv6 scanning for most scan types including SYN, connect, and UDP scans. IPv6 scanning is especially useful in modern enterprise networks and cloud environments that use dual-stack or IPv6-only configurations.

Learning Path

  1. 1
  2. 2
  3. 3
  4. 4
  5. 5

Related Tools

traceroute

Information Gathering

traceroute tracks the route packets take across an IP network on their way to a given host. It utilizes the IP protocol 'time to live' (TTL) field and attempts to elicit an ICMP TIME_EXCEEDED response.

Enum4linux

Information Gathering

Learn how to use Enum4linux to enumerate Windows and Samba systems over SMB: install it on Kali Linux, run your first scan, read the users, shares, groups and password policy it returns, and switch to enum4linux-ng for modern hosts that block null sessions.

SMBClient

Information Gathering

Learn how to use SMBClient on Kali Linux: install Samba's FTP-like SMB/CIFS client, list shares, connect as a guest or with credentials, browse folders, and upload or download files on Windows, Samba, or NAS devices. For authorized assessments, check ports 139/445 with Nmap before testing share permissions.

Masscan

Information Gathering

Masscan is an internet-scale port scanner. It can scan the entire Internet in under 6 minutes, transmitting up to 10 million packets per second utilizing asynchronous transmit setups.

Nikto

Vulnerability Analysis

Learn how to use Nikto, an open-source web server scanner written in Perl and pre-installed on Kali Linux, to audit servers you own or have written permission to test. Its 6700+ checks for potentially dangerous files and programs, plus tests for outdated software and misconfigurations, highlight issues that need verification.

Gobuster

Web Application

Learn how to use Gobuster, the fast Go-based directory and subdomain brute-forcer, with install steps, your first dir scan, wordlist picks, and result filtering — a beginner tutorial for Kali Linux.

Related Cybersecurity Guides

Tools · Beginner

Nmap Beginner Tutorial: Mastering Network Scanning

Learn Nmap from scratch covering host discovery, port scanning, service detection, NSE scripts, and practical examples.

OSINT · Intermediate

Nmap Advanced Techniques: Expert Network Scanning

Master advanced Nmap scanning techniques including NSE scripting, firewall evasion, performance tuning, and custom scan types for professional penetration testing.

Tools · Beginner

Network Scanning with Nmap for Beginners

A beginner-friendly guide to network scanning with Nmap covering host discovery, port scanning techniques, service detection, and practical scanning examples.

OSINT · Intermediate

Amass Guide: Open Source Attack Surface Mapping

Learn to use Amass for comprehensive attack surface mapping including DNS enumeration, subdomain discovery, integration with APIs, and visualizations.

Frequently Asked Questions

What is Nmap tool?

Nmap (Network Mapper) is a free, open-source network scanner used for host discovery, port scanning, service detection, and OS fingerprinting. Created by Gordon Lyon in 1997, it sends raw IP packets to identify active devices, open ports, and running services on any TCP/IP network.

What is Nmap tool used for?

Nmap is used for five primary tasks: host discovery (finding live devices), port scanning (identifying open ports), service detection (fingerprinting applications and versions), OS detection (determining operating systems), and vulnerability scanning via NSE scripts. Network administrators use it for security audits, while penetration testers use it to map attack surfaces before exploitation with tools like Metasploit.

How to use Nmap tool?

Install Nmap using your package manager (apt-get install nmap on Kali Linux), then run nmap followed by a target IP address or hostname. Start with a basic scan: nmap 192.168.1.1. Add flags like -sV for service detection, -O for OS detection, and -A for aggressive scanning. For subnet scans, use CIDR notation: nmap -sn 192.168.1.0/24. Practice in a lab environment before scanning live networks.

Is Nmap legal?

Nmap itself is legal software. However, scanning networks or systems without explicit written permission from the owner is illegal in most jurisdictions. Unauthorized scanning violates laws like the CFAA (US), Computer Misuse Act (UK), and similar legislation worldwide. Always obtain proper authorization before performing any network scans. Nmap is designed for legitimate security testing, network administration, and educational purposes.

Why is Nmap used in cybersecurity?

Nmap is the foundation of network reconnaissance in cybersecurity. It helps professionals discover assets, detect vulnerabilities, and assess security posture. The Nmap Scripting Engine (NSE) enables automated vulnerability detection, and results integrate seamlessly with exploitation frameworks like Metasploit. Both offensive (penetration testing) and defensive (security monitoring) teams depend on Nmap for network visibility.

What are the most common Nmap commands?

Essential Nmap commands include: nmap [target] for basic scanning, nmap -sV [target] for service detection, nmap -sn [target] for host discovery, nmap -O [target] for OS detection, nmap -A [target] for aggressive scanning, and nmap -p- [target] to scan all 65535 ports. For vulnerability scanning, use nmap --script vuln [target]. Save results with -oA for all formats or -oN for normal output.

Can Nmap run on Windows?

Yes, Nmap runs on Windows, Linux, and macOS. The Windows installer from nmap.org includes both the command-line tool and Zenmap, a graphical user interface for visualization and comparison. Nmap for Windows provides identical functionality to the Linux version. Android users can run Nmap through Termux. All platforms support the full Nmap Scripting Engine.

Is Nmap free?

Yes, Nmap is completely free and open source under the GNU General Public License (GPL). Download it from nmap.org without any cost. The Nmap Scripting Engine, Zenmap GUI, and all 700+ NSE scripts are included. Nmap is maintained by an active community of developers and security researchers, ensuring continuous updates and comprehensive documentation.

Are there online Nmap tools?

While web-based Nmap alternatives exist (such as online port scanners), they cannot replace Nmap's full capabilities. Online tools are limited to basic port scanning from their server's IP and cannot perform OS detection, NSE scripts, or stealth scans. For serious penetration testing, install Nmap locally using apt-get install nmap on Kali Linux or download from nmap.org. Practice in lab environments like HackTheBox or TryHackMe to learn safely.

Can Nmap detect operating systems?

Yes. Use nmap -O [target] for OS detection. Nmap analyzes TCP/IP stack responses, TCP window sizes, IP ID sequences, and other fingerprinting techniques to determine the target's operating system and version with high accuracy.

What is Nmap NSE?

Nmap Scripting Engine (NSE) is a Lua-based framework that extends Nmap's scanning capabilities with over 700 scripts. NSE scripts automate vulnerability detection (vuln category), brute-force testing (brute category), network discovery (discovery category), and more. Scripts are organized into categories: auth, broadcast, brute, default, discovery, dos, exploit, external, fuzzer, intrusive, malware, safe, version, and vuln. Run scripts with nmap --script [category or script name] [target].

How fast can Nmap scan?

Nmap speed depends on the timing template used (-T0 through -T5). T0 (Paranoid) takes hours per host; T3 (Normal) is the default; T5 (Insane) scans as fast as possible but may miss ports. A basic scan of 1000 ports on a single host typically completes in 1-5 seconds. Full port scans (-p-) take 2-10 minutes per host depending on timing and network conditions.

Does Nmap work on firewalled networks?

Yes, but with limitations. Nmap can use fragmentation (-f), decoys (-D), source port spoofing (--source-port), and idle scans (-sI) to bypass some firewall rules. However, stateful firewalls that track connections will block many evasion techniques. Use nmap -sN (Null scan) or -sF (FIN scan) to bypass stateless packet filters. Stateful inspection firewalls require more advanced techniques or direct network access.

What is the difference between -sS and -sT?

nmap -sS (SYN scan) sends SYN packets without completing the TCP handshake — it's faster, stealthier, and the default scan when running as root. nmap -sT (TCP connect scan) completes the full three-way handshake using the OS's connect() call, making it more reliable but slower and fully logged by the target. Use -sS for stealth; use -sT only when -sS isn't available (non-root).

Can Nmap scan IPv6 addresses?

Yes. Use nmap -6 [target] to scan IPv6 addresses. Nmap supports IPv6 scanning for most scan types including SYN, connect, and UDP scans. IPv6 scanning is especially useful in modern enterprise networks and cloud environments that use dual-stack or IPv6-only configurations.

What output formats does Nmap support?

Nmap supports four output formats: -oN (normal text), -oX (XML for import into Metasploit and other tools), -oG (greppable format for scripting), and -oA (all three formats simultaneously). XML output (-oX) is the most versatile for automated processing. Use -oA to save all formats at once for maximum flexibility in post-scan analysis.

How do I scan a specific port with Nmap?

Use -p [port number] to scan a specific port: nmap -p 80 192.168.1.1 scans only port 80. For multiple ports: nmap -p 80,443,8080 [target]. For port ranges: nmap -p 1-1024 [target]. For all ports: nmap -p- [target]. You can also use port names: nmap -p http [target].

What is an idle scan in Nmap?

An idle scan (nmap -sI zombie_host [target]) uses a third-party 'zombie' host to scan the target. The scan appears to come from the zombie rather than your IP, making it truly anonymous. The technique exploits predictable IP ID sequences on the zombie to determine port states. Find suitable zombies with nmap -O -sI [potential_zombie] [target].

How does Nmap integrate with Metasploit?

Nmap XML output (-oX) can be imported directly into Metasploit using the db_import command or db_nmap command. This allows Metasploit to automatically create hosts, services, and vulnerabilities from Nmap results. Workflow: nmap -sV -oX scan.xml [target] → msfconsole → db_import scan.xml → hosts → services → vulns.

Can Nmap scan through proxies?

Nmap has limited proxy support. For HTTP CONNECT proxies, use --proxies. For SOCKS4/SOCKS5 proxies, use --proxies socks4:// or socks5://. However, proxy scanning significantly limits available scan types — stealth scans, OS detection, and most NSE scripts won't work through proxies. Direct scanning is always preferred when possible.

How do I use Nmap in Kali Linux?

Nmap comes pre-installed on Kali Linux. If it is missing, install it with sudo apt update && sudo apt install nmap -y, then confirm it with nmap --version. Start with a scan of a host you own or have permission to test: nmap 192.168.1.1. Use sudo for raw-packet scans such as -sS (SYN) and -O (OS detection); without root, Nmap falls back to the -sT connect scan. Save every scan with -oA so you can review the results and import them into Metasploit.

What does open|filtered mean in Nmap?

It means Nmap could not tell whether the port is open or filtered because it received no reply that distinguishes the two states. This is common for UDP scans, because UDP has no handshake: a silent port might be open or might be firewalled. Add -sV to send a service probe, scan fewer UDP ports, or confirm the listener with the service owner instead of guessing from the state alone.

How do I scan all ports with Nmap?

Use nmap -p- 192.168.1.1 to scan all 65,535 TCP ports. Add -T4 on a reliable network to speed it up: nmap -p- -T4 192.168.1.1. A full scan takes roughly 2-10 minutes per host depending on timing and network conditions. For a fast first pass, scan the most common ports instead: nmap -F 192.168.1.1 covers the top 100, or use nmap --top-ports 100 192.168.1.1.

How do I fix 'Host seems down' in Nmap?

Nmap says this when its discovery probes get no reply, which usually means the host blocks ICMP or the discovery probes — not that the host is offline. First verify the address and the route to it, then add -Pn to skip host discovery and scan the target anyway: nmap -Pn 192.168.1.1. Only use -Pn on a host you are authorized to test, because it sends port probes to every address in the range.

Why is my Nmap scan so slow?

Full-port scans (-p-) and UDP scans (-sU) are slow by design: UDP has no handshake, so Nmap waits for timeouts on every port. Speed up a scan with -T4 timing, -F to scan only the top 100 ports, --top-ports to limit the port count, -n to skip reverse DNS lookups, or --min-rate 1000 to guarantee a minimum packet rate. Scan fewer hosts or ports at a time, and save results with -oA so you never have to re-run a slow scan.

Tags

#reconnaissance#network-scanning#port-scanning

Output Explanation

Nmap output shows: PORT (port number/protocol), STATE (open/closed/filtered), and SERVICE (what's running). Example — nmap -sT -p 22,80,443 127.0.0.1 against localhost returns: Starting Nmap 7.94SVN ( https://nmap.org ), Nmap scan report for localhost (127.0.0.1), Host is up (0.00074s latency)., then a PORT, STATE and SERVICE table with 22/tcp open ssh, 80/tcp closed http and 443/tcp closed https, then Nmap done: 1 IP address (1 host up) scanned in 0.06 seconds. Read it like this: "open" means a service accepts connections on that port; "closed" means the host answered but nothing is listening; "filtered" means a firewall silently drops the probe; "open|filtered" means Nmap cannot tell the two apart, which is common for UDP because UDP has no handshake — add -sV or scan fewer UDP ports for a clearer answer. Add -sV to replace the SERVICE guess with the real service and version, and -oA to save the report in normal, XML and grepable formats at once.

Ethical Usage Notice

This tool is designed for authorized security testing, educational purposes, and legitimate network administration only. Unauthorized access to computer systems is illegal.