Project

General

Profile

Download (24.4 KB) Statistics
| Branch: | Tag: | Revision:
1
<?php
2
/*
3
 * services_unbound.php
4
 *
5
 * part of pfSense (https://www.pfsense.org)
6
 * Copyright (c) 2004-2013 BSD Perimeter
7
 * Copyright (c) 2013-2016 Electric Sheep Fencing
8
 * Copyright (c) 2014-2021 Rubicon Communications, LLC (Netgate)
9
 * Copyright (c) 2014 Warren Baker (warren@pfsense.org)
10
 * All rights reserved.
11
 *
12
 * Licensed under the Apache License, Version 2.0 (the "License");
13
 * you may not use this file except in compliance with the License.
14
 * You may obtain a copy of the License at
15
 *
16
 * http://www.apache.org/licenses/LICENSE-2.0
17
 *
18
 * Unless required by applicable law or agreed to in writing, software
19
 * distributed under the License is distributed on an "AS IS" BASIS,
20
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
21
 * See the License for the specific language governing permissions and
22
 * limitations under the License.
23
 */
24

    
25
##|+PRIV
26
##|*IDENT=page-services-dnsresolver
27
##|*NAME=Services: DNS Resolver
28
##|*DESCR=Allow access to the 'Services: DNS Resolver' page.
29
##|*MATCH=services_unbound.php*
30
##|-PRIV
31

    
32
require_once("guiconfig.inc");
33
require_once("unbound.inc");
34
require_once("pfsense-utils.inc");
35
require_once("system.inc");
36

    
37
init_config_arr(array('unbound', 'hosts'));
38
init_config_arr(array('unbound', 'domainoverrides'));
39
$a_unboundcfg = &$config['unbound'];
40
$a_hosts = &$a_unboundcfg['hosts'];
41
$a_domainOverrides = &$a_unboundcfg['domainoverrides'];
42

    
43
if (isset($a_unboundcfg['enable'])) {
44
	$pconfig['enable'] = true;
45
}
46
if (isset($a_unboundcfg['enablessl'])) {
47
	$pconfig['enablessl'] = true;
48
}
49
if (isset($a_unboundcfg['dnssec'])) {
50
	$pconfig['dnssec'] = true;
51
}
52
if (isset($a_unboundcfg['python'])) {
53
	$pconfig['python'] = true;
54
}
55
if (isset($a_unboundcfg['forwarding'])) {
56
	$pconfig['forwarding'] = true;
57
}
58
if (isset($a_unboundcfg['forward_tls_upstream'])) {
59
	$pconfig['forward_tls_upstream'] = true;
60
}
61
if (isset($a_unboundcfg['regdhcp'])) {
62
	$pconfig['regdhcp'] = true;
63
}
64
if (isset($a_unboundcfg['regdhcpstatic'])) {
65
	$pconfig['regdhcpstatic'] = true;
66
}
67
if (isset($a_unboundcfg['regovpnclients'])) {
68
	$pconfig['regovpnclients'] = true;
69
}
70

    
71
$pconfig['python_order'] = $a_unboundcfg['python_order'];
72
$pconfig['python_script'] = $a_unboundcfg['python_script'];
73
$pconfig['port'] = $a_unboundcfg['port'];
74
$pconfig['tlsport'] = $a_unboundcfg['tlsport'];
75
$pconfig['sslcertref'] = $a_unboundcfg['sslcertref'];
76
$pconfig['custom_options'] = base64_decode($a_unboundcfg['custom_options']);
77

    
78
if (empty($a_unboundcfg['active_interface'])) {
79
	$pconfig['active_interface'] = array();
80
} else {
81
	$pconfig['active_interface'] = explode(",", $a_unboundcfg['active_interface']);
82
}
83

    
84
if (empty($a_unboundcfg['outgoing_interface'])) {
85
	$pconfig['outgoing_interface'] = array();
86
} else {
87
	$pconfig['outgoing_interface'] = explode(",", $a_unboundcfg['outgoing_interface']);
88
}
89

    
90
if (empty($a_unboundcfg['system_domain_local_zone_type'])) {
91
	$pconfig['system_domain_local_zone_type'] = "transparent";
92
} else {
93
	$pconfig['system_domain_local_zone_type'] = $a_unboundcfg['system_domain_local_zone_type'];
94
}
95

    
96
init_config_arr(array('cert'));
97
$a_cert = &$config['cert'];
98
$certs_available = false;
99

    
100
if (is_array($a_cert) && count($a_cert)) {
101
	$certs_available = true;
102
} else {
103
	$a_cert = array();
104
}
105

    
106
if ($_POST['apply']) {
107
	$retval = 0;
108
	$retval |= services_unbound_configure();
109
	if ($retval == 0) {
110
		clear_subsystem_dirty('unbound');
111
	}
112
	/* Update resolv.conf in case the interface bindings exclude localhost. */
113
	system_resolvconf_generate();
114
	/* Start or restart dhcpleases when it's necessary */
115
	system_dhcpleases_configure();
116
}
117

    
118
if ($_POST['save']) {
119
	$pconfig = $_POST;
120
	unset($input_errors);
121

    
122
	if (isset($pconfig['enable']) && isset($config['dnsmasq']['enable'])) {
123
		if ($pconfig['port'] == $config['dnsmasq']['port']) {
124
			$input_errors[] = gettext("The DNS Forwarder is enabled using this port. Choose a non-conflicting port, or disable the DNS Forwarder.");
125
		}
126
	}
127

    
128
	if (isset($pconfig['enablessl']) && (!$certs_available || empty($pconfig['sslcertref']))) {
129
		$input_errors[] = gettext("Acting as an SSL/TLS server requires a valid server certificate");
130
	}
131

    
132
	// forwarding mode requires having valid DNS servers
133
	if (isset($pconfig['forwarding'])) {
134
		$founddns = false;
135
		foreach (get_dns_nameservers(false, true) as $dns_server) {
136
			if (!ip_in_subnet($dns_server, "127.0.0.0/8")) {
137
				$founddns = true;
138
			}
139
		}
140
		if ($founddns == false) {
141
			$input_errors[] = gettext("At least one DNS server must be specified under System &gt; General Setup to enable Forwarding mode.");
142
		}
143
	}
144

    
145
	if (empty($pconfig['active_interface'])) {
146
		$input_errors[] = gettext("One or more Network Interfaces must be selected for binding.");
147
	} elseif (($config['system']['dnslocalhost'] != 'remote') && (!in_array("lo0", $pconfig['active_interface']) && !in_array("all", $pconfig['active_interface']))) {
148
		$input_errors[] = gettext("This system is configured to use the DNS Resolver as its DNS server, so Localhost or All must be selected in Network Interfaces.");
149
	}
150

    
151
	if (empty($pconfig['outgoing_interface'])) {
152
		$input_errors[] = gettext("One or more Outgoing Network Interfaces must be selected.");
153
	}
154

    
155
	if ($pconfig['port'] && !is_port($pconfig['port'])) {
156
		$input_errors[] = gettext("A valid port number must be specified.");
157
	}
158
	if ($pconfig['tlsport'] && !is_port($pconfig['tlsport'])) {
159
		$input_errors[] = gettext("A valid SSL/TLS port number must be specified.");
160
	}
161

    
162
	if (is_array($pconfig['active_interface']) && !empty($pconfig['active_interface'])) {
163
		$display_active_interface = $pconfig['active_interface'];
164
		$pconfig['active_interface'] = implode(",", $pconfig['active_interface']);
165
	}
166

    
167
	if ((isset($pconfig['regdhcp']) || isset($pconfig['regdhcpstatic'])) && !is_dhcp_server_enabled()) {
168
		$input_errors[] = gettext("DHCP Server must be enabled for DHCP Registration to work in DNS Resolver.");
169
	}
170

    
171
	if (($pconfig['system_domain_local_zone_type'] == "redirect") && isset($pconfig['regdhcp'])) {
172
		$input_errors[] = gettext('A System Domain Local Zone Type of "redirect" is not compatible with dynamic DHCP Registration.');
173
	}
174

    
175
	$display_custom_options = $pconfig['custom_options'];
176
	$pconfig['custom_options'] = base64_encode(str_replace("\r\n", "\n", $pconfig['custom_options']));
177

    
178
	if (is_array($pconfig['outgoing_interface']) && !empty($pconfig['outgoing_interface'])) {
179
		$display_outgoing_interface = $pconfig['outgoing_interface'];
180
		$pconfig['outgoing_interface'] = implode(",", $pconfig['outgoing_interface']);
181
	}
182

    
183
	$test_output = array();
184
	if (test_unbound_config($pconfig, $test_output)) {
185
		$input_errors[] = gettext("The generated config file cannot be parsed by unbound. Please correct the following errors:");
186
		$input_errors = array_merge($input_errors, $test_output);
187
	}
188

    
189
	if (!$input_errors) {
190
		$a_unboundcfg['enable'] = isset($pconfig['enable']);
191
		$a_unboundcfg['enablessl'] = isset($pconfig['enablessl']);
192
		$a_unboundcfg['port'] = $pconfig['port'];
193
		$a_unboundcfg['tlsport'] = $pconfig['tlsport'];
194
		$a_unboundcfg['sslcertref'] = $pconfig['sslcertref'];
195
		$a_unboundcfg['dnssec'] = isset($pconfig['dnssec']);
196

    
197
		$a_unboundcfg['python'] = isset($pconfig['python']);
198
		if (isset($pconfig['python'])) {
199
			$a_unboundcfg['python_order'] = $pconfig['python_order'];
200
			$a_unboundcfg['python_script'] = $pconfig['python_script'];
201
		} else {
202
			if (isset($a_unboundcfg['python_order'])) {
203
				unset($a_unboundcfg['python_order']);
204
			}
205
			if (isset($a_unboundcfg['python_script'])) {
206
				unset($a_unboundcfg['python_script']);
207
			}
208
		}
209

    
210
		$a_unboundcfg['forwarding'] = isset($pconfig['forwarding']);
211
		$a_unboundcfg['forward_tls_upstream'] = isset($pconfig['forward_tls_upstream']);
212
		$a_unboundcfg['regdhcp'] = isset($pconfig['regdhcp']);
213
		$a_unboundcfg['regdhcpstatic'] = isset($pconfig['regdhcpstatic']);
214
		$a_unboundcfg['regovpnclients'] = isset($pconfig['regovpnclients']);
215
		$a_unboundcfg['active_interface'] = $pconfig['active_interface'];
216
		$a_unboundcfg['outgoing_interface'] = $pconfig['outgoing_interface'];
217
		$a_unboundcfg['system_domain_local_zone_type'] = $pconfig['system_domain_local_zone_type'];
218
		$a_unboundcfg['custom_options'] = $pconfig['custom_options'];
219

    
220
		write_config(gettext("DNS Resolver configured."));
221
		mark_subsystem_dirty('unbound');
222
	}
223

    
224
	$pconfig['active_interface'] = $display_active_interface;
225
	$pconfig['outgoing_interface'] = $display_outgoing_interface;
226
	$pconfig['custom_options'] = $display_custom_options;
227
}
228

    
229

    
230
if ($pconfig['custom_options']) {
231
	$customoptions = true;
232
} else {
233
	$customoptions = false;
234
}
235

    
236
if ($_POST['act'] == "del") {
237
	if ($_POST['type'] == 'host') {
238
		if ($a_hosts[$_POST['id']]) {
239
			unset($a_hosts[$_POST['id']]);
240
			write_config(gettext("Host override deleted from DNS Resolver."));
241
			mark_subsystem_dirty('unbound');
242
			header("Location: services_unbound.php");
243
			exit;
244
		}
245
	} elseif ($_POST['type'] == 'doverride') {
246
		if ($a_domainOverrides[$_POST['id']]) {
247
			unset($a_domainOverrides[$_POST['id']]);
248
			write_config(gettext("Domain override deleted from DNS Resolver."));
249
			mark_subsystem_dirty('unbound');
250
			header("Location: services_unbound.php");
251
			exit;
252
		}
253
	}
254
}
255

    
256
function build_if_list($selectedifs) {
257
	$interface_addresses = get_possible_listen_ips(true);
258
	$iflist = array('options' => array(), 'selected' => array());
259

    
260
	$iflist['options']['all']	= gettext("All");
261
	if (empty($selectedifs) || empty($selectedifs[0]) || in_array("all", $selectedifs)) {
262
		array_push($iflist['selected'], "all");
263
	}
264

    
265
	foreach ($interface_addresses as $laddr => $ldescr) {
266
		$iflist['options'][$laddr] = htmlspecialchars($ldescr);
267

    
268
		if ($selectedifs && in_array($laddr, $selectedifs)) {
269
			array_push($iflist['selected'], $laddr);
270
		}
271
	}
272

    
273
	unset($interface_addresses);
274

    
275
	return($iflist);
276
}
277

    
278
$pgtitle = array(gettext("Services"), gettext("DNS Resolver"), gettext("General Settings"));
279
$pglinks = array("", "@self", "@self");
280
$shortcut_section = "resolver";
281

    
282
include_once("head.inc");
283

    
284
if ($input_errors) {
285
	print_input_errors($input_errors);
286
}
287

    
288
if ($_POST['apply']) {
289
	print_apply_result_box($retval);
290
}
291

    
292
if (is_subsystem_dirty('unbound')) {
293
	print_apply_box(gettext("The DNS resolver configuration has been changed.") . "<br />" . gettext("The changes must be applied for them to take effect."));
294
}
295

    
296
$tab_array = array();
297
$tab_array[] = array(gettext("General Settings"), true, "services_unbound.php");
298
$tab_array[] = array(gettext("Advanced Settings"), false, "services_unbound_advanced.php");
299
$tab_array[] = array(gettext("Access Lists"), false, "/services_unbound_acls.php");
300
display_top_tabs($tab_array, true);
301

    
302
$form = new Form();
303

    
304
$section = new Form_Section('General DNS Resolver Options');
305

    
306
$section->addInput(new Form_Checkbox(
307
	'enable',
308
	'Enable',
309
	'Enable DNS resolver',
310
	$pconfig['enable']
311
));
312

    
313
$section->addInput(new Form_Input(
314
	'port',
315
	'Listen Port',
316
	'number',
317
	$pconfig['port'],
318
	['placeholder' => '53']
319
))->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.');
320

    
321
$section->addInput(new Form_Checkbox(
322
	'enablessl',
323
	'Enable SSL/TLS Service',
324
	'Respond to incoming SSL/TLS queries from local clients',
325
	$pconfig['enablessl']
326
))->setHelp('Configures the DNS Resolver to act as a DNS over SSL/TLS server which can answer queries from clients which also support DNS over TLS. ' .
327
		'Activating this option disables automatic interface response routing behavior, thus it works best with specific interface bindings.' );
