centos7如何关闭防火墙

2023-04-18 10:44:00 centos7 防火墙 关闭

CentOS 7 中,关闭防火墙可以使用两种方法:

第一种方法是使用firewall-cmd命令,步骤如下:

1、使用root用户登录系统,在命令行输入:firewall-cmd --state,查看防火墙状态;

2、输入:firewall-cmd --zone=public --permanent --add-port=80/tcp,添加端口80;

3、输入:firewall-cmd --reload,重新加载防火墙规则;

4、输入:systemctl stop firewalld.service,停止firewalld服务;

5、输入:systemctl disable firewalld.service,禁用firewalld服务;

第二种方法是使用iptables命令,步骤如下:

1、使用root用户登录系统,在命令行输入:iptables -L,查看防火墙状态;

2、输入:iptables -A INPUT -p tcp --dport 80 -j ACCEPT,添加端口80;

3、输入:service iptables save,保存iptables规则;

4、输入:service iptables stop,停止iptables服务;

5、输入:chkconfig iptables off,禁用iptables服务;

以上就是CentOS 7如何关闭防火墙的两种方法,分别使用firewall-cmd和iptables命令,大家可以根据自己的实际情况,选择合适的方法,来关闭防火墙。

相关文章