Port Scanning with Nmap
Port scanning identifies which TCP and UDP ports are open on a target host. Open ports indicate running services — each one is a potential attack surface. The output feeds directly into service-specific enumeration and vulnerability discovery.
Run host discovery first to confirm the target is alive before port scanning. See ICMP Host Discovery and Ping Sweeps.
Fast Initial Scan
Start with a fast scan of the most common ports to get immediate results:
-F scans the top 100 ports. -T4 increases timing for faster results on a reliable network. This gives you something to work with in under 30 seconds while a full scan runs in the background.
Full TCP Port Scan
Scan all 65535 ports to avoid missing services on non-standard ports:
--min-rate 5000 pushes nmap to send at least 5000 packets per second. Adjust down on unstable or rate-limited networks. This is the scan to run on every target — services on high ports are missed by default scans constantly.
TCP SYN Scan
The default and most reliable scan type. Sends a SYN packet and records the response without completing the handshake:
Requires root. Without root, nmap falls back to a TCP connect scan (-sT) which completes the full handshake and is slightly louder.
Service Version Detection
Once you have a list of open ports, run version detection against them:
PORT STATE SERVICE VERSION 22/tcp open ssh OpenSSH 8.2p1 Ubuntu 4ubuntu0.11 80/tcp open http Apache httpd 2.4.41 3306/tcp open mysql MySQL 5.7.42
Version information feeds directly into CVE matching and service-specific enumeration. Always run -sV on confirmed open ports before moving on.
OS Detection
Requires root. nmap fingerprints the OS based on TCP/IP stack behaviour. The result is a best-guess with a confidence percentage — treat it as directional, not definitive.
Combined version and OS detection:
Combined Scan — Open Ports Then Deep Scan
A reliable two-phase approach: fast full port scan first, then detailed scan on confirmed open ports only.
-sC runs the default NSE scripts against detected services. This combination gives full coverage without wasting time running scripts against every port.
UDP Scanning
UDP services are missed by all TCP scans. Common high-value UDP ports worth checking explicitly:
Full UDP scans are slow — each closed port waits for an ICMP port unreachable response with a default timeout. Target specific ports unless you have time for a full sweep.
Saving Output
Always save scan output. Grepable format is easiest to parse:
-oA saves three formats simultaneously: normal (.nmap), grepable (.gnmap), and XML (.xml). The XML output is compatible with tools like Metasploit and searchsploit.
Scanning Multiple Hosts
Pass a file of targets:
Or scan an entire subnet:
Reading Results
Open ports are the primary output. For each open port:
Note the port number and service name
Check the version string for specific software and version
Match against service-specific enumeration pages for next steps
High ports (above 1024) with unfamiliar services are worth investigating first — they are most likely to be custom or misconfigured applications
Filtered ports mean a firewall is blocking the probe but the host may still be running a service there. Try from a different source address or use a different probe type if filtered ports are significant.
References
-
Nmap Reference Guidenmap.org/book/man.html (opens in new tab)
Official nmap manual covering all scan types, timing options, output formats, and flags.
-
Nmap Network Scanningnmap.org/book/toc.html (opens in new tab)
Official Guide Comprehensive reference for nmap usage including port scanning techniques and interpretation.
Was this helpful?
Your feedback helps improve this page.