328

    
329
if ($certs_available) {
330
	$section->addInput($input = new Form_Select(
331
		'sslcertref',
332
		'SSL/TLS Certificate',
333
		$pconfig['sslcertref'],
334
		cert_build_list('cert', 'IPsec')
335
	))->setHelp('The server certificate to use for SSL/TLS service. The CA chain will be determined automatically.');
336
} else {
337
	$section->addInput(new Form_StaticText(
338
		'SSL/TLS Certificate',
339
		sprintf('No Certificates have been defined. A certificate is required before SSL/TLS can be enabled. %1$s Create or Import %2$s a Certificate.',
340
		'<a href="system_certmanager.php">', '</a>')
341
	));
342
}
343

    
344
$section->addInput(new Form_Input(
345
	'tlsport',
346
	'SSL/TLS Listen Port',
347
	'number',
348
	$pconfig['tlsport'],
349
	['placeholder' => '853']
350
))->setHelp('The port used for responding to SSL/TLS DNS queries. It should normally be left blank unless another service needs to bind to TCP/UDP port 853.');
351

    
352
$activeiflist = build_if_list($pconfig['active_interface']);
353

    
354
$section->addInput(new Form_Select(
355
	'active_interface',
356
	'*Network Interfaces',
357
	$activeiflist['selected'],
358
	$activeiflist['options'],
359
	true
360
))->addClass('general', 'resizable')->setHelp('Interface IPs used by the DNS Resolver 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. ' .
361
			'The default behavior is to respond to queries on every available IPv4 and IPv6 address.');
