diff options
author | sarthurdev <965089+sarthurdev@users.noreply.github.com> | 2024-01-09 22:48:55 +0100 |
---|---|---|
committer | sarthurdev <965089+sarthurdev@users.noreply.github.com> | 2024-01-10 00:42:22 +0100 |
commit | 41913f4d1d63ddd39d9125b0140b8a33449c2cfb (patch) | |
tree | 1fb7ff1b452f13cc2af4c6c48d738729dc71e4ef /src | |
parent | 39bf15289ca10ff5b61eb4070292ffb13f53e94e (diff) | |
download | vyos-1x-41913f4d1d63ddd39d9125b0140b8a33449c2cfb.tar.gz vyos-1x-41913f4d1d63ddd39d9125b0140b8a33449c2cfb.zip |
dhcp: T5787: Prevent duplicate IP addresses on static mappings
Diffstat (limited to 'src')
-rwxr-xr-x | src/conf_mode/service_dhcp-server.py | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/src/conf_mode/service_dhcp-server.py b/src/conf_mode/service_dhcp-server.py index 329e18993..ceaba019e 100755 --- a/src/conf_mode/service_dhcp-server.py +++ b/src/conf_mode/service_dhcp-server.py @@ -223,6 +223,7 @@ def verify(dhcp): if 'static_mapping' in subnet_config: # Static mappings require just a MAC address (will use an IP from the dynamic pool if IP is not set) + used_ips = [] for mapping, mapping_config in subnet_config['static_mapping'].items(): if 'ip_address' in mapping_config: if ip_address(mapping_config['ip_address']) not in ip_network(subnet): @@ -234,6 +235,11 @@ def verify(dhcp): raise ConfigError(f'Either MAC address or Client identifier (DUID) is required for ' f'static mapping "{mapping}" within shared-network "{network}, {subnet}"!') + if mapping_config['ip_address'] in used_ips: + raise ConfigError(f'Configured IP address for static mapping "{mapping}" exists on another static mapping') + + used_ips.append(mapping_config['ip_address']) + # There must be one subnet connected to a listen interface. # This only counts if the network itself is not disabled! if 'disable' not in network_config: |