Add prefix key/value to the ipam/ip-addresses API endpoint response #8320

Closed
opened 2025-12-29 20:35:18 +01:00 by adam · 3 comments
Owner

Originally created by @atownson on GitHub (Jul 11, 2023).

NetBox version

v3.5.5

Feature type

Change to existing functionality

Proposed functionality

I propose to add a prefix (or parent_prefix) key/value to the response from the ipam/ip-addresses API endpoint that relates the IP address to the smallest parent prefix.

For example, if you have prefixes 192.168.0.0/20 and 192.168.128.0/24 in the global VRF and 192.168.0.0/25 in another VRF, IP address 192.168.0.1/24 with no VRF assignment would return 192.168.0.0/24 as the prefix.

This would need to be a nested object representing at least the id, prefix, and vrf values of the prefix.

This request might be related to #7845 but might not be blocked by it.

Use case

It is somewhat challenging to relate IP addresses to their parent prefixes via the API. Currently, we are getting all prefixes from the ipam/prefixes endpoint and iterating over each prefix invoking a GET request to ipam/ip-addresses?parent=prefix. One issue with this approach is that you're not guaranteed a complete list of IP addresses with this method (excludes any IP without a parent prefix). Implementing the change requested will reduce the number of API calls needed.

Database changes

Unknown

External dependencies

None

Originally created by @atownson on GitHub (Jul 11, 2023). ### NetBox version v3.5.5 ### Feature type Change to existing functionality ### Proposed functionality I propose to add a `prefix` (or `parent_prefix`) key/value to the response from the ipam/ip-addresses API endpoint that relates the IP address to the smallest parent prefix. For example, if you have prefixes 192.168.0.0/20 and 192.168.128.0/24 in the global VRF and 192.168.0.0/25 in another VRF, IP address 192.168.0.1/24 with no VRF assignment would return 192.168.0.0/24 as the prefix. This would need to be a nested object representing at least the `id`, `prefix`, and `vrf` values of the prefix. This request might be related to #7845 but might not be blocked by it. ### Use case It is somewhat challenging to relate IP addresses to their parent prefixes via the API. Currently, we are getting all prefixes from the ipam/prefixes endpoint and iterating over each prefix invoking a GET request to ipam/ip-addresses?parent=prefix. One issue with this approach is that you're not guaranteed a complete list of IP addresses with this method (excludes any IP without a parent prefix). Implementing the change requested will reduce the number of API calls needed. ### Database changes Unknown ### External dependencies None
adam added the type: featurepending closure labels 2025-12-29 20:35:18 +01:00
adam closed this issue 2025-12-29 20:35:18 +01:00
Author
Owner

@jsenecal commented on GitHub (Jul 12, 2023):

Probably fixed by #7845 as the API endpoints could expose the information

@jsenecal commented on GitHub (Jul 12, 2023): Probably fixed by #7845 as the API endpoints could expose the information
Author
Owner

@github-actions[bot] commented on GitHub (Oct 11, 2023):

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. NetBox is governed by a small group of core maintainers which means not all opened issues may receive direct feedback. Do not attempt to circumvent this process by "bumping" the issue; doing so will result in its immediate closure and you may be barred from participating in any future discussions. Please see our contributing guide.

@github-actions[bot] commented on GitHub (Oct 11, 2023): This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. NetBox is governed by a small group of core maintainers which means not all opened issues may receive direct feedback. **Do not** attempt to circumvent this process by "bumping" the issue; doing so will result in its immediate closure and you may be barred from participating in any future discussions. Please see our [contributing guide](https://github.com/netbox-community/netbox/blob/develop/CONTRIBUTING.md).
Author
Owner

@github-actions[bot] commented on GitHub (Nov 10, 2023):

This issue has been automatically closed due to lack of activity. In an effort to reduce noise, please do not comment any further. Note that the core maintainers may elect to reopen this issue at a later date if deemed necessary.

@github-actions[bot] commented on GitHub (Nov 10, 2023): This issue has been automatically closed due to lack of activity. In an effort to reduce noise, please do not comment any further. Note that the core maintainers may elect to reopen this issue at a later date if deemed necessary.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#8320