// 查看设置
[root@wode012 etc]# cat /proc/sys/net/ipv4/icmp_echo_ignore_all
0
// 测试
HuangChao-MacBookPro:~ hchao$ ping a.b.c.d
PING a.b.c.d (a.b.c.d): 56 data bytes
64 bytes from a.b.c.d: icmp_seq=0 ttl=55 time=6.690 ms
64 bytes from a.b.c.d: icmp_seq=1 ttl=55 time=5.536 ms
64 bytes from a.b.c.d: icmp_seq=2 ttl=55 time=23.421 ms
64 bytes from a.b.c.d: icmp_seq=3 ttl=55 time=8.740 ms
^C
--- a.b.c.d ping statistics ---
4 packets transmitted, 4 packets received, 0.0% packet loss
round-trip min/avg/max/stddev = 5.536/11.097/23.421/7.207 ms
HuangChao-MacBookPro:~ hchao$
// 修改配置
[root@wode012 etc]# vi /etc/sysctl.conf
[root@wode012 etc]#
# System default settings live in /usr/lib/sysctl.d/00-system.conf.
# To override those settings, enter new settings here, or in an /etc/sysctl.d/<name>.conf file
# disable ping
net.ipv4.icmp_echo_ignore_all=1
# For more information, see sysctl.conf(5) and sysctl.d(5).
// 生效
[root@wode012 etc]# sysctl -p
net.ipv4.icmp_echo_ignore_all = 1
[root@wode012 etc]#
// 测试
HuangChao-MacBookPro:~ hchao$ ping a.b.c.d
PING a.b.c.d (a.b.c.d): 56 data bytes
Request timeout for icmp_seq 0
Request timeout for icmp_seq 1
Request timeout for icmp_seq 2
Request timeout for icmp_seq 3
Request timeout for icmp_seq 4
Request timeout for icmp_seq 5
Request timeout for icmp_seq 6
Request timeout for icmp_seq 7
Request timeout for icmp_seq 8
^C
--- a.b.c.d ping statistics ---
10 packets transmitted, 0 packets received, 100.0% packet loss
HuangChao-MacBookPro:~ hchao$
本文出自 “黄超的IT笔记” 博客,请务必保留此出处http://huangchao.blog.51cto.com/10446378/1680794
原文地址:http://huangchao.blog.51cto.com/10446378/1680794