API allows setting primary_ip6 to an IPv4 address (and probably the other way around). #3586

Closed
opened 2025-12-29 18:30:01 +01:00 by adam · 1 comment
Owner

Originally created by @kevinreniers on GitHub (Apr 20, 2020).

Originally assigned to: @jeremystretch on GitHub.

Environment

  • Python version: 3.6.8
  • NetBox version: 2.7.10

Steps to Reproduce

  1. Have an IPv4 address
  2. Have a device
  3. Try to patch primary_ip6 of the device with an IPv4 address

Expected Behavior

I expected to see an HTTP 400 Bad Request or some indication that I was making a mistake.

Observed Behavior

NetBox set the primary IPv6 address field to an IPv4 address.

{
  "id": 2,
  "name": "dev",
  "display_name": "dev",
  "device_type": {
    "id": 2,
    "url": "https://netbox.local/api/dcim/device-types/2/",
    "manufacturer": {
      "id": 1,
      "url": "https://netbox.local/api/dcim/manufacturers/1/",
      "name": "dummy",
      "slug": "dummy"
    },
    "model": "dummy",
    "slug": "dummy",
    "display_name": "dummy dummy"
  },
  "device_role": {
    "id": 1,
    "url": "https://netbox.local/api/dcim/device-roles/1/",
    "name": "dummy",
    "slug": "dummy"
  },
  "tenant": null,
  "platform": null,
  "serial": "",
  "asset_tag": "CI00000001",
  "site": {
    "id": 5,
    "url": "https://netbox.local/api/dcim/sites/5/",
    "name": "site",
    "slug": "site"
  },
  "rack": null,
  "position": null,
  "face": null,
  "parent_device": null,
  "status": {
    "value": "active",
    "label": "Active",
    "id": 1
  },
  "primary_ip": {
    "id": 76,
    "url": "https://netbox.local/api/ipam/ip-addresses/76/",
    "family": 4,
    "address": "10.250.10.10/23"
  },
  "primary_ip4": {
    "id": 76,
    "url": "https://netbox.local/api/ipam/ip-addresses/76/",
    "family": 4,
    "address": "10.250.10.10/23"
  },
  "primary_ip6": {
    "id": 76,
    "url": "https://netbox.local/api/ipam/ip-addresses/76/",
    "family": 4,
    "address": "10.250.10.10/23"
  },
  "cluster": null,
  "virtual_chassis": null,
  "vc_position": null,
  "vc_priority": null,
  "comments": "",
  "local_context_data": null,
  "tags": [],
  "custom_fields": {},
  "config_context": {},
  "created": "2020-04-09",
  "last_updated": "2020-04-20T08:48:08.666396Z"
}
Originally created by @kevinreniers on GitHub (Apr 20, 2020). Originally assigned to: @jeremystretch on GitHub. ### Environment * Python version: 3.6.8 * NetBox version: 2.7.10 ### Steps to Reproduce 1. Have an IPv4 address 2. Have a device 3. Try to patch primary_ip6 of the device with an IPv4 address ### Expected Behavior I expected to see an HTTP 400 Bad Request or some indication that I was making a mistake. ### Observed Behavior NetBox set the primary IPv6 address field to an IPv4 address. ``` { "id": 2, "name": "dev", "display_name": "dev", "device_type": { "id": 2, "url": "https://netbox.local/api/dcim/device-types/2/", "manufacturer": { "id": 1, "url": "https://netbox.local/api/dcim/manufacturers/1/", "name": "dummy", "slug": "dummy" }, "model": "dummy", "slug": "dummy", "display_name": "dummy dummy" }, "device_role": { "id": 1, "url": "https://netbox.local/api/dcim/device-roles/1/", "name": "dummy", "slug": "dummy" }, "tenant": null, "platform": null, "serial": "", "asset_tag": "CI00000001", "site": { "id": 5, "url": "https://netbox.local/api/dcim/sites/5/", "name": "site", "slug": "site" }, "rack": null, "position": null, "face": null, "parent_device": null, "status": { "value": "active", "label": "Active", "id": 1 }, "primary_ip": { "id": 76, "url": "https://netbox.local/api/ipam/ip-addresses/76/", "family": 4, "address": "10.250.10.10/23" }, "primary_ip4": { "id": 76, "url": "https://netbox.local/api/ipam/ip-addresses/76/", "family": 4, "address": "10.250.10.10/23" }, "primary_ip6": { "id": 76, "url": "https://netbox.local/api/ipam/ip-addresses/76/", "family": 4, "address": "10.250.10.10/23" }, "cluster": null, "virtual_chassis": null, "vc_position": null, "vc_priority": null, "comments": "", "local_context_data": null, "tags": [], "custom_fields": {}, "config_context": {}, "created": "2020-04-09", "last_updated": "2020-04-20T08:48:08.666396Z" } ```
adam added the type: bugstatus: accepted labels 2025-12-29 18:30:01 +01:00
adam closed this issue 2025-12-29 18:30:01 +01:00
Author
Owner

@jeremystretch commented on GitHub (Apr 21, 2020):

We can do validation at the time of assignment, but currently there's no mechanism in place to prevent a user from changing an IPv4 address to v6 or vice versa. However that seems like a very unlikely use case, so maybe we should do that as well.

@jeremystretch commented on GitHub (Apr 21, 2020): We can do validation at the time of assignment, but currently there's no mechanism in place to prevent a user from changing an IPv4 address to v6 or vice versa. However that seems like a very unlikely use case, so maybe we should do that as well.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#3586