检测内网IP地址段的存活

#!/bin/bash

function detect(){
ping=`ping -c 1 $1 &>/dev/null`
}

for i in {0..254};do
detect 193.168.1.$i
if [ $? -eq 0 ];then
echo -e "\033[32mIP 193.168.1.$i is up\033[0m"
else
echo -e "\033[31mIP 193.168.1.$i is down\033[0m"
fi
done

 

posted @ 2017-05-11 11:47  孤鸟的悲歌丶  阅读(343)  评论(0编辑  收藏  举报