Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/apache-kafka/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
UCI。Lua脚本。如何编辑防火墙规则_Lua_Openwrt_Luci_Uci - Fatal编程技术网

UCI。Lua脚本。如何编辑防火墙规则

UCI。Lua脚本。如何编辑防火墙规则,lua,openwrt,luci,uci,Lua,Openwrt,Luci,Uci,我的配置中有一个主机的重定向规则,但有时我需要更改ip firewall.@redirect[0]=redirect firewall.@redirect[0].name='zd_ssh' firewall.@redirect[0].src='wan' firewall.@redirect[0].proto='tcp' firewall.@redirect[0].src_dport='8422' firewall.@redirect[0].dest='lan' firewall.@redirec

我的配置中有一个主机的重定向规则,但有时我需要更改ip

firewall.@redirect[0]=redirect
firewall.@redirect[0].name='zd_ssh'
firewall.@redirect[0].src='wan'
firewall.@redirect[0].proto='tcp'
firewall.@redirect[0].src_dport='8422'
firewall.@redirect[0].dest='lan'
firewall.@redirect[0].dest_port='22'
firewall.@redirect[0].target='DNAT'
firewall.@redirect[0].dest_ip='192.168.1.200'
firewall.@redirect[1]=redirect
firewall.@redirect[1].name='zd_https'
firewall.@redirect[1].src='wan'
firewall.@redirect[1].proto='tcp'
firewall.@redirect[1].src_dport='8443'
firewall.@redirect[1].dest='lan'
firewall.@redirect[1].dest_port='443'
firewall.@redirect[1].target='DNAT'
firewall.@redirect[1].dest_ip='192.168.1.200'
现在我在脚本中添加规则时遇到问题

uci_cursor:set("firewall", "firewall.@redirect[0]", "dest_ip", "192.168.1.200")
uci_cursor:set("firewall", "firewall.@redirect[1]", "dest_ip", "192.168.1.200")
它不起作用。我在OpenWRTwiki中发现,“防火墙”是一种类型,而不是一个节。 节应类似于cfg02f02f

现在的问题是:如何找到这个cfg02f02f


uci\u光标:get\u all(“系统”)不会显示任何内容。

最终找到解决方案:

require "uci"
x = uci.cursor()

x:foreach("firewall", "redirect", function(s)
     print('------------------')
     for key, value in pairs(s) do
         print(key .. ': ' .. tostring(value))
     end
end)