Skip to main content

On Linux, Once use kubevpn connect to k8s cluster network, then lost connection to internet network?

Reason​

There is no optimal method for setting up DNS in the Linux system, as there are numerous types of Linux distributions with different network management configurations.

Expect​

Set up a separate DNS for the tun device while preserving your internet connection.

Quick Recovery​

If you've already lost internet connectivity after disconnecting, try these steps first:

1. Disconnect all KubeVPN connections​

kubevpn disconnect --all

2. Check and restore your DNS configuration​

Check your current /etc/resolv.conf:

cat /etc/resolv.conf

If it looks incorrect, you may need to restore it from backup or restart your network manager:

# For NetworkManager
sudo systemctl restart NetworkManager

# For systemd-networkd
sudo systemctl restart systemd-networkd

# Or reboot your system as a last resort

Resolve​

Install and configure tools resolvectl to properly manage per-link DNS.

(1) Install tools resolvectl​

Package information for resolvectl:

Operating systemPackage nameInstallation
AlmaLinuxsystemd-resolveddnf install systemd-resolved
Arch Linuxsystemdpacman -S systemd
Debiansystemdapt install systemd
Fedorasystemd-resolveddnf install systemd-resolved
Red Hat Enterprise Linuxsystemd-resolveddnf install systemd-resolved
Rocky Linuxsystemd-resolveddnf install systemd-resolved
Ubuntusystemdapt install systemd

(2) Verify install and enable service​

Once installed, enable and start the service:

sudo systemctl enable systemd-resolved.service
sudo systemctl start systemd-resolved.service

Verify it's running:

resolvectl status

This shows information related to name resolution coming from the resolve daemon.

(3) Reboot​

Please reboot your computer, this is important to ensure the changes take effect properly.

After rebooting, use kubevpn connect — everything should work fine and you'll maintain internet connectivity while connected to the cluster.

Diagnostics​

If you still have issues after following the above steps, collect this information before opening an issue:

  1. KubeVPN logs:

    kubevpn logs
  2. Current DNS configuration:

    cat /etc/resolv.conf
    resolvectl status
  3. Network interfaces:

    ip addr show
    ip route show
  4. Your Linux distribution and version:

    lsb_release -a
    # or
    cat /etc/os-release