netbox-community / netbox

The premier source of truth powering network automation. Open source under Apache 2. Public demo: https://demo.netbox.dev
http://netboxlabs.com/oss/netbox/
Apache License 2.0
15.67k stars 2.53k forks source link

Add an optional site relationship to IP address records #5347

Closed pgnuta closed 3 years ago

pgnuta commented 3 years ago

Environment

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

jeremystretch commented 3 years ago

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.

sdktr commented 3 years ago

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

pgnuta commented 3 years ago

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.

jeremystretch commented 3 years ago

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.

pgnuta commented 3 years ago

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.

jeremystretch commented 3 years ago

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

pgnuta commented 3 years ago

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.