Network Beginner Network Scanning / Reconnaissance / Enumeration

Nmap � Network Scanning Reference

A practical Nmap reference for security analysts � host discovery, port scanning techniques, service and OS detection, NSE scripts, output formats, and reading scan results for threat assessment.

14 min read Network Scanning Blue Team / Pentesting

// What is Nmap?

Nmap (Network Mapper) is an open-source network scanning tool used to discover hosts, enumerate open ports, identify running services and their versions, detect operating systems, and run scripted checks against network services. It's available on Windows, Linux, and macOS.

For blue team analysts, Nmap is used in asset discovery, vulnerability assessments, and verifying network segmentation controls. For penetration testers, it's the standard reconnaissance tool for mapping attack surface before exploitation.

Always have authorisation before scanning. Scanning networks or systems you don't own or have explicit written permission to test is illegal in most jurisdictions. Even within your own organisation, active scanning can trigger IDS/IPS alerts and should be coordinated with the security team.

// Basic Syntax

Nmap � Basic syntax
nmap [scan type] [options] [target]

# Target formats
nmap 192.168.1.1               # Single IP
nmap 192.168.1.1-20            # IP range
nmap 192.168.1.0/24            # CIDR subnet
nmap 192.168.1.1 10.0.0.1      # Multiple IPs (space separated)
nmap -iL targets.txt           # Read targets from file
nmap scanme.nmap.org            # Hostname

Scan speed (-T timing)

FlagNameUse case
-T0ParanoidIDS evasion � extremely slow, one probe at a time
-T1SneakyIDS evasion � slow, minimal footprint
-T2PoliteReduces network load � slow
-T3NormalDefault � balanced speed and accuracy
-T4AggressiveFast � assumes reliable network. Most common choice for authorised scans
-T5InsaneVery fast but may miss results on slow networks or lose packets

// Host Discovery

Before port scanning, Nmap checks whether hosts are up. By default it sends ICMP echo requests, TCP SYN to 443, TCP ACK to 80, and ICMP timestamp requests.

FlagMethodNotes
-snPing scan only � no port scanDiscovers live hosts quickly without scanning ports. Useful for asset inventory.
-PnSkip ping � treat all hosts as upRequired when hosts block ICMP. Forces port scan on all targets even if they don't respond to ping.
-PEICMP echo requestStandard ping
-PSTCP SYN ping-PS80,443 � SYN to specified ports
-PATCP ACK pingCan bypass stateless firewalls that block SYN
-PUUDP pingUseful for hosts that filter TCP but allow UDP
-PRARP pingLocal network only � very reliable within the same subnet
-nNo DNS resolutionFaster � skips reverse DNS lookups
-RAlways resolve DNSResolve all targets including offline hosts

// Port Scanning

Scan types

FlagTypeHow it worksNotes
-sSTCP SYN (Stealth)Sends SYN, reads SYN-ACK (open) or RST (closed), never completes handshakeDefault when running as root. Faster, less logged than connect scan
-sTTCP ConnectFull three-way handshake using OS socket APIDefault without root. Slower, more likely to be logged
-sUUDPSends UDP packets, listens for ICMP port unreachable (closed) or service response (open)Slow � UDP has no handshake. Often combined with TCP: -sS -sU
-sATCP ACKSends ACK � returns RST from both open and closed ports. Used to map firewall rules, not port state.Shows which ports are filtered by a stateful firewall
-sN / -sF / -sXNULL / FIN / XmasSends packets with no/FIN/FIN+PSH+URG flags � no response = open|filteredCan bypass some non-stateful firewalls; doesn't work on Windows

Port selection

FlagBehaviour
-p 80Scan a single port
-p 80,443,8080Scan specific ports
-p 1-1024Scan port range
-p-Scan all 65,535 ports
-FFast scan � top 100 most common ports
--top-ports 1000Top N most common ports (default when no -p specified)
-p U:53,T:80,443Mixed UDP and TCP port specification

Port states

StateMeaning
openA service is actively accepting connections on this port
closedPort is accessible but no service is listening � RST returned
filteredFirewall is dropping probes � no response received. Nmap can't determine if open or closed.
open|filteredNmap can't distinguish � usually from UDP or stealth scans
unfilteredPort is accessible but Nmap can't determine open/closed (ACK scan result)

// Service & Version Detection

Service detection probes open ports to identify the application and version running behind them � much more useful than just knowing a port is open.

FlagDescription
-sVEnable service/version detection � sends probes and reads banners to identify the service
--version-intensity 0-9How hard to probe (0 = light, 9 = all probes). Default is 7. Higher = more accurate but slower.
--version-lightIntensity 2 � quick check, may miss some services
--version-allIntensity 9 � tries all probes, most accurate
Nmap � Service scan example output
PORT    STATE SERVICE  VERSION
22/tcp  open  ssh      OpenSSH 8.9p1 Ubuntu 3ubuntu0.6 (Ubuntu Linux; protocol 2.0)
80/tcp  open  http     Apache httpd 2.4.52 ((Ubuntu))
443/tcp open  ssl/http Apache httpd 2.4.52 ((Ubuntu))
3306/tcp open mysql   MySQL 8.0.32

// OS Detection

