Nmap Tutorial Series 2: Nmap Host Discovery

Nmap Discovery Scan

Now that you have a basic understanding of what Nmap is and its basic commands, we can dig a bit further and start to talk about Nmap Host Discovery options. When you start working for a client and you are presented with a new network, the first thing you want to do is to reduce the list of devices (or IPs) in the network into a list that only contains devices that are interesting for further investigation.

Gladly, we have Nmap Host Discovery to help us with this. In this article, we will go through all of the Nmap Host Discovery options and I explain what each option does.

Note: If you want to learn how to run Nmap on Windows using WSL 2, make sure to check out our complete WSL 2 tutorial series.

👀 This Tutorial has some related Articles!
👉 Part 1 - Nmap Basics 👉 Part 2 - Nmap Host Discovery 👉 Part 3 - Advanced Nmap Commands 👉 Part 4 - Nmap NSE Scripts 👉 Part 5 - Nmap on Windows

Table of Contents

Nmap Host Discovery Options

First, let’s take a brief look at all the available options:

Command Option
-sL List scan
-sn No port scan
-Pn No ping
-PS TCP SYN ping
-PA TCP ACK ping
-PU UDP ping
-PY SCTP INIT ping
-PE; -PP; -PM ICMP ping types
-P0 IP Protocol ping
-PR ARP ping
–disable-arp-ping No ARP or ND ping
–traceroute Trace path to host
-n No DNS resolution
-R DNS resolution for all targets
–resolve-all Scan each resolved address
–system-dns Use system DNS resolver
–dns-servers Servers to use for DNS queries

List Scan (-sL)

Terminalbash
nmap -sL 192.168.56.100-105

The list scan lists each host of the network without sending any packets to the hosts themselves. I found that this command does not work all the time, depending on what kind of setup you run it against.

Nmap List Scan

No Port Scan (-sn)

Terminalbash
nmap -sn 192.168.56.100-105

The no port scan option simply means that you don’t run a port scan after host discovery is done. It only prints out the available hosts that responded to the discovery probes. You can also call this a ping scan. According to Nmap.org, this is one step more intrusive than the previous list scan. It could be called light reconnaissance because it is not attracting too much attention.

Nmap No Port Scan

No Ping Scan(-Pn)

Terminalbash
nmap -Pn 192.168.56.100-105

The no ping scan skips the complete Nmap discovery process. Nmap directly starts to run it’s default port scans (1000 most used) if it finds the target IP is up.

Nmap No Ping Scan

TCP SYN Ping

Terminalbash
nmap -PS 192.168.56.100-105

This scanning option sends an empty TCP packet with the SYN flag attached to it. It defaults to port 80. The SYN flag tells the remote system that you are attempting to connect to it. If the port appears to be open, the target host will start the second step of the three-way TCP handshake by responding with an SYN/ACK TCP package.

This is especially useful for certain systems that block ICMP ping requests.

You can also change the default port 80 to something like port 22, 25, 113, 443, and so on. To do that, you can run:

Terminalbash
nmap -PS22 192.168.56.100-105
Nmap TCP SYN Ping

TCP ACK Ping

Terminalbash
nmap -PA 192.168.56.100-105

This method is also useful for networks that block ICMP requests. It discovers hosts by responding to nonexistent TCP connections to provoke a response from a target. If it founds a target to be up, it runs a default port scan against it.

Nmap TCP ACK Ping

UDP Ping

Terminalbash
sudo nmap -PU 192.168.56.100-105

The UDP ping sends UDP packets to get a response from a target. Most networks/firewalls will block UDP requests if they are properly configured, although it is worth a try to run it anyway. If you are not logged in as root, you need to add the sudo prefix to the command.

You are also able to change the default UDP port (80) by using nmap -PU22 or whatever port you like instead.

Nmap UDP Ping

SCTP INIT Ping

Terminalbash
nmap -PY 192.168.56.100-105

The SCTP (Stream Control Transmission Protocol) is mostly used to discover VOIP(Voice over IP, IP Telephony) based systems. You can also change the default port (80) by using nmap -PY22 or whatever port you like.

Nmap SCTP INIT ping

ICMP Echo Ping

Terminalbash
nmap -PE 192.168.56.100-105

This sends a default ICMP ping to a target and checks if it replies. Usually, if a network is properly configured, devices are set up to not reply to ICMP requests.

nmap icmp echo ping

