Send a ping to each IP on a subnet

bot47 picture bot47 · Feb 2, 2009 · Viewed 214.2k times · Source

Is there a command line based way to send pings to each computer in a subnet? Like

for(int i = 1; i < 254; i++)
    ping(192.168.1.i);

to enforce arp resolution?

Answer

Tom picture Tom · Feb 2, 2009

Not all machines have nmap available, but it's a wonderful tool for any network discovery, and certainly better than iterating through independent ping commands.

$ nmap -n -sP 10.0.0.0/24

Starting Nmap 4.20 ( http://insecure.org ) at 2009-02-02 07:41 CST
Host 10.0.0.1 appears to be up.
Host 10.0.0.10 appears to be up.
Host 10.0.0.104 appears to be up.
Host 10.0.0.124 appears to be up.
Host 10.0.0.125 appears to be up.
Host 10.0.0.129 appears to be up.
Nmap finished: 256 IP addresses (6 hosts up) scanned in 2.365 seconds