362

    
363
$outiflist = build_if_list($pconfig['outgoing_interface']);
364

    
365
$section->addInput(new Form_Select(
366
	'outgoing_interface',
367
	'*Outgoing Network Interfaces',
368
	$outiflist['selected'],
369
	$outiflist['options'],
370
	true
371
))->addClass('general', 'resizable')->setHelp('Utilize different network interface(s) that the DNS Resolver will use to send queries to authoritative servers and receive their replies. By default all interfaces are used.');
372

    
373
$section->addInput(new Form_Select(
374
	'system_domain_local_zone_type',
375
	'*System Domain Local Zone Type',
376
	$pconfig['system_domain_local_zone_type'],
377
	unbound_local_zone_types()
378
))->setHelp('The local-zone type used for the %1$s system domain (System | General Setup | Domain).  Transparent is the default.  Local-Zone type descriptions are available in the unbound.conf(5) manual pages.', $g['product_label']);
379

    
380
$section->addInput(new Form_Checkbox(
381
	'dnssec',
382
	'DNSSEC',
383
	'Enable DNSSEC Support',
384
	$pconfig['dnssec']
385
));
386

    
387
$section->addInput(new Form_Checkbox(
388
	'python',
389
	'Python Module',
390
	'Enable Python Module',
391
	$pconfig['python']
392
))->setHelp('Enable the Python Module.');
393

    
394
$python_files = glob("{$g['unbound_chroot_path']}/*.py");
395
$python_scripts = array();
396
if (!empty($python_files)) {
397
	foreach ($python_files as $file) {
398
		$file = pathinfo($file, PATHINFO_FILENAME);
399
		$python_scripts[$file] = $file;
400
	}
401
}
402
else {
403
	$python_scripts = array('' => 'No Python Module scripts found');
404
}
405

    
406
$section->addInput(new Form_Select(
407
	'python_order',
408
	'Python Module Order',
409
	$pconfig['python_order'],
410
	[ 'pre_validator' => 'Pre Validator', 'post_validator' => 'Post Validator' ]
411
))->setHelp('Select the Python Module ordering.');
412

    
413
$section->addInput(new Form_Select(
414
	'python_script',
415
	'Python Module Script',
416
	$pconfig['python_script'],
417
	$python_scripts
418
))->setHelp('Select the Python module script to utilize.');
419

    
420
$section->addInput(new Form_Checkbox(
421
	'forwarding',
422
	'DNS Query Forwarding',
423
	'Enable Forwarding Mode',
424
	$pconfig['forwarding']
425
))->setHelp('If this option is set, DNS queries will be forwarded to the upstream DNS servers defined under'.
426
					' %1$sSystem &gt; General Setup%2$s or those obtained via DHCP/PPP on WAN'.
427
					' (if DNS Server Override is enabled there).','<a href="system.php">','</a>');
