ping是通的
[root@nginx-2 ~]# ping 192.168.1.227
PING 192.168.1.227 (192.168.1.227) 56(84) bytes of data.
64 bytes from 192.168.1.227: icmp_seq=1 ttl=64 time=0.477 ms
64 bytes from 192.168.1.227: icmp_seq=2 ttl=64 time=0.139 ms
64 bytes from 192.168.1.227: icmp_seq=3 ttl=64 time=0.132 ms
64 bytes from 192.168.1.227: icmp_seq=4 ttl=64 time=0.101 ms
64 bytes from 192.168.1.227: icmp_seq=5 ttl=64 time=0.119 ms
64 bytes from 192.168.1.227: icmp_seq=6 ttl=64 time=0.119 ms
^C
--- 192.168.1.227 ping statistics ---
6 packets transmitted, 6 received, 0% packet loss, time 4999ms
rtt min/avg/max/mdev = 0.101/0.181/0.477/0.133 ms
禁用ping
[root@nginx-1 ~]# vim /etc/sysctl.conf
net.ipv4.icmp_echo_ignore_all=1
使其生效
[root@nginx-1 ~]# sysctl -p
net.ipv4.icmp_echo_ignore_all = 1
1代表禁止,0代表允许 修改完成后保存退出
测试
[root@nginx-2 ~]# ping 192.168.1.227
PING 192.168.1.227 (192.168.1.227) 56(84) bytes of data.
想要开启ping,直接改配置文件或者删除哪一行即可。