ICMP Timestamp Ping

Terminalbash
nmap -PP 192.168.56.100-105

As mentioned above, most systems are, or should be, configured to block ICMP Echo Pings. It is possible tho, that they still allow ICMP Timestamp pings. So this is always a good option to try.

nmap icmp timestamp ping

ICMP Address Mask Ping

Terminalbash
nmap -PM 192.168.56.103

This Address Mask Ping also uses an alternative ICMP request to provoke a response from a target. Another option to possibly bypass a firewall that is blocking default ICMP requests.

nmap icmp address mask ping

IP Protocol Ping

Terminalbash
sudo nmap -PO 192.168.56.103

The IP protocol ping allows you to send packets with specified protocol to the target. However, if you do not specify any particular protocol, the default protocols ICMP, IGMP, and IP-in-IP will be used. To specify a protocol use nmap -PO1,2,3,4 and so on. You find a list of all protocol numbers here.

nmap ip protocol ping

ARP Ping

Terminalbash
sudo nmap -PR 192.168.56.103

The Arp ping. This is the fastest method of discovering hosts on a network as of now. The biggest advantage is tho, that ARP requests can’t be blocked by hosts on a network, no matter if there is a firewall involved or not. You have to have access to the local network tho.

nmap arp ping

Traceroute

Terminalbash
sudo nmap --traceroute 192.168.56.103

If you have messed with networking before, you probably came across the traceroute (or tracert on Windows) command before. This is the same. It traces a route to the designated target. The image below is just an example of the command. If you’d run it against google.com or any domain, the TRACEROUTE output would be much longer. I won’t do that here to avoid exposing my own IP.

nmap traceroute

Force Reverse DNS Resolution

Terminalbash
nmap -R 192.168.56.103

Normally Nmap would only do reverse DNS lookups for hosts that are online. With the -R tag, you can enforce this and Nmap will try to resolve DNS names of all the specified IP addresses. Be aware tho, the -R option will decrease your scan performance tremendously.

nmap force reverse dns resolution

Disable Reverse DNS Resolution

Terminalbash
nmap -n 192.168.56.103

As mentioned in the previous Force Reverse DNS Resolution command, per default DNS resolution is only used against hosts that appear online. You can disable DNS resolution altogether if you do not need it. This will increase your scan performance and decrease your scan time tremendously.

With -n option: 0.10 seconds

nmap disable reverse dns resolution

Without -n option: 16.58 second

nmap disable reverse dns resolution

I’ll leave the math to you.

Alternative DNS Lookup Method

Terminalbash
nmap --system-dns 192.168.56.103

While not very often used in the field, this option allows you to tell Nmap to use the host systems DNS server for the DNS lookup. This scan slows down your scan time even more than the normal Reverse DNS Lookup. Just recognize the command exists.

In my example, the scan time appears fast because I run it on an isolated VirtualBox network. In reality, that is most likely not the case.

nmap alternative dns lookup method

Manually Specify DNS Servers

Terminalbash
nmap --dns-servers YourDnsServerAddress 192.168.56.103

The last option we look at is used to manually specify a DNS server for your Nmap scan. This could be used if you want to avoid that your DNS request appears in the local DNS server.

Conclusion

This should give you a good idea of how Nmap Host Discovery works and what kind of commands you can work with. In the next part of the series, we will look at some more advanced scanning techniques. Make sure to also check out my YouTube channel, as there is a video to every article.

👀 This Tutorial has some related Articles!
👉 Part 1 - Nmap Basics 👉 Part 2 - Nmap Host Discovery 👉 Part 3 - Advanced Nmap Commands 👉 Part 4 - Nmap NSE Scripts 👉 Part 5 - Nmap on Windows

whoami

Stefan

Stefan founded Ceos3c in 2016 and has spent a decade teaching cybersecurity, Linux, and web development through hands-on tutorials. He builds and ships real products while sharing his journey: ProofSwap.me, XPMetric.com, and EasyEarningsTracker.com. Find him on YouTube (youtube.com/stefanrows) and X (@StefanRows).

2 thoughts on “Nmap Tutorial Series 2: Nmap Host Discovery”

  1. Great post! I found the explanations on different host discovery techniques really helpful. The examples you provided made it easy to understand how to effectively use Nmap for scanning. Looking forward to the next part of the series!

Comments are closed. I keep the discussion here because the answers still help.