DHCP: Update DNS with hostname only static entries (#4689)

DHCP static mappings that have a hostname configured but no IP address,
now update the Outbound DNS entry with the IP assigned from the pool
This commit is contained in:
Gareth Owen 2021-08-12 10:52:45 -04:00 committed by GitHub
parent a31ec3c1ec
commit 3ca57fae8b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 8 additions and 2 deletions

View File

@ -1092,6 +1092,7 @@ EOD;
$dhhostname = str_replace(" ", "_", $sm['hostname']);
$dhhostname = str_replace(".", "_", $dhhostname);
$dhcpdconf .= " option host-name \"{$dhhostname}\";\n";
$dhcpdconf .= " set hostname-override = config-option host-name;\n";
}
if (!empty($sm['filename'])) {
$dhcpdconf .= " filename \"{$sm['filename']}\";\n";
@ -1561,6 +1562,7 @@ EOD;
$dhhostname = str_replace(" ", "_", $sm['hostname']);
$dhhostname = str_replace(".", "_", $dhhostname);
$dhcpdv6conf .= " option host-name {$dhhostname};\n";
$dhcpdv6conf .= " set hostname-override = config-option host-name;\n";
}
if (!empty($sm['filename'])) {
$dhcpdv6conf .= " filename \"{$sm['filename']}\";\n";

View File

@ -57,6 +57,7 @@ class DHCPDLease(object):
:param lines: lease section as list item
:return: dictionary
"""
hostname_override = None
lease = dict()
lease['address'] = lines[0].split()[1]
for line in lines:
@ -73,10 +74,15 @@ class DHCPDLease(object):
field_value = {'hardware-type': parts[1], 'mac-address': parts[2].split(';')[0]}
elif field_name in('uid', 'client-hostname') and len(parts) >= 2 and parts[1].find('"') > -1:
field_value = parts[1].split('"')[1]
elif field_name == 'set' and len(parts) >= 4 and parts[1] == 'hostname-override' and parts[3].find('"') > -1:
hostname_override = parts[3].split('"')[1]
if field_value is not None:
lease[field_name] = field_value
if hostname_override is not None:
lease['client-hostname'] = hostname_override
return lease
def watch(self):

View File

@ -354,7 +354,6 @@ include("head.inc");
<input name="hostname" type="text" value="<?=$pconfig['hostname'];?>" />
<div class="hidden" data-for="help_for_hostname">
<?=gettext("Name of the host, without domain part.");?>
<?=gettext("If no IP address is given above, hostname will not be visible to DNS services with lease registration enabled.");?>
</div>
</td>
</tr>

View File

@ -207,7 +207,6 @@ include("head.inc");
<input name="hostname" type="text" value="<?=$pconfig['hostname'];?>" />
<div class="hidden" data-for="help_for_hostname">
<?=gettext("Name of the host, without domain part.");?>
<?=gettext("If no IP address is given above, hostname will not be visible to DNS services with lease registration enabled.");?>
</div>
</td>
</tr>