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-2019 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
		if (isset($config['system']['dnsallowoverride'])) {
136
			$dns_servers = get_dns_servers();
137
			if (is_array($dns_servers)) {
138
				foreach ($dns_servers as $dns_server) {
139
					if (!ip_in_subnet($dns_server, "127.0.0.0/8")) {
140
						$founddns = true;
141
					}
142
				}
143
			}
144
		}
145
		if (is_array($config['system']['dnsserver'])) {
146
			foreach ($config['system']['dnsserver'] as $dnsserver) {
147
				if (is_ipaddr($dnsserver)) {
148
					$founddns = true;
149
				}
150
			}
151
		}
152
		if ($founddns == false) {
153
			$input_errors[] = gettext("At least one DNS server must be specified under System &gt; General Setup to enable Forwarding mode.");
154
		}
155
	}
156

    
157
	if (empty($pconfig['active_interface'])) {
158
		$input_errors[] = gettext("One or more Network Interfaces must be selected for binding.");
159
	} else if (!isset($config['system']['dnslocalhost']) && (!in_array("lo0", $pconfig['active_interface']) && !in_array("all", $pconfig['active_interface']))) {
160
		$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.");
161
	}
162

    
163
	if (empty($pconfig['outgoing_interface'])) {
164
		$input_errors[] = gettext("One or more Outgoing Network Interfaces must be selected.");
165
	}
166

    
167
	if ($pconfig['port'] && !is_port($pconfig['port'])) {
168
		$input_errors[] = gettext("A valid port number must be specified.");
169
	}
170
	if ($pconfig['sslport'] && !is_port($pconfig['sslport'])) {
171
		$input_errors[] = gettext("A valid SSL/TLS port number must be specified.");
172
	}
173

    
174
	if (is_array($pconfig['active_interface']) && !empty($pconfig['active_interface'])) {
175
		$display_active_interface = $pconfig['active_interface'];
176
		$pconfig['active_interface'] = implode(",", $pconfig['active_interface']);
177
	}
178

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

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

    
187
	$display_custom_options = $pconfig['custom_options'];
188
	$pconfig['custom_options'] = base64_encode(str_replace("\r\n", "\n", $pconfig['custom_options']));
189

    
190
	if (is_array($pconfig['outgoing_interface']) && !empty($pconfig['outgoing_interface'])) {
191
		$display_outgoing_interface = $pconfig['outgoing_interface'];
192
		$pconfig['outgoing_interface'] = implode(",", $pconfig['outgoing_interface']);
193
	}
194

    
195
	$test_output = array();
196
	if (test_unbound_config($pconfig, $test_output)) {
197
		$input_errors[] = gettext("The generated config file cannot be parsed by unbound. Please correct the following errors:");
198
		$input_errors = array_merge($input_errors, $test_output);
199
	}
200

    
201
	if (!$input_errors) {
202
		$a_unboundcfg['enable'] = isset($pconfig['enable']);
203
		$a_unboundcfg['enablessl'] = isset($pconfig['enablessl']);
204
		$a_unboundcfg['port'] = $pconfig['port'];
205
		$a_unboundcfg['sslport'] = $pconfig['sslport'];
206
		$a_unboundcfg['sslcertref'] = $pconfig['sslcertref'];
207
		$a_unboundcfg['dnssec'] = isset($pconfig['dnssec']);
208

    
209
		$a_unboundcfg['python'] = isset($pconfig['python']);
210
		if (isset($pconfig['python'])) {
211
			$a_unboundcfg['python_order'] = $pconfig['python_order'];
212
			$a_unboundcfg['python_script'] = $pconfig['python_script'];
213
		} else {
214
			if (isset($a_unboundcfg['python_order'])) {
215
				unset($a_unboundcfg['python_order']);
216
			}
217
			if (isset($a_unboundcfg['python_script'])) {
218
				unset($a_unboundcfg['python_script']);
219
			}
220
		}
221

    
222
		$a_unboundcfg['forwarding'] = isset($pconfig['forwarding']);
223
		$a_unboundcfg['forward_tls_upstream'] = isset($pconfig['forward_tls_upstream']);
224
		$a_unboundcfg['regdhcp'] = isset($pconfig['regdhcp']);
225
		$a_unboundcfg['regdhcpstatic'] = isset($pconfig['regdhcpstatic']);
226
		$a_unboundcfg['regovpnclients'] = isset($pconfig['regovpnclients']);
227
		$a_unboundcfg['active_interface'] = $pconfig['active_interface'];
228
		$a_unboundcfg['outgoing_interface'] = $pconfig['outgoing_interface'];
229
		$a_unboundcfg['system_domain_local_zone_type'] = $pconfig['system_domain_local_zone_type'];
230
		$a_unboundcfg['custom_options'] = $pconfig['custom_options'];
231

    
232
		write_config(gettext("DNS Resolver configured."));
233
		mark_subsystem_dirty('unbound');
234
	}
