将iptables规则重写为firewall-cmd

时间:2018-04-08 07:59:20

标签: linux iptables

我对Centos 7使用这些iptables规则:

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

但重新启动后,即使我运行iptables-save > /etc/sysconfig/iptables

,也不会保存

我如何为firewall-cmd重写它们?

1 个答案:

答案 0 :(得分:0)

RHEL / CentOS提供了简单的方法来永久保存IPv4和IPv6的iptables规则。 有一项名为&#34; iptables&#34;的服务。必须启用此功能。

# 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文件中。您也可以使用init脚本来保存当前规则。

# service iptables save

请查看以下链接了解详情:

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