6.1 Host Discovery Techniques & Ping Sweep Methodologies

Key Takeaways

  • Host discovery (ping sweeping) segregates responsive systems from inactive address space, preventing wasteful full-port scans across non-existent targets and minimizing network congestion.
  • The -sn flag (formerly -sP) disables port scanning entirely to execute host discovery only, whereas -Pn instructs Nmap to skip host discovery and treat all target hosts as active, which is crucial when perimeter firewalls drop probe packets.
  • Nmap employs diverse Layer 3 and Layer 4 discovery probes including ICMP Echo (-PE), ICMP Timestamp (-PP), ICMP Address Mask (-PM), TCP SYN ping (-PS), TCP ACK ping (-PA), and UDP ping (-PU).
  • On local Ethernet segments, Nmap defaults to Layer 2 ARP ping scans (-PR) regardless of specified Layer 3/4 flags, because ARP queries operate below operating system firewalls and cannot be blocked by host-level packet filters.
Last updated: September 2026

6.1 Host Discovery Techniques & Ping Sweep Methodologies

In professional penetration testing, conducting port scans across vast address spaces without prior host discovery is inefficient, noisy, and operationally reckless. An enterprise allocation such as a /16 subnet contains 65,536 potential IPv4 addresses. Attempting to scan the top 1,000 TCP ports across every unverified address results in more than 65 million packet transmissions. If only 200 hosts are active, over 99% of those packets are sent into dark address space, generating unnecessary bandwidth consumption, triggering network intrusion detection systems (NIDS), and inflating assessment timelines.

Host discovery (commonly termed a ping sweep) is the reconnaissance phase dedicated to determining which target IP addresses are associated with active, online systems. By establishing a verified inventory of live targets first, penetration testers can restrict intensive port enumeration, service detection, and vulnerability exploitation strictly to responsive assets.


The Role of Nmap in Target Identification

Network Mapper (Nmap) serves as the industry standard for network mapping and target enumeration. When invoked against target specifications (such as CIDR blocks, hostname ranges, or input files via -iL), Nmap's default execution workflow divides operations into distinct phases:

+-----------------------------------------------------------------------------+
|                           NMAP EXECUTION LIFECYCLE                          |
+-----------------------------------------------------------------------------+
| 1. Target Enumeration     : Resolves DNS names and builds target IP list    |
| 2. Host Discovery (Ping)  : Filters active hosts from inactive address space|
| 3. Reverse DNS Lookup     : Resolves hostnames for discovered live systems  |
| 4. Port Scanning          : Probes transport ports on confirmed live hosts  |
| 5. Service/OS Detection   : Interrogates open ports for software/OS versions|
| 6. NSE Script Scanning    : Executes automated Lua vulnerability scripts    |
| 7. Output Generation      : Writes findings to interactive and file formats |
+-----------------------------------------------------------------------------+

Core Discovery Control Flags: -sn and -Pn

Two essential command-line flags control how Nmap handles host discovery:

  • -sn (Ping Scan / Disable Port Scan): Historically designated as -sP. This option instructs Nmap to terminate execution immediately after completing host discovery. Nmap reports which hosts are online without transmitting a single port scan probe. This is the classic ping sweep mode used to rapidly map live devices across subnets.
  • -Pn (No Ping / Treat All Hosts as Online): In hardened network architectures, stateful firewalls or host-based security solutions (such as Windows Defender Firewall or Linux iptables/nftables) frequently drop ICMP Echo requests and unsolicited transport probes. Under default settings, if Nmap receives no response to its host discovery probes, it marks the target as offline and completely omits it from subsequent port scanning. The -Pn flag forces Nmap to skip the host discovery phase entirely and execute port scanning against every single target IP specified, assuming all targets are active.
# Rapid host discovery sweep across a /24 subnet without port scanning
nmap -sn 192.168.10.0/24

# Full port scan forcing Nmap to scan hosts that silently drop ping probes
nmap -Pn -p 1-65535 10.10.50.15

Default Host Discovery Probes: Privileged vs Unprivileged

