COMP-221 · Lesson 4 of 12 · 22 min
Host discovery
▶ Video coming soon A video version of this lesson is on the way.
At 9:15 on Monday, October 5, Dario sent Felix Aberdeen the first notification of active testing: external host discovery against Prairiefold's public block, from Ironwhistle's declared address, starting at 9:30 and expected to finish before 11:00. Felix replied with a thumbs-up and a note that the security operations team had been told to expect it. Tobias watched the clock tick past 9:30 and asked whether they should start. Dario said they should first check the target file one more time.
Host discovery answers the first question of active reconnaissance: which addresses have something alive behind them? It is objective 2.2's host discovery item, it draws on objective 2.1's network reconnaissance and network sniffing, and it is the first use in this course of Nmap, the most important tool named in objective 2.4.
Why discovery comes first
A /24 network has 256 addresses; a /16 has 65,536. Port scanning every port on every address takes a long time and creates a lot of traffic, most of it aimed at nothing. Discovery narrows the field to live hosts so that later, heavier scans are focused. It also produces an early finding: the number of live hosts compared with what the client believes it has. Prairiefold's asset list showed nine public services; discovery would find more.
Discovery is also where scope mistakes do the most damage, because a single wrong digit in a range can send probes to an entire network belonging to someone else. That is why Ironwhistle built target files from the scope workbook, had a second person check them, and used exclusion files for anything inside a range that was not to be touched.
# Targets built from the scope workbook (item E-1) and checked by a second tester
cat targets-E1.txt
203.0.113.0/26
# Exclusions inside or near the range, with the reason recorded in the workbook
cat exclude-E1.txt
203.0.113.1 # upstream router owned by the ISP
203.0.113.62 # ISP-managed monitoring hostHow discovery probes work
A host is considered up if anything comes back in response to a probe. Different probes work in different places, because firewalls and operating systems treat them differently.
ARP (Address Resolution Protocol) maps IPv4 addresses to hardware addresses on a local network segment. Every host must answer ARP requests for its own address to communicate at all, so an ARP sweep on the local subnet is fast and almost never misses a live host, even one with a host firewall dropping everything else. ARP does not cross routers, so it only works on the segment the tester is connected to.
ICMP echo requests, the packets behind ping, are the classic discovery probe. Many networks block them at the perimeter, and Windows hosts block inbound echo by default on public network profiles. ICMP timestamp and address mask requests sometimes slip through where echo is blocked. Absence of an ICMP reply proves very little.
TCP probes work because a live host must respond to a connection attempt somehow. A SYN sent to a port gets a SYN-ACK if the port is open or a reset (RST) if it is closed; either reply proves the host is there. A TCP ACK sent out of the blue gets an RST from a live host, and can pass through simple packet filters that only block new connection attempts. Probing common ports such as 443, 80 and 22 finds most internet-facing hosts.
UDP probes to common services, such as DNS on 53, SNMP on 161 or NTP on 123, can find hosts that block TCP and ICMP. They are slow and ambiguous: a closed UDP port normally returns an ICMP port unreachable message, which proves the host is up, but an open or filtered port often returns nothing.
Nmap host discovery
Nmap combines these probes. With the -sn option it performs host discovery only, without a port scan (older documentation calls this a ping scan). What it sends by default depends on where it runs and with what privileges. On a local Ethernet segment with administrator privileges, it uses ARP requests. Against remote targets with privileges, its default probes are an ICMP echo request, a TCP SYN to port 443, a TCP ACK to port 80 and an ICMP timestamp request. Without privileges, it falls back to TCP connection attempts to ports 80 and 443.
| Option | Effect |
|---|---|
| -sn | Host discovery only, no port scan |
| -sL | List scan: list the targets and do reverse DNS lookups, sending nothing to the targets themselves |
| -Pn | Skip discovery and treat every target as up (slow on large ranges, but finds hosts that drop all probes) |
| -PS port list | TCP SYN discovery probes to the given ports |
| -PA port list | TCP ACK discovery probes |
| -PU port list | UDP discovery probes |
| -PE, -PP, -PM | ICMP echo, timestamp and address mask requests |
| -PR | ARP discovery on the local network |
| -n and -R | Never or always do reverse DNS resolution |
| -iL file and --excludefile file | Read targets from a file and exclude addresses listed in another |
| -oA basename | Save output in normal, XML and grepable formats at once |
The list scan deserves a mention because it is so often forgotten. It resolves every address in a range to a name using reverse DNS and prints the list, without sending a single packet to the hosts themselves. It is a quick way to double-check a target file before an active scan: if the names that come back belong to some other organization, the range is wrong.
# Double-check the range first: reverse DNS only, nothing sent to the hosts
nmap -sL -iL targets-E1.txt --excludefile exclude-E1.txt
# External discovery with a broader set of probes
sudo nmap -sn -PE -PP -PS22,80,443,3389 -PA80,443 -PU53,161 \
-iL targets-E1.txt --excludefile exclude-E1.txt -oA E1-discovery-20261005sudo nmap -sn -iL targets-E1.txt --excludefile exclude-E1.txtStarting Nmap ( https://nmap.org ) Nmap scan report for mail.prairiefold.example (203.0.113.10) Host is up (0.019s latency). Nmap scan report for vpn.prairiefold.example (203.0.113.20) Host is up (0.021s latency). Nmap scan report for vpn-old.prairiefold.example (203.0.113.21) Host is up (0.020s latency). Nmap scan report for www.prairiefold.example (203.0.113.25) Host is up (0.018s latency). Nmap scan report for staging-portal.prairiefold.example (203.0.113.30) Host is up (0.022s latency). Nmap scan report for sftp-statements.prairiefold.example (203.0.113.40) Host is up (0.024s latency). Nmap scan report for 203.0.113.41 Host is up (0.024s latency). ... Nmap done: 62 IP addresses (14 hosts up) scanned in 6.84 seconds
Reading discovery output is straightforward, with two cautions. First, a host reported as up is only up for the probes that reached it; a host missing from the list may still exist behind a firewall that drops everything. Second, devices in front of the network can distort results. Some firewalls answer probes on behalf of every address in a range, making the whole range look alive. If every single address in a block responds with identical latency, suspect the firewall, not 64 real servers.
Tobias's fourteen live hosts included the nine services on Prairiefold's list, the two VPN addresses, the legacy file transfer server and two addresses with no DNS name. Those two, 203.0.113.41 and 203.0.113.44, became the most interesting items of the week. Lesson 5 follows them.
Internal discovery
Internal testing began a week later. Felix provisioned a network port at head office for Ironwhistle's test laptop on the staff workstation network, as the rules of engagement specified, and a second test point at Branch 07. In this course, the head office server network is represented by 192.0.2.0/25 and Branch 07's workstation network by 192.0.2.128/25; both are documentation ranges standing in for the client's real ones.
Inside a network, discovery works differently. ARP sweeps find everything on the local segment. Routed segments need IP probes, and internal firewalls are usually more permissive than the perimeter, so ICMP and TCP probes find most hosts. Internal discovery also produces far more results: Prairiefold's head office server network held 71 live hosts, and Branch 07's workstation network held 38.
# Local segment: ARP discovery is fast and reliable
sudo nmap -sn -PR 192.0.2.128/25 -oA BR07-arp-20261013
# A dedicated ARP tool lists addresses, hardware addresses and vendors
sudo arp-scan --localnetThe vendor information in ARP results is useful: the first half of a hardware address identifies its manufacturer. Branch 07's results included workstations, two printers, a time clock and an unexpected device whose vendor prefix belonged to a building automation manufacturer. That device went onto the list for fingerprinting and became part of the wireless story in lesson 10.
Passive discovery: listening first
On an internal network, a tester can learn a great deal without sending anything at all. Network protocols are chatty. Hosts broadcast ARP requests, request addresses by DHCP, announce themselves with multicast DNS and LLMNR, and network switches advertise themselves with CDP or LLDP. Simply capturing traffic for a few minutes reveals hosts, names, operating system hints and network devices.
Wireshark is the standard graphical packet analyzer; tcpdump is its command-line counterpart, ideal for capturing to a file on a test device and analyzing later. Both are named in objective 2.4. Capture filters decide what is recorded; display filters in Wireshark decide what is shown.
# Capture ten minutes of broadcast and multicast traffic to a file
sudo timeout 600 tcpdump -i eth0 -w BR07-passive-20261013.pcap \
"arp or port 67 or port 68 or port 5353 or port 5355 or port 137 or ether proto 0x88cc"
# Useful Wireshark display filters when reviewing the capture
# arp who is asking for whom
# dhcp host names and vendor classes in address requests
# mdns or llmnr names announced or requested on the segment
# lldp or cdp switch names, ports and management addressesPassive listening is quiet and safe, which is why Ironwhistle started every internal session with it. It is also a source of findings: LLDP frames revealed switch model and firmware, and LLMNR and NetBIOS name queries showed that name resolution fallbacks were enabled, which attacks covered in COMP-223, PenTest+: Attacks and Exploits, can abuse. The defensive recommendation, disabling LLMNR and NetBIOS over TCP/IP where they are not needed, came straight from this capture.
IPv6
Networks increasingly carry IPv6, and many organizations monitor it less well than IPv4. Sweeping an IPv6 subnet address by address is impractical, because a single /64 contains about 18 quintillion addresses. Instead, testers discover IPv6 hosts by listening for neighbor discovery traffic, by sending a probe to the all-nodes multicast address on the local link, and by collecting AAAA records from DNS. Prairiefold's internal networks had IPv6 enabled by default on Windows hosts, though not routed; Ironwhistle noted that monitoring tools watched only IPv4.
Timing and safety
Discovery scans are light, but timing still matters. Nmap's timing templates run from -T0 (paranoid) to -T5 (insane); -T3 is the default and -T4 is common on reliable networks. Slower timing reduces load and noise. Ironwhistle's rules of engagement capped the packet rate for branch networks, which ran over modest links, and the team used --max-rate to enforce it. Fragile devices, such as old printers, industrial controllers and medical or building systems, can misbehave even under light probing, so discovery on networks containing them is done slowly and with the owner's knowledge.
Comparing discovery with the asset inventory
The most useful thing discovery produces for a client is a comparison. Prairiefold kept an asset inventory in its IT service management platform, and Felix exported the parts covering the head office server network and Branch 07 so Ironwhistle could compare them with what the network actually showed. The comparison sorted every address into one of four groups.
| Group | Meaning | Head office servers | Branch 07 |
|---|---|---|---|
| Known and found | In the inventory and responding | 62 | 33 |
| Found, not known | Responding but missing from the inventory | 9 | 5 |
| Known, not found | In the inventory but not responding to any probe | 4 | 1 |
| Unresolved | Responding, but identity unclear until fingerprinting | 3 | 2 |
Each group means something different. Found but not known is the classic shadow IT problem: devices nobody is patching or monitoring because nobody knows they exist. At Branch 07 those five included the building automation controller and a consumer-grade wireless router plugged in behind a teller station. Known but not found can mean decommissioned equipment never removed from the inventory, a host that drops all probes, or a host that was simply switched off; each needs a short conversation with the client rather than an assumption. The comparison turned discovery from a list of addresses into a finding about asset management, which Gwendolyn said was the most useful page of the interim update.
Tobias learned one more habit here. When an address in the found-not-known group could plausibly belong to someone else, such as a vendor-managed device, he flagged it for Felix before fingerprinting it. Being on Prairiefold's network did not automatically make a device Prairiefold's to test, and the rules of engagement said third-party equipment needed the owner's agreement.
What defenders should see
Every active technique in this course has a defensive mirror. Host discovery from a single source to many destinations in a short time is a classic intrusion detection signature. Prairiefold's security operations team saw the external sweep within minutes, because they had been told to expect it and had a rule for it. They did not see the internal ARP sweep at Branch 07 at all, because nothing monitored ARP on branch networks. That was a detection gap worth reporting.
| Discovery technique | Detection | Reducing exposure |
|---|---|---|
| External ICMP and TCP sweeps | Perimeter IDS and firewall logs | Expose only necessary services; drop unsolicited probes |
| Internal ARP sweeps | ARP monitoring, network access control, switch logs | Network access control on switch ports; segment networks |
| Passive listening | Very hard to detect | Disable unnecessary broadcast protocols; encrypt management traffic |
| IPv6 multicast discovery | IPv6-aware monitoring | Disable IPv6 where unused, or monitor it equally |
Worked problem
Why did a known host not appear?
Felix says the head office has a print server at 192.0.2.60, but internal discovery from the workstation network with default probes did not report it. What could explain this, and what should Tobias try?
Show solution
- The host may be on a different routed segment, so ARP did not reach it, and a host firewall may drop ICMP and TCP probes to the default ports.
- Check whether the print server answers on printer-related ports, for example with TCP SYN probes to 515, 631 and 9100.
- If it still does not respond, scan it with -Pn so Nmap skips discovery and checks ports directly.
- Record which probes it did and did not answer: a host that drops all discovery traffic is behaving well from a defensive point of view.
Answer: Use probes suited to the host's role, or skip discovery with -Pn for that one address, and record the result either way.
Common mistakes
MistakeTyping a range from memory at the command line.
InsteadBuild target files from the scope workbook, have them checked, and use exclusion files.
MistakeConcluding that a host is down because it did not answer ping.
InsteadUse several probe types, and -Pn for important targets that drop discovery traffic.
MistakeBelieving a result where every address in a range is up.
InsteadSuspect a firewall answering on behalf of the range and verify with port scans.
MistakeStarting internal work with an aggressive sweep.
InsteadListen passively first, then probe at a rate the network can handle.
MistakeIgnoring IPv6.
InsteadDiscover IPv6 hosts through neighbor discovery, multicast and AAAA records.
Summary and key terms
- Host discovery finds live addresses so later scans are focused and the asset count can be compared with the client's list.
- ARP is reliable on the local segment; ICMP, TCP and UDP probes work across routers with varying success.
- Nmap -sn performs discovery only; its default probes depend on privileges and location.
- The list scan (-sL) checks a range with reverse DNS without probing hosts.
- Passive capture with Wireshark or tcpdump reveals hosts and protocols without sending traffic.
- IPv6 discovery relies on multicast, neighbor discovery and DNS, not sweeps.
- Timing limits protect fragile networks; detection of sweeps (or its absence) is part of the findings.
- Host discovery
- Finding which addresses in a range have live hosts.
- ARP
- Address Resolution Protocol, which maps IPv4 addresses to hardware addresses on a local segment.
- Ping sweep
- Sending ICMP echo requests to many addresses to see which respond.
- List scan
- An Nmap mode that lists targets and resolves their names without probing them.
- Exclusion file
- A list of addresses a scanning tool must skip.
- LLDP
- Link Layer Discovery Protocol, used by network devices to advertise identity and capabilities.
- Timing template
- An Nmap preset (T0 to T5) that controls scan speed and parallelism.
Practice problems
Work each problem on paper first, then reveal the answer to check.
Why does an ARP sweep find hosts that drop ICMP?
Show answer
Hosts must answer ARP for their own address to communicate on the local segment, regardless of host firewall rules for other traffic.
What does Nmap -Pn change?
Show answer
It skips host discovery and treats every target as up, so ports are scanned even on hosts that do not answer discovery probes.
Name two broadcast or multicast protocols a passive capture can use to identify hosts.
Show answer
Any two of ARP, DHCP, mDNS, LLMNR, NetBIOS name service, LLDP or CDP.
Lesson quiz · 5 questions
Score 60% or more to complete this lesson.
Create a free account to save your progress, take quizzes and earn a certificate.