1 |
5b237745
|
Scott Ullrich
|
<?php
|
2 |
|
|
/*
|
3 |
c5d81585
|
Renato Botelho
|
* services_dnsmasq.php
|
4 |
191cb31d
|
Stephen Beaver
|
*
|
5 |
c5d81585
|
Renato Botelho
|
* part of pfSense (https://www.pfsense.org)
|
6 |
81299b5c
|
Renato Botelho
|
* Copyright (c) 2004-2016 Rubicon Communications, LLC (Netgate)
|
7 |
c5d81585
|
Renato Botelho
|
* Copyright (c) 2003-2004 Bob Zoller <bob@kludgebox.com>
|
8 |
|
|
* All rights reserved.
|
9 |
191cb31d
|
Stephen Beaver
|
*
|
10 |
c5d81585
|
Renato Botelho
|
* originally based on m0n0wall (http://m0n0.ch/wall)
|
11 |
|
|
* Copyright (c) 2003-2004 Manuel Kasper <mk@neon1.net>.
|
12 |
|
|
* All rights reserved.
|
13 |
191cb31d
|
Stephen Beaver
|
*
|
14 |
b12ea3fb
|
Renato Botelho
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
15 |
|
|
* you may not use this file except in compliance with the License.
|
16 |
|
|
* You may obtain a copy of the License at
|
17 |
191cb31d
|
Stephen Beaver
|
*
|
18 |
b12ea3fb
|
Renato Botelho
|
* http://www.apache.org/licenses/LICENSE-2.0
|
19 |
191cb31d
|
Stephen Beaver
|
*
|
20 |
b12ea3fb
|
Renato Botelho
|
* Unless required by applicable law or agreed to in writing, software
|
21 |
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
22 |
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
23 |
|
|
* See the License for the specific language governing permissions and
|
24 |
|
|
* limitations under the License.
|
25 |
191cb31d
|
Stephen Beaver
|
*/
|
26 |
5b237745
|
Scott Ullrich
|
|
27 |
6b07c15a
|
Matthew Grooms
|
##|+PRIV
|
28 |
|
|
##|*IDENT=page-services-dnsforwarder
|
29 |
5230f468
|
jim-p
|
##|*NAME=Services: DNS Forwarder
|
30 |
6b07c15a
|
Matthew Grooms
|
##|*DESCR=Allow access to the 'Services: DNS Forwarder' page.
|
31 |
|
|
##|*MATCH=services_dnsmasq.php*
|
32 |
|
|
##|-PRIV
|
33 |
|
|
|
34 |
c81ef6e2
|
Phil Davis
|
require_once("guiconfig.inc");
|
35 |
7a927e67
|
Scott Ullrich
|
require_once("functions.inc");
|
36 |
|
|
require_once("filter.inc");
|
37 |
|
|
require_once("shaper.inc");
|
38 |
4dbcf2fb
|
Renato Botelho
|
require_once("system.inc");
|
39 |
5b237745
|
Scott Ullrich
|
|
40 |
d622a62e
|
Phil Davis
|
// Sort host entries for display in alphabetical order
|
41 |
8e7fea67
|
Steve Beaver
|
function hostcmp($a, $b) {
|
42 |
|
|
return strcasecmp($a['host'], $b['host']);
|
43 |
|
|
}
|
44 |
|
|
|
45 |
|
|
function hosts_sort() {
|
46 |
|
|
global $a_hosts;
|
47 |
|
|
|
48 |
|
|
if (!is_array($a_hosts)) {
|
49 |
|
|
return;
|
50 |
|
|
}
|
51 |
|
|
|
52 |
|
|
usort($a_hosts, "hostcmp");
|
53 |
|
|
}
|
54 |
|
|
|
55 |
d622a62e
|
Phil Davis
|
// Sort domain entries for display in alphabetical order
|
56 |
8e7fea67
|
Steve Beaver
|
function domaincmp($a, $b) {
|
57 |
|
|
return strcasecmp($a['domain'], $b['domain']);
|
58 |
|
|
}
|
59 |
|
|
|
60 |
|
|
function domains_sort() {
|
61 |
|
|
global $a_domainOverrides;
|
62 |
|
|
|
63 |
|
|
if (!is_array($a_domainOverrides)) {
|
64 |
|
|
return;
|
65 |
|
|
}
|
66 |
|
|
|
67 |
|
|
usort($a_domainOverrides, "domaincmp");
|
68 |
|
|
}
|
69 |
|
|
|
70 |
70edf50d
|
jim-p
|
$pconfig['enable'] = isset($config['dnsmasq']['enable']);
|
71 |
5b237745
|
Scott Ullrich
|
$pconfig['regdhcp'] = isset($config['dnsmasq']['regdhcp']);
|
72 |
6a01ea44
|
Bill Marquette
|
$pconfig['regdhcpstatic'] = isset($config['dnsmasq']['regdhcpstatic']);
|
73 |
aa994814
|
Andrew Thompson
|
$pconfig['dhcpfirst'] = isset($config['dnsmasq']['dhcpfirst']);
|
74 |
96ea7162
|
N0YB
|
$pconfig['strict_order'] = isset($config['dnsmasq']['strict_order']);
|
75 |
|
|
$pconfig['domain_needed'] = isset($config['dnsmasq']['domain_needed']);
|
76 |
7bdd28fb
|
Phil Davis
|
$pconfig['no_private_reverse'] = isset($config['dnsmasq']['no_private_reverse']);
|
77 |
e6c49e3d
|
jim-p
|
$pconfig['port'] = $config['dnsmasq']['port'];
|
78 |
8f9bffbc
|
Andrew Thompson
|
$pconfig['custom_options'] = $config['dnsmasq']['custom_options'];
|
79 |
b4323f39
|
jim-p
|
$pconfig['strictbind'] = isset($config['dnsmasq']['strictbind']);
|
80 |
8e7fea67
|
Steve Beaver
|
|
81 |
966ed611
|
Phil Davis
|
if (!empty($config['dnsmasq']['interface'])) {
|
82 |
79d03c40
|
jim-p
|
$pconfig['interface'] = explode(",", $config['dnsmasq']['interface']);
|
83 |
966ed611
|
Phil Davis
|
} else {
|
84 |
79d03c40
|
jim-p
|
$pconfig['interface'] = array();
|
85 |
966ed611
|
Phil Davis
|
}
|
86 |
b4323f39
|
jim-p
|
|
87 |
966ed611
|
Phil Davis
|
if (!is_array($config['dnsmasq']['hosts'])) {
|
88 |
5b237745
|
Scott Ullrich
|
$config['dnsmasq']['hosts'] = array();
|
89 |
966ed611
|
Phil Davis
|
}
|
90 |
0c2b5df7
|
Scott Ullrich
|
|
91 |
966ed611
|
Phil Davis
|
if (!is_array($config['dnsmasq']['domainoverrides'])) {
|
92 |
70edf50d
|
jim-p
|
$config['dnsmasq']['domainoverrides'] = array();
|
93 |
966ed611
|
Phil Davis
|
}
|
94 |
0c2b5df7
|
Scott Ullrich
|
|
95 |
70edf50d
|
jim-p
|
$a_hosts = &$config['dnsmasq']['hosts'];
|
96 |
589634a9
|
Steve Beaver
|
|
97 |
|
|
// Add a temporary index so we don't lose the order after sorting
|
98 |
|
|
for ($idx=0; $idx<count($a_hosts); $idx++) {
|
99 |
|
|
$a_hosts[$idx]['idx'] = $idx;
|
100 |
|
|
}
|
101 |
|
|
|
102 |
8e7fea67
|
Steve Beaver
|
hosts_sort();
|
103 |
589634a9
|
Steve Beaver
|
|
104 |
0c2b5df7
|
Scott Ullrich
|
$a_domainOverrides = &$config['dnsmasq']['domainoverrides'];
|
105 |
589634a9
|
Steve Beaver
|
|
106 |
|
|
// Add a temporary index so we don't lose the order after sorting
|
107 |
|
|
for ($idx=0; $idx<count($a_domainOverrides); $idx++) {
|
108 |
|
|
$a_domainOverrides[$idx]['idx'] = $idx;
|
109 |
|
|
}
|
110 |
|
|
|
111 |
8e7fea67
|
Steve Beaver
|
domains_sort();
|
112 |
5b237745
|
Scott Ullrich
|
|
113 |
|
|
if ($_POST) {
|
114 |
98d39683
|
jim-p
|
if ($_POST['apply']) {
|
115 |
|
|
$retval = 0;
|
116 |
|
|
$retval = services_dnsmasq_configure();
|
117 |
|
|
$savemsg = get_std_save_message($retval);
|
118 |
|
|
|
119 |
|
|
// Reload filter (we might need to sync to CARP hosts)
|
120 |
|
|
filter_configure();
|
121 |
|
|
/* Update resolv.conf in case the interface bindings exclude localhost. */
|
122 |
|
|
system_resolvconf_generate();
|
123 |
|
|
/* Start or restart dhcpleases when it's necessary */
|
124 |
|
|
system_dhcpleases_configure();
|
125 |
|
|
|
126 |
|
|
if ($retval == 0) {
|
127 |
|
|
clear_subsystem_dirty('hosts');
|
128 |
|
|
}
|
129 |
33ed4d60
|
Stephen Beaver
|
} else {
|
130 |
|
|
$pconfig = $_POST;
|
131 |
|
|
unset($input_errors);
|
132 |
6e3488e9
|
Phil Davis
|
|
133 |
33ed4d60
|
Stephen Beaver
|
$config['dnsmasq']['enable'] = ($_POST['enable']) ? true : false;
|
134 |
|
|
$config['dnsmasq']['regdhcp'] = ($_POST['regdhcp']) ? true : false;
|
135 |
|
|
$config['dnsmasq']['regdhcpstatic'] = ($_POST['regdhcpstatic']) ? true : false;
|
136 |
|
|
$config['dnsmasq']['dhcpfirst'] = ($_POST['dhcpfirst']) ? true : false;
|
137 |
|
|
$config['dnsmasq']['strict_order'] = ($_POST['strict_order']) ? true : false;
|
138 |
|
|
$config['dnsmasq']['domain_needed'] = ($_POST['domain_needed']) ? true : false;
|
139 |
|
|
$config['dnsmasq']['no_private_reverse'] = ($_POST['no_private_reverse']) ? true : false;
|
140 |
|
|
$config['dnsmasq']['custom_options'] = str_replace("\r\n", "\n", $_POST['custom_options']);
|
141 |
|
|
$config['dnsmasq']['strictbind'] = ($_POST['strictbind']) ? true : false;
|
142 |
6e3488e9
|
Phil Davis
|
|
143 |
33ed4d60
|
Stephen Beaver
|
if (isset($_POST['enable']) && isset($config['unbound']['enable'])) {
|
144 |
|
|
if ($_POST['port'] == $config['unbound']['port']) {
|
145 |
4bb7c0d1
|
bruno
|
$input_errors[] = gettext("The DNS Resolver is enabled using this port. Choose a non-conflicting port, or disable DNS Resolver.");
|
146 |
33ed4d60
|
Stephen Beaver
|
}
|
147 |
966ed611
|
Phil Davis
|
}
|
148 |
6e3488e9
|
Phil Davis
|
|
149 |
33ed4d60
|
Stephen Beaver
|
if ($_POST['port']) {
|
150 |
|
|
if (is_port($_POST['port'])) {
|
151 |
|
|
$config['dnsmasq']['port'] = $_POST['port'];
|
152 |
|
|
} else {
|
153 |
c9a66c65
|
NOYB
|
$input_errors[] = gettext("A valid port number must be specified.");
|
154 |
33ed4d60
|
Stephen Beaver
|
}
|
155 |
|
|
} else if (isset($config['dnsmasq']['port'])) {
|
156 |
|
|
unset($config['dnsmasq']['port']);
|
157 |
966ed611
|
Phil Davis
|
}
|
158 |
6e3488e9
|
Phil Davis
|
|
159 |
33ed4d60
|
Stephen Beaver
|
if (is_array($_POST['interface'])) {
|
160 |
|
|
$config['dnsmasq']['interface'] = implode(",", $_POST['interface']);
|
161 |
|
|
} elseif (isset($config['dnsmasq']['interface'])) {
|
162 |
|
|
unset($config['dnsmasq']['interface']);
|
163 |
966ed611
|
Phil Davis
|
}
|
164 |
6e3488e9
|
Phil Davis
|
|
165 |
33ed4d60
|
Stephen Beaver
|
if ($config['dnsmasq']['custom_options']) {
|
166 |
|
|
$args = '';
|
167 |
|
|
foreach (preg_split('/\s+/', $config['dnsmasq']['custom_options']) as $c) {
|
168 |
|
|
$args .= escapeshellarg("--{$c}") . " ";
|
169 |
|
|
}
|
170 |
|
|
exec("/usr/local/sbin/dnsmasq --test $args", $output, $rc);
|
171 |
|
|
if ($rc != 0) {
|
172 |
|
|
$input_errors[] = gettext("Invalid custom options");
|
173 |
|
|
}
|
174 |
c85b1242
|
Stephen Beaver
|
}
|
175 |
6e3488e9
|
Phil Davis
|
|
176 |
33ed4d60
|
Stephen Beaver
|
if (!$input_errors) {
|
177 |
|
|
write_config();
|
178 |
98d39683
|
jim-p
|
mark_subsystem_dirty('hosts');
|
179 |
966ed611
|
Phil Davis
|
}
|
180 |
8f9bffbc
|
Andrew Thompson
|
}
|
181 |
5b237745
|
Scott Ullrich
|
}
|
182 |
|
|
|
183 |
|
|
if ($_GET['act'] == "del") {
|
184 |
70edf50d
|
jim-p
|
if ($_GET['type'] == 'host') {
|
185 |
|
|
if ($a_hosts[$_GET['id']]) {
|
186 |
|
|
unset($a_hosts[$_GET['id']]);
|
187 |
|
|
write_config();
|
188 |
a368a026
|
Ermal Lu?i
|
mark_subsystem_dirty('hosts');
|
189 |
70edf50d
|
jim-p
|
header("Location: services_dnsmasq.php");
|
190 |
|
|
exit;
|
191 |
|
|
}
|
192 |
6e3488e9
|
Phil Davis
|
} elseif ($_GET['type'] == 'doverride') {
|
193 |
70edf50d
|
jim-p
|
if ($a_domainOverrides[$_GET['id']]) {
|
194 |
|
|
unset($a_domainOverrides[$_GET['id']]);
|
195 |
|
|
write_config();
|
196 |
a368a026
|
Ermal Lu?i
|
mark_subsystem_dirty('hosts');
|
197 |
70edf50d
|
jim-p
|
header("Location: services_dnsmasq.php");
|
198 |
|
|
exit;
|
199 |
|
|
}
|
200 |
|
|
}
|
201 |
5b237745
|
Scott Ullrich
|
}
|
202 |
0c2b5df7
|
Scott Ullrich
|
|
203 |
e6363160
|
sbeaver
|
function build_if_list() {
|
204 |
b1895639
|
Stephen Beaver
|
global $pconfig;
|
205 |
|
|
|
206 |
e6363160
|
sbeaver
|
$interface_addresses = get_possible_listen_ips(true);
|
207 |
|
|
$iflist = array('options' => array(), 'selected' => array());
|
208 |
|
|
|
209 |
|
|
$iflist['options'][""] = "All";
|
210 |
6e3488e9
|
Phil Davis
|
if (empty($pconfig['interface']) || empty($pconfig['interface'][0])) {
|
211 |
e6363160
|
sbeaver
|
array_push($iflist['selected'], "");
|
212 |
6e3488e9
|
Phil Davis
|
}
|
213 |
e6363160
|
sbeaver
|
|
214 |
|
|
foreach ($interface_addresses as $laddr => $ldescr) {
|
215 |
|
|
$iflist['options'][$laddr] = htmlspecialchars($ldescr);
|
216 |
|
|
|
217 |
6e3488e9
|
Phil Davis
|
if ($pconfig['interface'] && in_array($laddr, $pconfig['interface'])) {
|
218 |
e6363160
|
sbeaver
|
array_push($iflist['selected'], $laddr);
|
219 |
6e3488e9
|
Phil Davis
|
}
|
220 |
e6363160
|
sbeaver
|
}
|
221 |
|
|
|
222 |
|
|
unset($interface_addresses);
|
223 |
|
|
|
224 |
|
|
return($iflist);
|
225 |
|
|
}
|
226 |
|
|
|
227 |
9f5aa90f
|
Phil Davis
|
$pgtitle = array(gettext("Services"), gettext("DNS Forwarder"));
|
228 |
db88a3a2
|
Phil Davis
|
$shortcut_section = "forwarder";
|
229 |
b63695db
|
Scott Ullrich
|
include("head.inc");
|
230 |
0c2b5df7
|
Scott Ullrich
|
|
231 |
6e3488e9
|
Phil Davis
|
if ($input_errors) {
|
232 |
e6363160
|
sbeaver
|
print_input_errors($input_errors);
|
233 |
6e3488e9
|
Phil Davis
|
}
|
234 |
5b237745
|
Scott Ullrich
|
|
235 |
6e3488e9
|
Phil Davis
|
if ($savemsg) {
|
236 |
e6363160
|
sbeaver
|
print_info_box($savemsg, 'success');
|
237 |
6e3488e9
|
Phil Davis
|
}
|
238 |
e6363160
|
sbeaver
|
|
239 |
6e3488e9
|
Phil Davis
|
if (is_subsystem_dirty('hosts')) {
|
240 |
c9a66c65
|
NOYB
|
print_apply_box(gettext("The DNS forwarder configuration has been changed.") . "<br />" . gettext("The changes must be applied for them to take effect."));
|
241 |
6e3488e9
|
Phil Davis
|
}
|
242 |
e6363160
|
sbeaver
|
|
243 |
fae9a73c
|
sbeaver
|
$form = new Form();
|
244 |
e6363160
|
sbeaver
|
|
245 |
|
|
$section = new Form_Section('General DNS Forwarder Options');
|
246 |
|
|
|
247 |
|
|
$section->addInput(new Form_Checkbox(
|
248 |
|
|
'enable',
|
249 |
|
|
'Enable',
|
250 |
|
|
'Enable DNS forwarder',
|
251 |
|
|
$pconfig['enable']
|
252 |
08d1762e
|
Sjon Hortensius
|
))->toggles('.toggle-dhcp', 'disable');
|
253 |
e6363160
|
sbeaver
|
|
254 |
|
|
$section->addInput(new Form_Checkbox(
|
255 |
|
|
'regdhcp',
|
256 |
|
|
'DHCP Registration',
|
257 |
|
|
'Register DHCP leases in DNS forwarder',
|
258 |
|
|
$pconfig['regdhcp']
|
259 |
fae9a73c
|
sbeaver
|
))->setHelp(sprintf("If this option is set, then machines that specify".
|
260 |
70edf50d
|
jim-p
|
" their hostname when requesting a DHCP lease will be registered".
|
261 |
|
|
" in the DNS forwarder, so that their name can be resolved.".
|
262 |
3d7aaa1a
|
NOYB
|
" The domain in %sSystem: General Setup%s should also".
|
263 |
c9a66c65
|
NOYB
|
" be set to the proper value.",'<a href="system.php">','</a>'))
|
264 |
08d1762e
|
Sjon Hortensius
|
->addClass('toggle-dhcp');
|
265 |
e6363160
|
sbeaver
|
|
266 |
|
|
$section->addInput(new Form_Checkbox(
|
267 |
|
|
'regdhcpstatic',
|
268 |
|
|
'Static DHCP',
|
269 |
|
|
'Register DHCP static mappings in DNS forwarder',
|
270 |
|
|
$pconfig['regdhcpstatic']
|
271 |
fae9a73c
|
sbeaver
|
))->setHelp(sprintf("If this option is set, then DHCP static mappings will ".
|
272 |
70edf50d
|
jim-p
|
"be registered in the DNS forwarder, so that their name can be ".
|
273 |
3d7aaa1a
|
NOYB
|
"resolved. The domain in %sSystem: General Setup%s should also ".
|
274 |
c9a66c65
|
NOYB
|
"be set to the proper value.",'<a href="system.php">','</a>'))
|
275 |
08d1762e
|
Sjon Hortensius
|
->addClass('toggle-dhcp');
|
276 |
e6363160
|
sbeaver
|
|
277 |
|
|
$section->addInput(new Form_Checkbox(
|
278 |
|
|
'dhcpfirst',
|
279 |
|
|
'Prefer DHCP',
|
280 |
|
|
'Resolve DHCP mappings first',
|
281 |
|
|
$pconfig['dhcpfirst']
|
282 |
fae9a73c
|
sbeaver
|
))->setHelp(sprintf("If this option is set, then DHCP mappings will ".
|
283 |
aa994814
|
Andrew Thompson
|
"be resolved before the manual list of names below. This only ".
|
284 |
08d1762e
|
Sjon Hortensius
|
"affects the name given for a reverse lookup (PTR)."))
|
285 |
|
|
->addClass('toggle-dhcp');
|
286 |
e6363160
|
sbeaver
|
|
287 |
08d1762e
|
Sjon Hortensius
|
$group = new Form_Group('DNS Query Forwarding');
|
288 |
|
|
|
289 |
|
|
$group->add(new Form_Checkbox(
|
290 |
e6363160
|
sbeaver
|
'strict_order',
|
291 |
|
|
'DNS Query Forwarding',
|
292 |
|
|
'Query DNS servers sequentially',
|
293 |
|
|
$pconfig['strict_order']
|
294 |
fae9a73c
|
sbeaver
|
))->setHelp(sprintf("If this option is set, %s DNS Forwarder (dnsmasq) will ".
|
295 |
96ea7162
|
N0YB
|
"query the DNS servers sequentially in the order specified (<i>System - General Setup - DNS Servers</i>), ".
|
296 |
fae9a73c
|
sbeaver
|
"rather than all at once in parallel. ", $g['product_name']));
|
297 |
e6363160
|
sbeaver
|
|
298 |
08d1762e
|
Sjon Hortensius
|
$group->add(new Form_Checkbox(
|
299 |
e6363160
|
sbeaver
|
'domain_needed',
|
300 |
|
|
null,
|
301 |
|
|
'Require domain',
|
302 |
|
|
$pconfig['domain_needed']
|
303 |
fae9a73c
|
sbeaver
|
))->setHelp(sprintf("If this option is set, %s DNS Forwarder (dnsmasq) will ".
|
304 |
e6363160
|
sbeaver
|
"not forward A or AAAA queries for plain names, without dots or domain parts, to upstream name servers. ".
|
305 |
fae9a73c
|
sbeaver
|
"If the name is not known from /etc/hosts or DHCP then a \"not found\" answer is returned. ", $g['product_name']));
|
306 |
e6363160
|
sbeaver
|
|
307 |
08d1762e
|
Sjon Hortensius
|
$group->add(new Form_Checkbox(
|
308 |
e6363160
|
sbeaver
|
'no_private_reverse',
|
309 |
|
|
null,
|
310 |
|
|
'Do not forward private reverse lookups',
|
311 |
|
|
$pconfig['no_private_reverse']
|
312 |
fae9a73c
|
sbeaver
|
))->setHelp(sprintf("If this option is set, %s DNS Forwarder (dnsmasq) will ".
|
313 |
7bdd28fb
|
Phil Davis
|
"not forward reverse DNS lookups (PTR) for private addresses (RFC 1918) to upstream name servers. ".
|
314 |
|
|
"Any entries in the Domain Overrides section forwarding private \"n.n.n.in-addr.arpa\" names to a specific server are still forwarded. ".
|
315 |
fae9a73c
|
sbeaver
|
"If the IP to name is not known from /etc/hosts, DHCP or a specific domain override then a \"not found\" answer is immediately returned. ", $g['product_name']));
|
316 |
e6363160
|
sbeaver
|
|
317 |
08d1762e
|
Sjon Hortensius
|
$section->add($group);
|
318 |
|
|
|
319 |
e6363160
|
sbeaver
|
$section->addInput(new Form_Input(
|
320 |
|
|
'port',
|
321 |
|
|
'Listen Port',
|
322 |
08d1762e
|
Sjon Hortensius
|
'number',
|
323 |
|
|
$pconfig['port'],
|
324 |
|
|
['placeholder' => '53']
|
325 |
e6363160
|
sbeaver
|
))->setHelp('The port used for responding to DNS queries. It should normally be left blank unless another service needs to bind to TCP/UDP port 53.');
|
326 |
|
|
|
327 |
|
|
$iflist = build_if_list();
|
328 |
|
|
|
329 |
|
|
$section->addInput(new Form_Select(
|
330 |
|
|
'interface',
|
331 |
|
|
'Interfaces',
|
332 |
|
|
$iflist['selected'],
|
333 |
|
|
$iflist['options'],
|
334 |
|
|
true
|
335 |
|
|
))->setHelp('Interface IPs used by the DNS Forwarder for responding to queries from clients. If an interface has both IPv4 and IPv6 IPs, both are used. Queries to other interface IPs not selected below are discarded. ' .
|
336 |
|
|
'The default behavior is to respond to queries on every available IPv4 and IPv6 address.');
|
337 |
|
|
|
338 |
|
|
$section->addInput(new Form_Checkbox(
|
339 |
|
|
'strictbind',
|
340 |
08d1762e
|
Sjon Hortensius
|
'Strict binding',
|
341 |
e6363160
|
sbeaver
|
'Strict interface binding',
|
342 |
|
|
$pconfig['strictbind']
|
343 |
fae9a73c
|
sbeaver
|
))->setHelp('If this option is set, the DNS forwarder will only bind to the interfaces containing the IP addresses selected above, ' .
|
344 |
e6363160
|
sbeaver
|
'rather than binding to all interfaces and discarding queries to other addresses.' . '<br /><br />' .
|
345 |
fae9a73c
|
sbeaver
|
'This option does NOT work with IPv6. If set, dnsmasq will not bind to IPv6 addresses.');
|
346 |
e6363160
|
sbeaver
|
|
347 |
33ed4d60
|
Stephen Beaver
|
$section->addInput(new Form_Textarea(
|
348 |
e6363160
|
sbeaver
|
'custom_options',
|
349 |
|
|
'Custom options',
|
350 |
|
|
$pconfig['custom_options']
|
351 |
e78ecb96
|
NOYB
|
))->setHelp('Enter any additional options to add to the dnsmasq configuration here, separated by a space or newline.')
|
352 |
b6b7ab7d
|
Stephen Beaver
|
->addClass('advanced');
|
353 |
e6363160
|
sbeaver
|
|
354 |
|
|
$form->add($section);
|
355 |
|
|
print($form);
|
356 |
98f28b4e
|
k-paulius
|
|
357 |
b6b7ab7d
|
Stephen Beaver
|
?>
|
358 |
e6363160
|
sbeaver
|
<div class="panel panel-default">
|
359 |
c9679d8c
|
Stephen Beaver
|
<div class="panel-heading"><h2 class="panel-title"><?=gettext("Host Overrides")?></h2></div>
|
360 |
e6363160
|
sbeaver
|
<div class="panel-body table-responsive">
|
361 |
1c10ce97
|
PiBa-NL
|
<table class="table table-striped table-hover table-condensed sortable-theme-bootstrap table-rowdblclickedit" data-sortable>
|
362 |
e6363160
|
sbeaver
|
<thead>
|
363 |
70edf50d
|
jim-p
|
<tr>
|
364 |
e6363160
|
sbeaver
|
<th><?=gettext("Host")?></th>
|
365 |
|
|
<th><?=gettext("Domain")?></th>
|
366 |
|
|
<th><?=gettext("IP")?></th>
|
367 |
|
|
<th><?=gettext("Description")?></th>
|
368 |
21d973b2
|
Phil Davis
|
<th><?=gettext("Actions")?></th>
|
369 |
70edf50d
|
jim-p
|
</tr>
|
370 |
e6363160
|
sbeaver
|
</thead>
|
371 |
|
|
<tbody>
|
372 |
|
|
<?php
|
373 |
08d1762e
|
Sjon Hortensius
|
foreach ($a_hosts as $i => $hostent):
|
374 |
e6363160
|
sbeaver
|
?>
|
375 |
|
|
<tr>
|
376 |
|
|
<td>
|
377 |
a15714cc
|
NOYB
|
<?=$hostent['host']?>
|
378 |
e6363160
|
sbeaver
|
</td>
|
379 |
|
|
<td>
|
380 |
a15714cc
|
NOYB
|
<?=$hostent['domain']?>
|
381 |
e6363160
|
sbeaver
|
</td>
|
382 |
|
|
<td>
|
383 |
08d1762e
|
Sjon Hortensius
|
<?=$hostent['ip']?>
|
384 |
e6363160
|
sbeaver
|
</td>
|
385 |
|
|
<td>
|
386 |
|
|
<?=htmlspecialchars($hostent['descr'])?>
|
387 |
|
|
</td>
|
388 |
|
|
<td>
|
389 |
589634a9
|
Steve Beaver
|
<a class="fa fa-pencil" title="<?=gettext('Edit host override')?>" href="services_dnsmasq_edit.php?id=<?=$hostent['idx']?>"></a>
|
390 |
|
|
<a class="fa fa-trash" title="<?=gettext('Delete host override')?>" href="services_dnsmasq.php?type=host&act=del&id=<?=$hostent['idx']?>"></a>
|
391 |
e6363160
|
sbeaver
|
</td>
|
392 |
|
|
</tr>
|
393 |
|
|
|
394 |
|
|
<?php
|
395 |
|
|
if ($hostent['aliases']['item'] && is_array($hostent['aliases']['item'])):
|
396 |
231197bb
|
Phil Davis
|
foreach ($hostent['aliases']['item'] as $alias):
|
397 |
e6363160
|
sbeaver
|
?>
|
398 |
7bd5b320
|
Colin Fleming
|
<tr>
|
399 |
e6363160
|
sbeaver
|
<td>
|
400 |
a15714cc
|
NOYB
|
<?=$alias['host']?>
|
401 |
e6363160
|
sbeaver
|
</td>
|
402 |
|
|
<td>
|
403 |
a15714cc
|
NOYB
|
<?=$alias['domain']?>
|
404 |
e6363160
|
sbeaver
|
</td>
|
405 |
|
|
<td>
|
406 |
4bb7c0d1
|
bruno
|
<?=gettext("Alias for ");?><?=$hostent['host'] ? $hostent['host'] . '.' . $hostent['domain'] : $hostent['domain']?>
|
407 |
e6363160
|
sbeaver
|
</td>
|
408 |
|
|
<td>
|
409 |
39609bf9
|
Stephen Beaver
|
<i class="fa fa-angle-double-right text-info"></i>
|
410 |
e6363160
|
sbeaver
|
<?=htmlspecialchars($alias['description'])?>
|
411 |
|
|
</td>
|
412 |
|
|
<td>
|
413 |
c84a6977
|
heper
|
<a class="fa fa-pencil" title="<?=gettext('Edit host override')?>" href="services_dnsmasq_edit.php?id=<?=$i?>"></a>
|
414 |
e6363160
|
sbeaver
|
</td>
|
415 |
7bd5b320
|
Colin Fleming
|
</tr>
|
416 |
e6363160
|
sbeaver
|
<?php
|
417 |
|
|
endforeach;
|
418 |
|
|
endif;
|
419 |
|
|
endforeach;
|
420 |
|
|
?>
|
421 |
|
|
</tbody>
|
422 |
|
|
</table>
|
423 |
|
|
</div>
|
424 |
|
|
</div>
|
425 |
|
|
|
426 |
c10cb196
|
Stephen Beaver
|
<nav class="action-buttons">
|
427 |
c9679d8c
|
Stephen Beaver
|
<a href="services_dnsmasq_edit.php" class="btn btn-sm btn-success btn-sm">
|
428 |
9d5a20cf
|
heper
|
<i class="fa fa-plus icon-embed-btn"></i>
|
429 |
c9679d8c
|
Stephen Beaver
|
<?=gettext('Add')?>
|
430 |
|
|
</a>
|
431 |
e6363160
|
sbeaver
|
</nav>
|
432 |
|
|
|
433 |
|
|
<div class="panel panel-default">
|
434 |
c9679d8c
|
Stephen Beaver
|
<div class="panel-heading"><h2 class="panel-title"><?=gettext("Domain Overrides")?></h2></div>
|
435 |
e6363160
|
sbeaver
|
<div class="panel-body table-responsive">
|
436 |
1c10ce97
|
PiBa-NL
|
<table class="table table-striped table-hover table-condensed sortable-theme-bootstrap table-rowdblclickedit" data-sortable>
|
437 |
e6363160
|
sbeaver
|
<thead>
|
438 |
70edf50d
|
jim-p
|
<tr>
|
439 |
e6363160
|
sbeaver
|
<th><?=gettext("Domain")?></th>
|
440 |
|
|
<th><?=gettext("IP")?></th>
|
441 |
|
|
<th><?=gettext("Description")?></th>
|
442 |
21d973b2
|
Phil Davis
|
<th><?=gettext("Actions")?></th>
|
443 |
70edf50d
|
jim-p
|
</tr>
|
444 |
e6363160
|
sbeaver
|
</thead>
|
445 |
|
|
|
446 |
|
|
<tbody>
|
447 |
|
|
<?php
|
448 |
08d1762e
|
Sjon Hortensius
|
foreach ($a_domainOverrides as $i => $doment):
|
449 |
e6363160
|
sbeaver
|
?>
|
450 |
70edf50d
|
jim-p
|
<tr>
|
451 |
e6363160
|
sbeaver
|
<td>
|
452 |
a15714cc
|
NOYB
|
<?=$doment['domain']?>
|
453 |
e6363160
|
sbeaver
|
</td>
|
454 |
|
|
<td>
|
455 |
08d1762e
|
Sjon Hortensius
|
<?=$doment['ip']?>
|
456 |
e6363160
|
sbeaver
|
</td>
|
457 |
|
|
<td>
|
458 |
08d1762e
|
Sjon Hortensius
|
<?=htmlspecialchars($doment['descr'])?>
|
459 |
e6363160
|
sbeaver
|
</td>
|
460 |
|
|
<td>
|
461 |
589634a9
|
Steve Beaver
|
<a class="fa fa-pencil" title="<?=gettext('Edit domain override')?>" href="services_dnsmasq_domainoverride_edit.php?id=<?=$doment['idx']?>"></a>
|
462 |
|
|
<a class="fa fa-trash" title="<?=gettext('Delete domain override')?>" href="services_dnsmasq.php?act=del&type=doverride&id=<?=$doment['idx']?>"></a>
|
463 |
e6363160
|
sbeaver
|
</td>
|
464 |
70edf50d
|
jim-p
|
</tr>
|
465 |
e6363160
|
sbeaver
|
<?php
|
466 |
|
|
endforeach;
|
467 |
|
|
?>
|
468 |
|
|
</tbody>
|
469 |
7bd5b320
|
Colin Fleming
|
</table>
|
470 |
e6363160
|
sbeaver
|
</div>
|
471 |
|
|
</div>
|
472 |
|
|
|
473 |
c10cb196
|
Stephen Beaver
|
<nav class="action-buttons">
|
474 |
c9679d8c
|
Stephen Beaver
|
<a href="services_dnsmasq_domainoverride_edit.php" class="btn btn-sm btn-success btn-sm">
|
475 |
9d5a20cf
|
heper
|
<i class="fa fa-plus icon-embed-btn"></i>
|
476 |
c9679d8c
|
Stephen Beaver
|
<?=gettext('Add')?>
|
477 |
|
|
</a>
|
478 |
e6363160
|
sbeaver
|
</nav>
|
479 |
bd3b483a
|
Phil Davis
|
<div class="infoblock">
|
480 |
|
|
<?php
|
481 |
|
|
print_info_box(
|
482 |
|
|
'<p>' .
|
483 |
|
|
gettext('If the DNS forwarder is enabled, the DHCP service (if enabled) will automatically' .
|
484 |
|
|
' serve the LAN IP address as a DNS server to DHCP clients so they will use the forwarder.') . '</p><p>' .
|
485 |
|
|
sprintf(gettext('The DNS forwarder will use the DNS servers entered in %1$sSystem > General Setup%2$s or' .
|
486 |
|
|
' those obtained via DHCP or PPP on WAN if "Allow DNS server list to be overridden by DHCP/PPP on WAN" is checked.' .
|
487 |
|
|
' If that option is not used (or if a static IP address is used on WAN),' .
|
488 |
|
|
' at least one DNS server must be manually specified on the %1$sSystem > General Setup%2$s page.'),
|
489 |
|
|
'<a href="system.php">',
|
490 |
|
|
'</a>') .
|
491 |
|
|
'</p>',
|
492 |
|
|
'info',
|
493 |
|
|
false
|
494 |
|
|
);
|
495 |
|
|
?>
|
496 |
|
|
</div>
|
497 |
e6363160
|
sbeaver
|
|
498 |
c53fc00e
|
Phil Davis
|
<?php
|
499 |
c84a6977
|
heper
|
include("foot.inc");
|