Scanning random targets

Nmap supports a very interesting feature that allows us to run scans against random targets on the Internet. This is very useful when conducting research that needs a sample of random hosts.

This recipe shows you how to generate random hosts as targets of your Nmap scans.

How to do it...

To generate a random target list of 100 hosts, use the following Nmap command:

$ nmap -iR 100

Nmap will generate a list of 100 external IP addresses and scan them using the specified options. Let's combine this option with a ping scan:

$ nmap -sP -iR 3
Nmap scan report for host86-190-227-45.wlms-broadband.com (86.190.227.45)
Host is up (0.000072s latency).
Nmap scan report for 126.182.245.207
Host is up (0.00023s latency).
Nmap scan report ...

Get Nmap 6: Network Exploration and Security Auditing Cookbook now with the O’Reilly learning platform.

O’Reilly members experience live online training, plus books, videos, and digital content from nearly 200 publishers.