OS detection works by analysing TCP/IP stack characteristics � TTL values, window sizes, IP flags, and responses to crafted probes. It requires at least one open and one closed port to work reliably, and must be run as root/Administrator.

FlagDescription
-OEnable OS detection
--osscan-guessGuess OS even when confidence is low
--osscan-limitOnly try OS detection when there's at least one open and one closed port

OS detection is probabilistic � Nmap reports a confidence percentage (e.g. OS details: Microsoft Windows 10 (95%)). Firewalls and network address translation can reduce accuracy. Service banner grabbing with -sV often reveals more reliable OS information through application-layer banners.

// NSE Scripts

The Nmap Scripting Engine (NSE) extends Nmap with Lua scripts for vulnerability detection, service enumeration, brute forcing, and more. Scripts live in /usr/share/nmap/scripts/.

Flag / CategoryDescription
-sCRun default scripts � equivalent to --script=default. Safe, informational scripts for common services.
--script=vulnRun vulnerability detection scripts � checks for known CVEs and misconfigurations
--script=authRun authentication-related scripts � default credentials, anonymous access
--script=bannerSimple banner grabbing � reads the initial bytes sent by a service
--script=smb-vuln*All SMB vulnerability checks � includes EternalBlue (MS17-010) detection
--script=http-titleRetrieve the title from HTTP responses � quick web service enumeration
--script=ssl-certExtract SSL/TLS certificate details � hostname, expiry, issuer
--script=dns-bruteBrute-force DNS subdomains
Nmap � Common script combinations
# Default scripts + version detection (standard recon)
nmap -sV -sC -T4 192.168.1.0/24

# Check for EternalBlue (MS17-010) / WannaCry vulnerability
nmap -p 445 --script smb-vuln-ms17-010 192.168.1.0/24

# HTTP service enumeration
nmap -p 80,443,8080,8443 --script http-title,http-headers,http-methods 192.168.1.0/24

# SSL certificate inspection
nmap -p 443 --script ssl-cert,ssl-enum-ciphers 192.168.1.1

# SMB enumeration
nmap -p 445 --script smb-enum-shares,smb-enum-users,smb-security-mode 192.168.1.0/24

// Output Formats

Always save scan output � you'll want to refer back to it during an investigation or report.

FlagFormatBest for
-oN file.txtNormal � human-readable textQuick review, sharing with colleagues
-oX file.xmlXML � structured dataImporting into other tools (Metasploit, vulnerability scanners, custom scripts)
-oG file.gnmapGrepable � one line per hostShell scripting and grep-based parsing
-oA basenameAll three formats simultaneouslyStandard choice � saves basename.nmap, basename.xml, basename.gnmap
-v / -vvVerbose outputSee results as they come in rather than waiting for the scan to complete
--reasonShow reason for port stateUnderstand why a port is flagged open/filtered � which packet triggered the classification
--openOnly show open portsFilter output to relevant results on large subnet scans
Bash � Parsing grepable output
# Extract all hosts with port 22 open
grep "22/open" scan.gnmap | awk '{print $2}'

# List all open ports across all hosts
grep "Ports:" scan.gnmap | grep -oP '\d+/open' | sort -t/ -k1 -n | uniq -c | sort -rn

// Common Ports Reference

PortProtocolServiceNotes
21TCPFTPPlaintext � check for anonymous login
22TCPSSHCheck version for known CVEs
23TCPTelnetPlaintext � should not be open on modern systems
25TCPSMTPEmail � check for open relay
53TCP/UDPDNSUDP for queries; TCP for zone transfers (AXFR)
80TCPHTTPWeb � check for admin interfaces, default creds
110 / 995TCPPOP3 / POP3SLegacy auth � check for legacy protocol exposure
135TCPRPCWindows RPC endpoint mapper
139 / 445TCPNetBIOS / SMBFile sharing � check for EternalBlue, open shares
143 / 993TCPIMAP / IMAPSEmail � check for legacy auth
389 / 636TCPLDAP / LDAPSActive Directory � check for anonymous bind
443TCPHTTPSCheck cert validity, TLS version, cipher suites
3306TCPMySQLCheck if exposed externally � should be localhost only
3389TCPRDPWindows Remote Desktop � high-value attack target
5985 / 5986TCPWinRMPowerShell Remoting � HTTP/HTTPS
8080 / 8443TCPHTTP/HTTPS altWeb apps and management interfaces on non-standard ports

// Tips & Best Practices

Use -A for comprehensive single-host scans. The -A flag enables OS detection, version detection, script scanning, and traceroute in one flag � nmap -A -T4 192.168.1.1. Good for deep inspection of a specific target.

Scan large subnets in two passes. First do a fast ping sweep (-sn -T4) to identify live hosts, then port scan only the live hosts from the results. Much faster than port scanning the whole range blind.

Zenmap is Nmap's GUI. If you prefer a graphical interface, Zenmap ships with Nmap on Windows and provides a command builder, topology map, and results comparison feature. Useful for visualising large subnet scans.

Nmap generates significant network noise. Even a T3 SYN scan of a /24 subnet sends thousands of packets and will appear in firewall and IDS logs. Don't scan production networks without coordination � and be aware that aggressive scanning (-T4 / -T5) can temporarily impact service performance on sensitive hosts.