Project

General

Profile

Download (24.7 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-2023 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
$pconfig['enable'] = config_path_enabled('unbound');
38
$pconfig['enablessl'] = config_path_enabled('unbound', 'enablessl');
39
$pconfig['strictout'] = config_path_enabled('unbound', 'strictout');
40
$pconfig['dnssec'] = config_path_enabled('unbound', 'dnssec');
41
$pconfig['python'] = config_path_enabled('unbound', 'python');
42
$pconfig['forwarding'] = config_path_enabled('unbound', 'forwarding');
43
$pconfig['forward_tls_upstream'] = config_path_enabled('unbound', 'forward_tls_upstream');
44
$pconfig['regdhcp'] = config_path_enabled('unbound', 'regdhcp');
45
$pconfig['regdhcpstatic'] = config_path_enabled('unbound', 'regdhcpstatic');
46
$pconfig['regovpnclients'] = config_path_enabled('unbound', 'regovpnclients');
47

    
48
$pconfig['python_order'] = config_get_path('unbound/python_order');
49
$pconfig['python_script'] = config_get_path('unbound/python_script');
50
$pconfig['port'] = config_get_path('unbound/port');
51
$pconfig['tlsport'] = config_get_path('unbound/tlsport');
52
$pconfig['sslcertref'] = config_get_path('unbound/sslcertref');
53
$pconfig['custom_options'] = base64_decode(config_get_path('unbound/custom_options'));
54

    
55
if (config_get_path('unbound/active_interface')) {
56
	$pconfig['active_interface'] = explode(",", config_get_path('unbound/active_interface'));
57
} else {
58
	$pconfig['active_interface'] = array();
59
}
60

    
61
if (config_get_path('unbound/outgoing_interface')) {
62
	$pconfig['outgoing_interface'] = explode(",", config_get_path('unbound/outgoing_interface'));
63
} else {
64
	$pconfig['outgoing_interface'] = array();
65
}
66

    
67
$pconfig['system_domain_local_zone_type'] = config_get_path('unbound/system_domain_local_zone_type', 'transparent');
68

    
69
$certs_available = false;
70
if (count(config_get_path('cert', []))) {
71
	$certs_available = true;
72
}
73

    
74
if ($_POST['apply']) {
75
	$retval = 0;
76
	$retval |= services_unbound_configure();
77
	if ($retval == 0) {
78
		clear_subsystem_dirty('unbound');
79
	}
80
	/* Update resolv.conf in case the interface bindings exclude localhost. */
81
	system_resolvconf_generate();
82
	/* Start or restart dhcpleases when it's necessary */
83
	system_dhcpleases_configure();
84
}
85

    
86
if ($_POST['save']) {
87
	$pconfig = $_POST;
88
	unset($input_errors);
89

    
90
	if (isset($pconfig['enable']) && config_path_enabled('dnsmasq')) {
91
		if ($pconfig['port'] == config_get_path('dnsmasq/port')) {
92
			$input_errors[] = gettext("The DNS Forwarder is enabled using this port. Choose a non-conflicting port, or disable the DNS Forwarder.");
93
		}
94
	}
95

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

    
100
	// forwarding mode requires having valid DNS servers
101
	if (isset($pconfig['forwarding'])) {
102
		$founddns = false;
103
		foreach (get_dns_nameservers(false, true) as $dns_server) {
104
			if (!ip_in_subnet($dns_server, "127.0.0.0/8")) {
105
				$founddns = true;
106
			}
107
		}
108
		if ($founddns == false) {
109
			$input_errors[] = gettext("At least one DNS server must be specified under System > General Setup to enable Forwarding mode.");
110
		}
111
	}
112

    
113
	if (empty($pconfig['active_interface'])) {
114
		$input_errors[] = gettext("One or more Network Interfaces must be selected for binding.");
115
	} elseif ((config_get_path('system/dnslocalhost') != 'remote') && (!in_array("lo0", $pconfig['active_interface']) && !in_array("all", $pconfig['active_interface']))) {
116
		$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.");
117
	}
118

    
119
	if (empty($pconfig['outgoing_interface'])) {
120
		$input_errors[] = gettext("One or more Outgoing Network Interfaces must be selected.");
121
	}
122

    
123
	if ($pconfig['port'] && !is_port($pconfig['port'])) {
124
		$input_errors[] = gettext("A valid port number must be specified.");
125
	}
126
	if ($pconfig['tlsport'] && !is_port($pconfig['tlsport'])) {
127
		$input_errors[] = gettext("A valid SSL/TLS port number must be specified.");
128
	}
129

    
130
	if (is_array($pconfig['active_interface']) && !empty($pconfig['active_interface'])) {
131
		$display_active_interface = $pconfig['active_interface'];
132
		$pconfig['active_interface'] = implode(",", $pconfig['active_interface']);
133
	}
134

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

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

    
143
	$display_custom_options = $pconfig['custom_options'];
144
	$pconfig['custom_options'] = base64_encode(str_replace("\r\n", "\n", $pconfig['custom_options']));
145

    
146
	if (is_array($pconfig['outgoing_interface']) && !empty($pconfig['outgoing_interface'])) {
147
		$display_outgoing_interface = $pconfig['outgoing_interface'];
148
		$pconfig['outgoing_interface'] = implode(",", $pconfig['outgoing_interface']);
149
	}
150

    
151
	$test_output = array();
152
	if (test_unbound_config($pconfig, $test_output)) {
153
		$input_errors[] = gettext("The generated config file cannot be parsed by unbound. Please correct the following errors:");
154
		$input_errors = array_merge($input_errors, $test_output);
155
	}
156

    
157
	if (!$input_errors) {
158
		config_set_path('unbound/enable', isset($pconfig['enable']));
159
		config_set_path('unbound/enablessl', isset($pconfig['enablessl']));
160
		config_set_path('unbound/port', $pconfig['port']);
161
		config_set_path('unbound/tlsport', $pconfig['tlsport']);
162
		config_set_path('unbound/sslcertref', $pconfig['sslcertref']);
163
		config_set_path('unbound/strictout', isset($pconfig['strictout']));
164
		config_set_path('unbound/dnssec', isset($pconfig['dnssec']));
165

    
166
		config_set_path('unbound/python', isset($pconfig['python']));
167
		if (isset($pconfig['python'])) {
168
			config_set_path('unbound/python_order', $pconfig['python_order']);
169
			config_set_path('unbound/python_script', $pconfig['python_script']);
170
		} else {
171
			config_del_path('unbound/python_order');
172
			config_del_path('unbound/python_script');
173
		}
174

    
175
		config_set_path('unbound/forwarding', isset($pconfig['forwarding']));
176
		config_set_path('unbound/forward_tls_upstream', isset($pconfig['forward_tls_upstream']));
177
		config_set_path('unbound/regdhcp', isset($pconfig['regdhcp']));
178
		config_set_path('unbound/regdhcpstatic', isset($pconfig['regdhcpstatic']));
179
		config_set_path('unbound/regovpnclients', isset($pconfig['regovpnclients']));
180
		config_set_path('unbound/active_interface', $pconfig['active_interface']);
181
		config_set_path('unbound/outgoing_interface', $pconfig['outgoing_interface']);
182
		config_set_path('unbound/system_domain_local_zone_type', $pconfig['system_domain_local_zone_type']);
183
		config_set_path('unbound/custom_options', $pconfig['custom_options']);
184

    
185
		write_config(gettext("DNS Resolver configured."));
186
		mark_subsystem_dirty('unbound');
187
	}
188

    
189
	$pconfig['active_interface'] = $display_active_interface;
190
	$pconfig['outgoing_interface'] = $display_outgoing_interface;
191
	$pconfig['custom_options'] = $display_custom_options;
192
}
193

    
194

    
195
if ($pconfig['custom_options']) {
196
	$customoptions = true;
197
} else {
198
	$customoptions = false;
199
}
200

    
201
if ($_POST['act'] == "del") {
202
	if ($_POST['type'] == 'host') {
203
		if (config_get_path('unbound/hosts/' . $_POST['id'])) {
204
			config_del_path('unbound/hosts/' . $_POST['id']);
205
			write_config(gettext("Host override deleted from DNS Resolver."));
206
			mark_subsystem_dirty('unbound');
207
			header("Location: services_unbound.php");
208
			exit;
209
		}
210
	} elseif ($_POST['type'] == 'doverride') {
211
		if (config_get_path('unbound/domainoverrides/' . $_POST['id'])) {
212
			config_del_path('unbound/domainoverrides/' . $_POST['id']);
213
			write_config(gettext("Domain override deleted from DNS Resolver."));
214
			mark_subsystem_dirty('unbound');
215
			header("Location: services_unbound.php");
216
			exit;
217
		}
218
	}
219
}
220

    
221
function build_if_list($selectedifs) {
222
	$interface_addresses = get_possible_listen_ips(true);
223
	$iflist = array('options' => array(), 'selected' => array());
224

    
225
	$iflist['options']['all']	= gettext("All");
226
	if (empty($selectedifs) || empty($selectedifs[0]) || in_array("all", $selectedifs)) {
227
		array_push($iflist['selected'], "all");
228
	}
229

    
230
	foreach ($interface_addresses as $laddr => $ldescr) {
231
		$iflist['options'][$laddr] = htmlspecialchars($ldescr);
232

    
233
		if ($selectedifs && in_array($laddr, $selectedifs)) {
234
			array_push($iflist['selected'], $laddr);
235
		}
236
	}
237

    
238
	unset($interface_addresses);
239

    
240
	return($iflist);
241
}
242

    
243
$pgtitle = array(gettext("Services"), gettext("DNS Resolver"), gettext("General Settings"));
244
$pglinks = array("", "@self", "@self");
245
$shortcut_section = "resolver";
246

    
247
include_once("head.inc");
248

    
249
if ($input_errors) {
250
	print_input_errors($input_errors);
251
}
252

    
253
if ($_POST['apply']) {
254
	print_apply_result_box($retval);
255
}
256

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

    
261
$tab_array = array();
262
$tab_array[] = array(gettext("General Settings"), true, "services_unbound.php");
263
$tab_array[] = array(gettext("Advanced Settings"), false, "services_unbound_advanced.php");
264
$tab_array[] = array(gettext("Access Lists"), false, "/services_unbound_acls.php");
265
display_top_tabs($tab_array, true);
266

    
267
$form = new Form();
268

    
269
$section = new Form_Section('General DNS Resolver Options');
270

    
271
$section->addInput(new Form_Checkbox(
272
	'enable',
273
	'Enable',
274
	'Enable DNS resolver',
275
	$pconfig['enable']
276
));
277

    
278
$section->addInput(new Form_Input(
279
	'port',
280
	'Listen Port',
281
	'number',
282
	$pconfig['port'],
283
	['placeholder' => '53']
284
))->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.');
285

    
286
$section->addInput(new Form_Checkbox(
287
	'enablessl',
288
	'Enable SSL/TLS Service',
289
	'Respond to incoming SSL/TLS queries from local clients',
290
	$pconfig['enablessl']
291
))->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. ' .
292
		'Activating this option disables automatic interface response routing behavior, thus it works best with specific interface bindings.' );
