shell脚本实现快速ping网段内的IP地址-创新互联

有时候想看看网段中有哪些IP被用了,可以用这个快速ping做一个初步的判断。可以自己指定测试IP网段,并将测试结果整理排序到文件。

创新互联公司是专业的调兵山网站建设公司,调兵山接单;提供网站建设、成都网站制作,网页设计,网站设计,建网站,PHP网站建设等专业做网站服务;采用PHP框架,可快速的进行调兵山网站开发网页制作和功能扩展;专业做搜索引擎喜爱的网站,专业的做网站团队,希望更多企业前来合作!

#!/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!"

另外有需要云服务器可以了解下创新互联cdcxhl.cn,海内外云服务器15元起步,三天无理由+7*72小时售后在线,公司持有idc许可证,提供“云服务器、裸金属服务器、高防服务器、香港服务器、美国服务器、虚拟主机、免备案服务器”等云主机租用服务以及企业上云的综合解决方案,具有“安全稳定、简单易用、服务可用性高、性价比高”等特点与优势,专为企业上云打造定制,能够满足用户丰富、多元化的应用场景需求。

文章题目:shell脚本实现快速ping网段内的IP地址-创新互联
文章URL:https://www.cdcxhl.com/article42/ccodec.html

成都网站建设公司_创新互联,为您提供商城网站标签优化定制网站响应式网站做网站建站公司

广告

声明:本网站发布的内容(图片、视频和文字)以用户投稿、用户转载内容为主,如果涉及侵权请尽快告知,我们将会在第一时间删除。文章观点不代表本网站立场,如需处理请联系客服。电话:028-86922220;邮箱:631063699@qq.com。内容未经允许不得转载,或转载时需注明来源: 创新互联

绵阳服务器托管