235

    
236
	$pconfig['active_interface'] = $display_active_interface;
237
	$pconfig['outgoing_interface'] = $display_outgoing_interface;
238
	$pconfig['custom_options'] = $display_custom_options;
239
}
240

    
241

    
242
if ($pconfig['custom_options']) {
243
	$customoptions = true;
244
} else {
245
	$customoptions = false;
246
}
247

    
248
if ($_POST['act'] == "del") {
249
	if ($_POST['type'] == 'host') {
250
		if ($a_hosts[$_POST['id']]) {
251
			unset($a_hosts[$_POST['id']]);
252
			write_config(gettext("Host override deleted from DNS Resolver."));
253
			mark_subsystem_dirty('unbound');
254
			header("Location: services_unbound.php");
255
			exit;
256
		}
257
	} elseif ($_POST['type'] == 'doverride') {
258
		if ($a_domainOverrides[$_POST['id']]) {
259
			unset($a_domainOverrides[$_POST['id']]);
260
			write_config(gettext("Domain override deleted from DNS Resolver."));
261
			mark_subsystem_dirty('unbound');
262
			header("Location: services_unbound.php");
263
			exit;
264
		}
265
	}
266
}
267

    
268
function build_if_list($selectedifs) {
269
	$interface_addresses = get_possible_listen_ips(true);
270
	$iflist = array('options' => array(), 'selected' => array());
271

    
272
	$iflist['options']['all']	= gettext("All");
273
	if (empty($selectedifs) || empty($selectedifs[0]) || in_array("all", $selectedifs)) {
274
		array_push($iflist['selected'], "all");
275
	}
276

    
277
	foreach ($interface_addresses as $laddr => $ldescr) {
278
		$iflist['options'][$laddr] = htmlspecialchars($ldescr);
279

    
280
		if ($selectedifs && in_array($laddr, $selectedifs)) {
281
			array_push($iflist['selected'], $laddr);
282
		}
283
	}
284

    
285
	unset($interface_addresses);
286

    
287
	return($iflist);
288
}
289

    
290
$pgtitle = array(gettext("Services"), gettext("DNS Resolver"), gettext("General Settings"));
291
$pglinks = array("", "@self", "@self");
292
$shortcut_section = "resolver";
293

    
294
include_once("head.inc");
295

    
296
if ($input_errors) {
297
	print_input_errors($input_errors);
298
}
299

    
300
if ($_POST['apply']) {
301
	print_apply_result_box($retval);
302
}
303

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

    
308
$tab_array = array();
309
$tab_array[] = array(gettext("General Settings"), true, "services_unbound.php");
310
$tab_array[] = array(gettext("Advanced Settings"), false, "services_unbound_advanced.php");
311
$tab_array[] = array(gettext("Access Lists"), false, "/services_unbound_acls.php");
312
display_top_tabs($tab_array, true);
313

    
314
$form = new Form();
315

    
316
$section = new Form_Section('General DNS Resolver Options');
317

    
318
$section->addInput(new Form_Checkbox(
319
	'enable',
320
	'Enable',
321
	'Enable DNS resolver',
322
	$pconfig['enable']
323
));
324

    
325
$section->addInput(new Form_Input(
326
	'port',
327
	'Listen Port',
328
	'number',
329
	$pconfig['port'],
330
	['placeholder' => '53']
331
))->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.');
332

    
333
$section->addInput(new Form_Checkbox(
334
	'enablessl',
335
	'Enable SSL/TLS Service',
336
	'Respond to incoming SSL/TLS queries from local clients',
337
	$pconfig['enablessl']
338
))->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. ' .
339
		'Activating this option disables automatic interface response routing behavior, thus it works best with specific interface bindings.' );
340

    
341
if ($certs_available) {
342
	$values = array();
343
	foreach ($a_cert as $cert) {
344
		$values[ $cert['refid'] ] = $cert['descr'];
345
	}
346

    
347
	$section->addInput($input = new Form_Select(
348
		'sslcertref',
349
		'SSL/TLS Certificate',
350
		$pconfig['sslcertref'],
351
		$values
352
	))->setHelp('The server certificate to use for SSL/TLS service. The CA chain will be determined automatically.');
353
} else {
354
	$section->addInput(new Form_StaticText(
355
		'SSL/TLS Certificate',
356
		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.',
357
		'<a href="system_certmanager.php">', '</a>')
358
	));