428

    
429
$section->addInput(new Form_Checkbox(
430
	'forward_tls_upstream',
431
	null,
432
	'Use SSL/TLS for outgoing DNS Queries to Forwarding Servers',
433
	$pconfig['forward_tls_upstream']
434
))->setHelp('When set in conjunction with DNS Query Forwarding, queries to all upstream forwarding DNS servers will be sent using SSL/TLS on the default port of 853. Note that ALL configured forwarding servers MUST support SSL/TLS queries on port 853.');
435

    
436
$section->addInput(new Form_Checkbox(
437
	'regdhcp',
438
	'DHCP Registration',
439
	'Register DHCP leases in the DNS Resolver',
440
	$pconfig['regdhcp']
441
))->setHelp('If this option is set, then machines that specify their hostname when requesting an IPv4 DHCP lease will be registered'.
442
					' in the DNS Resolver so that their name can be resolved.'.
443
	    				' Note that this will cause the Resolver to reload and flush its resolution cache whenever a DHCP lease is issued.'.
444
					' The domain in %1$sSystem &gt; General Setup%2$s should also be set to the proper value.','<a href="system.php">','</a>');
445

    
446
$section->addInput(new Form_Checkbox(
447
	'regdhcpstatic',
448
	'Static DHCP',
449
	'Register DHCP static mappings in the DNS Resolver',
450
	$pconfig['regdhcpstatic']
451
))->setHelp('If this option is set, then DHCP static mappings will be registered in the DNS Resolver, so that their name can be resolved. '.
452
					'The domain in %1$sSystem &gt; General Setup%2$s should also be set to the proper value.','<a href="system.php">','</a>');
