Nmap Beginner’s Guide: Scan Networks
Nmap (Network Mapper) is a free, open-source tool that discovers devices on a network and inspects their open ports, running services, and operating systems. You give it an IP address or range, it sends crafted packets, and you get back a list of what’s reachable and what’s listening. This guide walks you through your first scans, explains the output, and covers safe, practical usage.
What Nmap Does and Why It Matters
Every computer on a network communicates through numbered ports (0–65535). Some ports are standard—80 for web, 443 for secure web, 22 for SSH—but any service can run on any port. Nmap sends probes to ports and analyzes the responses to determine which ones are open, what service is behind each, and sometimes which operating system the host runs. This makes it the go-to tool for network inventory, security auditing, and troubleshooting. System administrators use it to find unauthorized devices; security professionals use it to test firewall rules; and curious users use it to understand their home network.
Installation and First Scan
Nmap runs on Windows, macOS, and Linux. On Debian/Ubuntu, install with sudo apt install nmap; on Red Hat/Fedora, sudo dnf install nmap. Windows and macOS users download an installer from the official nmap.org site. After installation, open a terminal (or Command Prompt on Windows) and run your first scan:
nmap 192.168.1.1
Replace the IP with your router’s address (often 192.168.1.1 or 192.168.0.1). Nmap sends a default scan (SYN scan for privileged users, TCP connect otherwise) to the 1,000 most common ports. The output shows the host status, the open ports, and the service names Nmap guesses from the port number. For example, 22/tcp open ssh means port 22 is open and likely running SSH.
Common Scan Types and When to Use Them
Nmap offers several scan techniques, each with trade-offs between speed, stealth, and accuracy:
- TCP SYN scan (-sS): Sends a SYN packet; if the port responds with SYN-ACK, it’s open. This is the default for privileged users and is relatively fast and less likely to be logged than a full connection.
- TCP connect scan (-sT): Completes the full three-way handshake. Used when you lack root privileges on Unix systems or when SYN scan fails. More likely to be logged.
- UDP scan (-sU): Scans UDP ports (DNS, SNMP, DHCP). Slower and less reliable because UDP is connectionless, but essential for finding services that use UDP.
- Ping scan (-sn): Only discovers which hosts are up without scanning ports. Useful for a quick inventory of a network.
- Version detection (-sV): After finding open ports, Nmap probes the services to determine exact versions (e.g., Apache 2.4.41). Essential for vulnerability assessment.
For most beginners, starting with nmap -sV on a single host gives the most useful information: open ports plus the software versions.
Scanning a Range and Using Targets
Nmap accepts various target formats:
- Single IP:
nmap 192.168.1.1 - Range:
nmap 192.168.1.1-100(scans .1 through .100) - CIDR notation:
nmap 192.168.1.0/24(scans all 256 addresses in the subnet) - Hostname:
nmap scanme.nmap.org(Nmap’s test server)
You can also scan multiple targets in one command: nmap 192.168.1.1 192.168.1.5. To scan all 65,535 ports on a host, use -p- (e.g., nmap -p- 192.168.1.1). This takes longer but finds services on non-standard ports.
Reading the Output and Common Flags
Nmap’s default output lists each scanned host with a status line, then a table of ports. A port can be open (service is listening), closed (reachable but no service), filtered (a firewall dropped the packet), or unfiltered (reachable but state unknown). The STATE column is critical: an open port is a potential entry point, while filtered means the port is probably firewalled.
Useful flags to combine:
-v(verbose): shows more detail during the scan.-A: enables OS detection, version detection, script scanning, and traceroute. It’s aggressive but gives a full picture.-O: enables OS detection (requires root).-p: specifies ports, e.g.,-p 22,80,443or-p 1-1000.--top-ports 100: scans the 100 most common ports instead of the default 1,000.
Example: sudo nmap -sS -sV -O 192.168.1.5 performs a SYN scan with version and OS detection.
Safety, Legality, and Ethical Use
Scanning networks you do not own or have explicit permission to test is illegal in many jurisdictions and violates most ISP terms of service. Even on your own network, be cautious: aggressive scans can trigger intrusion detection systems or cause instability on older devices. Always get written permission before scanning any third-party system. For practice, Nmap’s official test server scanme.nmap.org is provided for this purpose, but avoid heavy scans that could disrupt it. Remember that Nmap is a tool; its ethical use depends entirely on the user.
Common Pitfalls and Troubleshooting
Beginners often encounter these issues:
- Permission denied: SYN scan and OS detection require root/admin. On Linux/macOS, prefix with
sudo; on Windows, run as Administrator. - All ports show filtered: A firewall is likely blocking your probes. Try a TCP connect scan (
-sT) or add-Pnto skip host discovery if the host doesn’t respond to ping. - Scan is too slow: Use
-T4for faster timing (T0–T5, with T4 being aggressive but safe for most networks). For UDP scans, expect slowness. - Misreading filtered vs. open: Filtered ports are not necessarily vulnerable; they may just be firewalled. Only open ports indicate a service is actively listening.
Alternatives and Complementary Tools
Nmap is not the only network scanner. Angry IP Scanner is a graphical tool that quickly finds live hosts. Zenmap is the official GUI for Nmap, helpful for visualizing results. Masscan is faster for scanning the entire internet but less feature-rich. For service exploitation or deeper analysis, tools like Metasploit or OpenVAS build on Nmap’s results. However, for most learning and everyday use, Nmap’s command-line interface remains the standard.
Frequently Asked Questions
Is Nmap legal to use? Yes, Nmap itself is legal software. However, scanning systems without authorization is illegal. Always scan only your own devices or networks where you have permission.
What is the difference between -sS and -sT? -sS (SYN scan) sends a SYN packet and doesn’t complete the handshake, making it faster and less noticeable. -sT (connect scan) completes the full TCP handshake, which is slower and more likely to be logged, but works without root privileges.
Why does Nmap say a port is filtered? A filtered port means Nmap received no response, usually because a firewall dropped the packet. It doesn’t confirm the port is closed; it just means Nmap couldn’t determine its status.
Can Nmap detect the operating system? Yes, with the -O flag, Nmap uses TCP/IP fingerprinting to guess the OS. It’s not always accurate, especially for devices with custom stacks, but it gives a good estimate.
How do I scan all ports? Use -p- to scan ports 1–65535. This takes much longer than the default 1,000 ports, so consider using --top-ports 1000 or a specific range like -p 1-5000 for faster results.
What should I do if Nmap shows no open ports? The host may be fully firewalled, or you might be scanning the wrong IP. Try a ping scan (-sn) to confirm the host is up, then use -Pn to skip host discovery.
Related
Method: the standard formula for this calculation, rounded as each result states. See how the calculators work or report an error.