如何通过命令行使用IP地址组创建OS X Server Admin防火墙规则?


0

(Lion)Server Admin.app具有将防火墙规则应用于ip地址组的强大功能,而无需编辑ipfw配置文件。

但是必须使用Server Admin GUI输入大而长的IP地址列表是一项繁琐的任务。

因此,我想知道如何从命令行创建防火墙IP地址组

我知道有一个/usr/sbin/serveradmin可以输出设置的功能,例如使用$ sudo serveradmin settings ipfilter:ipAddressGroupsWithRules:_array_id:10-net:*哪个输出:

ipfilter:ipAddressGroupsWithRules:_array_id:10-net:rules = _empty_array
ipfilter:ipAddressGroupsWithRules:_array_id:10-net:readOnly = no
ipfilter:ipAddressGroupsWithRules:_array_id:10-net:allowAll = no
ipfilter:ipAddressGroupsWithRules:_array_id:10-net:addresses:_array_index:0 = "10.0.0.0/8"
ipfilter:ipAddressGroupsWithRules:_array_id:10-net:name = "10-net"

哪个可以使用将文件转储到文件$ sudo serveradmin settings ipfilter:ipAddressGroupsWithRules:_array_id:10-net:* > 10-net.txt。但是,然后编辑该文件以将其重命名为新的组,例如:

ipfilter:ipAddressGroupsWithRules:_array_id:11-net:rules = _empty_array
ipfilter:ipAddressGroupsWithRules:_array_id:11-net:readOnly = no
ipfilter:ipAddressGroupsWithRules:_array_id:11-net:allowAll = no
ipfilter:ipAddressGroupsWithRules:_array_id:11-net:addresses:_array_index:0 = "11.0.0.0/8"
ipfilter:ipAddressGroupsWithRules:_array_id:11-net:name = "11-net"

并将其加载到serveradmin中$ sudo serveradmin settings < 10-net.txt,不会在ipfilter中创建新的“ ipAddressGroupsWithRules”规则。经验证$ sudo serveradmin settings ipfilter:ipAddressGroupsWithRules:_array_id:11-net:*

我究竟做错了什么?

Answers:


0

经过12小时的搜索并且没有找到ipfilter:ipAddressGroupsWithRules的任何示例,此https://help.apple.com/advancedserveradmin/mac/10.7/#apdA0111C46-F018-4C2C-B8D1-EDAEF73AC27E带来了有用的见解。

创建新规则(而不更新现有规则)唯一需要更改的是创建规则的第一行。例如:

ipfilter:ipAddressGroupsWithRules:_array_id:11-net = create
ipfilter:ipAddressGroupsWithRules:_array_id:11-net:readOnly = no
ipfilter:ipAddressGroupsWithRules:_array_id:11-net:allowAll = no
ipfilter:ipAddressGroupsWithRules:_array_id:11-net:addresses:_array_index:0 = "11.0.0.0/8"
ipfilter:ipAddressGroupsWithRules:_array_id:11-net:name = "11-net"

现在的输出$ sudo serveradmin settings < 10-net.txt不再:

ipfilter:ipAddressGroupsWithRules = _empty_array

但:

ipfilter:ipAddressGroupsWithRules:_array_id:11-net:readOnly = no
ipfilter:ipAddressGroupsWithRules:_array_id:11-net:allowAll = no
ipfilter:ipAddressGroupsWithRules:_array_id:11-net:addresses:_array_index:0 = "11.0.0.0/8"
ipfilter:ipAddressGroupsWithRules:_array_id:11-net:rules = _empty_array
ipfilter:ipAddressGroupsWithRules:_array_id:11-net:name = "11-net"

这是成功输入新设置的同义词。

By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.