不言不语

您现在的位置是: 首页 >  PHP

PHP

Centos7关闭防火墙

2022-06-05PHP
在centos7之前,我们临时性的完全关闭防火墙的命令:/etc/init.d/iptable stop。centos 7中防火墙是一个非常的强大的功能了,和之前的有些细微的区别。下面亲测centos7下关闭防火墙。

永久性关闭防火墙:

1、直接关闭防火墙

1
2

[root@Linux ~]# systemctl stop firewalld.service #停止firewall服务
[root@Linux ~]# systemctl disable firewalld.service #禁止firewall开机启动

2、设置 service

1

[root@Linux ~]# yum -y install iptables-services

如果要修改防火墙配置,如增加防火墙端口3306

1

[root@Linux ~]# vi /etc/sysconfig/iptables

增加规则

1

[root@Linux ~]# iptables -A INPUT -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT

保存退出后

1
2

[root@Linux ~]# systemctl restart iptables.service #重启防火墙使配置生效
[root@Linux ~]# systemctl enable iptables.service #设置防火墙开机启动

最后重启系统使设置生效即可。


文章评论