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
ping命令扫描局域网内的主机,布布扣,bubuko.com
原文:http://yangang.blog.51cto.com/4449016/1426577