Next available IP Address of a /31 prefix #2267

Closed
opened 2025-12-29 17:24:20 +01:00 by adam · 0 comments
Owner

Originally created by @avolmensky on GitHub (Jan 8, 2019).

Environment

  • Python version: 2.7.13
  • NetBox version: 2.5.2

Steps to Reproduce

When requesting next available IP from the API within a prefix that is a /31, an empty list is returned. This is causing issues further down the track with pynetbox not being able to create an IP address in a /31 prefix.

I have tracked this down to line 442 of ipam/models.py f7f6704fc1/netbox/ipam/models.py (L442)
According to RFC3021 first and last address in a /31 is a usable IP Address.

The following changes fix the problem. Should I create a PR for this?

From:

        if not self.is_pool:

To:

        if not self.is_pool and not (self.prefix.prefixlen == 31 and self.family == 4):
Originally created by @avolmensky on GitHub (Jan 8, 2019). ### Environment * Python version: 2.7.13 * NetBox version: 2.5.2 ### Steps to Reproduce When requesting next available IP from the API within a prefix that is a /31, an empty list is returned. This is causing issues further down the track with pynetbox not being able to create an IP address in a /31 prefix. I have tracked this down to line 442 of ipam/models.py https://github.com/digitalocean/netbox/blob/f7f6704fc1956427608c86870f4bd609df0fb8ef/netbox/ipam/models.py#L442 According to RFC3021 first and last address in a /31 is a usable IP Address. The following changes fix the problem. Should I create a PR for this? From: ``` # Remove unusable IPs from non-pool prefixes if not self.is_pool: ``` To: ``` # Remove unusable IPs from non-pool prefixes that are not ipv4 /31's if not self.is_pool and not (self.prefix.prefixlen == 31 and self.family == 4): ```
adam added the type: bugstatus: accepted labels 2025-12-29 17:24:20 +01:00
adam closed this issue 2025-12-29 17:24:20 +01:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#2267