-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Description
NetBox version
v4.4.5
Feature type
Data model extension
Proposed functionality
Introduce a new boolean field on IPRange objects: exclude_from_allocation = true | false
This flag would instruct NetBox to exclude the corresponding range from the automatic IP allocator (e.g. /prefixes/{id}/available-ips/) without preventing manual creation of IPAddress objects inside that range.
This solves the current limitation where populated = true simultaneously:
- prevents allocation (desired)
- but also blocks manual creation of IP addresses (undesired)
The two concepts mark_populated and exclude_from_allocator need to be separated to address real-world use cases
Use case
In NetBox 4.3+, the behavior of IP allocation inside a prefix has changed.
This change introduced a new side effect. When an IPRange is marked populated = true, it is impossible to create an IPAddress manually inside that range.
This was not the behavior in 4.2, and it breaks my workflow where an external system allocates IPs (OpenStack), and NetBox must record those IPs afterward (for DNS purposes).
My objects:
PrefixCAN:
id: 1
prefix: 192.168.0.0/24
IPRangeOpenstack:
id: 2
range: 192.168.0.0 - 192.168.0.100
description: OpenStack floating IPsWorkflow before NetBox 4.3
-
VMware IPs were allocated from the prefix using the API
POST /api/ipam/prefixes/1/available-ips/ -
NetBox automatically skipped IPs inside all IPRanges when calculating the next available IP.
This avoided collisions with IPs managed externally by OpenStack and probably already used. -
When OpenStack assigned a floating IP (e.g.
192.168.0.50), we could still manually create an IPAddress in NetBox with the following
POST /api/ipam/ip-addresses/
{
"address": "192.168.0.50/24",
"dns_name": api.myopenshift.domain.com",
"description": "API for OCP cluster #1"
}
Problem in NetBox 4.3+
To preserve the old allocation behavior, the current recommendation is to set mark_populated = true
This successfully prevents the allocator from picking an IP inside the OpenStack range when doing a POST /api/ipam/prefixes/1/available-ips/
However, once mark_populated=true is set, NetBox rejects any manual creation of IP addresses in that same range:
Cannot create IP address 192.168.0.50/24 inside range 192.168.0.0-192.168.0.100.
This makes it impossible to record floating IPs that are allocated by OpenStack but must still be present in NetBox to manage DNS records.
Database changes
class IPRange:
exclude_from_allocation = models.BooleanField(
default=False,
help_text="Exclude this range from automatic IP allocation"
)External dependencies
No response