359
}
360

    
361
$section->addInput(new Form_Input(
362
	'sslport',
363
	'SSL/TLS Listen Port',
364
	'number',
365
	$pconfig['sslport'],
366
	['placeholder' => '853']
367
))->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.');
368

    
369
$activeiflist = build_if_list($pconfig['active_interface']);
370

    
371
$section->addInput(new Form_Select(
372
	'active_interface',
373
	'*Network Interfaces',
374
	$activeiflist['selected'],
375
	$activeiflist['options'],
376
	true
377
))->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. ' .
378
			'The default behavior is to respond to queries on every available IPv4 and IPv6 address.');
379

    
380
$outiflist = build_if_list($pconfig['outgoing_interface']);
381

    
382
$section->addInput(new Form_Select(
383
	'outgoing_interface',
384
	'*Outgoing Network Interfaces',
385
	$outiflist['selected'],
386
	$outiflist['options'],
387
	true
388
))->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.');
389

    
390
$section->addInput(new Form_Select(
391
	'system_domain_local_zone_type',
392
	'*System Domain Local Zone Type',
393
	$pconfig['system_domain_local_zone_type'],
394
	unbound_local_zone_types()
395
))->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.');
396

    
397
$section->addInput(new Form_Checkbox(
398
	'dnssec',
399
	'DNSSEC',
400
	'Enable DNSSEC Support',
401
	$pconfig['dnssec']
402
));
403

    
404
$section->addInput(new Form_Checkbox(
405
	'python',
406
	'Python Module',
407
	'Enable Python Module',
408
	$pconfig['python']
409
))->setHelp('Enable the Python Module.');
410

    
411
$python_files = glob("{$g['unbound_chroot_path']}/*.py");
412
$python_scripts = array();
413
if (!empty($python_files)) {
414
	foreach ($python_files as $file) {
415
		$file = pathinfo($file, PATHINFO_FILENAME);
416
		$python_scripts[$file] = $file;
417
	}
418
}
419
else {
420
	$python_scripts = array('' => 'No Python Module scripts found');
421
}
422

    
423
$section->addInput(new Form_Select(
424
	'python_order',
425
	'Python Module Order',
426
	$pconfig['python_order'],
427
	[ 'pre_validator' => 'Pre Validator', 'post_validator' => 'Post Validator' ]
428
))->setHelp('Select the Python Module ordering.');
429

    
430
$section->addInput(new Form_Select(
431
	'python_script',
432
	'Python Module Script',
433
	$pconfig['python_script'],
434
	$python_scripts
435
))->setHelp('Select the Python module script to utilize.');
436

    
437
$section->addInput(new Form_Checkbox(
438
	'forwarding',
439
	'DNS Query Forwarding',
440
	'Enable Forwarding Mode',
441
	$pconfig['forwarding']
442
))->setHelp('If this option is set, DNS queries will be forwarded to the upstream DNS servers defined under'.
443
					' %1$sSystem &gt; General Setup%2$s or those obtained via DHCP/PPP on WAN'.
444
					' (if DNS Server Override is enabled there).','<a href="system.php">','</a>');
445

    
446
$section->addInput(new Form_Checkbox(
447
	'forward_tls_upstream',
448
	null,
449
	'Use SSL/TLS for outgoing DNS Queries to Forwarding Servers',
450
	$pconfig['forward_tls_upstream']
451
))->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.');
452

    
453
$section->addInput(new Form_Checkbox(
454
	'regdhcp',
455
	'DHCP Registration',
456
	'Register DHCP leases in the DNS Resolver',
457
	$pconfig['regdhcp']
458
))->setHelp('If this option is set, then machines that specify their hostname when requesting an IPv4 DHCP lease will be registered'.
459
					' in the DNS Resolver so that their name can be resolved.'.
460
					' The domain in %1$sSystem &gt; General Setup%2$s should also be set to the proper value.','<a href="system.php">','</a>');
461

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

    
470
$section->addInput(new Form_Checkbox(
471
	'regovpnclients',
472
	'OpenVPN Clients',
473
	'Register connected OpenVPN clients in the DNS Resolver',
474
	$pconfig['regovpnclients']
475
))->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. '.
476
					'The domain in %sSystem: General Setup%s should also be set to the proper value.','<a href="system.php">','</a>'));
