温馨提示×

centos防火墙如何停止

小樊
50
2026-09-30 00:14:04
栏目: 智能运维

在 CentOS 中,防火墙通常是 firewalld(CentOS 7 及以后)。下面按常见情况说明如何停止防火墙。


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

1. 停止防火墙(临时)

systemctl stop firewalld

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

systemctl disable firewalld

3. 查看防火墙状态

systemctl status firewalld

或

firewall-cmd --state

二、CentOS 6 及更早版本(使用 iptables)

1. 停止 iptables

service iptables stop

2. 关闭开机启动

chkconfig iptables off

三、确认是否已完全关闭

systemctl is-enabled firewalld

返回 disabled 表示不会开机启动。


⚠️ 安全提醒

  • 生产环境不建议直接关闭防火墙
  • 推荐做法:开放所需端口,而不是停止防火墙
    示例:
    firewall-cmd --zone=public --add-port=80/tcp --permanent
    firewall-cmd --reload
    

如果你能告诉我 CentOS 版本 和 使用场景(测试/生产),我可以给你更合适的建议。

0 踩