02. Host Discovery with Nmap
1. Nmap - Host Discovery¶
Command:
Explanation:
The -sn option in Nmap performs a "ping scan" to discover live hosts without conducting a full port scan. It sends ICMP echo requests or other probe packets to identify which hosts are active on the specified network.
Options:
<IP Address>: A single IP address to scan.<IP Range>: A range of IPs (e.g.,192.168.1.1-254) or subnet (e.g.,192.168.1.0/24).
Example:
Output:
Lists all active hosts on the 192.168.0.0/24 subnet.
Use Case:
This is useful when you only want to identify which devices are online without probing for open ports.
2. Netdiscover - ARP-based Network Discovery¶
Command:
Explanation: Netdiscover is a network reconnaissance tool used to identify live hosts in a network using ARP (Address Resolution Protocol). It is effective on local networks to detect devices even if ICMP (ping) is disabled.
Options:
-i eth0: Specifies the network interface to use (eth0in this example).-r 192.168.0.1/24: Specifies the range or subnet to scan (CIDR notation).
Example:
Output:
Displays a table with:
- IP Address: The discovered host's IP.
- MAC Address: Hardware address of the device.
- Vendor: Manufacturer of the device based on the MAC address.
Use Case:
Netdiscover is particularly useful for passive or active host discovery in environments where ICMP or other probes are blocked.
Comparison: Nmap vs. Netdiscover¶
| Feature | Nmap -sn | Netdiscover |
|---|---|---|
| Purpose | General-purpose host discovery | ARP-based host discovery |
| Protocol Used | ICMP, ARP, or other probes | ARP |
| Environment | Works on any network (local or remote) | Works on local networks only |
| Output Details | IP addresses of live hosts | IP, MAC addresses, and device vendors |
| Use Case | Identify active hosts in a wide network | Identify devices on a local network |
Practical Scenarios¶
-
Scan a Local Subnet for Active Devices:
Result: Identifies all live hosts in the
192.168.1.0/24subnet. -
Detect Devices on a WiFi Network:
Result: Lists all devices connected to the WiFi network, including their IPs and MAC addresses.
Key Points¶
- Nmap: More versatile and works on local and remote networks. Best for network mapping and host discovery.
- Netdiscover: Simple and effective for discovering devices on a local network using ARP. Ideal for environments with restricted protocols.
- Combination: Using both tools provides a comprehensive view of active devices in a network.
These tools are essential in network reconnaissance and security auditing to identify active hosts and potential targets. Always ensure ethical and legal use.