Using arp to list available host

By Andreas Schickedanz Jul 22, 2013

The last few days I was very busy and had no time to hang out or write a blog post. Nothing changed, I am still busy, but here are a few tips on how you could list all responding IP addresses within your network.

Today I had to figure out which IP address the DHCP server assigned to the weather station I connected to the internal network, so I could connect to it using the web interface of the station. Therefore I wrote a small bash script which receives a net address with the last number replaced with an asterisk:


for i in {1..254}
   host=`echo $net | sed 's/\*/'${i}'/g'`
   ping=`ping -c 1 $host | grep bytes | wc -l`

   if [ $ping -gt 1 ];then
      echo "$host is up!"
      available=$(($available + 1))

if [ "$available" -eq "0" ];then
   echo "No hosts in this net."

Save this script to If you would like to list all hosts of the internal network 192.168.1.*, just enter the following line within your terminal:

./ 192.168.1.*

However, this will take some time and will either return a list of available host or prompt “No hosts in this net.”. A much faster way to do this is using the arp command:

arp -a | grep 192.168.1

This will display all reachable hosts with the prefix of your net in the alternative (BSD) style.

Hope this will help someone. Until next time - Happy scripting!

is a Computer Science MSc. interested in hardware hacking, embedded Linux, compilers, etc.