check range of IP addresses for connectivity

#!/bin/bash
#####################################################################
##### Script to check range of IP addresses for connectivity #####
##### — Souvik Prasad (20.11.2003.) #####
#####################################################################

#### — configure— ####
network="203.197.118." # the class C network address with a trailing dot
lrange=65 # the lower limit of the range of IPs to scan
urange=127 # the upper limit of the range of IPs to scan
#### –end of configure– ####

while [ $lrange -le $urange ]
do
ip=`echo "$network$lrange"`
case `ping -qnc 3 -w10 $ip 2>&1` in
*’100% loss’*)
echo -e "$ip\txx"
;;
*)
echo -e "$ip\tok"
;;
esac
lrange=`expr $lrange + 1`
done

Leave a Reply

Your email address will not be published. Required fields are marked *