温馨提示×

centos防火墙怎么停止

小樊
41
2026-09-11 18:30:01
栏目: 智能运维

在 CentOS 中,防火墙通常是 firewalld(CentOS 7 及以上)。下面按常见情况说明:


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

1. 停止防火墙(临时)

systemctl stop firewalld

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

systemctl disable firewalld

3. 查看防火墙状态

systemctl status firewalld

4. 如果以后想重新启用

systemctl start firewalld
systemctl enable firewalld

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

停止 iptables

service iptables stop

关闭开机启动

chkconfig iptables off

三、确认是否已停止

firewall-cmd --state
  • not running 表示已停止

四、建议(重要)

⚠️ 生产环境不建议直接关闭防火墙
更推荐做法是放通需要的端口,例如:

firewall-cmd --permanent --add-port=80/tcp
firewall-cmd --reload

如果你能告诉我 CentOS 版本号是想临时关还是永久关,我可以给你更精确的命令。

0