diff --git a/netbox/ipam/models/ip.py b/netbox/ipam/models/ip.py index 015f9220c..615aa6965 100644 --- a/netbox/ipam/models/ip.py +++ b/netbox/ipam/models/ip.py @@ -849,6 +849,32 @@ class IPAddress(PrimaryModel): return self.address.version return None + @property + def is_oob_ip(self): + if self.assigned_object: + if self.family == 4: + if self.assigned_object.device.oob_ip4: + if self.assigned_object.device.oob_ip4.pk == self.pk: + return True + if self.family == 6: + if self.assigned_object.device.oob_ip6: + if self.assigned_object.device.oob_ip6.pk == self.pk: + return True + return False + + @property + def is_primary_ip(self): + if self.assigned_object: + if self.family == 4: + if self.assigned_object.device.primary_ip4: + if self.assigned_object.device.primary_ip4.pk == self.pk: + return True + if self.family == 6: + if self.assigned_object.device.primary_ip6: + if self.assigned_object.device.primary_ip6.pk == self.pk: + return True + return False + def _set_mask_length(self, value): """ Expose the IPNetwork object's prefixlen attribute on the parent model so that it can be manipulated directly, diff --git a/netbox/templates/ipam/ipaddress.html b/netbox/templates/ipam/ipaddress.html index e58ac736f..a3c55d76e 100644 --- a/netbox/templates/ipam/ipaddress.html +++ b/netbox/templates/ipam/ipaddress.html @@ -96,6 +96,14 @@ {% endfor %} + + Primary IP + {% checkmark object.is_primary_ip %} + + + OOB IP + {% checkmark object.is_oob_ip %} +