DHCPv6, replace domain name option with domain search list option (#3824)

* DHCPv6, fix Domain Search List bugs

Remove "domain-name" option (which doesn't exist in DHCPv6) from dhcpdv6.conf. For the global option (system domain) and static mappings, replace with "dhcp6.domain-search" option (already exists as an interface option).

* Remove domain name option

The domain name option doesn't exist in DHCPv6.

* Replace domain name with domain search list option

The domain name option doesn't exist in DHCPv6.

* fix dhcp6.domain-search option for static mappings
This commit is contained in:
Maurice 2019-11-22 10:23:16 +01:00 committed by Franco Fichtner
parent 38b613614b
commit d683929fc6
3 changed files with 21 additions and 27 deletions

View File

@ -1362,7 +1362,7 @@ function dhcpd_dhcp6_configure($verbose = false, $blacklist = array())
}
$dhcpdv6conf = <<<EOD
option domain-name "{$config['system']['domain']}";
option dhcp6.domain-search "{$config['system']['domain']}";
{$custoptionsv6}
default-lease-time 7200;
max-lease-time 86400;
@ -1399,9 +1399,6 @@ EOD;
}
$dnscfgv6 = "";
if (!empty($dhcpv6ifconf['domain'])) {
$dnscfgv6 .= " option domain-name \"{$dhcpv6ifconf['domain']}\";\n";
}
if (!empty($dhcpv6ifconf['domainsearchlist'])) {
$dnscfgv6 .= " option dhcp6.domain-search \"" . join("\",\"", preg_split("/[ ;]+/", $dhcpv6ifconf['domainsearchlist'])) . "\";\n";
@ -1513,8 +1510,8 @@ EOD;
$dhcpdv6conf .= " option root-path \"{$sm['rootpath']}\";\n";
}
if (!empty($sm['domain']) && ($sm['domain'] != $dhcpv6ifconf['domain'])) {
$dhcpdv6conf .= " option domain-name \"{$sm['domain']}\";\n";
if (!empty($sm['domainsearchlist']) && ($sm['domainsearchlist'] != $dhcpv6ifconf['domainsearchlist'])) {
$dhcpdv6conf .= " option dhcp6.domain-search \"" . join("\",\"", preg_split("/[ ;]+/", $sm['domainsearchlist'])) . "\";\n";
}
$dhcpdv6conf .= "}\n";

View File

@ -63,7 +63,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'GET') {
$pconfig['prefixrange_to'] = $config['dhcpdv6'][$if]['prefixrange']['to'];
$pconfig['prefixrange_length'] = $config['dhcpdv6'][$if]['prefixrange']['prefixlength'];
}
$config_copy_fieldsnames = array('defaultleasetime', 'maxleasetime', 'domain', 'domainsearchlist', 'ddnsdomain',
$config_copy_fieldsnames = array('defaultleasetime', 'maxleasetime', 'domainsearchlist', 'ddnsdomain',
'ddnsdomainprimary', 'ddnsdomainkeyname', 'ddnsdomainkey', 'bootfile_url', 'netmask',
'numberoptions', 'dhcpv6leaseinlocaltime', 'staticmap');
foreach ($config_copy_fieldsnames as $fieldname) {
@ -176,9 +176,6 @@ if ($_SERVER['REQUEST_METHOD'] === 'GET') {
if ((!empty($pconfig['ntp1']) && !is_ipaddrv6($pconfig['ntp1'])) || (!empty($pconfig['ntp2']) && !is_ipaddrv6($pconfig['ntp2']))) {
$input_errors[] = gettext("A valid IPv6 address must be specified for the primary/secondary NTP servers.");
}
if (!empty($pconfig['domain']) && !is_domain($pconfig['domain'])) {
$input_errors[] = gettext("A valid domain name must be specified for the DNS domain.");
}
if (!empty($pconfig['bootfile_url']) && !is_URL($pconfig['bootfile_url'])) {
$input_errors[] = gettext("A valid URL must be specified for the network bootfile.");
}
@ -237,7 +234,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'GET') {
$dhcpdconf = array();
// simple 1-on-1 copy
$config_copy_fieldsnames = array('defaultleasetime', 'maxleasetime', 'netmask', 'domain', 'domainsearchlist',
$config_copy_fieldsnames = array('defaultleasetime', 'maxleasetime', 'netmask', 'domainsearchlist',
'ddnsdomain', 'ddnsdomainprimary', 'ddnsdomainkeyname', 'ddnsdomainkey', 'bootfile_url',
'dhcpv6leaseinlocaltime');
foreach ($config_copy_fieldsnames as $fieldname) {
@ -556,21 +553,12 @@ if (isset($config['interfaces'][$if]['dhcpd6track6allowoverride'])) {
</div>
</td>
</tr>
<tr>
<td><a id="help_for_domain" href="#" class="showhelp"><i class="fa fa-info-circle"></i></a> <?=gettext("Domain name");?></td>
<td>
<input name="domain" type="text" id="domain" value="<?=$pconfig['domain'];?>" />
<div class="hidden" data-for="help_for_domain">
<?=gettext("The default is to use the domain name of this system as the default domain name provided by DHCP. You may specify an alternate domain name here.");?>
</div>
</td>
</tr>
<tr>
<td><a id="help_for_domainsearchlist" href="#" class="showhelp"><i class="fa fa-info-circle"></i></a> <?=gettext("Domain search list");?></td>
<td>
<input name="domainsearchlist" type="text" id="domainsearchlist" value="<?=$pconfig['domainsearchlist'];?>" />
<div class="hidden" data-for="help_for_domainsearchlist">
<?=gettext("The DHCP server can optionally provide a domain search list. Use the semicolon character as separator.");?>
<?=gettext("The default is to use the domain name of this system as the domain search list option provided by DHCPv6. You may optionally specify one or multiple domain(s) here. Use the semicolon character as separator.");?>
</div>
</td>
</tr>

View File

@ -45,7 +45,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'GET') {
// read form data
$pconfig = array();
$config_copy_fieldnames = array('duid', 'hostname', 'ipaddrv6', 'filename' ,'rootpath' ,'descr', 'domain');
$config_copy_fieldnames = array('duid', 'hostname', 'ipaddrv6', 'filename' ,'rootpath' ,'descr', 'domainsearchlist');
foreach ($config_copy_fieldnames as $fieldname) {
if (isset($if) && isset($id) && isset($config['dhcpdv6'][$if]['staticmap'][$id][$fieldname])) {
$pconfig[$fieldname] = $config['dhcpdv6'][$if]['staticmap'][$id][$fieldname];
@ -88,6 +88,15 @@ if ($_SERVER['REQUEST_METHOD'] === 'GET') {
if (empty($pconfig['duid']) || preg_match('/^([a-fA-F0-9]{2}[:])*([a-fA-F0-9]{2}){1}$/', $pconfig['duid']) !== 1) {
$input_errors[] = gettext("A valid DUID Identifier must be specified.");
}
if (!empty($pconfig['domainsearchlist'])) {
$domain_array=preg_split("/[ ;]+/",$pconfig['domainsearchlist']);
foreach ($domain_array as $curdomain) {
if (!is_domain($curdomain)) {
$input_errors[] = gettext("A valid domain search list must be specified.");
break;
}
}
}
/* check for overlaps */
$a_maps = &config_read_array('dhcpdv6', $if, 'staticmap');
@ -102,7 +111,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'GET') {
}
if (count($input_errors) == 0) {
$mapent = array();
$config_copy_fieldnames = array('duid', 'ipaddrv6', 'hostname', 'descr', 'filename', 'rootpath', 'domain');
$config_copy_fieldnames = array('duid', 'ipaddrv6', 'hostname', 'descr', 'filename', 'rootpath', 'domainsearchlist');
foreach ($config_copy_fieldnames as $fieldname) {
if (!empty($pconfig[$fieldname])) {
$mapent[$fieldname] = $pconfig[$fieldname];
@ -193,11 +202,11 @@ include("head.inc");
</td>
</tr>
<tr>
<td><a id="help_for_domain" href="#" class="showhelp"><i class="fa fa-info-circle"></i></a> <?=gettext("Domain name");?></td>
<td><a id="help_for_domainsearchlist" href="#" class="showhelp"><i class="fa fa-info-circle"></i></a> <?=gettext("Domain search list");?></td>
<td>
<input name="domain" type="text" value="<?=$pconfig['domain'];?>" />
<div class="hidden" data-for="help_for_domain">
<?=gettext("The default is to use the domain name of this system as the default domain name provided by DHCP. You may specify an alternate domain name here.");?>
<input name="domainsearchlist" type="text" value="<?=$pconfig['domainsearchlist'];?>" />
<div class="hidden" data-for="help_for_domainsearchlist">
<?=gettext("The default is to use the domain name of this system as the domain search list option provided by DHCPv6. You may optionally specify one or multiple domain(s) here. Use the semicolon character as separator.");?>
</div>
</td>
</tr>