Assign existing IP Address to Device Interface #1246

Closed
opened 2025-12-29 16:30:35 +01:00 by adam · 25 comments
Owner

Originally created by @KWI-TFenby on GitHub (Sep 19, 2017).

Issue type

[] Feature request
[X] Bug report
[ ] Documentation

Environment

  • Python version: Python 3.4.5
  • NetBox version: v2.2-beta1

Description

From the device page, there's only the option to add a new IP address. From the IP address edit page, the "Interface Assignment" section is hidden. There is actually a workaround if you manually modify the IP address edit URL to include ?interface=x. If it isn't desirable to have the Interface Assignment section show up on every IP Address edit screen, it'd be nice to have a button on the Device page next to the current "New IP" one.

Originally created by @KWI-TFenby on GitHub (Sep 19, 2017). <!-- Before opening a new issue, please search through the existing issues to see if your topic has already been addressed. Note that you may need to remove the "is:open" filter from the search bar to include closed issues. Check the appropriate type for your issue below by placing an x between the brackets. If none of the below apply, please raise your issue for discussion on our mailing list: https://groups.google.com/forum/#!forum/netbox-discuss Please note that issues which do not fall under any of the below categories will be closed. ---> ### Issue type [] Feature request <!-- Requesting the implementation of a new feature --> [X] Bug report <!-- Reporting unexpected or erroneous behavior --> [ ] Documentation <!-- Proposing a modification to the documentation --> <!-- Please describe the environment in which you are running NetBox. (Be sure to verify that you are running the latest stable release of NetBox before submitting a bug report.) --> ### Environment * Python version: Python 3.4.5 * NetBox version: v2.2-beta1 <!-- BUG REPORTS must include: * A list of the steps needed to reproduce the bug * A description of the expected 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 From the device page, there's only the option to add a new IP address. From the IP address edit page, the "Interface Assignment" section is hidden. There is actually a workaround if you manually modify the IP address edit URL to include ?interface=x. If it isn't desirable to have the Interface Assignment section show up on every IP Address edit screen, it'd be nice to have a button on the Device page next to the current "New IP" one.
adam added the type: feature label 2025-12-29 16:30:35 +01:00
adam closed this issue 2025-12-29 16:30:35 +01:00
Author
Owner

@candlerb commented on GitHub (Sep 20, 2017):

Related: #786, #1001, group thread

That thread says:

As interfaces can now be assigned to both devices and virtual machines, it becomes very difficult to specify interfaces without additional context. For instance, when creating an IP, you can assign it to an interface by searching for a device, by selecting a device (from a series of dropdowns), by searching for a virtual machine, or by selecting a virtual machine. It becomes very tedious and confusing to include all of these widgets in a single form.

Another option would be to allow linking an existing IP address to an interface, rather than vice versa. It might work like this:

  • When you click "Add address to interface" (on either a Device or VM) you get the same page as now
  • When you click Add, then the system searches for any existing address(es) with the same Address and VRF. If none are found, it just creates a new one as now, linked to this interface.
  • However, if one or more matching addresses are found, then it refreshes the page including a list of matches in a table, and offering the option to:
    • click on one of the existing addresses to link it to the this interface [^1]
    • create a new address anyway (this is only offered if the VRF allows duplicate addresses)

Alternate flow:

  • When you click "Add address to interface", you get a short form with Address, VRF and Search buttons only
  • After clicking Search, you get a new form:
    • Address and VRF displayed at top (non-editable)
    • Any existing matching IP addresses displayed in a table, with "Link to this address" button for each
    • Remaining fields for the Add Address page (Status, Role, Description, Tenancy... Create button). This section displayed only if the search returned no results, or the VRF allows duplicated IPs

[^1] If the address is already linked to another interface this should be indicated in the results table, but you can still take it over.