Nmap's default host discovery probe combination varies depending on the operating system user privileges and whether the target resides on the local subnet or across a routed network:

  1. Privileged Execution (Root or Administrator): When running with raw socket capabilities, Nmap transmits a multi-vector probe suite to remote targets:
    • ICMP Echo Request (-PE)
    • TCP SYN packet to port 443 (-PS443)
    • TCP ACK packet to port 80 (-PA80)
    • ICMP Timestamp Request (-PP)
  2. Unprivileged Execution (Non-Root User): When raw socket creation is denied by the operating system kernel, Nmap falls back to the Berkeley sockets API. It issues standard connect() system calls, transmitting TCP SYN packets to ports 80 and 443. ICMP probes cannot be generated by unprivileged users on Unix-like operating systems because raw ICMP sockets require administrative privileges.
  3. Local Subnet (Layer 2) Probes: Regardless of whether the user requests ICMP or TCP ping flags, if Nmap detects that the target IP address is on the same local Ethernet broadcast domain as the scanner interface, it overrides all Layer 3/4 ping options and uses ARP ping (-PR).

ICMP-Based Host Discovery Mechanisms

The Internet Control Message Protocol (ICMP) provides network diagnostics and error reporting. Nmap implements three specific ICMP query types for host discovery:

Scanner                               Target
   |                                     |
   |------ ICMP Echo Request (Type 8) --->|
   |<----- ICMP Echo Reply (Type 0) ------|  (Host is Live)
   |
   |--- ICMP Timestamp Request (Type 13)->|
   |<-- ICMP Timestamp Reply (Type 14) ---|  (Host is Live)
   |
   |-- ICMP Address Mask Req (Type 17) -->|
   |<-- ICMP Address Mask Reply (Type 18)-|  (Host is Live)

1. ICMP Echo Request (-PE)

  • Protocol Mechanics: Transmits an ICMP Type 8, Code 0 (Echo Request) packet. A responsive host returns an ICMP Type 0, Code 0 (Echo Reply).
  • Operational Reality: This is standard ping. Because ping has historically been associated with network mapping, reconnaissance, and denial-of-service attacks (e.g., Smurf attacks), almost all modern perimeter firewalls, cloud security groups (AWS Security Groups, Azure Network Security Groups), and default Windows client firewalls block inbound ICMP Echo requests.

2. ICMP Timestamp Request (-PP)

  • Protocol Mechanics: Transmits an ICMP Type 13, Code 0 (Timestamp Request). Active systems reply with an ICMP Type 14, Code 0 (Timestamp Reply) containing the current time coordinated in milliseconds since midnight UTC.
  • Firewall Evasion Utility: Network administrators frequently configure edge firewalls with simple rules such as "Block ICMP Echo" rather than blocking the entire ICMP protocol family. Consequently, Timestamp Requests often traverse firewalls that drop Echo packets, eliciting replies from enterprise routers, Unix servers, and network storage appliances.

3. ICMP Address Mask Request (-PM)

  • Protocol Mechanics: Transmits an ICMP Type 17, Code 0 (Address Mask Request) intended historically to allow diskless workstations to determine their subnet mask during bootstrap. Responsive hosts reply with ICMP Type 18, Code 0 (Address Mask Reply).
  • Operational Limitations: While modern operating systems generally ignore or drop Type 17 requests due to security recommendations, legacy embedded systems, older Unix installations, and specific telecommunication hardware continue to answer, confirming host availability.

Transport-Layer Discovery Probes: TCP and UDP

When edge firewalls block all ICMP query types, penetration testers rely on transport-layer discovery probes that mimic legitimate application traffic.

                                  TCP SYN PING (-PS)
Scanner                                                         Target (Port Open)
   |----------------- TCP SYN (Seq=x, Port 80) ------------------>|
   |<---------------- TCP SYN-ACK (Seq=y, Ack=x+1) ---------------| (Host is LIVE)
   |----------------- TCP RST (Seq=x+1) ------------------------->| (Tear down)

