内核参数禁ping方法
1.修改文件 /etc/sysctl.conf,在文件末尾增加一行命令
命令:net.ipv4.icmp_echo_ignore_all = 1
2.保存文件后,运行刷新命令,更新配置
命令:sysctl -p
iptables防火墙方法
1.允许ping命令
iptables -A INPUT -p icmp --icmp-type echo-request -j ACCEPT iptables -A OUTPUT -p icmp --icmp-type echo-reply -j ACCEPT
或者也可以临时停止防火墙:
service iptables stop
2.禁止ping命令
iptables -A INPUT -p icmp --icmp-type 8 -s 0/0 -j DROP
注:centos6和centos7关闭禁用防火墙命令
centos6:
service iptables stop
chkconfig iptables off
centos7:
systemctl stop firewalld
systemctl disable firewalld
分类:Centos
标签:
评论已关闭!