@candlerb commented on GitHub (Sep 20, 2017): Related: #786, #1001, [group thread](https://groups.google.com/forum/#!topic/netbox-discuss/6VOcdSV8P7o) That thread says: > As interfaces can now be assigned to both devices and virtual machines, it becomes very difficult to specify interfaces without additional context. For instance, when creating an IP, you can assign it to an interface by searching for a device, by selecting a device (from a series of dropdowns), by searching for a virtual machine, or by selecting a virtual machine. It becomes very tedious and confusing to include all of these widgets in a single form. Another option would be to allow linking an existing IP address to an interface, rather than vice versa. It might work like this: * When you click "Add address to interface" (on either a Device or VM) you get the same page as now * When you click Add, then the system searches for any existing address(es) with the same Address and VRF. If none are found, it just creates a new one as now, linked to this interface. * However, if one or more matching addresses *are* found, then it refreshes the page including a list of matches in a table, and offering the option to: - click on one of the existing addresses to link it to the this interface [^1] - create a new address anyway (this is only offered if the VRF allows duplicate addresses) Alternate flow: * When you click "Add address to interface", you get a short form with Address, VRF and Search buttons only * After clicking Search, you get a new form: - Address and VRF displayed at top (non-editable) - Any existing matching IP addresses displayed in a table, with "Link to this address" button for each - Remaining fields for the Add Address page (Status, Role, Description, Tenancy... Create button). This section displayed only if the search returned no results, or the VRF allows duplicated IPs ----- [^1] If the address is already linked to another interface this should be indicated in the results table, but you can still take it over.
Author
Owner

@candlerb commented on GitHub (Sep 20, 2017):

Just to be clear: the UI no longer appears to offer any way to assign an existing IP address object to an interface.

You have to delete the address, and recreate it when you add to an interface. This is inconvenient because it means all the information relating to that address has to be re-entered (Status, Role, Description, Tenancy etc); furthermore, the Address changes its API ID, and the Django history of changes to that object is lost.

A specific use case is when migrating from a flat IPAM spreadsheet to Netbox. Starting from a flat model you likely will import all the IP addresses first, and then later decide to create devices/vms/interfaces to attach them to.

@candlerb commented on GitHub (Sep 20, 2017): Just to be clear: the UI no longer appears to offer any way to assign an *existing* IP address object to an interface. You have to delete the address, and recreate it when you add to an interface. This is inconvenient because it means all the information relating to that address has to be re-entered (Status, Role, Description, Tenancy etc); furthermore, the Address changes its API ID, and the Django history of changes to that object is lost. A specific use case is when migrating from a flat IPAM spreadsheet to Netbox. Starting from a flat model you likely will import all the IP addresses first, and then later decide to create devices/vms/interfaces to attach them to.
Author
Owner

@awerner commented on GitHub (Sep 27, 2017):

We're currently experiencing the use case @candlerb mentioned, using ?interface=X is a workaround, but it would be nice to have a way to do this without needing to resort manipulating the URL.

It would be also a nice workflow being able to select a free IP in the IPAM and then assing it to an interface when creating the IP address.

@awerner commented on GitHub (Sep 27, 2017): We're currently experiencing the use case @candlerb mentioned, using ?interface=X is a workaround, but it would be nice to have a way to do this without needing to resort manipulating the URL. It would be also a nice workflow being able to select a free IP in the IPAM and then assing it to an interface when creating the IP address.
Author
Owner

@phurrelmann commented on GitHub (Oct 2, 2017):

Additionally it is no longer possible to move an ip-address from one device to another without deleting and re-adding the ip-address.
IMHO this is not an enhancement but an regression, as functionality is lost

@phurrelmann commented on GitHub (Oct 2, 2017): Additionally it is no longer possible to move an ip-address from one device to another without deleting and re-adding the ip-address. IMHO this is not an enhancement but an regression, as functionality is lost
Author
Owner

@dirtycajunrice commented on GitHub (Oct 16, 2017):

Both linked cases are closed. One should stay open until resolution correct?

@dirtycajunrice commented on GitHub (Oct 16, 2017): Both linked cases are closed. One should stay open until resolution correct?
Author
Owner

@InsaneSplash commented on GitHub (Oct 17, 2017):

I think this is also a bug and not a feature request.

@InsaneSplash commented on GitHub (Oct 17, 2017): I think this is also a bug and not a feature request.
Author
Owner

@explody commented on GitHub (Oct 27, 2017):

I'll chime in and add that this really is a critical feature. I completely sympathize about the potential for an excessively cluttered dialog in attempting to associated interface/VM-interface back and forth to an IP. But, I would be willing to take slight clutter to (re)gain this feature.