Scanner                                                         Target (Port Closed)
   |----------------- TCP SYN (Seq=x, Port 81) ------------------>|
   |<---------------- TCP RST (Seq=0, Ack=x+1) -------------------| (Host is LIVE)


                                  TCP ACK PING (-PA)
Scanner                                                         Target (Any State)
   |----------------- TCP ACK (Seq=x, Port 80) ------------------>|
   |<---------------- TCP RST (Seq=x, Ack=0) ---------------------| (Host is LIVE)


                                   UDP PING (-PU)
Scanner                                                         Target (Port Closed)
   |----------------- UDP Datagram (Port 40125) ----------------->|
   |<---------- ICMP Port Unreachable (Type 3, Code 3) -----------| (Host is LIVE)

1. TCP SYN Ping (-PS [portlist])

  • Mechanics: Transmits an empty TCP packet with the SYN (Synchronize) control flag set. The default destination port is 80 if no port list is specified, but custom ports can be defined (e.g., -PS22,80,443,3389).
  • Target Response Behavior:
    • Open Port: If the probed port is open, the target TCP stack attempts to establish a connection by returning a SYN-ACK packet. Nmap's raw socket engine immediately transmits a RST (Reset) packet to abort the half-open connection before an application session is established.
    • Closed Port: If the probed port is closed, the target TCP stack responds with a RST packet.
  • Key Architectural Fact: In either case—whether the port returns SYN-ACK or RST—the transmission of a valid TCP response definitively proves that the target host is active and connected to the network!

2. TCP ACK Ping (-PA [portlist])

  • Mechanics: Transmits an empty TCP packet with the ACK (Acknowledgment) control flag set to port 80 (or custom ports). Under RFC 793, an ACK packet arriving at a host without an established connection or matching sequence number is invalid; the target stack is required to discard the packet and generate a RST packet.
  • Firewall Evasion Utility: The TCP ACK ping is effective against stateless packet-filtering firewalls. Basic stateless firewalls permit inbound packets if the ACK flag is set, operating on the simplistic assumption that an ACK packet represents returning traffic from an established internal client connection. The probe slips through the firewall, hits the target host, and causes the target's operating system to return a RST, confirming the host is alive.

3. UDP Ping (-PU [portlist])

  • Mechanics: Transmits an empty UDP datagram (or protocol-specific payload) to a high, typically unassigned destination port (default: 40125).
  • Target Response Behavior:
    • Closed Port: When a UDP datagram arrives at a closed port, the target operating system generates an ICMP Type 3, Code 3 (Destination Unreachable: Port Unreachable) error message.
    • Open Port: If the port is open, the listening service may reply with an application-specific response, or discard the empty packet silently without generating an error.
  • Key Architectural Fact: Receiving an ICMP Port Unreachable message proves that the target machine is online, operational, and capable of generating Layer 3 ICMP errors.

Layer 2 Discovery: ARP Ping (-PR)

When a penetration tester assesses targets located within the same local Ethernet broadcast domain (e.g., connected to the same internal office VLAN, corporate Wi-Fi network, or lab switch), standard Layer 3 and Layer 4 discovery probes are unnecessary and suboptimal.

Scanner (192.168.1.50)                           Target Host (192.168.1.100)
   |                                                    |
   |--- Broadcast: Who has 192.168.1.100? Tell .50 ---->| (ARP Request)
   |                                                    |
   |<-- Unicast: 192.168.1.100 is at 00:0c:29:ab:cd:ef -| (ARP Reply - LIVE!)

Mechanics of ARP Ping

Under IPv4 networking, a host cannot transmit an IP packet to a local destination without first resolving the target's 32-bit logical IP address to its 48-bit physical Media Access Control (MAC) address using the Address Resolution Protocol (ARP). Nmap issues raw ARP request frames (who-has target_IP tell scanner_IP). If the target system is powered on and connected to the medium, its network interface card (NIC) must generate a unicast ARP reply frame containing its physical MAC address.

