2017-06-15 118 views
0

我有一個主機在我的配置重定向規則,但有時我需要更改ip。UCI。 Lua腳本。如何編輯防火牆規則

[email protected][0]=redirect 
[email protected][0].name='zd_ssh' 
[email protected][0].src='wan' 
[email protected][0].proto='tcp' 
[email protected][0].src_dport='8422' 
[email protected][0].dest='lan' 
[email protected][0].dest_port='22' 
[email protected][0].target='DNAT' 
[email protected][0].dest_ip='192.168.1.200' 
[email protected][1]=redirect 
[email protected][1].name='zd_https' 
[email protected][1].src='wan' 
[email protected][1].proto='tcp' 
[email protected][1].src_dport='8443' 
[email protected][1].dest='lan' 
[email protected][1].dest_port='443' 
[email protected][1].target='DNAT' 
[email protected][1].dest_ip='192.168.1.200' 

在我的腳本添加規則現在我遇到的問題

uci_cursor:set("firewall", "[email protected][0]", "dest_ip", "192.168.1.200") 
uci_cursor:set("firewall", "[email protected][1]", "dest_ip", "192.168.1.200") 

它不工作。我在openwrt wiki中發現「防火牆」是一種類型,而不是一節「。 部分應該看起來像cfg​​02f02f

現在的問題是:如何找到這個cfg02f02f?

uci_cursor:get_all(「system」)does not show me anything。

回答

1

終於找到了解決辦法:

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)