您好,登录后才能下订单哦!
有时候想看看网段中有哪些IP被用了,可以用这个快速ping做一个初步的判断。可以自己指定测试IP网段,并将测试结果整理排序到文件。
#!/bin/bash
#V1.0 2019-09-10
#Ping test shell script by tutor
clear
>ip-up.txt
>ip-down.txt
while true;
do
read -p "Please input the ip segment for ping test(like 192.168.100) : " segment
if [ -z $segment ] ; then
segment="192.168.100"
fi
echo -n "the ip segment is ${segment} , are you sure to continue [y/n] ? "
read action
if [ -z $action ] ; then
break
fi
if [ "$action" = "y" ]; then
break
fi
done
echo "ping test is ready to run! "
for i in {1..254}
do
{
ping -c2 -W1 ${segment}.${i} &>/dev/null
if [ $? -eq 0 ]; then
echo "${segment}.$i is up" &>/dev/null >> ip-up.txt
else
echo "${segment}.$i is down" &>/dev/null >> ip-down.txt
fi
}&
done
wait
sort -n -k 4 -t . ip-up.txt -o ip-up.txt
cat ip-up.txt
sort -n -k 4 -t . ip-down.txt -o ip-down.txt
cat ip-down.txt
echo "ping test are finished!"
免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。