Project

General

Profile

Download (24.1 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-2020 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['sslport'] = $a_unboundcfg['sslport'];
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['sslport'] && !is_port($pconfig['sslport'])) {
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['sslport'] = $pconfig['sslport'];
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
	'sslport',
346
	'SSL/TLS Listen Port',
347
	'number',
348
	$pconfig['sslport'],
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 pfSense system domain (System | General Setup | Domain).  Transparent is the default.  Local-Zone type descriptions are available in the unbound.conf(5) manual pages.');
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
					' The domain in %1$sSystem &gt; General Setup%2$s should also be set to the proper value.','<a href="system.php">','</a>');
444

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

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

    
461
$btnadv = new Form_Button(
462
	'btnadvcustom',
463
	'Custom options',
464
	null,
465
	'fa-cog'
466
);
467

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

    
470
$section->addInput(new Form_StaticText(
471
	'Display Custom Options',
472
	$btnadv
473
));
474

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

    
481
$form->add($section);
482
print($form);
483
?>
484

    
485
<script type="text/javascript">
486
//<![CDATA[
487
events.push(function() {
488

    
489
	// Show advanced custom options ==============================================
490
	var showadvcustom = false;
491

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

    
502
		hideInput('custom_options', !showadvcustom);
503

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

    
512
	// If the enable checkbox is not checked, hide all inputs
513
	function hideGeneral() {
514
		var hide = ! $('#enable').prop('checked');
515

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

    
528
	// Un-hide additional controls
529
	$('#btnadvcustom').click(function(event) {
530
		show_advcustom();
531
	});
532

    
533
	// When 'enable' is clicked, disable/enable the following hide inputs
534
	$('#enable').click(function() {
535
		hideGeneral();
536
	});
537

    
538
	// On initial load
539
	if ($('#custom_options').val().length == 0) {
540
		hideInput('custom_options', true);
541
	}
542

    
543
	hideGeneral();
544
	show_advcustom(true);
545

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

    
557
});
558
//]]>
559
</script>
560

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

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

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

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

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

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

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

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

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

    
715
<?php include("foot.inc");
(144-144/230)