检测内网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 "33[32mIP 193.168.1.$i is up33[0m"
else
echo -e "33[31mIP 193.168.1.$i is down33[0m"
fi
done

原文地址:https://www.cnblogs.com/sjie0224/p/6840204.html