Duplicate addresses counting towards prefix utilization #1606

Closed
opened 2025-12-29 16:33:26 +01:00 by adam · 4 comments
Owner

Originally created by @DanSheps on GitHub (Mar 6, 2018).

Issue type

[ ] Feature request
[X ] Bug report
[ ] Documentation

Environment

  • Python version: 3.4.5
  • NetBox version: 2.3.0

Description

It appears that netaddr.IPSet is not filtering out duplicate prefixes from the prefix-list. I don't believe this is intended behaviour.

Reproduction

To reproduce, create a duplicate address under any prefix and it will increase utilization.

Originally created by @DanSheps on GitHub (Mar 6, 2018). ### Issue type [ ] Feature request <!-- An enhancement of existing functionality --> [X ] Bug report <!-- Unexpected or erroneous behavior --> [ ] Documentation <!-- A modification to the documentation --> ### Environment * Python version: 3.4.5 * NetBox version: 2.3.0 ### Description It appears that netaddr.IPSet is not filtering out duplicate prefixes from the prefix-list. I don't believe this is intended behaviour. #### Reproduction To reproduce, create a duplicate address under any prefix and it will increase utilization.
adam added the type: bugstatus: accepted labels 2025-12-29 16:33:26 +01:00
adam closed this issue 2025-12-29 16:33:26 +01:00
Author
Owner

@dirtycajunrice commented on GitHub (Mar 6, 2018):

This IS in fact how it has been. This makes it infinitely easier to find and FIX those subnets for people migrating to netbox. If you do not want this behavior you can turn on the Unique setting to disallow duplicates

@dirtycajunrice commented on GitHub (Mar 6, 2018): This IS in fact how it has been. This makes it infinitely easier to find and FIX those subnets for people migrating to netbox. If you do not want this behavior you can turn on the Unique setting to disallow duplicates
Author
Owner

@DanSheps commented on GitHub (Mar 6, 2018):

Except with the Unique setting, you can't have two devices with the same address assigned (HSRP), which is what I want. I did misspeak, I meant get_utilization not netaddr.IPSet (I was looking at the wrong class)

I don't think this is intended behaviour, or at the very least it should be toggleable if it is intended behaviour.

The fix is pretty easy:

child_count = netaddr.IPSet([netaddr.IPAddress(ip.address) for ip in self.get_child_ips()]).size

Instead of

child_count = self.get_child_ips().count()
@DanSheps commented on GitHub (Mar 6, 2018): Except with the Unique setting, you can't have two devices with the same address assigned (HSRP), which is what I want. I did misspeak, I meant get_utilization not netaddr.IPSet (I was looking at the wrong class) I don't think this is intended behaviour, or at the very least it should be toggleable if it is intended behaviour. The fix is pretty easy: child_count = netaddr.IPSet([netaddr.IPAddress(ip.address) for ip in self.get_child_ips()]).size Instead of child_count = self.get_child_ips().count()
Author
Owner

@dirtycajunrice commented on GitHub (Mar 6, 2018):

I understand what you are saying. IP addresses already have an HSRP Role set, and honestly... i think the fix would be better suited as allowing a toggle for the IP addresses to have a many to many relationship instead of a bandaid of the utilization percent. This needs input from Jeremy either way tho

@dirtycajunrice commented on GitHub (Mar 6, 2018): I understand what you are saying. IP addresses already have an HSRP Role set, and honestly... i think the fix would be better suited as allowing a toggle for the IP addresses to have a many to many relationship instead of a bandaid of the utilization percent. This needs input from Jeremy either way tho
Author
Owner

@DanSheps commented on GitHub (Mar 6, 2018):

toggle for the IP addresses to have a many to many relationship instead of a bandaid of the utilization percent.

That would be nice.

However when I look at it, while there are more addresses, strictly by count, in the prefix, the total utilization is still only 100%. I don't think utilization should really ever be over 100%, but that is just me.

I think a better way to handle the flagging of duplicate IP addresses might be to flag the prefix as "having duplicates" as it also gives you a quick look at duplicates whereas your utilization could be 80% but 50% of those could be duplicates.

@DanSheps commented on GitHub (Mar 6, 2018): > toggle for the IP addresses to have a many to many relationship instead of a bandaid of the utilization percent. That would be nice. However when I look at it, while there are more addresses, strictly by count, in the prefix, the total utilization is still only 100%. I don't think utilization should really ever be over 100%, but that is just me. I think a better way to handle the flagging of duplicate IP addresses might be to flag the prefix as "having duplicates" as it also gives you a quick look at duplicates whereas your utilization could be 80% but 50% of those could be duplicates.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#1606