嘿,我一直在尝试找到一些代码,允许我通过 UCI 更新我的防火墙规则。
我目前添加新规则的方式是这样的:
uci add firewall rule
uci set firewall.@rule[21].name='B Macbook Air'
uci set firewall.@rule[21].src='lan'
uci set firewall.@rule[21].family='ipv4'
uci set firewall.@rule[21].src_ip='192.168.1.227'
uci set firewall.@rule[21].src_mac='00:00:00:00:00:00'
uci set firewall.@rule[21].dest='wan'
uci set firewall.@rule[21].proto='all'
uci set firewall.@rule[21].target='REJECT'
uci set firewall.@rule[21].enabled='1'
uci commit firewall
这会产生正确的规则露西(分支(git-22.347.45520-d30ab74)):
我更新规则之一的启用或禁用的方式是这样的:
uci set firewall.@rule[21].name="B Macbook Air"
uci set firewall.@rule[21].enabled="1"
uci commit firewall
哪个按预期工作,但我想知道是否有一种方法也只需调用防火墙规则名称而不需要知道位置(即:[21])?
像这样:
uci set [email protected]="B Macbook Air"
uci set [email protected]="1"
uci commit firewall
但当然上面的方法是行不通的。给出的错误为
root@turris:~# uci 设置[电子邮件受保护]=“B Macbook Air”
uci:参数无效
这可以吗?