首页 > 代码库 > ping命令扫描局域网内的主机
ping命令扫描局域网内的主机
linux: 禁ping
vim /proc/sys/net/ipv4/icmp_echo_ignore_all
0 代表允许 1代表禁止
ping.sh
#!/bin/bash for i in {2..5}; do host=122.152.172.$i ping -c2 $host >/dev/null if [ $? = 0 ] then echo "122.152.172.$i is connected" else echo "122.152.172.$i is not connected" fi done
显示结果:
[root@primary_server workspace]# ./ping.sh 122.152.172.1 is connected 122.152.172.2 is connected 122.152.172.3 is connected 122.152.172.4 is not connected 122.152.172.5 is not connected
本文出自 “yangang” 博客,请务必保留此出处http://yangang.blog.51cto.com/4449016/1426577
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。