Add an optional site relationship to IP address records #4275

Closed
opened 2025-12-29 18:34:22 +01:00 by adam · 7 comments
Owner

Originally created by @pgnuta on GitHub (Nov 16, 2020).

Environment

  • Python version: 3.6.8
  • NetBox version: 2.9.9

Proposed Functionality

Add an optional site relationship to IP address records.

Use Case

For automation purposes it would be useful to sometimes understand where an IP address notionally belongs or is routed to. Understanding that this relationship can be easily derived when an entire prefix is allocated to a tenant/site, in the specific corner-case of allocating /32 IP addresses to a range of tenants out of a shared prefix this is not possible.

Database Changes

Add a 1-many relationship between the ip address table and the site table.

External Dependencies

Originally created by @pgnuta on GitHub (Nov 16, 2020). <!-- NOTE: IF YOUR ISSUE DOES NOT FOLLOW THIS TEMPLATE, IT WILL BE CLOSED. This form is only for proposing specific new features or enhancements. If you have a general idea or question, please post to our mailing list instead of opening an issue: https://groups.google.com/g/netbox-discuss NOTE: Due to an excessive backlog of feature requests, we are not currently accepting any proposals which significantly extend NetBox's feature scope. Please describe the environment in which you are running NetBox. Be sure that you are running an unmodified instance of the latest stable release before submitting a bug report. --> ### Environment * Python version: 3.6.8 * NetBox version: 2.9.9 <!-- Describe in detail the new functionality you are proposing. Include any specific changes to work flows, data models, or the user interface. --> ### Proposed Functionality Add an optional site relationship to IP address records. <!-- Convey an example use case for your proposed feature. Write from the perspective of a NetBox user who would benefit from the proposed functionality and describe how. ---> ### Use Case For automation purposes it would be useful to sometimes understand where an IP address notionally belongs or is routed to. Understanding that this relationship can be easily derived when an entire prefix is allocated to a tenant/site, in the specific corner-case of allocating /32 IP addresses to a range of tenants out of a shared prefix this is not possible. <!-- Note any changes to the database schema necessary to support the new feature. For example, does the proposal require adding a new model or field? (Not all new features require database changes.) ---> ### Database Changes Add a 1-many relationship between the ip address table and the site table. <!-- List any new dependencies on external libraries or services that this new feature would introduce. For example, does the proposal require the installation of a new Python package? (Not all new features introduce new dependencies.) --> ### External Dependencies
adam closed this issue 2025-12-29 18:34:22 +01:00
Author
Owner

@jeremystretch commented on GitHub (Nov 16, 2020):

IP addresses can be assigned to sites via prefix and/or device assignment, and can be assigned directly to tenants if needed. I don't see a use case for the proposed relationship. Further, it would allow for logically inconsistent relationships; e.g. assigning IP address 192.168.0.1/24 to site A but its parent prefix 192.168.0.0/24 to site B.

@jeremystretch commented on GitHub (Nov 16, 2020): IP addresses can be assigned to sites via prefix and/or device assignment, and can be assigned directly to tenants if needed. I don't see a use case for the proposed relationship. Further, it would allow for logically inconsistent relationships; e.g. assigning IP address 192.168.0.1/24 to site A but its parent prefix 192.168.0.0/24 to site B.
Author
Owner

@sdktr commented on GitHub (Nov 16, 2020):

image
^^^ we use the mentioned 'inherit-site-from-parent-prefix' in our external netbox frontend. In this concatenated IPAM view the Site column for an IP is based on

  1. Associated Device.Site
  2. Parent.Prefix.Site
