1 -- Copyright 2008 Steven Barth <steven@midlink.org>
2 -- Licensed to the public under the Apache License 2.0.
4 local ipc = require "luci.ip"
6 m = Map("dhcp", translate("DHCP and DNS"),
7 translate("Dnsmasq is a combined <abbr title=\"Dynamic Host Configuration Protocol" ..
8 "\">DHCP</abbr>-Server and <abbr title=\"Domain Name System\">DNS</abbr>-" ..
9 "Forwarder for <abbr title=\"Network Address Translation\">NAT</abbr> " ..
12 s = m:section(TypedSection, "dnsmasq", translate("Server Settings"))
16 s:tab("general", translate("General Settings"))
17 s:tab("files", translate("Resolv and Hosts Files"))
18 s:tab("tftp", translate("TFTP Settings"))
19 s:tab("advanced", translate("Advanced Settings"))
21 s:taboption("general", Flag, "domainneeded",
22 translate("Domain required"),
23 translate("Don't forward <abbr title=\"Domain Name System\">DNS</abbr>-Requests without " ..
24 "<abbr title=\"Domain Name System\">DNS</abbr>-Name"))
26 s:taboption("general", Flag, "authoritative",
27 translate("Authoritative"),
28 translate("This is the only <abbr title=\"Dynamic Host Configuration Protocol\">DHCP</" ..
29 "abbr> in the local network"))
32 s:taboption("files", Flag, "readethers",
33 translate("Use <code>/etc/ethers</code>"),
34 translate("Read <code>/etc/ethers</code> to configure the <abbr title=\"Dynamic Host " ..
35 "Configuration Protocol\">DHCP</abbr>-Server"))
37 s:taboption("files", Value, "leasefile",
38 translate("Leasefile"),
39 translate("file where given <abbr title=\"Dynamic Host Configuration Protocol\">DHCP</" ..
40 "abbr>-leases will be stored"))
42 s:taboption("files", Flag, "noresolv",
43 translate("Ignore resolve file")).optional = true
45 rf = s:taboption("files", Value, "resolvfile",
46 translate("Resolve file"),
47 translate("local <abbr title=\"Domain Name System\">DNS</abbr> file"))
49 rf:depends("noresolv", "")
53 s:taboption("files", Flag, "nohosts",
54 translate("Ignore <code>/etc/hosts</code>")).optional = true
56 s:taboption("files", DynamicList, "addnhosts",
57 translate("Additional Hosts files")).optional = true
60 s:taboption("advanced", Flag, "boguspriv",
61 translate("Filter private"),
62 translate("Do not forward reverse lookups for local networks"))
64 s:taboption("advanced", Flag, "filterwin2k",
65 translate("Filter useless"),
66 translate("Do not forward requests that cannot be answered by public name servers"))
69 s:taboption("advanced", Flag, "localise_queries",
70 translate("Localise queries"),
71 translate("Localise hostname depending on the requesting subnet if multiple IPs are available"))
73 s:taboption("general", Value, "local",
74 translate("Local server"),
75 translate("Local domain specification. Names matching this domain are never forwarded and are resolved from DHCP or hosts files only"))
77 s:taboption("general", Value, "domain",
78 translate("Local domain"),
79 translate("Local domain suffix appended to DHCP names and hosts file entries"))
81 s:taboption("advanced", Flag, "expandhosts",
82 translate("Expand hosts"),
83 translate("Add local domain suffix to names served from hosts files"))
85 s:taboption("advanced", Flag, "nonegcache",
86 translate("No negative cache"),
87 translate("Do not cache negative replies, e.g. for not existing domains"))
89 s:taboption("advanced", Value, "serversfile",
90 translate("Additional servers file"),
91 translate("This file may contain lines like 'server=/domain/1.2.3.4' or 'server=1.2.3.4' for"..
92 "domain-specific or full upstream <abbr title=\"Domain Name System\">DNS</abbr> servers."))
94 s:taboption("advanced", Flag, "strictorder",
95 translate("Strict order"),
96 translate("<abbr title=\"Domain Name System\">DNS</abbr> servers will be queried in the " ..
97 "order of the resolvfile")).optional = true
100 bn = s:taboption("advanced", DynamicList, "bogusnxdomain", translate("Bogus NX Domain Override"),
101 translate("List of hosts that supply bogus NX domain results"))
104 bn.placeholder = "67.215.65.132"
107 s:taboption("general", Flag, "logqueries",
108 translate("Log queries"),
109 translate("Write received DNS requests to syslog")).optional = true
111 df = s:taboption("general", DynamicList, "server", translate("DNS forwardings"),
112 translate("List of <abbr title=\"Domain Name System\">DNS</abbr> " ..
113 "servers to forward requests to"))
116 df.placeholder = "/example.org/10.1.2.3"
119 rp = s:taboption("general", Flag, "rebind_protection",
120 translate("Rebind protection"),
121 translate("Discard upstream RFC1918 responses"))
126 rl = s:taboption("general", Flag, "rebind_localhost",
127 translate("Allow localhost"),
128 translate("Allow upstream responses in the 127.0.0.0/8 range, e.g. for RBL services"))
130 rl:depends("rebind_protection", "1")
133 rd = s:taboption("general", DynamicList, "rebind_domain",
134 translate("Domain whitelist"),
135 translate("List of domains to allow RFC1918 responses for"))
138 rd:depends("rebind_protection", "1")
139 rd.datatype = "host(1)"
140 rd.placeholder = "ihost.netflix.com"
143 pt = s:taboption("advanced", Value, "port",
144 translate("<abbr title=\"Domain Name System\">DNS</abbr> server port"),
145 translate("Listening port for inbound DNS queries"))
152 qp = s:taboption("advanced", Value, "queryport",
153 translate("<abbr title=\"Domain Name System\">DNS</abbr> query port"),
154 translate("Fixed source port for outbound DNS queries"))
158 qp.placeholder = translate("any")
161 lm = s:taboption("advanced", Value, "dhcpleasemax",
162 translate("<abbr title=\"maximal\">Max.</abbr> <abbr title=\"Dynamic Host Configuration " ..
163 "Protocol\">DHCP</abbr> leases"),
164 translate("Maximum allowed number of active DHCP leases"))
167 lm.datatype = "uinteger"
168 lm.placeholder = translate("unlimited")
171 em = s:taboption("advanced", Value, "ednspacket_max",
172 translate("<abbr title=\"maximal\">Max.</abbr> <abbr title=\"Extension Mechanisms for " ..
173 "Domain Name System\">EDNS0</abbr> packet size"),
174 translate("Maximum allowed size of EDNS.0 UDP packets"))
177 em.datatype = "uinteger"
178 em.placeholder = 1280
181 cq = s:taboption("advanced", Value, "dnsforwardmax",
182 translate("<abbr title=\"maximal\">Max.</abbr> concurrent queries"),
183 translate("Maximum allowed number of concurrent DNS queries"))
186 cq.datatype = "uinteger"
190 s:taboption("tftp", Flag, "enable_tftp",
191 translate("Enable TFTP server")).optional = true
193 tr = s:taboption("tftp", Value, "tftp_root",
194 translate("TFTP server root"),
195 translate("Root directory for files served via TFTP"))
198 tr:depends("enable_tftp", "1")
202 db = s:taboption("tftp", Value, "dhcp_boot",
203 translate("Network boot image"),
204 translate("Filename of the boot image advertised to clients"))
207 db:depends("enable_tftp", "1")
208 db.placeholder = "pxelinux.0"
210 o = s:taboption("general", Flag, "localservice",
211 translate("Local Service Only"),
212 translate("Limit DNS service to subnets interfaces on which we are serving DNS."))
216 o = s:taboption("general", Flag, "nonwildcard",
217 translate("Non-wildcard"),
218 translate("Bind only to specific interfaces rather than wildcard address."))
222 o = s:taboption("general", DynamicList, "interface",
223 translate("Listen Interfaces"),
224 translate("Limit listening to these interfaces, and loopback."))
226 o:depends("nonwildcard", true)
228 o = s:taboption("general", DynamicList, "notinterface",
229 translate("Exclude interfaces"),
230 translate("Prevent listening on thise interfaces."))
232 o:depends("nonwildcard", true)
234 m:section(SimpleSection).template = "admin_network/lease_status"
236 s = m:section(TypedSection, "host", translate("Static Leases"),
237 translate("Static leases are used to assign fixed IP addresses and symbolic hostnames to " ..
238 "DHCP clients. They are also required for non-dynamic interface configurations where " ..
239 "only hosts with a corresponding lease are served.") .. "<br />" ..
240 translate("Use the <em>Add</em> Button to add a new lease entry. The <em>MAC-Address</em> " ..
241 "indentifies the host, the <em>IPv4-Address</em> specifies to the fixed address to " ..
242 "use and the <em>Hostname</em> is assigned as symbolic name to the requesting host. " ..
243 "The optional <em>Lease time</em> can be used to set non-standard host-specific " ..
244 "lease time, e.g. 12h, 3d or infinite."))
248 s.template = "cbi/tblsection"
250 name = s:option(Value, "name", translate("Hostname"))
251 name.datatype = "hostname"
254 mac = s:option(Value, "mac", translate("<abbr title=\"Media Access Control\">MAC</abbr>-Address"))
255 mac.datatype = "list(macaddr)"
258 ip = s:option(Value, "ip", translate("<abbr title=\"Internet Protocol Version 4\">IPv4</abbr>-Address"))
259 ip.datatype = "or(ip4addr,'ignore')"
261 time = s:option(Value, "leasetime", translate("Lease time"))
264 hostid = s:option(Value, "hostid", translate("<abbr title=\"Internet Protocol Version 6\">IPv6</abbr>-Suffix (hex)"))
266 ipc.neighbors({ family = 4 }, function(n)
267 if n.mac and n.dest then
268 ip:value(n.dest:string())
269 mac:value(n.mac, "%s (%s)" %{ n.mac, n.dest:string() })
273 function ip.validate(self, value, section)
274 local m = mac:formvalue(section) or ""
275 local n = name:formvalue(section) or ""
276 if value and #n == 0 and #m == 0 then
277 return nil, translate("One of hostname or mac address must be specified!")
279 return Value.validate(self, value, section)