51工具盒子

依楼听风雨
笑看云卷云舒,淡观潮起潮落

Centos7关闭firewall防火墙,启用iptables防火墙

从Centos7开始默认使用firewall防火墙了

换成iptables防火墙,操作步骤如下:

关闭firewalld防火墙,关闭开机自启
systemctl stop firewalld.service systemctl disable firewalld.service

|-----|----------------------------------------------------------------------| | 1 2 | systemctl stop firewalld.service systemctl disable firewalld.service |

安装iptables防火墙,设置开机自启
yum -y install iptables-services net-tools systemctl enable iptables.service

|-----|------------------------------------------------------------------------------| | 1 2 | yum -y install iptables-services net-tools systemctl enable iptables.service |

然后编辑iptables防火墙规则就好了
vim /etc/sysconfig/iptables

|---|-----------------------------| | 1 | vim /etc/sysconfig/iptables |

来个示例:
*filter :INPUT ACCEPT [0:0] :FORWARD ACCEPT [0:0] :OUTPUT ACCEPT [0:0] -A INPUT -m state --state RELATED,ESTABLISHED -j ACCEPT -A INPUT -p icmp -j ACCEPT -A INPUT -i lo -j ACCEPT -A INPUT -p tcp -m state --state NEW -m tcp --dport 80 -j ACCEPT -A INPUT -j REJECT --reject-with icmp-host-prohibited -A FORWARD -j REJECT --reject-with icmp-host-prohibited COMMIT

|-------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | 1 2 3 4 5 6 7 8 9 10 11 | *filter :INPUT ACCEPT [0:0] :FORWARD ACCEPT [0:0] :OUTPUT ACCEPT [0:0] -A INPUT -m state --state RELATED,ESTABLISHED -j ACCEPT -A INPUT -p icmp -j ACCEPT -A INPUT -i lo -j ACCEPT -A INPUT -p tcp -m state --state NEW -m tcp --dport 80 -j ACCEPT -A INPUT -j REJECT --reject-with icmp-host-prohibited -A FORWARD -j REJECT --reject-with icmp-host-prohibited COMMIT |


赞(0)
未经允许不得转载:工具盒子 » Centos7关闭firewall防火墙,启用iptables防火墙