Skip to content
Tutorials Center
My learning

Topics

Lesson 10 of 36 ยท Host Discovery

Host Discovery Overview

Learn how Nmap decides a host is up, the default discovery probes, ping sweeps with -sn, skipping discovery with -Pn, and when each choice is right.

Before Nmap spends time scanning ports on an address, it first asks "is anything there?". This step is host discovery, often called a ping scan or ping sweep. It saves enormous time on large networks (most addresses in a /16 are empty) but it can also fool you: a host that ignores the probes looks dead. Understanding the default behavior, and the options that change it, prevents the most common beginner mistake of scanning a live machine and concluding "host seems down".

Commands are read-only; run them only on networks you own. Python editors model the decisions with invented data.

Default discovery

If you do not choose anything, the probes depend on your privileges and where the target is:

Situation Default probes
Target on your local Ethernet, running as root ARP request (very reliable)
Target elsewhere, running as root ICMP echo request, TCP SYN to 443, TCP ACK to 80, ICMP timestamp request
Target elsewhere, normal user TCP connect (SYN) to ports 80 and 443

If any probe gets an answer, the host is considered up and ports are scanned. If none does, Nmap prints that the host seems down and moves on.

TEXT
$ nmap 203.0.113.50
Note: Host seems down. If it is really up, but blocking our ping probes, try -Pn
Nmap done: 1 IP address (0 hosts up) scanned in 3.05 seconds

Example output (invented host). That note is Nmap's honest hint: a firewall may be eating the probes.

-sn: discovery only (the ping scan)

-sn means "no port scan". Nmap performs discovery and then prints the hosts that are up. It used to be called -sP. This is the fastest way to answer "what is alive on this network?".

Terminal
sudo nmap -sn 192.0.2.0/24
TEXT
Nmap scan report for router.example.net (192.0.2.1)
Host is up (0.0010s latency).
MAC Address: 00:11:22:AA:BB:01 (Example Vendor)
Nmap scan report for 192.0.2.10
Host is up (0.0030s latency).
MAC Address: 00:11:22:AA:BB:0A (Example Vendor)
Nmap done: 256 IP addresses (2 hosts up) scanned in 2.31 seconds

Example output. On a local network you also see MAC addresses and the hardware vendor guessed from the first three bytes (the OUI), which is useful for inventory. See ARP and Local Discovery.

-Pn: skip discovery

-Pn (no ping) tells Nmap to treat every target as up and go straight to the port scan. Use it when you know the host is there but ICMP and the default probes are filtered, which is common for internet-facing servers behind firewalls. The cost: scanning a range of mostly empty addresses becomes very slow, because Nmap probes every port of every address and waits on each silent one.

Terminal
nmap -Pn -p 22,80,443 203.0.113.50

Rule of thumb: use -sn to find hosts, use -Pn when you are certain about a particular host.

Choosing discovery probes

The discovery options (-P*) choose which probes are sent. A full tour is in Discovery Probes: TCP, UDP and ICMP, but here is the map:

Option Probe
-PR ARP request (local network only)
-PE ICMP echo request (classic ping)
-PP ICMP timestamp request
-PM ICMP address mask request
-PS[ports] TCP SYN to the ports (default 80)
-PA[ports] TCP ACK to the ports (default 80)
-PU[ports] UDP packet to the ports (default 40125)
-PY[ports] SCTP INIT chunk
-PO[protocols] IP protocol ping
-PN / -Pn No discovery

You may combine them: -PE -PS443 -PA80 sends three kinds of probe.

Picking a discovery method

Same LAN ARP is best. It is hard to block.
Across routers Mix ICMP and TCP probes.
Firewalled Try TCP to open ports, or use -Pn.

Match the probe to what the network allows.

1 / 2

What "up" really means

A host counts as up when any valid reply arrives: an ARP answer, an ICMP echo reply, a SYN-ACK or a RST to a TCP probe (a reset means the host is there and the port is closed), or a UDP/ICMP error. Even an unfriendly refusal proves existence. That is why TCP discovery to an unused port still finds the host.

flowchart TD
  A["Target"] --> B{"Local Ethernet and root?"}
  B -- yes --> C["ARP request"]
  B -- no --> D["ICMP echo + TCP SYN 443 + TCP ACK 80 + ICMP timestamp"]
  C --> E{"Any reply?"}
  D --> E
  E -- yes --> F["Host is up: scan ports"]
  E -- no --> G["Host seems down: skip it"]

Figure: the default discovery decision flow.

A stand-in: the default probe choice

Here is a function that mirrors the table above, returning which probes Nmap would send for a given situation. It is a simplification of Nmap's real logic.

Python Which discovery probes are used?

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

A stand-in: simulate a ping sweep

This simulation holds an invented network where some hosts answer pings, some only answer TCP, and some drop everything. It shows why combining probes finds more hosts, and why -Pn (probing everything) finds the silent one but costs time.

Python Ping sweep with different probe sets

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

The hardened host 192.0.2.30 is alive but invisible to discovery, and -Pn would find it by scanning ports anyway. The non-existent 192.0.2.40 shows the price: -Pn wastes time on it.

Practical advice

  • On your own LAN, run sudo nmap -sn 192.168.1.0/24 as root so ARP is used; it finds almost everything that is switched on.
  • Across firewalls, combine probes: -PE -PS22,80,443 -PA3389.
  • If a known host shows as down, retry with -Pn before concluding anything.
  • Use -sn -n for very fast sweeps (-n skips DNS).
  • Save a host list for later: nmap -sn -oG - 192.0.2.0/24 | awk '/Up$/{print $2}'.

Check your understanding

Quick check ยท 4 questions

of 4 answered You scored / 4 ยท perfect!

  1. 1. What does -sn do?

    -sn is the ping scan: it lists hosts that are up and stops.
  2. 2. A remote server is known to be online, but Nmap reports 'host seems down'. What is the best next step?

    Firewalls often block the default discovery probes; -Pn goes straight to the port scan.
  3. 3. Which counts as a sign that a host is up?

    Any valid reply, including a reset from a closed port, proves the host exists.
  4. 4. Which probe does Nmap use by default on a local Ethernet when running as root?

    ARP is reliable on the same segment and cannot be blocked by most host firewalls.

Summary

  • Discovery decides which targets get a port scan; any valid reply counts as "up".
  • Defaults: ARP on the local LAN as root; ICMP + TCP probes elsewhere.
  • -sn lists live hosts; -Pn skips discovery for hosts that hide.
  • Combine probe types (-PE, -PS, -PA, -PU) for firewalled networks.
  • -Pn on large ranges is slow, so use it deliberately.

Next: ARP and Local Discovery