293

    
294
if ($certs_available) {
295
	$section->addInput($input = new Form_Select(
296
		'sslcertref',
297
		'SSL/TLS Certificate',
298
		$pconfig['sslcertref'],
299
		cert_build_list('cert', 'IPsec')
300
	))->setHelp('The server certificate to use for SSL/TLS service. The CA chain will be determined automatically.');
301
} else {
302
	$section->addInput(new Form_StaticText(
303
		'SSL/TLS Certificate',
304
		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.',
305
		'<a href="system_certmanager.php">', '</a>')
306
	));
307
}
308

    
309
$section->addInput(new Form_Input(
310
	'tlsport',
311
	'SSL/TLS Listen Port',
312
	'number',
313
	$pconfig['tlsport'],
314
	['placeholder' => '853']
315
))->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.');
316

    
317
$activeiflist = build_if_list($pconfig['active_interface']);
318

    
319
$section->addInput(new Form_Select(
320
	'active_interface',
321
	'*Network Interfaces',
322
	$activeiflist['selected'],
323
	$activeiflist['options'],
324
	true
325
))->addClass('general', 'resizable')->setHelp('Interface IP addresses used by the DNS Resolver for responding to queries from clients. If an interface has both IPv4 and IPv6 addresses, both are used. Queries to addresses not selected in this list are discarded. ' .
326
			'The default behavior is to respond to queries on every available IPv4 and IPv6 address.');