453

    
454
$section->addInput(new Form_Checkbox(
455
	'regovpnclients',
456
	'OpenVPN Clients',
457
	'Register connected OpenVPN clients in the DNS Resolver',
458
	$pconfig['regovpnclients']
459
))->setHelp(sprintf('If this option is set, then the common name (CN) of connected OpenVPN clients will be ' .
460
	    'registered in the DNS Resolver, so that their name can be resolved. This only works for OpenVPN ' .
461
	    'servers (Remote Access SSL/TLS or User Auth with Username as Common Name option) operating ' .
462
	    'in "tun" mode. The domain in %sSystem: General Setup%s should also be set to the proper value.',
463
	    '<a href="system.php">','</a>'));
464

    
465
$btnadv = new Form_Button(
466
	'btnadvcustom',
467
	'Custom options',
468
	null,
469
	'fa-cog'
470
);
471

    
472
$btnadv->setAttribute('type','button')->addClass('btn-info btn-sm');
473

    
474
$section->addInput(new Form_StaticText(
475
	'Display Custom Options',
476
	$btnadv
477
));
478

    
479
$section->addInput(new Form_Textarea (
480
	'custom_options',
481
	'Custom options',
482
	$pconfig['custom_options']
483
))->setHelp('Enter any additional configuration parameters to add to the DNS Resolver configuration here, separated by a newline.');
484

    
485
$form->add($section);
486
print($form);
487
?>
488

    
489
<script type="text/javascript">
490
//<![CDATA[
491
events.push(function() {
492

    
493
	// Show advanced custom options ==============================================
494
	var showadvcustom = false;
495

    
496
	function show_advcustom(ispageload) {
497
		var text;
498
		// On page load decide the initial state based on the data.
499
		if (ispageload) {
500
			showadvcustom = <?=($customoptions ? 'true' : 'false');?>;
501
		} else {
502
			// It was a click, swap the state.
503
			showadvcustom = !showadvcustom;
504
		}
505

    
506
		hideInput('custom_options', !showadvcustom);
507

    
508
		if (showadvcustom) {
509
			text = "<?=gettext('Hide Custom Options');?>";
510
		} else {
511
			text = "<?=gettext('Display Custom Options');?>";
512
		}
513
		$('#btnadvcustom').html('<i class="fa fa-cog"></i> ' + text);
514
	}
515

    
516
	// If the enable checkbox is not checked, hide all inputs
517
	function hideGeneral() {
518
		var hide = ! $('#enable').prop('checked');
519

    
520
		hideMultiClass('general', hide);
521
		hideInput('port', hide);
522
		hideSelect('system_domain_local_zone_type', hide);
523
		hideCheckbox('dnssec', hide);
524
		hideCheckbox('forwarding', hide);
525
		hideCheckbox('regdhcp', hide);
526
		hideCheckbox('regdhcpstatic', hide);
527
		hideCheckbox('regovpnclients', hide);
528
		hideInput('btnadvcustom', hide);
529
		hideInput('custom_options', hide || !showadvcustom);
530
	}
531

    
532
	// Un-hide additional controls
533
	$('#btnadvcustom').click(function(event) {
534
		show_advcustom();
535
	});
536

    
537
	// When 'enable' is clicked, disable/enable the following hide inputs
538
	$('#enable').click(function() {
539
		hideGeneral();
540
	});
541

    
542
	// On initial load
543
	if ($('#custom_options').val().length == 0) {
544
		hideInput('custom_options', true);
545
	}
546

    
547
	hideGeneral();
548
	show_advcustom(true);
549

    
550
	// When the Python Module 'enable' is clicked, disable/enable the Python Module options
551
	function show_python_script() {
552
		var python = $('#python').prop('checked');
553
		hideInput('python_order', !python);
554
		hideInput('python_script', !python);
555
	}
556
	show_python_script();
557
	$('#python').click(function () {
558
		show_python_script();
559
	});
560

    
561
});
562
//]]>
563
</script>
564

    
565
<div class="panel panel-default">
566
	<div class="panel-heading"><h2 class="panel-title"><?=gettext("Host Overrides")?></h2></div>
