diff --git a/networks/forms.py b/networks/forms.py index b3cc8e4f..691dd8a1 100644 --- a/networks/forms.py +++ b/networks/forms.py @@ -61,6 +61,14 @@ class AddNetPool(forms.Form): def clean_subnet(self): return checked_subnet(self.cleaned_data["subnet"], 4) + def clean(self): + cleaned = super().clean() + # one fixed address per address of the DHCP range + subnet = cleaned.get("subnet") + if cleaned.get("fixed") and subnet and ipaddress.ip_network(subnet, strict=False).prefixlen < 24: + self.add_error("fixed", _("Fixed addresses need an IPv4 subnet of /24 or smaller")) + return cleaned + def clean_subnet6(self): return checked_subnet(self.cleaned_data["subnet6"], 6) diff --git a/networks/templates/create_net_block.html b/networks/templates/create_net_block.html index 0b79c182..4caf6db6 100644 --- a/networks/templates/create_net_block.html +++ b/networks/templates/create_net_block.html @@ -60,7 +60,7 @@