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:
brew install nmapsudo apt install nmapsudo yum install nmapYour 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.
Frequently Asked Questions
Continue Learning
Nmap Beginner Tutorial: Mastering Network Scanning
Learn Nmap from scratch covering host discovery, port scanning, service detection, NSE scripts, and practical examples.
Tools · IntermediateMasscan Guide: High-Speed Network Scanner
Learn Masscan for high-speed network scanning with millions of packets per second, covering options, output formats, and practical scanning examples.
Tools · BeginnerSMB Enumeration Guide: Discovering Windows Shares and Users
Complete guide to SMB enumeration for discovering Windows shares, users, groups, and network resources using Enum4Linux, SMBClient, NBTScan, and Nmap.
Tools · IntermediateHow to Use Burp Suite: Beginner's Guide to Web App Security Testing in Kali Linux
Learn how to use Burp Suite to intercept requests, test with Repeater and Intruder, follow a worked DVWA example, and start free with Community Edition.
Related Security Tools
Nmap
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.
Information GatheringRustScan
RustScan is a modern, high-speed port scanner built in Rust that can find all open ports within seconds and automatically pipes them directly into Nmap for deeper script processing.
Information GatheringMasscan
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.
Stress Testinghping3
hping3 is a command-line network tool for crafting, sending, and analyzing custom TCP/IP packets. Built for firewall testing, port scanning, OS fingerprinting, path MTU discovery, and authorized stress testing, it gives you control over nearly every field of the TCP, UDP, ICMP, and raw IP headers — the flags, sequence numbers, window size, TTL, fragmentation, and payload — and then shows you exactly how the target answers. Where Nmap runs predefined scan types, hping3 is the packet workbench you reach for when the question is "what does the firewall do with THIS exact packet?" It runs on raw sockets (so it needs root), supports scan and listen modes, and includes a Tcl scripting engine for automating protocol experiments in a lab.