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
15 local sys = require "luci.sys"
17 m = Map("dhcp", translate("DHCP and DNS"),
18 translate("Dnsmasq is a combined <abbr title=\"Dynamic Host Configuration Protocol" ..
19 "\">DHCP</abbr>-Server and <abbr title=\"Domain Name System\">DNS</abbr>-" ..
20 "Forwarder for <abbr title=\"Network Address Translation\">NAT</abbr> " ..
23 s = m:section(TypedSection, "dnsmasq", translate("Server Settings"))
27 s:tab("general", translate("General Settings"))
28 s:tab("files", translate("Resolv and Hosts Files"))
29 s:tab("tftp", translate("TFTP Settings"))
30 s:tab("advanced", translate("Advanced Settings"))
32 s:taboption("general", Flag, "domainneeded",
33 translate("Domain required"),
34 translate("Don't forward <abbr title=\"Domain Name System\">DNS</abbr>-Requests without " ..
35 "<abbr title=\"Domain Name System\">DNS</abbr>-Name"))
37 s:taboption("general", Flag, "authoritative",
38 translate("Authoritative"),
39 translate("This is the only <abbr title=\"Dynamic Host Configuration Protocol\">DHCP</" ..
40 "abbr> in the local network"))
43 s:taboption("files", Flag, "readethers",
44 translate("Use <code>/etc/ethers</code>"),
45 translate("Read <code>/etc/ethers</code> to configure the <abbr title=\"Dynamic Host " ..
46 "Configuration Protocol\">DHCP</abbr>-Server"))
48 s:taboption("files", Value, "leasefile",
49 translate("Leasefile"),
50 translate("file where given <abbr title=\"Dynamic Host Configuration Protocol\">DHCP</" ..
51 "abbr>-leases will be stored"))
53 s:taboption("files", Flag, "noresolv",
54 translate("Ignore resolve file")).optional = true
56 rf = s:taboption("files", Value, "resolvfile",
57 translate("Resolve file"),
58 translate("local <abbr title=\"Domain Name System\">DNS</abbr> file"))
60 rf:depends("noresolv", "")
64 s:taboption("files", Flag, "nohosts",
65 translate("Ignore Hosts files")).optional = true
67 hf = s:taboption("files", DynamicList, "addnhosts",
68 translate("Additional Hosts files"))
70 hf:depends("nohosts", "")
74 s:taboption("advanced", Flag, "boguspriv",
75 translate("Filter private"),
76 translate("Do not forward reverse lookups for local networks"))
78 s:taboption("advanced", Flag, "filterwin2k",
79 translate("Filter useless"),
80 translate("Do not forward requests that cannot be answered by public name servers"))
83 s:taboption("advanced", Flag, "localise_queries",
84 translate("Localise queries"),
85 translate("Localise hostname depending on the requesting subnet if multiple IPs are available"))
87 s:taboption("general", Value, "local",
88 translate("Local server"),
89 translate("Local domain specification. Names matching this domain are never forwared and resolved from DHCP or hosts files only"))
91 s:taboption("general", Value, "domain",
92 translate("Local domain"),
93 translate("Local domain suffix appended to DHCP names and hosts file entries"))
95 s:taboption("advanced", Flag, "expandhosts",
96 translate("Expand hosts"),
97 translate("Add local domain suffix to names served from hosts files"))
99 s:taboption("advanced", Flag, "nonegcache",
100 translate("No negative cache"),
101 translate("Do not cache negative replies, e.g. for not existing domains"))
103 s:taboption("advanced", Flag, "strictorder",
104 translate("Strict order"),
105 translate("<abbr title=\"Domain Name System\">DNS</abbr> servers will be queried in the " ..
106 "order of the resolvfile")).optional = true
109 bn = s:taboption("advanced", DynamicList, "bogusnxdomain", translate("Bogus NX Domain Override"),
110 translate("List of hosts that supply bogus NX domain results"))
113 bn.placeholder = "67.215.65.132"
116 s:taboption("general", Flag, "logqueries",
117 translate("Log queries"),
118 translate("Write received DNS requests to syslog")).optional = true
120 df = s:taboption("general", DynamicList, "server", translate("DNS forwardings"),
121 translate("List of <abbr title=\"Domain Name System\">DNS</abbr> " ..
122 "servers to forward requests to"))
125 df.placeholder = "/example.org/10.1.2.3"
128 rp = s:taboption("general", Flag, "rebind_protection",
129 translate("Rebind protection"),
130 translate("Discard upstream RFC1918 responses"))
135 rl = s:taboption("general", Flag, "rebind_localhost",
136 translate("Allow localhost"),
137 translate("Allow upstream responses in the 127.0.0.0/8 range, e.g. for RBL services"))
139 rl:depends("rebind_protection", "1")
142 rd = s:taboption("general", DynamicList, "rebind_domain",
143 translate("Domain whitelist"),
144 translate("List of domains to allow RFC1918 responses for"))
146 rd:depends("rebind_protection", "1")
148 rd.placeholder = "ihost.netflix.com"
151 pt = s:taboption("advanced", Value, "port",
152 translate("<abbr title=\"Domain Name System\">DNS</abbr> server port"),
153 translate("Listening port for inbound DNS queries"))
160 qp = s:taboption("advanced", Value, "queryport",
161 translate("<abbr title=\"Domain Name System\">DNS</abbr> query port"),
162 translate("Fixed source port for outbound DNS queries"))
166 qp.placeholder = translate("any")
169 lm = s:taboption("advanced", Value, "dhcpleasemax",
170 translate("<abbr title=\"maximal\">Max.</abbr> <abbr title=\"Dynamic Host Configuration " ..
171 "Protocol\">DHCP</abbr> leases"),
172 translate("Maximum allowed number of active DHCP leases"))
175 lm.datatype = "uinteger"
176 lm.placeholder = translate("unlimited")
179 em = s:taboption("advanced", Value, "ednspacket_max",
180 translate("<abbr title=\"maximal\">Max.</abbr> <abbr title=\"Extension Mechanisms for " ..
181 "Domain Name System\">EDNS0</abbr> packet size"),
182 translate("Maximum allowed size of EDNS.0 UDP packets"))
185 em.datatype = "uinteger"
186 em.placeholder = 1280
189 cq = s:taboption("advanced", Value, "dnsforwardmax",
190 translate("<abbr title=\"maximal\">Max.</abbr> concurrent queries"),
191 translate("Maximum allowed number of concurrent DNS queries"))
194 cq.datatype = "uinteger"
198 s:taboption("tftp", Flag, "enable_tftp",
199 translate("Enable TFTP server")).optional = true
201 tr = s:taboption("tftp", Value, "tftp_root",
202 translate("TFTP server root"),
203 translate("Root directory for files served via TFTP"))
206 tr:depends("enable_tftp", "1")
210 db = s:taboption("tftp", Value, "dhcp_boot",
211 translate("Network boot image"),
212 translate("Filename of the boot image advertised to clients"))
215 db:depends("enable_tftp", "1")
216 db.placeholder = "pxelinux.0"
219 m:section(SimpleSection).template = "admin_network/lease_status"
221 s = m:section(TypedSection, "host", translate("Static Leases"),
222 translate("Static leases are used to assign fixed IP addresses and symbolic hostnames to " ..
223 "DHCP clients. They are also required for non-dynamic interface configurations where " ..
224 "only hosts with a corresponding lease are served.") .. "<br />" ..
225 translate("Use the <em>Add</em> Button to add a new lease entry. The <em>MAC-Address</em> " ..
226 "indentifies the host, the <em>IPv4-Address</em> specifies to the fixed address to " ..
227 "use and the <em>Hostname</em> is assigned as symbolic name to the requesting host."))
231 s.template = "cbi/tblsection"
233 name = s:option(Value, "name", translate("Hostname"))
234 name.datatype = "hostname"
237 mac = s:option(Value, "mac", translate("<abbr title=\"Media Access Control\">MAC</abbr>-Address"))
238 mac.datatype = "list(macaddr)"
241 ip = s:option(Value, "ip", translate("<abbr title=\"Internet Protocol Version 4\">IPv4</abbr>-Address"))
242 ip.datatype = "or(ip4addr,'ignore')"
244 hostid = s:option(Value, "hostid", translate("<abbr title=\"Internet Protocol Version 6\">IPv6</abbr>-Suffix (hex)"))
246 sys.net.arptable(function(entry)
247 ip:value(entry["IP address"])
250 entry["HW address"] .. " (" .. entry["IP address"] .. ")"
254 function ip.validate(self, value, section)
255 local m = mac:formvalue(section) or ""
256 local n = name:formvalue(section) or ""
257 if value and #n == 0 and #m == 0 then
258 return nil, translate("One of hostname or mac address must be specified!")
260 return Value.validate(self, value, section)