477

    
478
$btnadv = new Form_Button(
479
	'btnadvcustom',
480
	'Custom options',
481
	null,
482
	'fa-cog'
483
);
484

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

    
487
$section->addInput(new Form_StaticText(
488
	'Display Custom Options',
489
	$btnadv
490
));
491

    
492
$section->addInput(new Form_Textarea (
493
	'custom_options',
494
	'Custom options',
495
	$pconfig['custom_options']
496
))->setHelp('Enter any additional configuration parameters to add to the DNS Resolver configuration here, separated by a newline.');
497

    
498
$form->add($section);
499
print($form);
500
?>
501

    
502
<script type="text/javascript">
503
//<![CDATA[
504
events.push(function() {
505

    
506
	// Show advanced custom options ==============================================
507
	var showadvcustom = false;
508

    
509
	function show_advcustom(ispageload) {
510
		var text;
511
		// On page load decide the initial state based on the data.
512
		if (ispageload) {
513
			showadvcustom = <?=($customoptions ? 'true' : 'false');?>;
514
		} else {
515
			// It was a click, swap the state.
516
			showadvcustom = !showadvcustom;
517
		}
518

    
519
		hideInput('custom_options', !showadvcustom);
520

    
521
		if (showadvcustom) {
522
			text = "<?=gettext('Hide Custom Options');?>";
523
		} else {
524
			text = "<?=gettext('Display Custom Options');?>";
525
		}
526
		$('#btnadvcustom').html('<i class="fa fa-cog"></i> ' + text);
527
	}
528

    
529
	// If the enable checkbox is not checked, hide all inputs
530
	function hideGeneral() {
531
		var hide = ! $('#enable').prop('checked');
532

    
533
		hideMultiClass('general', hide);
534
		hideInput('port', hide);
535
		hideSelect('system_domain_local_zone_type', hide);
536
		hideCheckbox('dnssec', hide);
537
		hideCheckbox('forwarding', hide);
538
		hideCheckbox('regdhcp', hide);
539
		hideCheckbox('regdhcpstatic', hide);
540
		hideCheckbox('regovpnclients', hide);
541
		hideInput('btnadvcustom', hide);
542
		hideInput('custom_options', hide || !showadvcustom);
543
	}
544

    
545
	// Un-hide additional controls
546
	$('#btnadvcustom').click(function(event) {
547
		show_advcustom();
548
	});
549

    
550
	// When 'enable' is clicked, disable/enable the following hide inputs
551
	$('#enable').click(function() {
552
		hideGeneral();
553
	});
554

    
555
	// On initial load
556
	if ($('#custom_options').val().length == 0) {
557
		hideInput('custom_options', true);
558
	}
559

    
560
	hideGeneral();
561
	show_advcustom(true);
562

    
563
	// When the Python Module 'enable' is clicked, disable/enable the Python Module options
564
	function show_python_script() {
565
		var python = $('#python').prop('checked');
566
		hideInput('python_order', !python);
567
		hideInput('python_script', !python);
568
	}
569
	show_python_script();
570
	$('#python').click(function () {
571
		show_python_script();
572
	});
573

    
574
});
575
//]]>
576
</script>
577

    
578
<div class="panel panel-default">
579
	<div class="panel-heading"><h2 class="panel-title"><?=gettext("Host Overrides")?></h2></div>
580
	<div class="panel-body table-responsive">
581
		<table class="table table-striped table-hover table-condensed sortable-theme-bootstrap table-rowdblclickedit" data-sortable>
582
			<thead>
583
				<tr>
584
					<th><?=gettext("Host")?></th>
585
					<th><?=gettext("Parent domain of host")?></th>
586
					<th><?=gettext("IP to return for host")?></th>
587
					<th><?=gettext("Description")?></th>
588
					<th><?=gettext("Actions")?></th>
589
				</tr>
590
			</thead>
591
			<tbody>
592
<?php
593
$i = 0;
594
foreach ($a_hosts as $hostent):
595
?>
596
				<tr>
597
					<td>
598
						<?=$hostent['host']?>
599
					</td>
600
					<td>
601
						<?=$hostent['domain']?>
602
					</td>
603
					<td>
604
						<?=$hostent['ip']?>
605
					</td>
606
					<td>
607
						<?=htmlspecialchars($hostent['descr'])?>
608
					</td>
609
					<td>
610
						<a class="fa fa-pencil"	title="<?=gettext('Edit host override')?>" href="services_unbound_host_edit.php?id=<?=$i?>"></a>
611
						<a class="fa fa-trash"	title="<?=gettext('Delete host override')?>" href="services_unbound.php?type=host&amp;act=del&amp;id=<?=$i?>" usepost></a>
612
					</td>
613
				</tr>
