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

我开始使用RHEL7并学习一些有关systemd的变化。

有没有办法执行/sbin/service iptables savefirewalld

 $ /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. 

我可以从文档find最接近的并行--reload

 Reload the firewall without loosing state information: $ firewall-cmd --reload 

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

RHEL 7.0中的firewalld版本没有“保存”脚本,也没有办法将正在运行的防火墙configuration复制到永久configuration中。 使用firewalld保存防火墙更改,方法是在执行更改的命令行中添加--permanent 。 没有它,你所做的任何改变都是暂时的,当系统重新启动时将会丢失。

例如:

 firewall-cmd --add-service=http # Running config firewall-cmd --add-service=http --permanent # Startup config 

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

 firewall-cmd --runtime-to-permanent 

我需要添加SIP服务和一些IP

在/ usr / lib / firewalld / services /目录下,我添加基于其他xml服务文件的sip.xml文件。

 <?xml version="1.0" encoding="utf-8"?> <service> <short>SIP</short> <description>This is SIP, Yo! </description> <port protocol="udp" port="5060"/> </service> 

然后我把sip服务加到了firewalld上

 # firewall-cmd --add-service=sip --permanent 

然后我在/etc/firewalld/zones/public.xml中添加了要服务的IP

 <?xml version="1.0" encoding="utf-8"?> <zone> <short>Public</short> <description></description> <service name="dhcpv6-client"/> <service name="http"/> <service name="ssh"/> <service name="https"/> <rule family="ipv4"> <source address="xxxx/32"/> <service name="sip"/> <accept/> </rule> </zone> 

如果添加日志级别,还可以添加LOG

  <rule family="ipv4"> <source address="xxxx/32"/> <service name="sip" <log prefix="sip" level="info"/> <accept/> </rule> 

将规则添加到您的区域后,执行

 # firewall-cmd --reload 

检查你的iptables – 你应该全部设置。