2 LuCI - Lua Configuration Interface
4 Copyright 2008 Steven Barth <steven@midlink.org>
6 Licensed under the Apache License, Version 2.0 (the "License");
7 you may not use this file except in compliance with the License.
8 You may obtain a copy of the License at
10 http://www.apache.org/licenses/LICENSE-2.0
14 local fs = require "nixio.fs"
15 local sys = require "luci.sys"
17 m = Map("firewall", translate("Manage Port Forwarding"))
19 s = m:section(TypedSection, "redirect", translate("Manual Port Forwarding"),
20 translate([[To manually define a forwarding rule you have to specify at least
21 the internal IP-address and port of the service that should be forwarded.
22 If you ommit the external port it will be the same as the internal port.
23 You also can forward a range of ports by using the syntax first-last Port
24 (e.g. 1024-1030) in the port field.]]))
25 s.template = "cbi/tblsection"
29 name = s:option(Value, "_name", translate("Name"), translate("optional"))
32 iface = s:option(ListValue, "src", translate("Zone"))
33 iface:value("wan", "Internet")
36 proto = s:option(ListValue, "proto", translate("Protocol"))
37 proto:value("tcp", "TCP")
38 proto:value("udp", "UDP")
39 proto:value("tcpudp", "TCP+UDP")
41 dport = s:option(Value, "src_dport", translate("Internal Port"))
44 to = s:option(Value, "dest_ip", translate("Internal Address"), translate("Device running the service"))
45 for i, dataset in ipairs(sys.net.arptable()) do
46 to:value(dataset["IP address"])
49 toport = s:option(Value, "dest_port", translate("External Port"), translate("optional"));
53 if fs.access("/etc/config/upnpd") then
55 s = m2:section(NamedSection, "config", "upnpd", translate("Automatic Port Forwarding (UPnP IGD)"),
56 translate([[Allows UPnP-capable applications to automatically forward ports on the router to their IP-Address.
57 Be aware that this is a potential security risk as applications are not authenticated.]]))
60 on = s:option(ListValue, "external_iface", translate("Port Forwarding Restrictions"))
61 on:value("none", translate("Manual Forwarding Only"))
62 on:value("wan", translate("Automatic and Manual Forwarding"))