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.
Why Network Scanning Matters
You need to discover every device, open port, and running service on a target network. Network scanning is the first active step in reconnaissance — it reveals the attack surface. Nmap (Network Mapper) is the industry standard for this task.
Understanding Networks and IP Addresses
Before scanning, understand the basics. Every device on a network has an IP address. A subnet mask determines which part of the address identifies the network and which identifies the host.
IP Address: 192.168.1.100
Subnet Mask: 255.255.255.0 (/24)
Network: 192.168.1.0
Host Range: 192.168.1.1 - 192.168.1.254
Broadcast: 192.168.1.255
Installing Nmap
Nmap comes pre-installed on Kali Linux. For other systems:
Your First Scan
Let's start with a basic scan to discover live hosts on your local network:
nmap -sn 192.168.1.0/24
The -sn flag tells Nmap to perform a ping scan (host discovery) without port scanning. This sends ICMP echo requests, TCP SYN to port 443, and TCP ACK to port 80.
Port Scanning Basics
Ports are virtual endpoints for network communication. Common ports include:
| Port | Service | Protocol |
|------|-----------|----------|
| 22 | SSH | TCP |
| 80 | HTTP | TCP |
| 443 | HTTPS | TCP |
| 53 | DNS | UDP/TCP |
| 3306 | MySQL | TCP |
TCP SYN Scan (Default, Requires Root)
nmap -sS 192.168.1.1
Sends SYN packets and analyzes responses. SYN/ACK means open, RST means closed, no response means filtered. This is fast and stealthy.
TCP Connect Scan
nmap -sT 192.168.1.1
Completes the full TCP handshake. Used when you lack root privileges. More detectable than SYN scan.
UDP Scan
nmap -sU 192.168.1.1
Scans UDP ports. Slower than TCP because UDP is connectionless and requires waiting for responses or timeouts.
Selecting Ports to Scan
nmap -p 22,80,443 192.168.1.1 # Specific ports
nmap -p 1-1000 192.168.1.1 # Port range
nmap -p- 192.168.1.1 # All 65535 ports
nmap --top-ports 100 192.168.1.1 # Most common 100 ports
Scanning all 65535 ports takes time. Use top-ports for quick assessments.
Service Version Detection
Identify exactly which software is running on open ports:
nmap -sV 192.168.1.1
This reveals version information like "OpenSSH 8.9p1 Ubuntu 3ubuntu0.6" which helps identify vulnerable software versions.
Operating System Detection
nmap -O 192.168.1.1
Uses TCP/IP fingerprinting to identify the operating system. Requires root privileges. Results are best guesses, not guarantees.
Output Formats
nmap -oN scan.txt 192.168.1.1 # Normal output
nmap -oX scan.xml 192.168.1.1 # XML (parsable)
nmap -oG scan.grep 192.168.1.1 # Greppable format
nmap -oA scan 192.168.1.1 # All formats
Practical Scanning Examples
Scan Your Local Network
nmap -sn 192.168.1.0/24
Comprehensive Scan of a Target
nmap -sS -sV -O -p- 192.168.1.1
Scan with Default NSE Scripts
nmap -sC 192.168.1.1
Scan for Common Vulnerabilities
nmap --script vuln 192.168.1.1
Legal and Ethical Considerations
Only scan networks and systems you own or have explicit written permission to test. Network scanning without authorization is illegal in many jurisdictions under computer misuse laws. Always practice in your own lab environment using virtual machines.
Start with local network discovery, practice on your own VMs, and build your skills before any real-world engagement.