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", Flag, "strictorder",
90 translate("Strict order"),
91 translate("<abbr title=\"Domain Name System\">DNS</abbr> servers will be queried in the " ..
92 "order of the resolvfile")).optional = true
95 bn = s:taboption("advanced", DynamicList, "bogusnxdomain", translate("Bogus NX Domain Override"),
96 translate("List of hosts that supply bogus NX domain results"))
99 bn.placeholder = "67.215.65.132"
102 s:taboption("general", Flag, "logqueries",
103 translate("Log queries"),
104 translate("Write received DNS requests to syslog")).optional = true
106 df = s:taboption("general", DynamicList, "server", translate("DNS forwardings"),
107 translate("List of <abbr title=\"Domain Name System\">DNS</abbr> " ..
108 "servers to forward requests to"))
111 df.placeholder = "/example.org/10.1.2.3"
114 rp = s:taboption("general", Flag, "rebind_protection",
115 translate("Rebind protection"),
116 translate("Discard upstream RFC1918 responses"))
121 rl = s:taboption("general", Flag, "rebind_localhost",
122 translate("Allow localhost"),
123 translate("Allow upstream responses in the 127.0.0.0/8 range, e.g. for RBL services"))
125 rl:depends("rebind_protection", "1")
128 rd = s:taboption("general", DynamicList, "rebind_domain",
129 translate("Domain whitelist"),
130 translate("List of domains to allow RFC1918 responses for"))
132 rd:depends("rebind_protection", "1")
134 rd.placeholder = "ihost.netflix.com"
137 pt = s:taboption("advanced", Value, "port",
138 translate("<abbr title=\"Domain Name System\">DNS</abbr> server port"),
139 translate("Listening port for inbound DNS queries"))
146 qp = s:taboption("advanced", Value, "queryport",
147 translate("<abbr title=\"Domain Name System\">DNS</abbr> query port"),
148 translate("Fixed source port for outbound DNS queries"))
152 qp.placeholder = translate("any")
155 lm = s:taboption("advanced", Value, "dhcpleasemax",
156 translate("<abbr title=\"maximal\">Max.</abbr> <abbr title=\"Dynamic Host Configuration " ..
157 "Protocol\">DHCP</abbr> leases"),
158 translate("Maximum allowed number of active DHCP leases"))
161 lm.datatype = "uinteger"
162 lm.placeholder = translate("unlimited")
165 em = s:taboption("advanced", Value, "ednspacket_max",
166 translate("<abbr title=\"maximal\">Max.</abbr> <abbr title=\"Extension Mechanisms for " ..
167 "Domain Name System\">EDNS0</abbr> packet size"),
168 translate("Maximum allowed size of EDNS.0 UDP packets"))
171 em.datatype = "uinteger"
172 em.placeholder = 1280
175 cq = s:taboption("advanced", Value, "dnsforwardmax",
176 translate("<abbr title=\"maximal\">Max.</abbr> concurrent queries"),
177 translate("Maximum allowed number of concurrent DNS queries"))
180 cq.datatype = "uinteger"
184 s:taboption("tftp", Flag, "enable_tftp",
185 translate("Enable TFTP server")).optional = true
187 tr = s:taboption("tftp", Value, "tftp_root",
188 translate("TFTP server root"),
189 translate("Root directory for files served via TFTP"))
192 tr:depends("enable_tftp", "1")
196 db = s:taboption("tftp", Value, "dhcp_boot",
197 translate("Network boot image"),
198 translate("Filename of the boot image advertised to clients"))
201 db:depends("enable_tftp", "1")
202 db.placeholder = "pxelinux.0"
205 m:section(SimpleSection).template = "admin_network/lease_status"
207 s = m:section(TypedSection, "host", translate("Static Leases"),
208 translate("Static leases are used to assign fixed IP addresses and symbolic hostnames to " ..
209 "DHCP clients. They are also required for non-dynamic interface configurations where " ..
210 "only hosts with a corresponding lease are served.") .. "<br />" ..
211 translate("Use the <em>Add</em> Button to add a new lease entry. The <em>MAC-Address</em> " ..
212 "indentifies the host, the <em>IPv4-Address</em> specifies to the fixed address to " ..
213 "use and the <em>Hostname</em> is assigned as symbolic name to the requesting host."))
217 s.template = "cbi/tblsection"
219 name = s:option(Value, "name", translate("Hostname"))
220 name.datatype = "hostname"
223 mac = s:option(Value, "mac", translate("<abbr title=\"Media Access Control\">MAC</abbr>-Address"))
224 mac.datatype = "list(macaddr)"
227 ip = s:option(Value, "ip", translate("<abbr title=\"Internet Protocol Version 4\">IPv4</abbr>-Address"))
228 ip.datatype = "or(ip4addr,'ignore')"
230 hostid = s:option(Value, "hostid", translate("<abbr title=\"Internet Protocol Version 6\">IPv6</abbr>-Suffix (hex)"))
232 ipc.neighbors({ family = 4 }, function(n)
233 if n.mac and n.dest then
234 ip:value(n.dest:string())
235 mac:value(n.mac, "%s (%s)" %{ n.mac, n.dest:string() })
239 function ip.validate(self, value, section)
240 local m = mac:formvalue(section) or ""
241 local n = name:formvalue(section) or ""
242 if value and #n == 0 and #m == 0 then
243 return nil, translate("One of hostname or mac address must be specified!")
245 return Value.validate(self, value, section)