Command Line Ping Sweep

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 see 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

This entry was posted in CentOS, Dedicated Server, General, Tips and Tricks. Bookmark the permalink.

Leave a Reply