567
	<div class="panel-body table-responsive">
568
		<table class="table table-striped table-hover table-condensed sortable-theme-bootstrap table-rowdblclickedit" data-sortable>
569
			<thead>
570
				<tr>
571
					<th><?=gettext("Host")?></th>
572
					<th><?=gettext("Parent domain of host")?></th>
573
					<th><?=gettext("IP to return for host")?></th>
574
					<th><?=gettext("Description")?></th>
575
					<th><?=gettext("Actions")?></th>
576
				</tr>
577
			</thead>
578
			<tbody>
579
<?php
580
$i = 0;
581
foreach ($a_hosts as $hostent):
582
?>
583
				<tr>
584
					<td>
585
						<?=$hostent['host']?>
586
					</td>
587
					<td>
588
						<?=$hostent['domain']?>
589
					</td>
590
					<td>
591
						<?=$hostent['ip']?>
592
					</td>
593
					<td>
594
						<?=htmlspecialchars($hostent['descr'])?>
595
					</td>
596
					<td>
597
						<a class="fa fa-pencil"	title="<?=gettext('Edit host override')?>" href="services_unbound_host_edit.php?id=<?=$i?>"></a>
598
						<a class="fa fa-trash"	title="<?=gettext('Delete host override')?>" href="services_unbound.php?type=host&amp;act=del&amp;id=<?=$i?>" usepost></a>