@sdktr commented on GitHub (Nov 16, 2020): ![image](https://user-images.githubusercontent.com/19833687/99307834-58ae0f00-2857-11eb-9e3a-ee3814d9b889.png) ^^^ we use the mentioned 'inherit-site-from-parent-prefix' in our external netbox frontend. In this concatenated IPAM view the Site column for an IP is based on 1) Associated Device.Site 2) Parent.Prefix.Site
Author
Owner

@pgnuta commented on GitHub (Nov 16, 2020):

In terms of consistency of relationships it is perfectly valid to assign a prefix to a site A but then take individual IP addresses from that prefix and assign them to site B. That is the least-effort method of documenting prefix and IP allocation and also the most efficient method of actually routing that prefix on any platform that i'm aware of. That logic works both from the point of view of flow-down site inheritance through prefixes to IP addresses and also is literally how you would route it on a network using prefix length as the primary route selection method.

This modification also allows for blind assignment of resources to sites where you don't manage the devices onsite and therefore it is not appropriate to document the device configuration which would allow the association of the IP address to the device and thus the site location via that method.

Lastly this modification doesn't take away from any of the other methods of documenting IP assignment whether by device assignment or NAT relationships.

@pgnuta commented on GitHub (Nov 16, 2020): In terms of consistency of relationships it is perfectly valid to assign a prefix to a site A but then take individual IP addresses from that prefix and assign them to site B. That is the least-effort method of documenting prefix and IP allocation and also the most efficient method of actually routing that prefix on any platform that i'm aware of. That logic works both from the point of view of flow-down site inheritance through prefixes to IP addresses and also is literally how you would route it on a network using prefix length as the primary route selection method. This modification also allows for blind assignment of resources to sites where you don't manage the devices onsite and therefore it is not appropriate to document the device configuration which would allow the association of the IP address to the device and thus the site location via that method. Lastly this modification doesn't take away from any of the other methods of documenting IP assignment whether by device assignment or NAT relationships.
Author
Owner

@jeremystretch commented on GitHub (Nov 16, 2020):

In terms of consistency of relationships it is perfectly valid to assign a prefix to a site A but then take individual IP addresses from that prefix and assign them to site B.

I have to disagree. Assigning a prefix to a site implies that the entire prefix belongs to the site. (If it didn't, you would break it into smaller child prefixes for correct assignment.) This may not fit you specific needs, but it is how NetBox was designed and we won't deviate from that model.

@jeremystretch commented on GitHub (Nov 16, 2020): > In terms of consistency of relationships it is perfectly valid to assign a prefix to a site A but then take individual IP addresses from that prefix and assign them to site B. I have to disagree. Assigning a prefix to a site implies that the _entire_ prefix belongs to the site. (If it didn't, you would break it into smaller child prefixes for correct assignment.) This may not fit you specific needs, but it is how NetBox was designed and we won't deviate from that model.
Author
Owner

@pgnuta commented on GitHub (Nov 16, 2020):

This comes back to a previous topic which is '/32 prefixes not being valid'. Without the ability to create /32 prefixes you're forced to use /31 or larger which implies then that the smallest number of IP addresses that you can assign to a specific site is 2. I don't agree that this is valid.

@pgnuta commented on GitHub (Nov 16, 2020): This comes back to a previous topic which is '/32 prefixes not being valid'. Without the ability to create /32 prefixes you're forced to use /31 or larger which implies then that the smallest number of IP addresses that you can assign to a specific site is 2. I don't agree that this is valid.
Author
Owner

@jeremystretch commented on GitHub (Nov 16, 2020):

That's something you're welcome to propose in a separate issue, but it's wholly unrelated to this topic.

@jeremystretch commented on GitHub (Nov 16, 2020): That's something you're welcome to propose in a separate issue, but it's wholly unrelated to this topic.
Author
Owner

@pgnuta commented on GitHub (Nov 16, 2020):

I figured it would be pointless as it had been discussed and rejected several times in the past like here: https://github.com/netbox-community/netbox/issues/922 and a pull request rejected here: 30aa83025d

Unless you're prepared to revisit this topic then i guess this discussion is closed.

@pgnuta commented on GitHub (Nov 16, 2020): I figured it would be pointless as it had been discussed and rejected several times in the past like here: https://github.com/netbox-community/netbox/issues/922 and a pull request rejected here: https://github.com/asenci/netbox/commit/30aa83025d475be7e2603cff103bb31f18260ccf Unless you're prepared to revisit this topic then i guess this discussion is closed.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#4275