温馨提示×

centos防火墙怎样永久关

小樊
50
2026-09-21 03:26:33
栏目: 智能运维

在 CentOS 中“永久关闭防火墙”通常指 禁用 firewalld 服务,使其开机不启动,并可选择立即停止当前运行。


一、CentOS 7 / 8 / Stream(使用 firewalld)

1️⃣ 停止防火墙(当前生效)

systemctl stop firewalld

2️⃣ 禁止开机启动(永久关闭)

systemctl disable firewalld

3️⃣ 确认状态

systemctl status firewalld

看到 inactive (dead) 且 disabled 即成功。


二、CentOS 6(使用 iptables,老版本)

service iptables stop
chkconfig iptables off

三、额外说明(很重要)

⚠️ 安全风险提示

生产环境不建议完全关闭防火墙,推荐做法是:

  • 开放指定端口(如 80、443、22)
firewall-cmd --permanent --add-port=80/tcp
firewall-cmd --reload

如果你只是临时测试

可以只执行:

systemctl stop firewalld

不执行 disable,重启后防火墙会自动恢复。


四、确认系统版本

cat /etc/redhat-release

如果你告诉我 CentOS 版本 + 使用场景(服务器/测试/内网),我可以给你更合适的防火墙方案。

0 踩