Simple bash one-liner to ping an entire network range

Just a quick post…

I knocked this one-liner up as a lazy way of finding out what addresses will answer a ping on a particular address range. I used the ‘seq’ command in Linux to produce the address numbers from 1 to 254 for the for-loop.

Heres the one-liner itself:

for i in `seq 1 254`; do ping -t 3 -c 5 10.10.0.$i; done

So whats happening?

Ping executes with a timeout after 3 pings to each address and will try to execute 5 ping requests to each address that is created by the loop.

You could add whatever else you wanted around the outside of the one-liner to tailor it to your specific needs, for example get the script to only output positive ping results that are returned and exclude timeouts.


(c) Matt Palmer – 21 Nov 2012



One thought on “Simple bash one-liner to ping an entire network range”