diff options
author | Christian Poessinger <christian@poessinger.com> | 2019-10-03 22:51:34 +0200 |
---|---|---|
committer | Christian Poessinger <christian@poessinger.com> | 2019-10-03 22:51:34 +0200 |
commit | 5848a4d6095e6d7bc70e34e0b7b7e2c3d8e3303f (patch) | |
tree | b419cf74699a10433b236431ba7d1405d0b1c627 /src/conf_mode | |
parent | 56235420984746dc1ce23479257c68db0c2a3d2f (diff) | |
download | vyos-1x-5848a4d6095e6d7bc70e34e0b7b7e2c3d8e3303f.tar.gz vyos-1x-5848a4d6095e6d7bc70e34e0b7b7e2c3d8e3303f.zip |
dhcp-server: T1707: remove DHCP static-mappings from address pool
Previously when static-mappings have been created the address was still within
the DHCP pool resulting in log entries as follows:
dhcpd: Dynamic and static leases present for 192.0.2.51
dhcpd: Remove host declaration DMZ_PC2 or remove 192.0.2.51
dhcpd: from the dynamic address pool for DMZ
(cherry picked from commit 6f954ab56768af9a07d8a1dc086f54ddefa58da7)
Diffstat (limited to 'src/conf_mode')
-rwxr-xr-x | src/conf_mode/dhcp_server.py | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/src/conf_mode/dhcp_server.py b/src/conf_mode/dhcp_server.py index a08c39699..f19bcb250 100755 --- a/src/conf_mode/dhcp_server.py +++ b/src/conf_mode/dhcp_server.py @@ -525,6 +525,7 @@ def get_config(): # Static DHCP leases if conf.exists('static-mapping'): + addresses_for_exclude = [] for mapping in conf.list_nodes('static-mapping'): conf.set_level('service dhcp-server shared-network-name {0} subnet {1} static-mapping {2}'.format(network, net, mapping)) mapping = { @@ -542,6 +543,7 @@ def get_config(): # IP address used for this DHCP client if conf.exists('ip-address'): mapping['ip_address'] = conf.return_value('ip-address') + addresses_for_exclude.append(mapping['ip_address']) # MAC address of requesting DHCP client if conf.exists('mac-address'): @@ -560,6 +562,13 @@ def get_config(): # append static-mapping configuration to subnet list subnet['static_mapping'].append(mapping) + # Now we have all static DHCP leases - we also need to slice them + # out of our DHCP ranges to avoid ISC DHCPd warnings as: + # dhcpd: Dynamic and static leases present for 192.0.2.51. + # dhcpd: Remove host declaration DMZ_PC1 or remove 192.0.2.51 + # dhcpd: from the dynamic address pool for DMZ + subnet['range'] = dhcp_slice_range(addresses_for_exclude, subnet['range']) + # Reset config level to matching hirachy conf.set_level('service dhcp-server shared-network-name {0} subnet {1}'.format(network, net)) |