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.
- Settings
- Network
- VPN
- +
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.
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.
Sign in
Sign in through the app or with the client's login command.
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.
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.
Or import with nmcli
For WireGuard:
sudo nmcli connection import type wireguard file ~/wg0.confFor OpenVPN:
sudo nmcli connection import type openvpn file ~/client.ovpnConnect
Turn the VPN on in the top-bar menu, or run:
nmcli connection up wg0Replace
wg0with the connection name shown bynmcli connection show.
How to check the VPN is working on Linux
Check the interface
ip addrYou should see a tunnel interface such as
wg0ortun0with an address.Check the route
ip route get 1.1.1.1The output should show the tunnel interface (
dev wg0ordev tun0).Check DNS
resolvectl statusThe 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
| Setting | Where to find it | Why it matters |
|---|---|---|
| Connect automatically | Settings → Network → VPN → gear → Identity / General | Reconnects after reboot. |
| Kill switch | Provider client, or firewall rules that allow traffic only through the tunnel | Prevents leaks if the tunnel drops. |
| IPv6 | Provider client or connection IPv6 settings | Avoids IPv6 leaks if your VPN does not support IPv6. |
Fixing common Linux VPN problems
| Problem | What to try |
|---|---|
| OpenVPN is missing from the VPN type list | Add the NetworkManager OpenVPN plugin from your distribution's package manager, then log out and back in. |
| Connected, but DNS still shows the ISP | Make 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 suspend | Reconnect 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.
- nmcli reference manual NetworkManager
- WireGuard quick start WireGuard
- OpenVPN 2.6 manual OpenVPN
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