How to set up a VPN on Linux: Ubuntu, Fedora and Arch
The easiest way to set up a VPN on Linux is to install your VPN provider's Linux app, sign in and connect. If you were given a config file or settings instead, add them to NetworkManager in your desktop's network settings, or, for a WireGuard file, bring the tunnel up from the terminal with sudo wg-quick up wg0.
Below are all three routes, with commands and labels taken from the WireGuard, GNOME, NetworkManager and Ubuntu documentation, plus how to check the VPN is working and how to switch it off. The steps work on Ubuntu, Debian, Fedora and Arch; only the package command changes.
Which route you need
Ask what your VPN came with:
- A Linux app or install command. Most consumer VPN services that support Linux work this way. Use route 1.
- Settings or a config file for NetworkManager. Workplaces, schools and some providers hand out a server address and login, or a file such as an .ovpn. If you use a desktop and want a point-and-click switch, use route 2.
- A WireGuard .conf file. Use route 3. It works on any distribution, with or without a desktop.
If you are not sure which type of VPN you have, ask whoever gave you the details. The type has to match the server.
Route 1: set up a VPN on Linux with an app
VPN apps for Linux usually install from the terminal. Secria VPN's Linux download page is a typical example. It covers Debian, Ubuntu, Fedora, Arch "and most others" on x86_64 and ARM64, and installs with one line:
curl -fsSL https://secria.me/install.sh | sudo sh
The page says the script "checks the release against our pinned post-quantum key, then installs." If you prefer your package manager, the same page has packages:
- Debian and Ubuntu: download the .deb, then install it with
sudo apt install ./followed by the file name. Keep the./so apt installs this file instead of searching for one. - Fedora, Red Hat and openSUSE:
sudo dnf installwith the .rpm link from the page (sudo zypper installon openSUSE). - Arch and Manjaro:
sudo pacman -Uwith the package link from the page.
Package managers pull in what the app needs (for Secria: wireguard-tools, nftables and iproute2). Then:
- Run
secria-vpn(or your provider's command). - Sign in.
- Connect.
To remove it later, Secria's page gives sudo secria-vpn uninstall, which "disconnects, clears the kill switch and removes everything we added." With another provider, use its own uninstall steps, so no firewall rules are left behind.
Route 2: set up a VPN with NetworkManager
These steps come from GNOME Help's page on connecting to a VPN. Other desktops have their own network settings, so the labels may differ.
First, add support for your VPN type. GNOME's help says you may need extra software depending on the type. Open your software installer, search for the NetworkManager package for your VPN type and install it. If there is no NetworkManager package for it, install the client software from the company that provides the VPN instead.
Then add the connection:
- Open the Activities overview and start typing Network.
- Click Network to open the panel.
- Click the + button next to the VPN section to add a new connection.
- Choose which kind of VPN connection you have.
- Fill in the VPN connection details, then press Add.
To connect, open the system menu on the right side of the top bar, click the VPN connection and select Connect. You may need to enter a password. Once connected, GNOME shows a lock shaped icon in the top bar.
From the terminal instead. NetworkManager's nmcli tool can import a VPN config file, as long as the matching VPN plugin is installed. The nmcli manual gives this example for an OpenVPN file:
nmcli con import type openvpn file ~/Downloads/frootvpn.ovpn
Then nmcli connection up "name" connects it and nmcli connection down "name" disconnects it, using the connection's name.
Route 3: set up WireGuard with wg-quick
If your provider or workplace gave you a WireGuard configuration file, the WireGuard tools are all you need. Our post on what WireGuard is explains the protocol.
1. Install the tools. From wireguard.com/install:
- Ubuntu:
sudo apt install wireguard - Debian:
apt install wireguard(as root) - Fedora:
sudo dnf install wireguard-tools - Arch:
sudo pacman -S wireguard-tools - openSUSE:
sudo zypper install wireguard-tools
2. Put the config file in place. The wg-quick manual says the file name is the interface name followed by .conf, and that wg-quick looks in /etc/wireguard/ first. So a file saved as /etc/wireguard/wg0.conf creates an interface called wg0. A client file for "tunneling all traffic" has an [Interface] section (Address, DNS, PrivateKey) and a [Peer] section (PublicKey, AllowedIPs = 0.0.0.0/0, Endpoint), and can include a PresharedKey. Keep the file private: it holds your private key.
3. Bring it up.
sudo wg-quick up wg0
4. Start it at boot (optional). Ubuntu's WireGuard documentation notes that wg-quick is also exposed as a systemd service named after the interface:
sudo systemctl enable wg-quick@wg0
How to check that your Linux VPN works
- Look at the status. On GNOME, the lock shaped icon in the top bar means the VPN is connected. In a terminal,
nmcli connection show --activelists all active connections, so a NetworkManager VPN should appear there. - For wg-quick, run
sudo wg show. WireGuard's quick start sayswg showdisplays the current configuration of your WireGuard interfaces. - Check your IP address. Note your public IP address with the VPN off, then check again with it on. It should now be the VPN server's.
- Run a DNS leak test to make sure your lookups go through the VPN too.
Our guide on how to tell if your VPN is working has each test, including terminal versions you can run on Linux.
How to turn off a VPN on Linux
- VPN app: disconnect in the app, or uninstall it with its uninstall command.
- GNOME: click the system menu on the top bar and click Turn Off under the name of your VPN connection.
- nmcli:
nmcli connection down "name". - wg-quick:
sudo wg-quick down wg0. If you started it with the systemd service, usesudo systemctl stop wg-quick@wg0instead. Ubuntu's docs list start, stop, reload and restart for that service.
Common snags
nmcli will not import the file. The manual says the proper VPN plugin has to be installed for import to work. Install the NetworkManager package for your VPN type first.
DNS does not change with wg-quick. The wg-quick manual says the DNS line in the config is applied through resolvconf, so that is the part of your setup to look at. Run the DNS leak test above to confirm.
apt says it cannot find the package. You probably left out the ./ before the .deb file name, so apt searched its repositories instead of installing the file.
Traffic leaks when the tunnel drops. A VPN app with a kill switch handles this for you. For wg-quick, the manual shows an example of a so-called "kill-switch" using PostUp and PreDown firewall lines. Read our post on what a VPN kill switch is before you set one up by hand.
Two VPNs at once. Two VPN apps, or an app plus a wg-quick tunnel, fight over routes. Keep one running.
Frequently asked questions
How do I set up a VPN on Ubuntu?
Install your VPN provider's Linux app, or install WireGuard with sudo apt install wireguard and bring up your config with sudo wg-quick up wg0. If you use the GNOME desktop, you can also add a VPN in the Network panel with the + button next to VPN.
Is setting up a VPN on Ubuntu Server different?
The app and wg-quick routes are the same, since neither needs a desktop. The GNOME route needs a desktop. Setting up your own VPN server is a different job from connecting to one, and this guide covers connecting.
Where do I put a WireGuard config file on Linux?
In /etc/wireguard/, named after the interface, such as /etc/wireguard/wg0.conf. That is where wg-quick looks first.
What is the easiest way to get a free VPN on Linux?
Pick a service that has a real free plan and a Linux app, so you install with one command and sign in. Check how it pays for its servers before you trust it; our post on whether free VPNs are safe explains what to look for.
How do I set up a VPN on Arch Linux?
Install WireGuard with sudo pacman -S wireguard-tools and use wg-quick, or install your provider's Arch package with sudo pacman -U.
Secria VPN on Linux
If you want to try a VPN without paying, Secria VPN Free works on Linux, Windows, Mac, iPhone, iPad and Android with a free Secria account, no card needed. Create the account with a @secria.me address and a password, install with the one line above, run secria-vpn and sign in. Free servers are in Frankfurt and Dallas, one device at a time.
Every plan, Free included, gets the same encryption: WireGuard with an ML-KEM-1024 post-quantum key added to every session, on by default. You also get a kill switch and DNS blocking that helps block ads and trackers. Servers are RAM-only. No activity logs: we do not record browsing, DNS queries or traffic contents. Paid plans add every location, Multi-Hop, split tunneling and 5 devices. See Secria VPN.
Secria fact-checks every post against primary sources. Spotted something wrong or out of date? Email hq@secria.me and we will correct it.