327

    
328
$outiflist = build_if_list($pconfig['outgoing_interface']);
329

    
330
$section->addInput(new Form_Select(
331
	'outgoing_interface',
332
	'*Outgoing Network Interfaces',
333
	$outiflist['selected'],
334
	$outiflist['options'],
335
	true
336
))->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.');
337

    
338
$section->addInput(new Form_Checkbox(
339
	'strictout',
340
	'Strict Outgoing Network Interface Binding',
341
	'Do not send recursive queries if none of the selected Outgoing Network Interfaces are available.',
342
	$pconfig['strictout']
343
))->setHelp('By default the DNS Resolver sends recursive DNS requests over any available interfaces if none of the selected Outgoing Network Interfaces are available. This option makes the DNS Resolver refuse recursive queries.');
344

    
345
$section->addInput(new Form_Select(
346
	'system_domain_local_zone_type',
347
	'*System Domain Local Zone Type',
348
	$pconfig['system_domain_local_zone_type'],
349
	unbound_local_zone_types()
350
))->setHelp('The local-zone type used for the %1$s system domain (System | General Setup | Domain).  Transparent is the default.', g_get('product_label'));
351

    
352
$section->addInput(new Form_Checkbox(
353
	'dnssec',
354
	'DNSSEC',
355
	'Enable DNSSEC Support',
356
	$pconfig['dnssec']
357
));
358

    
359
$section->addInput(new Form_Checkbox(
360
	'python',
361
	'Python Module',
362
	'Enable Python Module',
363
	$pconfig['python']
364
))->setHelp('Enable the Python Module.');
365

    
366
$python_files = glob("{$g['unbound_chroot_path']}/*.py");
367
$python_scripts = array();
368
if (!empty($python_files)) {
369
	foreach ($python_files as $file) {
370
		$file = pathinfo($file, PATHINFO_FILENAME);
371
		$python_scripts[$file] = $file;
372
	}
373
}
374
else {
375
	$python_scripts = array('' => 'No Python Module scripts found');
376
}
377

    
378
$section->addInput(new Form_Select(
379
	'python_order',
380
	'Python Module Order',
381
	$pconfig['python_order'],
382
	[ 'pre_validator' => 'Pre Validator', 'post_validator' => 'Post Validator' ]
383
))->setHelp('Select the Python Module ordering.');
384

    
385
$section->addInput(new Form_Select(
386
	'python_script',
387
	'Python Module Script',
388
	$pconfig['python_script'],
389
	$python_scripts
390
))->setHelp('Select the Python module script to utilize.');
391

    
392
$section->addInput(new Form_Checkbox(
393
	'forwarding',
394
	'DNS Query Forwarding',
395
	'Enable Forwarding Mode',
396
	$pconfig['forwarding']
397
))->setHelp('If this option is set, DNS queries will be forwarded to the upstream DNS servers defined under'.
398
					' %1$sSystem &gt; General Setup%2$s or those obtained via dynamic ' .
399
					'interfaces such as DHCP, PPP, or OpenVPN (if DNS Server Override ' .
400
				        'is enabled there).','<a href="system.php">','</a>');
