On this page 20 sections
- Start with host discovery
- When the host does not respond to discovery
- Understand why Nmap reports a result
- ARP discovery on local networks
- Choose which ports to scan
- TCP SYN scan
- TCP ACK scan
- UDP scanning
- Detect services and versions
- Nmap Scripting Engine
- Operating system detection
- Aggressive enumeration
- Save scan results
- Verbose output and progress
- Timing templates
- Control retries and packet rate
- RTT timeout control
- Interface and source options
- Use a specific DNS server
- A practical enumeration workflow
Start with host discovery
Before scanning ports, it is often useful to determine which hosts are reachable. Nmap can perform host discovery without starting a full port scan. The behaviour changes depending on whether the target is on the local network or across routed networks.
nmap -sn 10.20.20.0/24nmap -sn -PE target1.sam0x.menmap -sn -n 10.20.20.0/24When the host does not respond to discovery
A host may be online but not respond to the discovery probes Nmap normally uses. The -Pn option tells Nmap to treat the target as online and continue directly with the port scan. This is useful when ICMP or other discovery traffic is filtered.
nmap -Pn target1.sam0x.meUnderstand why Nmap reports a result
When troubleshooting a scan, --reason explains why Nmap considers a host or port to be in a particular state. --packet-trace goes further by displaying packets sent and received during the scan.
nmap --reason target1.sam0x.menmap --packet-trace target1.sam0x.meARP discovery on local networks
On a local Ethernet network, Nmap can use ARP for host discovery. ARP is generally very reliable because devices on the same Layer 2 segment must answer ARP requests to communicate. The --disable-arp-ping option disables this behaviour when you specifically want to test another discovery method.
nmap --disable-arp-ping target1.sam0x.meChoose which ports to scan
The port selection has a major impact on scan time. A quick scan can focus on common ports, while a complete enumeration should eventually cover the full TCP port range.
nmap -F target1.sam0x.menmap --top-ports 1000 target1.sam0x.menmap -p 22,80,443 target1.sam0x.menmap -p 22-110 target1.sam0x.menmap -p- target1.sam0x.meTCP SYN scan
The SYN scan is one of the most commonly used TCP scan types. Nmap sends a SYN packet and evaluates the response without completing a normal TCP connection. It is commonly used for efficient TCP port discovery.
sudo nmap -sS target1.sam0x.mesudo nmap -sS -p- target1.sam0x.meTCP ACK scan
An ACK scan is mainly useful for understanding firewall filtering behaviour rather than determining whether a service is listening. It can help distinguish between filtered and unfiltered ports depending on how the target network handles ACK packets.
sudo nmap -sA target1.sam0x.meUDP scanning
UDP enumeration is different from TCP because many UDP services do not respond when a probe is sent. This can make UDP scans slower and results may appear as open|filtered when Nmap cannot determine the exact state.
sudo nmap -sU target1.sam0x.mesudo nmap -sU --top-ports 50 target1.sam0x.meDetect services and versions
Finding an open port is only the beginning. The -sV option probes discovered services to identify the application, protocol and possible version running behind each port.
nmap -sV target1.sam0x.menmap -sV -p 22,80,443 target1.sam0x.meNmap Scripting Engine
The Nmap Scripting Engine (NSE) extends Nmap with scripts for discovery, enumeration and protocol-specific checks. -sC runs the default script category, while --script allows a specific script or group of scripts to be selected.
nmap -sC target1.sam0x.menmap -sV -sC target1.sam0x.menmap --script http-enum -p 80,443 target1.sam0x.menmap --script smb-os-discovery -p 445 target1.sam0x.meOperating system detection
Nmap can estimate the operating system by comparing network responses against its fingerprint database. OS detection is more reliable when Nmap can observe both open and closed ports.
sudo nmap -O target1.sam0x.meAggressive enumeration
The -A option enables several enumeration features at once, including OS detection, service/version detection, default NSE scripts and traceroute. It provides a lot of information but also generates more traffic than a focused scan.
sudo nmap -A target1.sam0x.meSave scan results
Saving results is important when scans are part of a larger enumeration process. Nmap supports normal text, XML, grepable output and -oA, which creates several output formats from a single scan.
nmap -sV target1.sam0x.me -oN target1.txtnmap -sV target1.sam0x.me -oX target1.xmlnmap -sV target1.sam0x.me -oG target1.gnmapnmap -sV target1.sam0x.me -oA scans/target1Verbose output and progress
Long scans can take time. Verbose mode provides additional information while the scan runs, and --stats-every can periodically display scan progress.
nmap -v target1.sam0x.menmap -vv target1.sam0x.menmap -p- --stats-every=5s target1.sam0x.meTiming templates
Nmap timing templates range from T0 to T5. Lower values are slower and more conservative, while higher values make the scan more aggressive. Faster is not always better because packet loss, latency or rate limiting can reduce scan accuracy.
nmap -T2 target1.sam0x.menmap -T4 target1.sam0x.meControl retries and packet rate
Performance can also be adjusted directly. --max-retries limits how often Nmap retransmits probes, while --min-rate requests a minimum packet sending rate. These options can reduce scan time but aggressive values may cause ports to be missed on unstable networks.
nmap -p- --max-retries 2 target1.sam0x.menmap -p- --min-rate 300 target1.sam0x.meRTT timeout control
Round-trip timeout values determine how long Nmap waits for responses. Reducing these values can improve performance on fast and predictable networks, but values that are too aggressive may cause valid responses to be missed.
nmap --initial-rtt-timeout 50ms --max-rtt-timeout 100ms target1.sam0x.meInterface and source options
Nmap can be instructed to use a specific network interface, source address or source port. These options are mainly useful when working with multiple interfaces, routing scenarios or controlled network testing.
sudo nmap -e eth0 target1.sam0x.mesudo nmap -S 10.20.20.10 target1.sam0x.mesudo nmap -g 53 target1.sam0x.meUse a specific DNS server
Nmap can perform DNS resolution through a specified DNS server instead of relying only on the system resolver.
nmap --dns-server 10.20.20.53 target1.sam0x.meA practical enumeration workflow
A useful workflow is to start with discovery, identify open ports, and only then perform deeper enumeration against the services that were actually discovered. This keeps scans organised and avoids running every option at once.
nmap -sn 10.20.20.0/24sudo nmap -sS -p- --min-rate 300 --stats-every=5s target1.sam0x.me -oA scans/target1-portsnmap -sV -sC -p 22,80,443 target1.sam0x.me -oA scans/target1-services