luci-mod-admin-full: dnsmasq options quietdhcp and sequential_ip
[project/luci.git] / modules / luci-mod-admin-full / luasrc / model / cbi / admin_network / dhcp.lua
1 -- Copyright 2008 Steven Barth <steven@midlink.org>
2 -- Licensed to the public under the Apache License 2.0.
3
4 local ipc = require "luci.ip"
5
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> " ..
10 "firewalls"))
11
12 s = m:section(TypedSection, "dnsmasq", translate("Server Settings"))
13 s.anonymous = true
14 s.addremove = false
15
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"))
20
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"))
25
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"))
30
31
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"))
36
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"))
41
42 s:taboption("files", Flag, "noresolv",
43 translate("Ignore resolve file")).optional = true
44
45 rf = s:taboption("files", Value, "resolvfile",
46 translate("Resolve file"),
47 translate("local <abbr title=\"Domain Name System\">DNS</abbr> file"))
48
49 rf:depends("noresolv", "")
50 rf.optional = true
51
52
53 s:taboption("files", Flag, "nohosts",
54 translate("Ignore <code>/etc/hosts</code>")).optional = true
55
56 s:taboption("files", DynamicList, "addnhosts",
57 translate("Additional Hosts files")).optional = true
58
59 qu = s:taboption("advanced", Flag, "quietdhcp",
60 translate("Suppress logging"),
61 translate("Suppress logging of the routine operation of these protocols"))
62 qu.optional = true
63
64 se = s:taboption("advanced", Flag, "sequential_ip",
65 translate("Allocate IP sequentially"),
66 translate("Allocate IP addresses sequentially, starting from the lowest available address"))
67 se.optional = true
68
69 s:taboption("advanced", Flag, "boguspriv",
70 translate("Filter private"),
71 translate("Do not forward reverse lookups for local networks"))
72
73 s:taboption("advanced", Flag, "filterwin2k",
74 translate("Filter useless"),
75 translate("Do not forward requests that cannot be answered by public name servers"))
76
77
78 s:taboption("advanced", Flag, "localise_queries",
79 translate("Localise queries"),
80 translate("Localise hostname depending on the requesting subnet if multiple IPs are available"))
81
82 s:taboption("general", Value, "local",
83 translate("Local server"),
84 translate("Local domain specification. Names matching this domain are never forwarded and are resolved from DHCP or hosts files only"))
85
86 s:taboption("general", Value, "domain",
87 translate("Local domain"),
88 translate("Local domain suffix appended to DHCP names and hosts file entries"))
89
90 s:taboption("advanced", Flag, "expandhosts",
91 translate("Expand hosts"),
92 translate("Add local domain suffix to names served from hosts files"))
93
94 s:taboption("advanced", Flag, "nonegcache",
95 translate("No negative cache"),
96 translate("Do not cache negative replies, e.g. for not existing domains"))
97
98 s:taboption("advanced", Flag, "strictorder",
99 translate("Strict order"),
100 translate("<abbr title=\"Domain Name System\">DNS</abbr> servers will be queried in the " ..
101 "order of the resolvfile")).optional = true
102
103
104 bn = s:taboption("advanced", DynamicList, "bogusnxdomain", translate("Bogus NX Domain Override"),
105 translate("List of hosts that supply bogus NX domain results"))
106
107 bn.optional = true
108 bn.placeholder = "67.215.65.132"
109
110
111 s:taboption("general", Flag, "logqueries",
112 translate("Log queries"),
113 translate("Write received DNS requests to syslog")).optional = true
114
115 df = s:taboption("general", DynamicList, "server", translate("DNS forwardings"),
116 translate("List of <abbr title=\"Domain Name System\">DNS</abbr> " ..
117 "servers to forward requests to"))
118
119 df.optional = true
120 df.placeholder = "/example.org/10.1.2.3"
121
122
123 rp = s:taboption("general", Flag, "rebind_protection",
124 translate("Rebind protection"),
125 translate("Discard upstream RFC1918 responses"))
126
127 rp.rmempty = false
128
129
130 rl = s:taboption("general", Flag, "rebind_localhost",
131 translate("Allow localhost"),
132 translate("Allow upstream responses in the 127.0.0.0/8 range, e.g. for RBL services"))
133
134 rl:depends("rebind_protection", "1")
135
136
137 rd = s:taboption("general", DynamicList, "rebind_domain",
138 translate("Domain whitelist"),
139 translate("List of domains to allow RFC1918 responses for"))
140
141 rd:depends("rebind_protection", "1")
142 rd.datatype = "host"
143 rd.placeholder = "ihost.netflix.com"
144
145
146 pt = s:taboption("advanced", Value, "port",
147 translate("<abbr title=\"Domain Name System\">DNS</abbr> server port"),
148 translate("Listening port for inbound DNS queries"))
149
150 pt.optional = true
151 pt.datatype = "port"
152 pt.placeholder = 53
153
154
155 qp = s:taboption("advanced", Value, "queryport",
156 translate("<abbr title=\"Domain Name System\">DNS</abbr> query port"),
157 translate("Fixed source port for outbound DNS queries"))
158
159 qp.optional = true
160 qp.datatype = "port"
161 qp.placeholder = translate("any")
162
163
164 lm = s:taboption("advanced", Value, "dhcpleasemax",
165 translate("<abbr title=\"maximal\">Max.</abbr> <abbr title=\"Dynamic Host Configuration " ..
166 "Protocol\">DHCP</abbr> leases"),
167 translate("Maximum allowed number of active DHCP leases"))
168
169 lm.optional = true
170 lm.datatype = "uinteger"
171 lm.placeholder = translate("unlimited")
172
173
174 em = s:taboption("advanced", Value, "ednspacket_max",
175 translate("<abbr title=\"maximal\">Max.</abbr> <abbr title=\"Extension Mechanisms for " ..
176 "Domain Name System\">EDNS0</abbr> packet size"),
177 translate("Maximum allowed size of EDNS.0 UDP packets"))
178
179 em.optional = true
180 em.datatype = "uinteger"
181 em.placeholder = 1280
182
183
184 cq = s:taboption("advanced", Value, "dnsforwardmax",
185 translate("<abbr title=\"maximal\">Max.</abbr> concurrent queries"),
186 translate("Maximum allowed number of concurrent DNS queries"))
187
188 cq.optional = true
189 cq.datatype = "uinteger"
190 cq.placeholder = 150
191
192
193 s:taboption("tftp", Flag, "enable_tftp",
194 translate("Enable TFTP server")).optional = true
195
196 tr = s:taboption("tftp", Value, "tftp_root",
197 translate("TFTP server root"),
198 translate("Root directory for files served via TFTP"))
199
200 tr.optional = true
201 tr:depends("enable_tftp", "1")
202 tr.placeholder = "/"
203
204
205 db = s:taboption("tftp", Value, "dhcp_boot",
206 translate("Network boot image"),
207 translate("Filename of the boot image advertised to clients"))
208
209 db.optional = true
210 db:depends("enable_tftp", "1")
211 db.placeholder = "pxelinux.0"
212
213
214 m:section(SimpleSection).template = "admin_network/lease_status"
215
216 s = m:section(TypedSection, "host", translate("Static Leases"),
217 translate("Static leases are used to assign fixed IP addresses and symbolic hostnames to " ..
218 "DHCP clients. They are also required for non-dynamic interface configurations where " ..
219 "only hosts with a corresponding lease are served.") .. "<br />" ..
220 translate("Use the <em>Add</em> Button to add a new lease entry. The <em>MAC-Address</em> " ..
221 "indentifies the host, the <em>IPv4-Address</em> specifies to the fixed address to " ..
222 "use and the <em>Hostname</em> is assigned as symbolic name to the requesting host."))
223
224 s.addremove = true
225 s.anonymous = true
226 s.template = "cbi/tblsection"
227
228 name = s:option(Value, "name", translate("Hostname"))
229 name.datatype = "hostname"
230 name.rmempty = true
231
232 mac = s:option(Value, "mac", translate("<abbr title=\"Media Access Control\">MAC</abbr>-Address"))
233 mac.datatype = "list(macaddr)"
234 mac.rmempty = true
235
236 ip = s:option(Value, "ip", translate("<abbr title=\"Internet Protocol Version 4\">IPv4</abbr>-Address"))
237 ip.datatype = "or(ip4addr,'ignore')"
238
239 hostid = s:option(Value, "hostid", translate("<abbr title=\"Internet Protocol Version 6\">IPv6</abbr>-Suffix (hex)"))
240
241 ipc.neighbors({ family = 4 }, function(n)
242 if n.mac and n.dest then
243 ip:value(n.dest:string())
244 mac:value(n.mac, "%s (%s)" %{ n.mac, n.dest:string() })
245 end
246 end)
247
248 function ip.validate(self, value, section)
249 local m = mac:formvalue(section) or ""
250 local n = name:formvalue(section) or ""
251 if value and #n == 0 and #m == 0 then
252 return nil, translate("One of hostname or mac address must be specified!")
253 end
254 return Value.validate(self, value, section)
255 end
256
257
258 return m