Creating an IP from within a prefix allows for it to be created in a different prefix altogether #8527

Closed
opened 2025-12-29 20:37:48 +01:00 by adam · 1 comment
Owner

Originally created by @artiomello on GitHub (Aug 29, 2023).

NetBox version

v3.5.5

Python version

3.8

Steps to Reproduce

  1. Select an existing prefix, e.g. 172.28.23.96/27
  2. Go to IP Addresses
  3. Click on either xx IPs available or + Add IP Address
  4. By default the next available IP address from the prefix will be used, but you can change it to, let's say, 172.28.23.140/27 and create it
  5. IP is created that belongs to a different prefix, than you were creating it from

Expected Behavior

Even though it might be quite obvious to those more experienced in networking, but there should be some preventive logic that doesn't allow creating IP addresses from a specific prefix that don't belong to it.

That is, the prefix from the example is 172.28.23.96/27, which has these available addresses inside of it: 172.28.23.97 - 172.28.23.126. I should not be allowed creating 172.28.23.140/27 from within that prefix.

Observed Behavior

Right now you're able to create any IP from any prefix, even an IP that doesn't belong to the selected prefix, which might provide some confusion, especially for the least attentive and/or experienced in networking.

As a side note, the range for a specific prefix is not mentioned anywhere and in the case of a less intuitive mask/subnet (smaller than /24), it's not clear which address belongs to which subnet, especially in the borderline cases.

Under the IP address list you can see the already assigned addresses, but the available ones are but a calculated number on a button that leads to creation of a new one:
image
I'm not able to click that button and select a free address to choose from because it leads directly to the creation form.

So to summarize, you don't really see the available range for a prefix and thus can't really work within its limits only. Thus it's possible to make mistakes, especially if you're striving for a prettier number (for whatever reason) than what's available next.

Originally created by @artiomello on GitHub (Aug 29, 2023). ### NetBox version v3.5.5 ### Python version 3.8 ### Steps to Reproduce 1. Select an existing prefix, e.g. `172.28.23.96/27` 2. Go to IP Addresses 3. Click on either `xx IPs available` or `+ Add IP Address` 4. By default the next available IP address from the prefix will be used, but you can change it to, let's say, `172.28.23.140/27` and create it 5. IP is created that belongs to a different prefix, than you were creating it from ### Expected Behavior Even though it might be quite obvious to those more experienced in networking, but there should be some preventive logic that doesn't allow creating IP addresses from a specific prefix that don't belong to it. That is, the prefix from the example is `172.28.23.96/27`, which has these available addresses inside of it: `172.28.23.97 - 172.28.23.126`. I should not be allowed creating `172.28.23.140/27` from within that prefix. ### Observed Behavior Right now you're able to create any IP from any prefix, even an IP that doesn't belong to the selected prefix, which might provide some confusion, especially for the least attentive and/or experienced in networking. As a side note, the range for a specific prefix is not mentioned anywhere and in the case of a less intuitive mask/subnet (smaller than /24), it's not clear which address belongs to which subnet, especially in the borderline cases. Under the IP address list you can see the already assigned addresses, but the available ones are but a calculated number on a button that leads to creation of a new one: ![image](https://github.com/netbox-community/netbox/assets/102314521/e9cb03d9-67c5-46da-a726-66e7759ab787) I'm not able to click that button and select a free address to choose from because it leads directly to the creation form. So to summarize, you don't really see the available range for a prefix and thus can't really work within its limits only. Thus it's possible to make mistakes, especially if you're striving for a prettier number (for whatever reason) than what's available next.
adam closed this issue 2025-12-29 20:37:48 +01:00
Author
Owner

@jeremystretch commented on GitHub (Aug 29, 2023):

This is expected behavior. Clicking the "add IP address" button from the prefix view merely pre-populates the IP address field with the first available IP within that prefix. It still uses the same form as if you created an IP address from any other view, and of course the user is free to change the initial address value.

@jeremystretch commented on GitHub (Aug 29, 2023): This is expected behavior. Clicking the "add IP address" button from the prefix view merely pre-populates the IP address field with the first available IP within that prefix. It still uses the same form as if you created an IP address from any other view, and of course the user is free to change the initial address value.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#8527