The ability to cleanly find, (pre)create and associate IPs-to-interfaces and interfaces-to-IPs is well worth the complication IMHO. (I can give gory details on our live use cases if it's interesting)

@candlerb's ideas are minimal and the first is transparent, which is great. Here's another that involves user input but also provides good feedback to the user when creating or reassigning IPs

  • Add a prefix selector dropdown on the add-ip-address form, constrained to the prefixes associated with the device's site, perhaps grouped by VRF. This selector can be optional, and the IP field can still accept freeform IP/mask input. This has a side effect of allowing IP-in-prefix validation, at least on the user side, if a prefix is selected.
  • If a prefix is selected, the Address input field could have a widget akin to https://github.com/djk2/django-popup-view-field (which can render existing views and could be useful elsewhere as well), which would allow for selecting an existing IP. Constraining this to only when a prefix is selected dodges around an excessively large contents inside the widget. It also could give an opportunity for users to see free IPs inside a prefix, for selection rather than manual entry.

Since it's comparatively easy to reassign or even recreate IPs via the API, this mostly distills down to a UI/UX issue, IMHO. Honestly, not my strong suit but I do know the current UX is is very difficult for my engineers ;)

I'd be happy to help work on this.

@explody commented on GitHub (Oct 27, 2017): I'll chime in and add that this really is a critical feature. I completely sympathize about the potential for an excessively cluttered dialog in attempting to associated interface/VM-interface back and forth to an IP. But, I would be willing to take slight clutter to (re)gain this feature. The ability to cleanly find, (pre)create and associate IPs-to-interfaces and interfaces-to-IPs is well worth the complication IMHO. (I can give gory details on our live use cases if it's interesting) @candlerb's ideas are minimal and the first is transparent, which is great. Here's another that involves user input but also provides good feedback to the user when creating or reassigning IPs * Add a prefix selector dropdown on the add-ip-address form, constrained to the prefixes associated with the device's site, perhaps grouped by VRF. This selector can be optional, and the IP field can still accept freeform IP/mask input. This has a side effect of allowing IP-in-prefix validation, at least on the user side, if a prefix is selected. * If a prefix is selected, the Address input field could have a widget akin to https://github.com/djk2/django-popup-view-field (which can render existing views and could be useful elsewhere as well), which would allow for selecting an existing IP. Constraining this to only when a prefix is selected dodges around an excessively large contents inside the widget. It also could give an opportunity for users to see _free_ IPs inside a prefix, for selection rather than manual entry. Since it's comparatively easy to reassign or even recreate IPs via the API, this mostly distills down to a UI/UX issue, IMHO. Honestly, not my strong suit but I do know the current UX is is very difficult for my engineers ;) I'd be happy to help work on this.
Author
Owner

@francoisbeaulieu commented on GitHub (Oct 31, 2017):

Pardon my naïveté, but wouldn't the simplest solution be to redefine the VMs as a subcategory of devices, (say, by adding a column VM, which defaults to 'no', in the devices table) which would allow to populate the form's drop-down with only devices?

@francoisbeaulieu commented on GitHub (Oct 31, 2017): Pardon my naïveté, but wouldn't the simplest solution be to redefine the VMs as a subcategory of devices, (say, by adding a column VM, which defaults to 'no', in the devices table) which would allow to populate the form's drop-down with only devices?
Author
Owner

@candlerb commented on GitHub (Nov 1, 2017):

Devices and VMs already share the same Interface object.

The issue being discussed here is: (1) being able to assign an existing IP address to an interface; and (2) being able to move an existing IP address from one interface to another interface on a different device or VM.

Certainly, if you approach this from the IP Address side, you'd have to identify the interface to attach it to. This could be done simply by a search on the name, showing all Devices and VMs that the search matches. That's more convenient anyway than drilling down via Site -> Rack -> Device, or Cluster -> VM.

If you've already navigated to a particular Device->Interface or VM->Interface, then you just want to search for a particular IP address to attach to it.