The Security Significance of ARP Ping

  • Immunity to Host Firewalls: Personal and host-based firewalls (such as Windows Defender Firewall, macOS Application Firewall, and basic Linux iptables filter chains) operate at OSI Layer 3 (Network) and Layer 4 (Transport). They inspect IP headers and TCP/UDP ports. ARP operates at Layer 2 (Data Link). An operating system cannot block ARP requests intended for its own IP address without severing all local network connectivity. Therefore, even a fully patched Windows host configured with "Block all incoming connections" will reply to ARP requests.
  • Speed and Efficiency: ARP ping sweeps operate at wire speed, mapping an entire /24 subnet in under two seconds.
  • Nmap Default Behavior: Whenever Nmap detects that the target specification resides on the local subnet, it automatically executes ARP ping (-PR), silently overriding any ICMP (-PE) or TCP (-PS) flags specified on the command line. To test how a local host responds to IP-level probes, the tester must explicitly disable ARP discovery using --disable-arp-ping.

Host Discovery Strategies in Hardened Environments

In modern security assessments, perimeter defenses rarely drop all protocols uniformly. Combining multiple probe types into a composite discovery command maximizes the probability of eliciting a response from active hosts while minimizing false negatives.

Discovery FlagProtocol & TypeProbe SpecificationExpected Response (Host Live)Primary Use Case
-snMulti-vectorNone (Disables port scan)Protocol dependentRapid host mapping sweep
-PnNoneSkips discovery entirelyAssumes onlineFirewalls dropping all probes
-PEICMP Type 8Echo RequestICMP Type 0 (Echo Reply)Standard network discovery
-PPICMP Type 13Timestamp RequestICMP Type 14 (Timestamp Reply)Bypassing basic ICMP filters
-PMICMP Type 17Address Mask RequestICMP Type 18 (Mask Reply)Legacy Unix & network routers
-PS[portlist]TCP SYNSYN to designated portsSYN-ACK (open) or RST (closed)Ingress firewalls allowing web
-PA[portlist]TCP ACKACK to designated portsRST (open or closed)Stateless packet filters
-PU[portlist]UDPUDP to high/custom portICMP Type 3 Code 3 unreachablePenetrating TCP-only filters
-PRARP FrameLayer 2 ARP RequestARP Reply frameLocal Ethernet / VLAN sweeps

Practical Hardened Multi-Probe Configuration

When scanning across external enterprise perimeters or inter-VLAN enterprise firewalls, practitioners execute a multi-layered discovery sweep:

nmap -sn -PE -PP -PS21,22,80,443,3389 -PA80,443,8080 -PU53,161 198.51.100.0/24

This configuration ensures that if border firewalls block ICMP Echo requests, incoming probes targeting standard web ports (80/443), administrative protocols (SSH 22, RDP 3389), stateless ACK inspection holes, or network infrastructure UDP services (DNS 53, SNMP 161) will still elicit an active response from live backend systems.

Test Your Knowledge

During an external penetration test against an enterprise network, an analyst executes nmap -sn 198.51.100.0/24 from a remote Linux system with administrative root privileges. Under default settings, which combination of discovery probes will Nmap transmit to identify active hosts?

A
B
C
D
Test Your Knowledge

An analyst attempts to perform a port scan against a hardened web server located behind a corporate firewall. The initial scan reports that the host is down, even though client web browsers can successfully load pages from the site. Which Nmap command option should the analyst use to force port scanning without dropping the target during discovery?

A
B
C
D
Test Your Knowledge

While conducting an internal infrastructure assessment from a testing workstation connected to the corporate office network, an analyst executes nmap -sn -PE -PS80,443 192.168.10.0/24. Network capture logs reveal that the scanner is transmitting only ARP requests, with zero ICMP or TCP traffic observed. What explains this scanner behavior?

A
B
C
D
Test Your Knowledge

An analyst must perform host discovery across a network protected by a stateless packet-filtering firewall configured to allow established TCP sessions (packets with the ACK control flag set) while dropping all inbound SYN packets. Which Nmap discovery technique will successfully pass through this filter and elicit a response from active targets?

A
B
C
D