Pulling Next Available IP is not properly scoped to Prefix #3999

Closed
opened 2025-12-29 18:32:32 +01:00 by adam · 2 comments
Owner

Originally created by @grizzthedj on GitHub (Aug 19, 2020).

Environment

  • Python version: 2.7.10
  • NetBox version: 2.8.9

Running the netbox-docker container locally on MAC OS High Sierra.

Steps to Reproduce

  1. Create 2 Tenants (TenantA and TenantB)
  2. Create a prefix of 100.10.10.0/29 and set the Tenant to TenantA (assume the generated prefix ID is 1)
  3. Create a prefix of 100.10.10.0/29 and set the Tenant to TenantB (assume the generated prefix ID is 2)
  4. Add the IP address 100.10.10.1/29 to the prefix in TenantA
  5. Make API call to get next available IP from prefix in TenantB: /api/ipam/prefixes/2/available-ips/?limit=1

Expected Behavior

I would expect that given we are specifying the unique prefix ID in the URL, the next available IP would be drawn from that specific prefix. In the above example, since there were no IP's added to TenantB's prefix, I would expect 100.10.10.1/29 to be returned as the next available IP.

Observed Behavior

When making API calls to get the next available IP from both prefixes, 100.10.10.2/29 was returned in both cases.

/api/ipam/prefixes/1/available-ips/?limit=1
/api/ipam/prefixes/2/available-ips/?limit=1
Originally created by @grizzthedj on GitHub (Aug 19, 2020). ### Environment * Python version: 2.7.10 * NetBox version: 2.8.9 Running the netbox-docker container locally on MAC OS High Sierra. ### Steps to Reproduce 1. Create 2 Tenants (`TenantA` and `TenantB`) 2. Create a prefix of `100.10.10.0/29` and set the Tenant to `TenantA` (assume the generated prefix ID is 1) 3. Create a prefix of `100.10.10.0/29` and set the Tenant to `TenantB` (assume the generated prefix ID is 2) 4. Add the IP address `100.10.10.1/29` to the prefix in `TenantA` 5. Make API call to get next available IP from prefix in `TenantB`: `/api/ipam/prefixes/2/available-ips/?limit=1` ### Expected Behavior I would expect that given we are specifying the unique prefix ID in the URL, the next available IP would be drawn from that specific prefix. In the above example, since there were no IP's added to `TenantB`'s prefix, I would expect `100.10.10.1/29` to be returned as the next available IP. ### Observed Behavior When making API calls to get the next available IP from both prefixes, `100.10.10.2/29` was returned in both cases. ``` /api/ipam/prefixes/1/available-ips/?limit=1 /api/ipam/prefixes/2/available-ips/?limit=1 ```
adam closed this issue 2025-12-29 18:32:32 +01:00
Author
Owner

@jeremystretch commented on GitHub (Aug 21, 2020):

This is expected behavior. IPs and prefixes are namespaced only by VRF assignment. Because these all exist in the global table, NetBox sees 100.10.10.1 as used for either prefix. Tenant assignment is not considered for this purpose, because NetBox cannot assume the function of tenancy for every use case.

In order to reach the desired operation, you'll need to separate prefixes and IPs by VRFs belonging to either tenant.

@jeremystretch commented on GitHub (Aug 21, 2020): This is expected behavior. IPs and prefixes are namespaced only by VRF assignment. Because these all exist in the global table, NetBox sees 100.10.10.1 as used for either prefix. Tenant assignment is not considered for this purpose, because NetBox cannot assume the function of tenancy for every use case. In order to reach the desired operation, you'll need to separate prefixes and IPs by VRFs belonging to either tenant.
Author
Owner

@grizzthedj commented on GitHub (Aug 24, 2020):

Thanks @jeremystretch for the clarification here

@grizzthedj commented on GitHub (Aug 24, 2020): Thanks @jeremystretch for the clarification here
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#3999