这两天得到消息称CentOS8到明年就不受支持了,很多升级到CentOS8的国内外小伙伴叫苦不迭。但实际上大部分网站环境都是基于CentOS7的,更有甚者还在CentOS6一直不升级。其中CentOS7系统默认是firewall防火墙,用惯了CentOS6系统iptables防火墙的小伙伴非常不习惯,这里就分享一下CentOS7系统默认firewall防火墙更换为iptables防火墙图文教程。
一、将CentOS7系统默认firewall防火墙改为iptables防火墙
查询firewall防火墙是否在运行
systemctl status firewalld
一般会返回如下代码如图

1、首先停止并屏蔽firewalld服务
停止firewalld服务:
systemctl stop firewalld
屏蔽firewalld服务:
systemctl mask firewalld
2、安装iptables-service软件包
yum install iptables-services
这里输入y进行安装
3、在引导时启用iptables服务
systemctl enable iptables
4、启动iptables服务
systemctl start iptables
5、保存防火墙规则
service iptables save
再去查看发现已经有了iptables文件
查看iptables防火墙是否启动
systemctl status iptables
二、CentOS改回firewalld防火墙
1) 开机自动启动firewalld防火墙
systemctl enable firewalld.service
2)关闭开机制动启动
systemctl disable firewalld.service
3)查看状态
systemctl status firewalld
4)启用防火墙firewalld
systemctl start firewalld.service