有没有办法在RHEL7中使用firewalld运行保存?

Pet*_*ter 13 iptables systemd firewalld rhel7

我开始使用 RHEL7 并了解一些 systemd 带来的变化。

有没有办法/sbin/service iptables save在firewalld中执行?

$ /sbin/service iptables save
The service command supports only basic LSB actions (start, stop, restart, try-restart, reload, force-reload, status). For other actions, please try to use systemctl.
Run Code Online (Sandbox Code Playgroud)

我可以从文档中找到的最接近的平行是--reload

Reload the firewall without loosing state information:
$ firewall-cmd --reload
Run Code Online (Sandbox Code Playgroud)

但它没有明确说明它是否在保存。

Mic*_*ton 25

RHEL 7.0 中的firewalld 版本没有“保存”脚本,也无法将正在运行的防火墙配置复制到永久配置中。您可以通过添加--permanent到进行更改的命令行来使用 firewalld 保存防火墙更改。没有它,您所做的任何更改都是暂时的,并且会在系统重新启动时丢失。

例如:

firewall-cmd --add-service=http                 # Running config
firewall-cmd --add-service=http --permanent     # Startup config
Run Code Online (Sandbox Code Playgroud)

更高(后 RHEL 7)版本的 firewalld 确实包含一种保存运行配置的方法,现在在 Fedora 和RHEL 7.1 中可用。在这种情况下,命令很简单:

firewall-cmd --runtime-to-permanent
Run Code Online (Sandbox Code Playgroud)

  • 为了继续迈克尔汉普顿的评论,我发现我必须在运行“firewall-cmd --runtime-to-permanent”后重新启动firewalld服务(“systemctl restart firewalld”)才能正确保存防火墙规则,尤其是在不得不通过 iptables 手动删除一些规则之后。firewalld 似乎缓存了一些规则,因此“firewall-cmd --reload”可能会从 firewalld 重新制定应该通过“--runtime-to-permanent”命令删除的规则。 (2认同)
  • 请注意,--runtime-to-permanent 命令不会出现在 tab 补全中,但事实上它确实存在(在 CentOS 7.5 系统上测试)。 (2认同)