@candlerb commented on GitHub (Nov 1, 2017): Devices and VMs already share the same Interface object. The issue being discussed here is: (1) being able to assign an existing IP address to an interface; and (2) being able to move an existing IP address from one interface to another interface on a different device or VM. Certainly, if you approach this from the IP Address side, you'd have to identify the interface to attach it to. This could be done simply by a search on the name, showing all Devices and VMs that the search matches. That's more convenient anyway than drilling down via Site -> Rack -> Device, or Cluster -> VM. If you've already navigated to a particular Device->Interface or VM->Interface, then you just want to search for a particular IP address to attach to it.
Author
Owner

@ckupe commented on GitHub (Nov 3, 2017):

Adding my +1 to this issue. Was about to report this myself.

Before there was VM support, we had added "FQDN" and "Port Translation" custom fields to our IP objects. We also resorted to putting machine names in the Description so we could find their IPs.

When I started trying to connect all of the pre-existing IPs with these VMs, I discovered the fact that assignment of the IP is impossible from either end. Can't connect it by editing the IP, or can't connect it when creating the interface on the VM and trying to assign the IP.

I can see how this interaction is easily overlooked, but it has halted documentation. Without a way to at least bulk-import these interface creation+assignments or a way to link these objects, it's too tedious to delete and recreate IPs.

@ckupe commented on GitHub (Nov 3, 2017): Adding my +1 to this issue. Was about to report this myself. Before there was VM support, we had added "FQDN" and "Port Translation" custom fields to our IP objects. We also resorted to putting machine names in the Description so we could find their IPs. When I started trying to connect all of the pre-existing IPs with these VMs, I discovered the fact that assignment of the IP is impossible from either end. Can't connect it by editing the IP, or can't connect it when creating the interface on the VM and trying to assign the IP. I can see how this interaction is easily overlooked, but it has halted documentation. Without a way to at least bulk-import these interface creation+assignments or a way to link these objects, it's too tedious to delete and recreate IPs.
Author
Owner

@GitRost commented on GitHub (Nov 3, 2017):

Аnd me, you can also add to this issue.
Created in advance a lot of the right ip addresses and then was unpleasant surprised trying to assign them devices and ports!
I had to use a crutch "? interface = x"

@GitRost commented on GitHub (Nov 3, 2017): Аnd me, you can also add to this issue. Created in advance a lot of the right ip addresses and then was unpleasant surprised trying to assign them devices and ports! I had to use a crutch "? interface = x"
Author
Owner

@sylaan commented on GitHub (Nov 6, 2017):

I am also affected by this. We have first migrated all our IPs into Netbox and then, as we add devices, we assign IPs to various interfaces. This is no longer possible since the last update.

I don't really understand why #1639 is marked as a duplicate of this and closed. It seems to me it's a severe loss of functionality. If the assigning of an IP to a device interface is supposed to be done now by editing the device, then this issue should be a bug since that's not possible.

@sylaan commented on GitHub (Nov 6, 2017): I am also affected by this. We have first migrated all our IPs into Netbox and then, as we add devices, we assign IPs to various interfaces. This is no longer possible since the last update. I don't really understand why #1639 is marked as a duplicate of this and closed. It seems to me it's a severe loss of functionality. If the assigning of an IP to a device interface is supposed to be done now by editing the device, then this issue should be a bug since that's not possible.
Author
Owner

@ckupe commented on GitHub (Nov 6, 2017):

Until they fix this, the workaround is to append '?interface=###' to the URL where ### is the interface number referencing the device interface you need to connect. The options will appear.

This is still incredibly tedious though. I might just create a script button that hooks into the browser or a hack-job extension to do this in the meantime.

@ckupe commented on GitHub (Nov 6, 2017): Until they fix this, the workaround is to append '?interface=###' to the URL where ### is the interface number referencing the device interface you need to connect. The options will appear. This is still incredibly tedious though. I might just create a script button that hooks into the browser or a hack-job extension to do this in the meantime.
Author
Owner

@candlerb commented on GitHub (Nov 6, 2017):

Just to be clear, you add this to the URL when you are editing the IP address. Example:

  • Navigate to /ipam/ip-addresses/9/edit/
  • Change this to /ipam/ip-addresses/9/edit/?interface=33 in the URL bar
  • Hit Enter to redraw the page. The correct interface should now be shown.
  • Click Save

And to find it's interface 33, you first need to navigate to the device or VM in question, and click the edit button (pencil) next to the interface.

