温馨提示×

centos防火墙怎样停止服务

小樊
49
2026-10-11 17:37:04
栏目: 智能运维

在 CentOS 中,防火墙通常是 firewalld(CentOS 7 及以后)。下面分别说明不同版本和方式的“停止防火墙服务”。


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

1. 停止防火墙(临时)

systemctl stop firewalld

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

systemctl disable firewalld

3. 查看防火墙状态

systemctl status firewalld

4. 若想彻底不用的额外操作(可选)

systemctl mask firewalld

这样防止被其他服务误启动


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

停止 iptables 服务

service iptables stop

关闭开机启动

chkconfig iptables off

三、仅临时放行(不推荐直接关防火墙)

如果只是访问某个端口,更安全的方式是:

firewall-cmd --zone=public --add-port=端口/tcp --permanent
firewall-cmd --reload

四、注意事项(重要)

  • 生产环境不建议直接关闭防火墙
  • 云服务器还要看云厂商安全组
  • 关闭后服务器暴露风险较大

如果你告诉我:

  • CentOS 具体版本
  • 是本地还是云服务器
  • 想“临时停”还是“永久关”

我可以给你更合适的命令。

0 踩