Error when creating VPN tunnels with same Outside IP #9048

Closed
opened 2025-12-29 20:44:47 +01:00 by adam · 1 comment
Owner

Originally created by @markkuleinio on GitHub (Jan 5, 2024).

Originally assigned to: @jeremystretch on GitHub.

Deployment Type

Self-hosted

NetBox Version

v3.7.0

Python Version

3.9

Steps to Reproduce

Setup for test device:

  1. Create site MySite
  2. Create manufacturer Test
  3. Create device type TestModel
  4. Create device role VPN
  5. Create device TestDevice (using the attribute values above)
  6. For the device, create interfaces tunnel.[1-2] (type = virtual)
  7. For the device, create interface Internet (type = f.ex. 1000base-T)
  8. For the Internet interface, add IP address 123.123.123.123/32

Now the actual VPN tunnels:

  1. Create VPN tunnel Tunnel1:
    • encap = IPsec - Tunnel
    • first termination:
      • Role = Hub
      • Type = Device
      • Device = TestDevice
      • Interface = tunnel.1
      • Outside IP = 123.123.123.123/32
  2. Create another VPN tunnel Tunnel2:
    • encap = IPsec - Tunnel
    • first termination:
      • Role = Hub
      • Type = Device
      • Device = TestDevice
      • Interface = tunnel.2
      • Outside IP = 123.123.123.123/32

Expected Behavior

Both tunnels and terminations are created successfully, as they will both terminate on the same Outside IP. That is the usual way of using several tunnels on the same device.

Observed Behavior

When pressing the Create button for the second tunnel:

"
Server Error

There was a problem with your request. Please contact an administrator.
The complete exception is provided below:
<class 'django.db.utils.IntegrityError'>

duplicate key value violates unique constraint "vpn_tunneltermination_outside_ip_id_key"
DETAIL: Key (outside_ip_id)=(14) already exists.

Python version: 3.9.2
NetBox version: 3.7.0
Plugins: None installed
"

Originally created by @markkuleinio on GitHub (Jan 5, 2024). Originally assigned to: @jeremystretch on GitHub. ### Deployment Type Self-hosted ### NetBox Version v3.7.0 ### Python Version 3.9 ### Steps to Reproduce Setup for test device: 1. Create site MySite 2. Create manufacturer Test 3. Create device type TestModel 4. Create device role VPN 5. Create device **TestDevice** (using the attribute values above) 6. For the device, create interfaces **tunnel.[1-2]** (type = virtual) 7. For the device, create interface **Internet** (type = f.ex. 1000base-T) 8. For the Internet interface, add IP address **123.123.123.123/32** Now the actual VPN tunnels: 9. Create VPN tunnel **Tunnel1**: - encap = IPsec - Tunnel - first termination: - Role = Hub - Type = Device - Device = TestDevice - Interface = tunnel.1 - Outside IP = 123.123.123.123/32 10. Create another VPN tunnel **Tunnel2**: - encap = IPsec - Tunnel - first termination: - Role = Hub - Type = Device - Device = TestDevice - Interface = tunnel.2 - Outside IP = 123.123.123.123/32 ### Expected Behavior Both tunnels and terminations are created successfully, as they will both terminate on the same Outside IP. That is the usual way of using several tunnels on the same device. ### Observed Behavior When pressing the Create button for the second tunnel: " Server Error There was a problem with your request. Please contact an administrator. The complete exception is provided below: <class 'django.db.utils.IntegrityError'> duplicate key value violates unique constraint "vpn_tunneltermination_outside_ip_id_key" DETAIL: Key (outside_ip_id)=(14) already exists. Python version: 3.9.2 NetBox version: 3.7.0 Plugins: None installed "
adam added the type: bugstatus: acceptedseverity: medium labels 2025-12-29 20:44:47 +01:00
adam closed this issue 2025-12-29 20:44:48 +01:00
Author
Owner

@markkuleinio commented on GitHub (Jan 5, 2024):

By the way, the error is output differently if I just create Tunnel2 first without terminations, and then go to Tunnel Terminations to create one:

image

= there is no Server Error but an error message "Tunnel termination with this Outside ip already exists" in the form.

Just putting this out here if someone tests the issue this way.

@markkuleinio commented on GitHub (Jan 5, 2024): By the way, the error is output differently if I just create **Tunnel2** first _without_ terminations, and then go to Tunnel Terminations to create one: ![image](https://github.com/netbox-community/netbox/assets/25136274/c86af8d9-bffc-4901-8ef7-0a09da447f9b) = there is no Server Error but an error message "Tunnel termination with this Outside ip already exists" in the form. Just putting this out here if someone tests the issue this way.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#9048