标签:ipad for let pad tool 连接 class pre lse
本例以c类地址为例,如果是A类或者B类地址,将脚本稍作修改即可ipaddr=`/usr/sbin/ip a | grep $1 | grep inet | awk '{print $2}'`
netmask=`echo ${ipaddr} | awk -F "/" '{print $2}'`
if [ $netmask -eq 24 ];then
subnets=`echo ${ipaddr} | awk -F "." '{print $1"."$2"."$3"."}'`
acount=0
for i in `seq 1 25`
do
/usr/bin/ping ${subnets}${i} -c 2 > /dev/null
if [ $? -eq 0 ];then
echo "${subnets}$i is online"
let count+=1
else
echo "${subnets}$i is not online"
fi
done
fi
echo "There are $count hosts onlie"执行脚本时需要加上参数(网卡的连接名,如ens33)
标签:ipad for let pad tool 连接 class pre lse
原文地址:http://blog.51cto.com/13434336/2147879