401

    
402
$section->addInput(new Form_Checkbox(
403
	'forward_tls_upstream',
404
	null,
405
	'Use SSL/TLS for outgoing DNS Queries to Forwarding Servers',
406
	$pconfig['forward_tls_upstream']
407
))->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.');
408

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

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

    
427
$section->addInput(new Form_Checkbox(
428
	'regovpnclients',
429
	'OpenVPN Clients',
430
	'Register connected OpenVPN clients in the DNS Resolver',
431
	$pconfig['regovpnclients']
432
))->setHelp(sprintf('If this option is set, then the common name (CN) of connected OpenVPN clients will be ' .
433
	    'registered in the DNS Resolver, so that their name can be resolved. This only works for OpenVPN ' .
434
	    'servers (Remote Access SSL/TLS or User Auth with Username as Common Name option) operating ' .
435
	    'in "tun" mode. The domain in %sSystem: General Setup%s should also be set to the proper value.',
436
	    '<a href="system.php">','</a>'));
437

    
438
$btnadv = new Form_Button(
439
	'btnadvcustom',
440
	'Custom options',
441
	null,
442
	'fa-cog'
443
);
444

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

    
447
$section->addInput(new Form_StaticText(
448
	'Display Custom Options',
449
	$btnadv
450
));
451

    
452
$section->addInput(new Form_Textarea (
453
	'custom_options',
454
	'Custom options',
455
	$pconfig['custom_options']
456
))->setHelp('Enter any additional configuration parameters to add to the DNS Resolver configuration here, separated by a newline.');
457

    
458
$form->add($section);
459
print($form);
460
?>
461

    
462
<script type="text/javascript">
463
//<![CDATA[
464
events.push(function() {
465

    
466
	// Show advanced custom options ==============================================
467
	var showadvcustom = false;
468

    
469
	function show_advcustom(ispageload) {
470
		var text;
471
		// On page load decide the initial state based on the data.
472
		if (ispageload) {
473
			showadvcustom = <?=($customoptions ? 'true' : 'false');?>;
474
		} else {
475
			// It was a click, swap the state.
476
			showadvcustom = !showadvcustom;
477
		}
478

    
479
		hideInput('custom_options', !showadvcustom);
480

    
481
		if (showadvcustom) {
482
			text = "<?=gettext('Hide Custom Options');?>";
483
		} else {
484
			text = "<?=gettext('Display Custom Options');?>";
485
		}
486
		$('#btnadvcustom').html('<i class="fa fa-cog"></i> ' + text);
487
	}
488

    
489
	// If the enable checkbox is not checked, hide all inputs
490
	function hideGeneral() {
491
		var hide = ! $('#enable').prop('checked');
492

    
493
		hideMultiClass('general', hide);
494
		hideInput('port', hide);
495
		hideSelect('system_domain_local_zone_type', hide);
496
		hideCheckbox('strictout', hide);
497
		hideCheckbox('dnssec', hide);
498
		hideCheckbox('forwarding', hide);
499
		hideCheckbox('regdhcp', hide);
500
		hideCheckbox('regdhcpstatic', hide);
501
		hideCheckbox('regovpnclients', hide);
502
		hideInput('btnadvcustom', hide);
503
		hideInput('custom_options', hide || !showadvcustom);
504
	}
505

    
506
	// Un-hide additional controls
507
	$('#btnadvcustom').click(function(event) {
508
		show_advcustom();
509
	});
510

    
511
	// When 'enable' is clicked, disable/enable the following hide inputs
512
	$('#enable').click(function() {
513
		hideGeneral();
514
	});
515

    
516
	// On initial load
517
	if ($('#custom_options').val().length == 0) {
518
		hideInput('custom_options', true);
519
	}
520

    
521
	hideGeneral();
522
	show_advcustom(true);
523

    
524
	// When the Python Module 'enable' is clicked, disable/enable the Python Module options
525
	function show_python_script() {
526
		var python = $('#python').prop('checked');
527
		hideInput('python_order', !python);
528
		hideInput('python_script', !python);
529
	}
530
	show_python_script();
531
	$('#python').click(function () {
532
		show_python_script();
533
	});
534

    
535
});
536
//]]>
537
</script>
538

    
539
<div class="panel panel-default">
540
	<div class="panel-heading"><h2 class="panel-title"><?=gettext("Host Overrides")?></h2></div>
