From 333c2eb63d185c5eab7cbf5e9882fff91d733999 Mon Sep 17 00:00:00 2001 From: Maurice Date: Thu, 20 Feb 2020 17:39:23 +0100 Subject: [PATCH 1/8] re-add 'domain' to dhcpdv6 interface configuration 'domain' was removed in #3824 because it is not used by dhcpdv6. But it is used by unbound and dnsmasq for DNS registration of DHCP static mappings. Just set it to the first entry of the domain search list. --- src/www/services_dhcpv6.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/www/services_dhcpv6.php b/src/www/services_dhcpv6.php index 9325baf4a..8e3fa967c 100644 --- a/src/www/services_dhcpv6.php +++ b/src/www/services_dhcpv6.php @@ -272,6 +272,11 @@ if ($_SERVER['REQUEST_METHOD'] === 'GET') { if (!empty($pconfig['ntp2'])) { $dhcpdconf['ntpserver'][] = $pconfig['ntp2']; } + // set 'domain' to first entry of 'domainsearchlist' + // (used only for DNS registration of static mappings) + if (!empty($pconfig['domainsearchlist'])) { + $dhcpdconf['domain'] = $domain_array[0]; + } $dhcpdconf['numberoptions'] = $pconfig['numberoptions']; // copy structures back in @@ -558,7 +563,7 @@ if (isset($config['interfaces'][$if]['dhcpd6track6allowoverride'])) { From 49002d1bd708f46a37f65c43ed71b3ed306eefcc Mon Sep 17 00:00:00 2001 From: Maurice Date: Thu, 20 Feb 2020 18:20:31 +0100 Subject: [PATCH 2/8] re-add 'domain' to dhcpdv6 static mappings 'domain' was replaced by 'domainsearchlist' in #3824 because 'domain' is not used by dhcpdv6. But it is used by unbound and dnsmasq for DNS registration of DHCP static mappings. Just set it to the first entry of the domain search list. --- src/www/services_dhcpv6_edit.php | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/www/services_dhcpv6_edit.php b/src/www/services_dhcpv6_edit.php index 362fc62fa..8e3d33b09 100644 --- a/src/www/services_dhcpv6_edit.php +++ b/src/www/services_dhcpv6_edit.php @@ -122,6 +122,12 @@ if ($_SERVER['REQUEST_METHOD'] === 'GET') { } } + // set 'domain' to first entry of 'domainsearchlist' + // (used only for DNS registration) + if (!empty($pconfig['domainsearchlist'])) { + $mapent['domain'] = $domain_array[0]; + } + if (isset($id)) { $config['dhcpdv6'][$if]['staticmap'][$id] = $mapent; } else { @@ -210,7 +216,9 @@ include("head.inc"); From a19662c7c2bd92927dfc04c3b91681d89340180f Mon Sep 17 00:00:00 2001 From: Maurice Date: Thu, 20 Feb 2020 20:29:33 +0100 Subject: [PATCH 3/8] migrate domain to domainsearchlist, don't save domain --- src/www/services_dhcpv6.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/www/services_dhcpv6.php b/src/www/services_dhcpv6.php index 8e3fa967c..da5c248b1 100644 --- a/src/www/services_dhcpv6.php +++ b/src/www/services_dhcpv6.php @@ -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', 'domainsearchlist', 'ddnsdomain', + $config_copy_fieldsnames = array('defaultleasetime', 'maxleasetime', 'domain', 'domainsearchlist', 'ddnsdomain', 'ddnsdomainprimary', 'ddnsdomainkeyname', 'ddnsdomainkey', 'ddnsdomainalgorithm', 'bootfile_url', 'netmask', 'numberoptions', 'dhcpv6leaseinlocaltime', 'staticmap'); foreach ($config_copy_fieldsnames as $fieldname) { @@ -86,6 +86,11 @@ if ($_SERVER['REQUEST_METHOD'] === 'GET') { $pconfig['ntp1'] = !empty($config['dhcpdv6'][$if]['ntpserver'][0]) ? $config['dhcpdv6'][$if]['ntpserver'][0] : ""; $pconfig['ntp2'] = !empty($config['dhcpdv6'][$if]['ntpserver'][1]) ? $config['dhcpdv6'][$if]['ntpserver'][1] : ""; + // backward compatibility: migrate 'domain' to 'domainsearchlist' + if (empty($pconfig['domainsearchlist'])) { + $pconfig['domainsearchlist'] = $pconfig['domain']; + } + } elseif ($_SERVER['REQUEST_METHOD'] === 'POST') { // handle identifiers and actions if (!empty($_POST['if']) && !empty($config['interfaces'][$_POST['if']])) { @@ -272,11 +277,6 @@ if ($_SERVER['REQUEST_METHOD'] === 'GET') { if (!empty($pconfig['ntp2'])) { $dhcpdconf['ntpserver'][] = $pconfig['ntp2']; } - // set 'domain' to first entry of 'domainsearchlist' - // (used only for DNS registration of static mappings) - if (!empty($pconfig['domainsearchlist'])) { - $dhcpdconf['domain'] = $domain_array[0]; - } $dhcpdconf['numberoptions'] = $pconfig['numberoptions']; // copy structures back in From 14958018082289d48316af034a0317ea0783a55b Mon Sep 17 00:00:00 2001 From: Maurice Date: Thu, 20 Feb 2020 20:35:27 +0100 Subject: [PATCH 4/8] migrate domain to domainsearchlist, don't save domain --- src/www/services_dhcpv6_edit.php | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/www/services_dhcpv6_edit.php b/src/www/services_dhcpv6_edit.php index 8e3d33b09..d1dcf98aa 100644 --- a/src/www/services_dhcpv6_edit.php +++ b/src/www/services_dhcpv6_edit.php @@ -45,7 +45,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'GET') { // read form data $pconfig = array(); - $config_copy_fieldnames = array('duid', 'hostname', 'ipaddrv6', 'filename' ,'rootpath' ,'descr', 'domainsearchlist'); + $config_copy_fieldnames = array('duid', 'hostname', 'ipaddrv6', 'filename' ,'rootpath' ,'descr', 'domain', '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]; @@ -55,6 +55,12 @@ if ($_SERVER['REQUEST_METHOD'] === 'GET') { $pconfig[$fieldname] = null; } } + + // backward compatibility: migrate 'domain' to 'domainsearchlist' + if (empty($pconfig['domainsearchlist'])) { + $pconfig['domainsearchlist'] = $pconfig['domain']; + } + } elseif ($_SERVER['REQUEST_METHOD'] === 'POST') { $input_errors = array(); $pconfig = $_POST; @@ -122,12 +128,6 @@ if ($_SERVER['REQUEST_METHOD'] === 'GET') { } } - // set 'domain' to first entry of 'domainsearchlist' - // (used only for DNS registration) - if (!empty($pconfig['domainsearchlist'])) { - $mapent['domain'] = $domain_array[0]; - } - if (isset($id)) { $config['dhcpdv6'][$if]['staticmap'][$id] = $mapent; } else { From 4344817120728ad0ef3e758dc3371c0fe65b3c7b Mon Sep 17 00:00:00 2001 From: Maurice Date: Thu, 20 Feb 2020 21:03:41 +0100 Subject: [PATCH 5/8] DNS registration for DHCPv6 static mappings, check domainsearchlist first, domain second --- src/etc/inc/plugins.inc.d/unbound.inc | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/etc/inc/plugins.inc.d/unbound.inc b/src/etc/inc/plugins.inc.d/unbound.inc index d97c5767a..88ba55c3d 100644 --- a/src/etc/inc/plugins.inc.d/unbound.inc +++ b/src/etc/inc/plugins.inc.d/unbound.inc @@ -680,8 +680,20 @@ function unbound_add_host_entries() } $domain = $config['system']['domain']; - if ($host['domain']) { + // set domain to first entry of host's domain search list + if ($host['domainsearchlist']) { + $domain_array=preg_split("/[ ;]+/",$host['domainsearchlist']); + $domain = $domain_array[0]; + // backward compatibilty: 'domain' was replaced by 'domainsearchlist' + // in dhcpv6 static mappings, but may still exist in older configs + } elseif ($host['domain']) { $domain = $host['domain']; + // set domain to first entry of interface's domain search list + } elseif ($dhcpifconf['domainsearchlist']) { + $domain_array=preg_split("/[ ;]+/",$dhcpifconf['domainsearchlist']); + $domain = $domain_array[0]; + // backward compatibilty: 'domain' was removed from dhcpv6 + // interface settings, but may still exist in older configs } elseif ($dhcpifconf['domain']) { $domain = $dhcpifconf['domain']; } From 8d2939a5fdab10770b4302e2f3b4521536e7519f Mon Sep 17 00:00:00 2001 From: Maurice Date: Thu, 20 Feb 2020 21:10:35 +0100 Subject: [PATCH 6/8] DNS registration for DHCPv6 static mappings, check domainsearchlist first, domain second --- src/etc/inc/plugins.inc.d/dnsmasq.inc | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/etc/inc/plugins.inc.d/dnsmasq.inc b/src/etc/inc/plugins.inc.d/dnsmasq.inc index 54a195dfe..82e490dde 100644 --- a/src/etc/inc/plugins.inc.d/dnsmasq.inc +++ b/src/etc/inc/plugins.inc.d/dnsmasq.inc @@ -265,8 +265,20 @@ function _dnsmasq_add_host_entries() } $domain = $config['system']['domain']; - if ($host['domain']) { + // set domain to first entry of host's domain search list + if ($host['domainsearchlist']) { + $domain_array=preg_split("/[ ;]+/",$host['domainsearchlist']); + $domain = $domain_array[0]; + // backward compatibilty: 'domain' was replaced by 'domainsearchlist' + // in dhcpv6 static mappings, but may still exist in older configs + } elseif ($host['domain']) { $domain = $host['domain']; + // set domain to first entry of interface's domain search list + } elseif ($dhcpifconf['domainsearchlist']) { + $domain_array=preg_split("/[ ;]+/",$dhcpifconf['domainsearchlist']); + $domain = $domain_array[0]; + // backward compatibilty: 'domain' was removed from dhcpv6 + // interface settings, but may still exist in older configs } elseif ($dhcpifconf['domain']) { $domain = $dhcpifconf['domain']; } From 38ce06ea6725146c7e29888b140b6daca18f26d5 Mon Sep 17 00:00:00 2001 From: Maurice Date: Thu, 20 Feb 2020 21:49:02 +0100 Subject: [PATCH 7/8] DHCP registration, clarifications Registrations of static mappings do not always use the system domain. The domains configured for individual static mappings or for the DHCP servers always had higher priority. Static mapping registrations work for both DHCPv6 and DHCPv4, dynamic lease registrations only for DHCPv4. --- src/www/services_unbound.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/www/services_unbound.php b/src/www/services_unbound.php index 24d770691..c381ddfe3 100644 --- a/src/www/services_unbound.php +++ b/src/www/services_unbound.php @@ -229,13 +229,13 @@ include_once("head.inc"); - + /> - + @@ -258,10 +258,10 @@ include_once("head.inc"); /> From c9599a34bbdeda61456bee8837e8a0b875303a12 Mon Sep 17 00:00:00 2001 From: Maurice Date: Thu, 20 Feb 2020 21:57:40 +0100 Subject: [PATCH 8/8] DHCP registration, clarifications Registrations of static mappings do not always use the system domain. The domains configured for individual static mappings or for the DHCP servers always had higher priority. Static mapping registrations work for both DHCPv6 and DHCPv4, dynamic lease registrations only for DHCPv4. --- src/www/services_dnsmasq.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/www/services_dnsmasq.php b/src/www/services_dnsmasq.php index aa69129f9..be90a9d40 100644 --- a/src/www/services_dnsmasq.php +++ b/src/www/services_dnsmasq.php @@ -293,13 +293,13 @@ $( document ).ready(function() { - + /> - + @@ -322,10 +322,10 @@ $( document ).ready(function() { />