SDB:Swisscom Internet Box VPN

Jump to: navigation, search

Situation

Connecting openSUSE Tumbleweed or Leap to a Swisscom Internet Box using IKEv2 / PSK VPN via NetworkManager and strongSwan (charon-nm).

Without specific adjustments, the connection may fail to negotiate, fail to reconnect mid-session due to orphan kernel IPsec states, or cause systemd to deadlock and hang during system shutdown.

Procedure

1. Install Required Packages

Install strongSwan and its NetworkManager integration plugin:

sudo zypper install strongswan strongswan-nm NetworkManager-strongswan

Note: Reboots or restarting NetworkManager after installing these packages ensures D-Bus handles are registered properly.

2. Router Configuration (Swisscom Internet Box)

  1. Access your router web interface (default: http://192.168.1.1).
  2. Go to Network / Application Settings -> VPN.
  3. Enable IKEv2 / PSK VPN.
  4. Set a Pre-Shared Key (PSK) that is at least 20 characters long.
Icon-warning.png
Warning: PSK Length Requirement: charon-nm hard-rejects any PSK under 20 characters before Phase 1 negotiation starts. A shorter key will cause NetworkManager to fail immediately with Error: Connection activation failed: No valid secrets.

3. NetworkManager GUI Configuration

In NetworkManager, add a new VPN connection of type IPsec/IKEv2 (strongSwan):

Connection Settings

  • Connection name: Home (or your preferred name)

VPN Tab

  • Server Address: YOUR_DYNAMIC_DNS.internet-box.ch
  • Server Identity: YOUR_DYNAMIC_DNS.internet-box.ch
  • Authentication: Pre-shared key
  • Client Identity: YOUR_VPN_USERNAME
  • Password (PSK): YOUR_20+_CHAR_PSK

Options

  • Request an inner IP address: Checked
  • Enforce UDP encapsulation: Unchecked
  • Use IP compression: Unchecked

4. Keyfile Permissions & Secret Handling

Ensure proper ownership and permissions for connection keyfiles stored by NetworkManager:

sudo chown root:root /etc/NetworkManager/system-connections/*.nmconnection
sudo chmod 600 /etc/NetworkManager/system-connections/*.nmconnection
sudo systemctl restart NetworkManager

5. Fixing Reconnection Failures (Kernel XFRM Cleanup)

By default, when charon-nm disconnects, it may leave orphan Linux kernel XFRM Security Associations (SAs) active, blocking subsequent reconnect attempts.

Edit /etc/strongswan.d/charon-nm.conf and add flush_policies = yes and delete_rekeyed = yes inside the charon-nm block:

charon-nm {
    load_modular = yes

    # Ensure kernel XFRM states and policies are cleared on disconnect
    flush_policies = yes
    delete_rekeyed = yes

    plugins {
        include charon-nm/*.conf
    }
}

6. Fixing Shutdown Hangs (Systemd Override)

When shutting down, charon-nm often fails to exit due to a missing D-Bus termination signal, causing systemd to hang indefinitely waiting for NetworkManager.service.

Create a systemd drop-in override for NetworkManager:

Run the editor:

sudo systemctl edit NetworkManager

Add the following lines:

[Service]
ExecStopPost=-/usr/bin/killall -q -9 charon-nm

Save and exit.

7. Verification

  • Connect: nmcli connection up "Home"
  • Disconnect: nmcli connection down "Home"
  • Check Process Status: ps aux | grep charon-nm
  • Check Kernel IPsec States: sudo ip xfrm state

See Also