【问题标题】:Rewrite iptables rules to firewall-cmd将 iptables 规则重写为 firewall-cmd
【发布时间】:2018-05-03 13:55:42
【问题描述】:

我将这些 iptables 规则用于 Centos 7:

iptables --table nat --append POSTROUTING --out-interface <internet_interface> -j MASQUERADE
iptables --append FORWARD --in-interface <internal_interface> -j ACCEPT

但重启后,即使我运行iptables-save &gt; /etc/sysconfig/iptables,它们也没有保存

如何为firewall-cmd 重写它们?

【问题讨论】:

  • 所以你的要求是让他们在重启后使用 iptables 或 firewall-cmd 在 Centos 7 中工作?
  • @TarunLalwani 正确 - 我需要将它们重写到 firewall-cmd 并在重启后工作。
  • 请添加systemctl status firewalldsystemctl status iptables的输出

标签: linux iptables


【解决方案1】:

RHEL/CentOS 提供了简单的方法来永久保存 IPv4 和 IPv6 的 iptables 规则。 有一个名为“iptables”的服务。这必须启用。

# chkconfig --list | grep iptables
  iptables          0:off   1:off   2:on    3:on    4:on    5:on    6:off
# chkconfig iptables on

对于 IPv4,规则保存在文件 /etc/sysconfig/iptables 中,对于 IPv6,规则保存在文件 /etc/sysconfig/ip6tables 中。您也可以使用初始化脚本来保存当前规则。

# service iptables save

详情请查看以下链接:

https://www.thomas-krenn.com/en/wiki/Saving_Iptables_Firewall_Rules_Permanently

【讨论】:

  • 好的,但我需要firewalld语法的规则。
  • firewalld 的界面与您的问题完全不同。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2014-06-30
  • 2016-08-09
  • 2014-01-11
  • 2012-08-22
相关资源
最近更新 更多