检查子网内存活的主机

检查子网内存活的主机

因为测试需要,需要查看检测子网的通信情况,因为未知原因,有点虚拟机能ping通,有的ping,故需要对已存在的虚拟都进行扫描
写了一个脚本来检测存在的主机

#!/bin/bash 
# 文件名: ping.sh
for ip in 192.168.$1.{1..255} ; 
do
(
    ping $ip -c2 &> /dev/null ;
    if [ $? -eq 0 ];
    then
    echo $ip is alive
    fi
    )&
done 
wait 

执行./ping.sh 1

猜你喜欢

转载自www.cnblogs.com/mrwuzs/p/10276035.html