CentOS 7 防火墙常用操作及常见问题处理

本文详细介绍如何在CentOS系统中进行防火墙的基本操作,包括启动、关闭、添加放行端口、锁定与解锁防火墙服务,以及如何将防火墙从firewall替换成iptables。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

一、常用操作

1、启动防火墙:

systemctl start firewalld.service

2、关闭防火墙:

systemctl stop firewalld.service

3、添加放行端口:

firewall-cmd --zone=public --add-port=8161/tcp --permanent (--permanent永久生效,没有此参数重启后失效)

4、锁定防火墙服务(防止添加端口等操作):

systemctl mask firewalld

5、取消锁定:(当出现 “firewalld.service: Unit is masked” 错误时,说明服务被锁定,此时我们取消锁定即可)

systemctl unmask firewalld

二、附录

CentOS 7 默认使用的是firewall作为防火墙,可通过如下操作改为iptables防火墙。

1、停止 firewall

systemctl stop firewalld.service

2、禁止 firewall 开机启动

systemctl disable firewalld.service

3、安装 iptables-services

yum install iptables-services

4、启用iptables-services

systemctl enable iptables

5、启动 iptables

service iptables start

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值