1. it168资讯网首页
  2. 网站教程

CentOS7系统默认firewall防火墙更换为iptables防火墙图文教程

这两天得到消息称CentOS8到明年就不受支持了,很多升级到CentOS8的国内外小伙伴叫苦不迭。但实际上大部分网站环境都是基于CentOS7的,更有甚者还在CentOS6一直不升级。其中CentOS…

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

一、将CentOS7系统默认firewall防火墙改为iptables防火墙

查询firewall防火墙是否在运行

systemctl status firewalld

一般会返回如下代码如图

CentOS7系统默认firewall防火墙更换为iptables防火墙图文教程插图

1、首先停止并屏蔽firewalld服务

停止firewalld服务:

systemctl stop firewalld

屏蔽firewalld服务:

systemctl mask firewalld

2、安装iptables-service软件包

yum install iptables-services

这里输入y进行安装

CentOS7系统默认firewall防火墙更换为iptables防火墙图文教程插图1

3、在引导时启用iptables服务

systemctl enable iptables

4、启动iptables服务

systemctl start iptables

5、保存防火墙规则

service iptables save

再去查看发现已经有了iptables文件

查看iptables防火墙是否启动

systemctl status iptables
CentOS7系统默认firewall防火墙更换为iptables防火墙图文教程插图2

二、CentOS改回firewalld防火墙

1) 开机自动启动firewalld防火墙

systemctl enable firewalld.service

2)关闭开机制动启动

systemctl disable firewalld.service

3)查看状态

systemctl status firewalld

4)启用防火墙firewalld

systemctl start firewalld.service

原创文章,作者:admin,如若转载,请注明出处:https://www.it168.online/webtech/2415/

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注