POST /ipam/prefixes/{id}/available-prefixes/ does not respect VRF parameter #1708

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

Originally created by @hreeder on GitHub (May 1, 2018).

Issue type

[ ] Feature request
[x] Bug report
[ ] Documentation

Environment

  • Python version:
  • NetBox version: 2.3.3

Description

When POSTing to /ipam/prefixes/{id}/available-prefixes/ using the following data:

{
  "prefix_length": 27,
  "vrf": 5
}

I get this as a return value:

{
  "id": 366,
  "prefix": "10.0.0.0/27",
  "site": null,
  "vrf": 6,
  "tenant": null,
  "vlan": null,
  "status": 1,
  "role": null,
  "is_pool": false,
  "description": "",
  "created": "2018-05-01",
  "last_updated": "2018-05-01T17:41:24.763950+01:00"
}

The VRF ID being 6 is because the parent prefix is in VRF 6 - looks like the following is overriding the VRF to be that of the parent prefix no matter if it's specified or not.
e5454d6714/netbox/ipam/api/views.py (L108)

Originally created by @hreeder on GitHub (May 1, 2018). ### Issue type [ ] Feature request <!-- An enhancement of existing functionality --> [x] Bug report <!-- Unexpected or erroneous behavior --> [ ] Documentation <!-- A modification to the documentation --> ### Environment * Python version: * NetBox version: 2.3.3 <!-- BUG REPORTS must include: * A list of the steps needed for someone else to reproduce the bug * A description of the expected and observed behavior * Any relevant error messages (screenshots may also help) FEATURE REQUESTS must include: * A detailed description of the proposed functionality * A use case for the new feature * A rough description of any necessary changes to the database schema * Any relevant third-party libraries which would be needed --> ### Description When POSTing to `/ipam/prefixes/{id}/available-prefixes/` using the following data: ```json { "prefix_length": 27, "vrf": 5 } ``` I get this as a return value: ```json { "id": 366, "prefix": "10.0.0.0/27", "site": null, "vrf": 6, "tenant": null, "vlan": null, "status": 1, "role": null, "is_pool": false, "description": "", "created": "2018-05-01", "last_updated": "2018-05-01T17:41:24.763950+01:00" } ``` The VRF ID being 6 is because the parent prefix is in VRF 6 - looks like the following is overriding the VRF to be that of the parent prefix no matter if it's specified or not. https://github.com/digitalocean/netbox/blob/e5454d6714a6f3b42166e774e7ed2dd244f63d5a/netbox/ipam/api/views.py#L108
adam closed this issue 2025-12-29 16:34:38 +01:00
Author
Owner

@jeremystretch commented on GitHub (Aug 7, 2018):

Specifying a VRF different from the parent won't work. Say you have a container 192.0.2.0/24 in VRF ABC and you want to allocate the next available /27 in a different VRF. This will create 192.0.2.0/27. If you then reissue that request to get the next available /26, NetBox will return 192.0.2.0/27 again, because the previous call created the prefix in a different VRF. This will end up just creating a duplicate prefix each time.

@jeremystretch commented on GitHub (Aug 7, 2018): Specifying a VRF different from the parent won't work. Say you have a container 192.0.2.0/24 in VRF ABC and you want to allocate the next available /27 in a different VRF. This will create 192.0.2.0/27. If you then reissue that request to get the next available /26, NetBox will return 192.0.2.0/27 again, because the previous call created the prefix in a different VRF. This will end up just creating a duplicate prefix each time.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#1708