599
					</td>
600
				</tr>
601

    
602
<?php
603
	if ($hostent['aliases']['item'] && is_array($hostent['aliases']['item'])):
604
		foreach ($hostent['aliases']['item'] as $alias):
605
?>
606
				<tr>
607
					<td>
608
						<?=$alias['host']?>
609
					</td>
610
					<td>
611
						<?=$alias['domain']?>
612
					</td>
613
					<td>
614
						<?=gettext("Alias for ");?><?=$hostent['host'] ? $hostent['host'] . '.' . $hostent['domain'] : $hostent['domain']?>
615
					</td>
616
					<td>
617
						<i class="fa fa-angle-double-right text-info"></i>
618
						<?=htmlspecialchars($alias['description'])?>
619
					</td>
620
					<td>
621
						<a class="fa fa-pencil"	title="<?=gettext('Edit host override')?>" 	href="services_unbound_host_edit.php?id=<?=$i?>"></a>
622
					</td>
623
				</tr>
624
<?php
625
		endforeach;
626
	endif;
627
	$i++;
628
endforeach;
629
?>
630
			</tbody>
631
		</table>
632
	</div>
633
</div>
634

    
635
<span class="help-block">
636
	Enter any individual hosts for which the resolver's standard DNS lookup process should be overridden and a specific
637
	IPv4 or IPv6 address should automatically be returned by the resolver. Standard and also non-standard names and parent domains
