美文网首页
批量发ping和测试端口

批量发ping和测试端口

作者: 平头哥2 | 来源:发表于2020-04-29 16:09 被阅读0次

批量发ping

#! /bin/bash
for i in `cat allip`
do
ping=`ping -c 1 $i|grep loss|awk '{print $6}'|awk -F "%" '{print $1}'`
if [ $ping -eq 100  ];then
echo ping $i fail
else
echo ping $i ok
fi
done

allip

10.5.160.26
10.5.160.27
10.5.160.28
10.5.47.220
10.5.47.221
10.5.47.222
10.5.47.223
10.5.47.224

批量检测端口

#!/bin/bash  
cat ./ip-ports.txt | while read line
do
  nc -w 10 -z $line > /dev/null 2>&1
  if [ $? -eq 0 ]
  then
    echo $line:ok
  else
    echo $line:fail
  fi
done
10.5.160.27 554
10.5.160.28 554
10.5.47.220 554
10.5.47.221 554
10.5.47.222 554
10.5.47.223 554
10.5.47.224 554

相关文章

网友评论

      本文标题:批量发ping和测试端口

      本文链接:https://www.haomeiwen.com/subject/kvhnwhtx.html