541
	<div class="panel-body table-responsive">
542
		<table class="table table-striped table-hover table-condensed sortable-theme-bootstrap table-rowdblclickedit" data-sortable>
543
			<thead>
544
				<tr>
545
					<th><?=gettext("Host")?></th>
546
					<th><?=gettext("Parent domain of host")?></th>
547
					<th><?=gettext("IP to return for host")?></th>
548
					<th><?=gettext("Description")?></th>
549
					<th><?=gettext("Actions")?></th>
550
				</tr>
551
			</thead>
552
			<tbody>
553
<?php
554
foreach (config_get_path('unbound/hosts', []) as $idx => $hostent):
555
?>
556
				<tr>
557
					<td>
558
						<?=$hostent['host']?>
559
					</td>
560
					<td>
561
						<?=$hostent['domain']?>
562
					</td>
563
					<td>
564
						<?=$hostent['ip']?>
565
					</td>
566
					<td>
567
						<?=htmlspecialchars($hostent['descr'])?>
568
					</td>
569
					<td>
570
						<a class="fa fa-pencil"	title="<?=gettext('Edit host override')?>" href="services_unbound_host_edit.php?id=<?=$idx?>"></a>
571
						<a class="fa fa-trash"	title="<?=gettext('Delete host override')?>" href="services_unbound.php?type=host&amp;act=del&amp;id=<?=$idx?>" usepost></a>
