From 478b27ae18660a4069a2a6aa859bced7570a2b16 Mon Sep 17 00:00:00 2001 From: Austin de Coup-Crank Date: Mon, 15 May 2023 14:52:29 -0500 Subject: [PATCH] Allow net IDs in /31, /32, /127, /128 --- netbox/ipam/forms/model_forms.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/netbox/ipam/forms/model_forms.py b/netbox/ipam/forms/model_forms.py index d1c7dd551..0a851345b 100644 --- a/netbox/ipam/forms/model_forms.py +++ b/netbox/ipam/forms/model_forms.py @@ -354,14 +354,14 @@ class IPAddressForm(TenancyForm, NetBoxModelForm): # Do not allow assigning a network ID or broadcast address to an interface. if interface: if address := self.cleaned_data.get('address'): - if address.ip == address.network: + if address.ip == address.network and address.prefixlen not in (31, 32, 127, 128): self.add_error( 'interface', - "This address is a network ID, which may not be assigned to an interface.") + f"{address} is a network ID, which may not be assigned to an interface.") if address.ip == address.broadcast: self.add_error( 'interface', - "This is a broadcast address, which may not be assigned to an interface.") + f"{address} is a broadcast address, which may not be assigned to an interface.") def save(self, *args, **kwargs): ipaddress = super().save(*args, **kwargs)