614

    
615
<?php
616
	if ($hostent['aliases']['item'] && is_array($hostent['aliases']['item'])):
617
		foreach ($hostent['aliases']['item'] as $alias):
618
?>
619
				<tr>
620
					<td>
621
						<?=$alias['host']?>
622
					</td>
623
					<td>
624
						<?=$alias['domain']?>
625
					</td>
626
					<td>
627
						<?=gettext("Alias for ");?><?=$hostent['host'] ? $hostent['host'] . '.' . $hostent['domain'] : $hostent['domain']?>
628
					</td>
629
					<td>
630
						<i class="fa fa-angle-double-right text-info"></i>
631
						<?=htmlspecialchars($alias['description'])?>
632
					</td>
633
					<td>
634
						<a class="fa fa-pencil"	title="<?=gettext('Edit host override')?>" 	href="services_unbound_host_edit.php?id=<?=$i?>"></a>
635
					</td>
636
				</tr>
637
<?php
638
		endforeach;
639
	endif;
640
	$i++;
641
endforeach;
642
?>
643
			</tbody>
644
		</table>
645
	</div>
646
</div>
647

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

    
656
<nav class="action-buttons">
657
	<a href="services_unbound_host_edit.php" class="btn btn-sm btn-success">
658
		<i class="fa fa-plus icon-embed-btn"></i>
659
		<?=gettext('Add')?>
660
	</a>
661
</nav>
662

    
663
<div class="panel panel-default">
664
	<div class="panel-heading"><h2 class="panel-title"><?=gettext("Domain Overrides")?></h2></div>
665
	<div class="panel-body table-responsive">
666
		<table class="table table-striped table-hover table-condensed sortable-theme-bootstrap table-rowdblclickedit" data-sortable>
667
			<thead>
668
				<tr>
669
					<th><?=gettext("Domain")?></th>
670
					<th><?=gettext("Lookup Server IP Address")?></th>
671
					<th><?=gettext("Description")?></th>
672
					<th><?=gettext("Actions")?></th>
673
				</tr>
674
			</thead>
675

    
676
			<tbody>
677
<?php
678
$i = 0;
679
foreach ($a_domainOverrides as $doment):
680
?>
681
				<tr>
682
					<td>
683
						<?=$doment['domain']?>&nbsp;
684
					</td>
685
					<td>
686
						<?=$doment['ip']?>&nbsp;
687
					</td>
688
					<td>
689
						<?=htmlspecialchars($doment['descr'])?>&nbsp;
690
					</td>
691
					<td>
692
						<a class="fa fa-pencil"	title="<?=gettext('Edit domain override')?>" href="services_unbound_domainoverride_edit.php?id=<?=$i?>"></a>
693
						<a class="fa fa-trash"	title="<?=gettext('Delete domain override')?>" href="services_unbound.php?act=del&amp;type=doverride&amp;id=<?=$i?>" usepost></a>
694
					</td>
695
				</tr>
696
<?php
697
	$i++;
698
endforeach;
699
?>
700
			</tbody>
701
		</table>
702
	</div>
703
</div>
704

    
705
<span class="help-block">
706
	Enter any domains for which the resolver's standard DNS lookup process should be overridden and a different (non-standard)
707
	lookup server should be queried instead. Non-standard, 'invalid' and local domains, and subdomains, can also be entered,
708
	such as 'test', 'mycompany.localdomain', '1.168.192.in-addr.arpa', or 'somesite.com'. The IP address is treated as the
709
	authoritative lookup server for the domain (including all of its subdomains), and other lookup servers will not be queried.
710
</span>
711

    
712
<nav class="action-buttons">
713
	<a href="services_unbound_domainoverride_edit.php" class="btn btn-sm btn-success">
714
		<i class="fa fa-plus icon-embed-btn"></i>
715
		<?=gettext('Add')?>
716
	</a>
717
</nav>
718

    
719
<div class="infoblock">
720
	<?php print_info_box(sprintf(gettext('If the DNS Resolver is enabled, the DHCP'.
721
		' service (if enabled) will automatically serve the LAN IP'.
722
		' address as a DNS server to DHCP clients so they will use'.
723
		' the DNS Resolver. If Forwarding is enabled, the DNS Resolver will use the DNS servers'.
724
		' entered in %1$sSystem &gt; General Setup%2$s'.
725
		' or those obtained via DHCP or PPP on WAN if &quot;Allow'.
726
		' DNS server list to be overridden by DHCP/PPP on WAN&quot;'.
727
		' is checked.'), '<a href="system.php">', '</a>'), 'info', false); ?>
728
</div>
729

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