跳到主要内容
轻点工具箱手边的小事,交给我。

firewall-cmd

区分 firewalld 运行时与永久配置

区分 firewalld 运行时与永久配置

用途与范围

firewall-cmd 是 firewalld 客户端,管理区域、服务、端口和策略。运行时与永久配置分开,iptables 本身也能即时改规则,旧“必须全部刷新才生效”的对比不成立。

语法

firewall-cmd [OPTION...]

常用选项与参数

--state 运行状态,--get-active-zones 区域,--zone=NAME --list-all 查看;--permanent 读写永久配置,通常需 reload 才成为运行时;--runtime-to-permanent 用当前覆盖永久配置。

示例

firewall-cmd --state
# 只查询守护进程状态,不开端口、改变区域或重载规则。

结果与使用边界

reload 以永久配置替换运行时,运行时独有改动会丢失;complete-reload 更可能中断连接。--new-service 只是建立服务定义,--add-service 才把定义加入区域,--list-ports 不包括服务定义间接开放的所有端口。旧无效 --enable ports 写法及默认停用防火墙教程已去除。

用途说明核对:2026-11-29 · 项目手册与依据