@candlerb commented on GitHub (Nov 6, 2017): Just to be clear, you add this to the URL when you are editing the IP address. Example: * Navigate to `/ipam/ip-addresses/9/edit/` * Change this to `/ipam/ip-addresses/9/edit/?interface=33` in the URL bar * Hit Enter to redraw the page. The correct interface should now be shown. * Click Save And to find it's interface 33, you first need to navigate to the device or VM in question, and click the edit button (pencil) next to the interface.
Author
Owner

@sylaan commented on GitHub (Nov 6, 2017):

Yes, I am familiar with the workaround and I am using it. It works but it's extremely inconvenient, as already mentioned. I hope this will be solved soon. I am just very surprised this is treated as a feature request and not a bug.

@sylaan commented on GitHub (Nov 6, 2017): Yes, I am familiar with the workaround and I am using it. It works but it's extremely inconvenient, as already mentioned. I hope this will be solved soon. I am just very surprised this is treated as a feature request and not a bug.
Author
Owner

@InsaneSplash commented on GitHub (Nov 8, 2017):

Can we change this to a bug as this was available in a previous version?

@InsaneSplash commented on GitHub (Nov 8, 2017): Can we change this to a bug as this was available in a previous version?
Author
Owner

@KWI-TFenby commented on GitHub (Nov 8, 2017):

We only just started using netbox, so I didn't even realize when reporting this that it was a regression, which it definitely is if this was possible in previous versions. This issue is the reason we've had to put our implementation on hold.

@KWI-TFenby commented on GitHub (Nov 8, 2017): We only just started using netbox, so I didn't even realize when reporting this that it was a regression, which it definitely is if this was possible in previous versions. This issue is the reason we've had to put our implementation on hold.
Author
Owner

@InsaneSplash commented on GitHub (Nov 8, 2017):

Yup, It has only been removed since the VM support was added.

@InsaneSplash commented on GitHub (Nov 8, 2017): Yup, It has only been removed since the VM support was added.
Author
Owner

@KWI-TFenby commented on GitHub (Nov 10, 2017):

Sweet! Testing now. Thank you @jeremystretch!

@KWI-TFenby commented on GitHub (Nov 10, 2017): Sweet! Testing now. Thank you @jeremystretch!
Author
Owner

@candlerb commented on GitHub (Nov 10, 2017):

Works for me. Cheers!

@candlerb commented on GitHub (Nov 10, 2017): Works for me. Cheers!
Author
Owner

@sylaan commented on GitHub (Nov 11, 2017):

Awesome, thanks!

@sylaan commented on GitHub (Nov 11, 2017): Awesome, thanks!
Author
Owner

@InsaneSplash commented on GitHub (Nov 15, 2017):

I upgraded to 2.2.5 and when I edit an IP address that is not linked to an interface it still does not provide the option to select a device/interface unless I use the work around of appending ?interface= to the URL?

@InsaneSplash commented on GitHub (Nov 15, 2017): I upgraded to 2.2.5 and when I edit an IP address that is not linked to an interface it still does not provide the option to select a device/interface unless I use the work around of appending ?interface= to the URL?
Author
Owner

@dirtycajunrice commented on GitHub (Nov 15, 2017):

@insanesplash it is now another tab. You will see the "add an IP address" vs find one at the top of the page after you click the green plus

@dirtycajunrice commented on GitHub (Nov 15, 2017): @insanesplash it is now another tab. You will see the "add an IP address" vs find one at the top of the page after you click the green plus
Author
Owner

@candlerb commented on GitHub (Nov 15, 2017):

That is: you can't do it directly from the IP address. Instead, you have to navigate to the device or VM where you want to attach the IP, then click the green plus next to the interface you want to attach it to, then use the tab as @DirtyCajunRice says.

@candlerb commented on GitHub (Nov 15, 2017): That is: you can't do it directly from the IP address. Instead, you have to navigate to the device or VM where you want to attach the IP, then click the green plus next to the interface you want to attach it to, then use the tab as @DirtyCajunRice says.
Author
Owner

@dirtycajunrice commented on GitHub (Nov 15, 2017):

Still minor issue but created new issue #1718

@dirtycajunrice commented on GitHub (Nov 15, 2017): Still minor issue but created new issue #1718
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#1246