VirtualMachine model does not check family of ip address assigned as primary_ip4/6 #6911

Closed
opened 2025-12-29 19:46:35 +01:00 by adam · 1 comment
Owner

Originally created by @amhn on GitHub (Aug 30, 2022).

Originally assigned to: @jeremystretch on GitHub.

NetBox version

v3.3.1

Python version

3.10

Steps to Reproduce

  1. Create virtual machine "vm1"
  2. Create VM interface "vm_int1"
  3. Create IP address "127.0.0.1/8"
  4. Assign 127.0.0.1/8 to VM interface "vm_int1"
  5. Execute PATCH request to /api/virtualization/virtual-machines/ (Insert respective Ids of VM and IP):
curl -X PATCH \
      -H  "accept: application/json" -H  "Authorization: Token $NETBOX_TOKEN" \
      --data '{"primary_ip6": 1}' -H "Content-Type: application/json" 
      "http://localhost:8000/api/virtualization/virtual-machines/1/"

Expected Behavior

An error is returned that an IPv4 address can not be assigned as primary_ipv6

Observed Behavior

IPv4 address is assigned as primary_ip6
image

Originally created by @amhn on GitHub (Aug 30, 2022). Originally assigned to: @jeremystretch on GitHub. ### NetBox version v3.3.1 ### Python version 3.10 ### Steps to Reproduce 1. Create virtual machine "vm1" 2. Create VM interface "vm_int1" 3. Create IP address "127.0.0.1/8" 4. Assign 127.0.0.1/8 to VM interface "vm_int1" 5. Execute PATCH request to /api/virtualization/virtual-machines/ (Insert respective Ids of VM and IP): ``` curl -X PATCH \ -H "accept: application/json" -H "Authorization: Token $NETBOX_TOKEN" \ --data '{"primary_ip6": 1}' -H "Content-Type: application/json" "http://localhost:8000/api/virtualization/virtual-machines/1/" ``` ### Expected Behavior An error is returned that an IPv4 address can not be assigned as primary_ipv6 ### Observed Behavior IPv4 address is assigned as primary_ip6 ![image](https://user-images.githubusercontent.com/67868947/187533885-e97c04b8-816d-460a-aec5-aaa8d7e086b1.png)
adam added the type: bugstatus: accepted labels 2025-12-29 19:46:35 +01:00
adam closed this issue 2025-12-29 19:46:35 +01:00
Author
Owner

@jeremystretch commented on GitHub (Sep 1, 2022):

We may be able to reuse some of the validation that we have in place for this on the Device model, however that also checks for interfaces on virtual chassis members, which doesn't apply to virtual machines.

@jeremystretch commented on GitHub (Sep 1, 2022): We may be able to reuse some of the validation that we have in place for this on the Device model, however that also checks for interfaces on virtual chassis members, which doesn't apply to virtual machines.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#6911