How to set up a VPN on Linux

Connect a Linux desktop or laptop to a VPN using your provider's client or the NetworkManager tools that ship with most popular distributions such as Ubuntu and Fedora.

Before you start

  • An account with a VPN provider you trust
  • Administrator (sudo) access
  • A WireGuard (.conf) or OpenVPN (.ovpn) file from your provider's account area
  • For OpenVPN in NetworkManager: the NetworkManager OpenVPN plugin, available in your distribution's package manager

Not sure which provider to use yet? Start with how to choose a trustworthy VPN.

Where to find VPN settings on GNOME desktops
  1. Settings
  2. Network
  3. VPN
  4. +

Security tip: configuration files contain private keys. Keep them in your home folder with restricted permissions and never share them.

Set up a VPN on Linux with your provider's client

The provider's app is the easiest option and usually includes a kill switch, DNS leak protection and modern protocols such as WireGuard.

  1. Check for an official Linux client

    Many providers offer a Linux app or command-line client with a kill switch built in. Follow the provider's official instructions for your distribution.

  2. Sign in

    Sign in through the app or with the client's login command.

  3. Connect

    Connect to a nearby server, then enable the client's kill switch and auto-connect options.

Set up a VPN manually with NetworkManager

NetworkManager supports WireGuard natively and OpenVPN through a plugin. You can use the desktop settings or the nmcli command line.

Linux terminal importing a WireGuard file with nmcli, bringing the wg0 connection up and confirming that traffic routes through wg0
Illustration: Importing and connecting a WireGuard profile with nmcli. Menu names and layout may differ slightly on your device.
  1. Import from the desktop

    Open Settings → Network, click + next to VPN, choose Import from file and select your .conf or .ovpn file. Enter your user name and password if asked.

  2. Or import with nmcli

    For WireGuard:

    sudo nmcli connection import type wireguard file ~/wg0.conf

    For OpenVPN:

    sudo nmcli connection import type openvpn file ~/client.ovpn
  3. Connect

    Turn the VPN on in the top-bar menu, or run:

    nmcli connection up wg0

    Replace wg0 with the connection name shown by nmcli connection show.

How to check the VPN is working on Linux

  1. Check the interface

    ip addr

    You should see a tunnel interface such as wg0 or tun0 with an address.

  2. Check the route

    ip route get 1.1.1.1

    The output should show the tunnel interface (dev wg0 or dev tun0).

  3. Check DNS

    resolvectl status

    The tunnel interface should list your VPN provider's DNS servers.

For a complete set of leak tests, see how to check if your VPN is working.

Recommended Linux VPN settings

SettingWhere to find itWhy it matters
Connect automaticallySettings → Network → VPN → gear → Identity / GeneralReconnects after reboot.
Kill switchProvider client, or firewall rules that allow traffic only through the tunnelPrevents leaks if the tunnel drops.
IPv6Provider client or connection IPv6 settingsAvoids IPv6 leaks if your VPN does not support IPv6.

Fixing common Linux VPN problems

ProblemWhat to try
OpenVPN is missing from the VPN type listAdd the NetworkManager OpenVPN plugin from your distribution's package manager, then log out and back in.
Connected, but DNS still shows the ISPMake sure the VPN connection's DNS settings are applied (check with resolvectl status) and that no custom DNS is forced elsewhere.
The connection drops after suspendReconnect with nmcli connection up, or enable automatic connection for the VPN.

Linux VPN questions

Is WireGuard built into Linux?

Yes. WireGuard has been part of the Linux kernel since version 5.6, and NetworkManager can manage WireGuard connections.

Can I use a VPN on Linux without a provider app?

Yes. Import a WireGuard or OpenVPN configuration file from your provider into NetworkManager.

How do I disconnect from the command line?

Run nmcli connection down followed by the connection name.

Sources and official documentation

If your screen differs from our description, the official documentation takes precedence.

Ready to protect your connection?

Follow our step-by-step guide to choose a trustworthy provider, set up your device and confirm that your VPN is working.

GET VPN