572
					</td>
573
				</tr>
574

    
575
<?php
576
	foreach (array_get_path($hostent, 'aliases/item', []) as $alias):
577
?>
578
				<tr>
579
					<td>
580
						<?=$alias['host']?>
581
					</td>
582
					<td>
583
						<?=$alias['domain']?>
584
					</td>
585
					<td>
586
						<?=gettext("Alias for ");?><?=$hostent['host'] ? $hostent['host'] . '.' . $hostent['domain'] : $hostent['domain']?>
587
					</td>
588
					<td>
589
						<i class="fa fa-angle-double-right text-info"></i>
590
						<?=htmlspecialchars($alias['description'])?>
591
					</td>
592
					<td>
593
						<a class="fa fa-pencil"	title="<?=gettext('Edit host override')?>" 	href="services_unbound_host_edit.php?id=<?=$idx?>"></a>
594
					</td>
595
				</tr>
596
<?php
597
	endforeach;
598
endforeach;
599
?>
600
			</tbody>
601
		</table>
602
	</div>
603
</div>
604

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

    
613
<nav class="action-buttons">
614
	<a href="services_unbound_host_edit.php" class="btn btn-sm btn-success">
615
		<i class="fa fa-plus icon-embed-btn"></i>
616
		<?=gettext('Add')?>
617
	</a>
618
</nav>
619

    
620
<div class="panel panel-default">
621
	<div class="panel-heading"><h2 class="panel-title"><?=gettext("Domain Overrides")?></h2></div>
622
	<div class="panel-body table-responsive">
623
		<table class="table table-striped table-hover table-condensed sortable-theme-bootstrap table-rowdblclickedit" data-sortable>
624
			<thead>
625
				<tr>
626
					<th><?=gettext("Domain")?></th>
627
					<th><?=gettext("Lookup Server IP Address")?></th>
628
					<th><?=gettext("Description")?></th>
629
					<th><?=gettext("Actions")?></th>
630
				</tr>
631
			</thead>
632

    
633
			<tbody>
634
<?php
635
$i = 0;
636
foreach (config_get_path('unbound/domainoverrides') as $doment):
637
?>
638
				<tr>
639
					<td>
640
						<?=$doment['domain']?>&nbsp;
641
					</td>
642
					<td>
643
						<?=$doment['ip']?>&nbsp;
644
					</td>
645
					<td>
646
						<?=htmlspecialchars($doment['descr'])?>&nbsp;
647
					</td>
648
					<td>
649
						<a class="fa fa-pencil"	title="<?=gettext('Edit domain override')?>" href="services_unbound_domainoverride_edit.php?id=<?=$i?>"></a>
650
						<a class="fa fa-trash"	title="<?=gettext('Delete domain override')?>" href="services_unbound.php?act=del&amp;type=doverride&amp;id=<?=$i?>" usepost></a>
651
					</td>
652
				</tr>
653
<?php
654
	$i++;
655
endforeach;
656
?>
657
			</tbody>
658
		</table>
659
	</div>
660
</div>
661

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

    
671
<nav class="action-buttons">
672
	<a href="services_unbound_domainoverride_edit.php" class="btn btn-sm btn-success">
673
		<i class="fa fa-plus icon-embed-btn"></i>
674
		<?=gettext('Add')?>
675
	</a>
676
</nav>
677

    
678
<div class="infoblock">
679
	<?php print_info_box(sprintf(gettext('If the DNS Resolver is enabled, the DHCP'.
680
		' service (if enabled) will automatically serve the LAN IP'.
681
		' address as a DNS server to DHCP clients so they will use'.
682
		' the DNS Resolver. If Forwarding is enabled, the DNS Resolver will use the DNS servers'.
683
		' entered in %1$sSystem &gt; General Setup%2$s'.
684
		' or those obtained via DHCP or PPP on WAN if &quot;Allow'.
685
		' DNS server list to be overridden by DHCP/PPP on WAN&quot;'.
686
		' is checked.'), '<a href="system.php">', '</a>'), 'info', false); ?>
687
</div>
688

    
689
<?php include("foot.inc");
(141-141/228)