Send a ping to each IP on a subnet Send a ping to each IP on a subnet shell shell

Send a ping to each IP on a subnet


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/24Starting Nmap 4.20 ( http://insecure.org ) at 2009-02-02 07:41 CSTHost 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


I would suggest the use of fping with the mask option, since you are not restricting yourself in ping.

fping -g 192.168.1.0/24

The response will be easy to parse in a script:

192.168.1.1 is alive192.168.1.2 is alive192.168.1.3 is alive192.168.1.5 is alive...192.168.1.4 is unreachable192.168.1.6 is unreachable192.168.1.7 is unreachable...

Note: Using the argument -a will restrict the output to reachable ip addresses, you may want to use it otherwise fping will also print unreachable addresses:

fping -a -g 192.168.1.0/24

From man:

fping differs from ping in that you can specify any number of targets on the command line, or specify a file containing the lists of targets to ping. Instead of sending to one target until it times out or replies, fping will send out a ping packet and move on to the next target in a round-robin fashion.

More info: http://fping.org/


Broadcast ping:

$ ping 192.168.1.255PING 192.168.1.255 (192.168.1.255): 56 data bytes64 bytes from 192.168.1.154: icmp_seq=0 ttl=64 time=0.104 ms64 bytes from 192.168.1.51: icmp_seq=0 ttl=64 time=2.058 ms (DUP!)64 bytes from 192.168.1.151: icmp_seq=0 ttl=64 time=2.135 ms (DUP!)...

(Add a -b option on Linux)