How to do a ping sweep in Linux

Sometimes it can be handy to ‘see’, what is around you on a network. For instance when you’re using DHCP on a network and you want to find which addresses are already taken. Or you want to check whether specific machines are up and running… Of course there are various tools you can install or use, but there are times that you just can’t reach for the right tool(s)…

You don’t want to do a ping sweep for nothing ;-)…

Of course there is a way of ping sweeping from the command line 🙂 By simply using the ‘FOR’, ‘PIPE’ and ‘GREP’ commands in a clever way.

for i in {1..254}; do ping -c 1 -W 1 192.168.1.$i | grep ‘from’; done

Naturally you can stop the ping sweep by entering Ctrl+z


Suggestions for improving this article are welcome, please let me know and drop me a line.