温馨提示×

centos防火墙怎样重启

小樊
38
2026-09-30 00:13:02
栏目: 智能运维

在 CentOS 中,防火墙一般是 firewalld(CentOS 7 及以上默认)。下面是常用的重启方法:

一、使用 systemctl(推荐)

# 重启防火墙
systemctl restart firewalld

# 查看防火墙状态
systemctl status firewalld

# 设置开机自启(可选)
systemctl enable firewalld

二、使用 firewall-cmd(重新加载规则,不算“重启服务”)

如果只是想重新加载防火墙规则,可以用:

firewall-cmd --reload

这不会中断已有连接,比 restart 更平滑。

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

如果是老版本 CentOS:

service iptables restart

或

/etc/init.d/iptables restart

四、确认防火墙是否运行

firewall-cmd --state

返回 running 表示正在运行。

如果你是想关闭/开启防火墙或开放某个端口,也可以告诉我具体需求。

0 踩