638
	can be entered, such as 'test', 'nas.home.arpa', 'mycompany.localdomain', '1.168.192.in-addr.arpa', or 'somesite.com'. Any lookup attempt for
639
	the host will automatically return the given IP address, and the usual lookup server for the domain will not be queried for
640
	the host's records.
641
</span>
642

    
643
<nav class="action-buttons">
644
	<a href="services_unbound_host_edit.php" class="btn btn-sm btn-success">
645
		<i class="fa fa-plus icon-embed-btn"></i>
646
		<?=gettext('Add')?>
647
	</a>
648
</nav>
649

    
650
<div class="panel panel-default">
651
	<div class="panel-heading"><h2 class="panel-title"><?=gettext("Domain Overrides")?></h2></div>
652
	<div class="panel-body table-responsive">
653
		<table class="table table-striped table-hover table-condensed sortable-theme-bootstrap table-rowdblclickedit" data-sortable>
654
			<thead>
655
				<tr>
656
					<th><?=gettext("Domain")?></th>
657
					<th><?=gettext("Lookup Server IP Address")?></th>
658
					<th><?=gettext("Description")?></th>
659
					<th><?=gettext("Actions")?></th>
660
				</tr>
661
			</thead>
662

    
663
			<tbody>
664
<?php
665
$i = 0;
666
foreach ($a_domainOverrides as $doment):
667
?>
668
				<tr>
669
					<td>
670
						<?=$doment['domain']?>&nbsp;
671
					</td>
672
					<td>
673
						<?=$doment['ip']?>&nbsp;
674
					</td>
675
					<td>
676
						<?=htmlspecialchars($doment['descr'])?>&nbsp;
677
					</td>
678
					<td>
679
						<a class="fa fa-pencil"	title="<?=gettext('Edit domain override')?>" href="services_unbound_domainoverride_edit.php?id=<?=$i?>"></a>
680
						<a class="fa fa-trash"	title="<?=gettext('Delete domain override')?>" href="services_unbound.php?act=del&amp;type=doverride&amp;id=<?=$i?>" usepost></a>
681
					</td>
682
				</tr>
683
<?php
684
	$i++;
685
endforeach;
686
?>
687
			</tbody>
688
		</table>
689
	</div>
690
</div>
691

    
692
<span class="help-block">
693
	Enter any domains for which the resolver's standard DNS lookup process should be overridden and a different (non-standard)
694
	lookup server should be queried instead. Non-standard, 'invalid' and local domains, and subdomains, can also be entered,
695
	such as 'test', 'nas.home.arpa', 'mycompany.localdomain', '1.168.192.in-addr.arpa', or 'somesite.com'. The IP address is treated as the
696
	authoritative lookup server for the domain (including all of its subdomains), and other lookup servers will not be queried.
697
	If there are multiple authoritative DNS servers available for a domain then make a separate entry for each, 
698
	using the same domain name.
699
</span>
700

    
701
<nav class="action-buttons">
702
	<a href="services_unbound_domainoverride_edit.php" class="btn btn-sm btn-success">
703
		<i class="fa fa-plus icon-embed-btn"></i>
704
		<?=gettext('Add')?>
705
	</a>
706
</nav>
707

    
708
<div class="infoblock">
709
	<?php print_info_box(sprintf(gettext('If the DNS Resolver is enabled, the DHCP'.
710
		' service (if enabled) will automatically serve the LAN IP'.
711
		' address as a DNS server to DHCP clients so they will use'.
712
		' the DNS Resolver. If Forwarding is enabled, the DNS Resolver will use the DNS servers'.
713
		' entered in %1$sSystem &gt; General Setup%2$s'.
714
		' or those obtained via DHCP or PPP on WAN if &quot;Allow'.
715
		' DNS server list to be overridden by DHCP/PPP on WAN&quot;'.
716
		' is checked.'), '<a href="system.php">', '</a>'), 'info', false); ?>
717
</div>
718

    
719
<?php include("foot.inc");
(141-141/227)