Loading...
← Back to all posts VPN Guides

Linux and VPN: How to Set Up a VPN on Linux

November 28, 2026 · 12 min read
Linux and VPN: How to Set Up a VPN on Linux

Linux supports VPNs natively, so you can protect your traffic using a provider's app, the command line, or a manual WireGuard or OpenVPN configuration. The right method depends on how much control you want, and this guide covers each one for privacy-conscious users who want to stop ISPs, advertisers and hackers from tracking or intercepting their browsing. Whether your focus is Linux and VPN basics or a hardened, leak-proof setup, the steps below take you from first connection to verified protection.

Why Do Linux Users Need a VPN?

Linux users need a VPN because the operating system's security does not hide your traffic from your internet service provider, advertisers or anyone watching an unsecured network.

Linux is well regarded for its permission model and transparent codebase, yet none of that conceals your IP address or encrypts packets as they leave your machine. Your ISP can still see which domains you request. Websites can still fingerprint your connection. On public Wi-Fi, an attacker on the same network can attempt interception regardless of your distribution.

A VPN addresses three specific exposures:

  • ISP visibility: Encrypted tunnels stop your provider from logging the sites you visit.
  • Advertiser tracking: Your real IP address is replaced by the server's address, which weakens IP-based profiling.
  • Network interception: Traffic is encrypted before it reaches the local router, which protects you on shared or hostile networks. Our guide to public Wi-Fi and VPN protection explains this risk in more detail.

If you want a broader primer before configuring anything, read what a VPN is and why you need one in 2026.

Which VPN Protocol Should You Use on Linux?

WireGuard is the best default for most Linux users, with OpenVPN as a dependable alternative when you need broad compatibility or specific firewall behavior.

Both protocols are mature and well supported by the kernel and common tooling. WireGuard is built into modern Linux kernels, uses a compact codebase and is generally faster than OpenVPN. OpenVPN has a longer track record, runs over TCP as well as UDP, and can pass through restrictive networks more easily.

Feature WireGuard OpenVPN
Kernel support Built into modern Linux kernels User-space application
Setup complexity Low, short config file Moderate, longer config
Transport UDP UDP or TCP
Typical speed Generally faster Generally slower
Firewall traversal Can be blocked on strict networks Works well over TCP port 443
Best use Daily privacy and speed Restrictive networks, legacy setups

Choose WireGuard first. Switch to OpenVPN if a network blocks UDP traffic or your provider recommends it for a particular server. For a deeper look at the open-source side of this choice, see our overview of open-source VPN software.

WireGuard versus OpenVPN comparison

What Are the Ways to Install a VPN on Linux?

There are three ways to install a VPN on Linux: a provider's graphical app, a command-line client, or a manual configuration file imported into NetworkManager or a tunnel tool.

Each approach suits a different level of comfort with the terminal:

  1. Graphical app. The simplest option. You sign in, pick a server and connect. Best for desktop users on Ubuntu, Fedora or Linux Mint who want minimal friction.
  2. Command-line client. Scriptable, light on resources and suited to servers, headless machines and minimalist window managers.
  3. Manual configuration. You import a WireGuard or OpenVPN file yourself. This gives the most control and works on any distribution, including those a provider does not officially package for.

Manual configuration is the most portable path, so the next sections focus on it. If you want a wider walkthrough that is not specific to Linux, how to set up a VPN covers the general process.

How Do You Set Up WireGuard on Linux?

Install the wireguard-tools package, place your provider's configuration file in /etc/wireguard/, then bring the tunnel up with wg-quick.

The Ubuntu Server documentation notes that WireGuard can be configured with wg and wg-quick from the wireguard-tools package, although NetworkManager and systemd-networkd can also configure it without those utilities. Follow these steps on a Debian-based system:

  1. Install the tools: sudo apt install wireguard wireguard-tools
  2. Copy your configuration file, for example wg0.conf, to /etc/wireguard/
  3. Restrict its permissions: sudo chmod 600 /etc/wireguard/wg0.conf
  4. Start the tunnel: sudo wg-quick up wg0
  5. Confirm it is active: sudo wg show
  6. Stop it when needed: sudo wg-quick down wg0

On Fedora, use sudo dnf install wireguard-tools. On Arch, the package is also wireguard-tools.

If you want the tunnel to survive reboots, the ArchWiki explains that WireGuard configurations can be made persistent with wg-quick@.service or a supported network manager such as NetworkManager or systemd-networkd. On systemd distributions, sudo systemctl enable wg-quick@wg0 starts the tunnel at boot.

Ubuntu's own guidance also documents routing all traffic through the VPN as a default gateway, which is the configuration privacy-focused users want: every packet leaves through the encrypted tunnel rather than only traffic for a private subnet.

How Do You Use NetworkManager for a VPN on Linux?

NetworkManager lets you import a WireGuard or OpenVPN profile and toggle it from the desktop, with no separate daemon to manage.

According to the NetworkManager documentation, WireGuard is supported natively from version 1.16.0, so no VPN plugin is required. You can import a file from the terminal:

nmcli connection import type wireguard file wg0.conf
nmcli connection up wg0

For OpenVPN, install the plugin first (network-manager-openvpn-gnome on Debian and Ubuntu) and import the .ovpn file with nmcli connection import type openvpn file client.ovpn.

Users who manage networking through Netplan can follow Ubuntu's tutorial on accessing NetworkManager settings through Netplan, which demonstrates creating a WireGuard tunnel with netplan set and applying it with sudo netplan apply.

NetworkManager has a practical advantage for laptops: it manages the tunnel from the desktop, so protection does not depend on remembering to run a command.

How Do You Set Up OpenVPN on Linux?

Install the OpenVPN client, import your provider's .ovpn file, and start the connection with your credentials or certificate.

The official OpenVPN 3 Linux client provides packages for Ubuntu, Debian, RHEL and Fedora. After adding the repository, a typical session looks like this:

  1. Install the client: sudo apt install openvpn3
  2. Import the profile: openvpn3 config-import --config client.ovpn --persistent
  3. Start the session: openvpn3 session-start --config client.ovpn
  4. Check status: openvpn3 sessions-list
  5. End the session: openvpn3 session-manage --config client.ovpn --disconnect

The older OpenVPN 2 client remains available in most distribution repositories and runs with sudo openvpn --config client.ovpn. Both work well. OpenVPN is a good choice when UDP is filtered, since you can select a TCP profile on port 443.

Linux VPN setup workflow

Which Features Matter Most in a Linux VPN?

The features that matter most are a verified no-logs policy, strong encryption, a kill switch, split tunnelling and the absence of bandwidth caps.

For privacy-conscious users, the technical details behind each feature determine whether the VPN protects you in practice:

  • No-logs policy: The provider should collect no browsing activity, traffic data, DNS queries, connection timestamps or IP addresses.
  • RAM-only servers: Data is never written to disk and is wiped on reboot, which limits what could ever be recovered from a server.
  • AES-256 encryption: The standard for encrypting VPN traffic.
  • Automatic kill switch: Blocks traffic if the tunnel drops, so your real IP never leaks.
  • Split tunnelling: Sends only selected apps through the VPN while others use your normal connection.
  • Unlimited bandwidth: Removes the temptation to disconnect during large downloads.

ZioFree includes each of these. Its ZioFree VPN Monthly plan offers unlimited bandwidth with access to all servers, along with AES-256 encryption, an automatic kill switch, split tunnelling and a strict no-logs policy backed by RAM-only servers. For pricing and the full list of supported platforms, check the product page directly.

Note that if you need a macOS client, check ZioFree's site for current platform availability.

Which Features Matter Most in a Linux VPN?

How Do You Add a Kill Switch on Linux?

You can add a kill switch on Linux with firewall rules that drop all traffic not going through the VPN interface.

Many provider apps include a kill switch, but a manual setup needs one you build yourself. With ufw, a simple default-deny approach works:

  1. Reset and set defaults: sudo ufw default deny outgoing and sudo ufw default deny incoming
  2. Allow traffic on the tunnel: sudo ufw allow out on wg0
  3. Allow the connection to the VPN server's IP and port so the tunnel can establish: sudo ufw allow out to <server-ip> port <port> proto udp
  4. Enable the firewall: sudo ufw enable

With these rules, if the tunnel drops, the firewall blocks everything else. Your real IP address never reaches the internet. Users comfortable with nftables or iptables can write equivalent rules, and the PostUp and PreDown lines in a WireGuard configuration can load and remove them automatically.

This layered approach matters. A kill switch inside the VPN client protects against most drops, while a firewall rule protects against client crashes as well.

How Do You Check That Your Linux VPN Is Not Leaking?

Verify your VPN by comparing your IP address, DNS resolver and IPv6 status with and without the tunnel active.

Run these checks after every new configuration:

  • IP address: Run curl ifconfig.me before and after connecting. The address should change to the VPN server's.
  • DNS leaks: Run resolvectl status and confirm DNS queries use the VPN's resolver, not your ISP's.
  • IPv6 leaks: Run ip -6 addr and curl -6 ifconfig.me. If IPv6 traffic bypasses the tunnel, disable IPv6 with sudo sysctl -w net.ipv6.conf.all.disable_ipv6=1 or ensure your configuration routes ::/0 through the tunnel.
  • WebRTC: Test in your browser, since WebRTC can expose local addresses even when the tunnel works.

DNS leaks are the most common failure on Linux, especially on systems running systemd-resolved. If you see your ISP's resolver, set the DNS entry in your WireGuard or OpenVPN profile and confirm NetworkManager applies it.

How Do You Create Your Own VPN Server on Linux?

You create a VPN server by installing WireGuard or OpenVPN on a remote Linux machine, generating keys, and defining peers that are allowed to connect.

The outline for a WireGuard server is short:

  1. Rent a VPS running a current Linux distribution.
  2. Install wireguard-tools and enable IP forwarding with net.ipv4.ip_forward=1.
  3. Generate a key pair with wg genkey and wg pubkey.
  4. Write /etc/wireguard/wg0.conf with the server's private key, listening port and a [Peer] block for each client.
  5. Add NAT rules so client traffic can reach the internet.
  6. Start the interface with sudo wg-quick up wg0.

Ubuntu's documentation covers peer-to-site and site-to-site setups as well as default-gateway routing, which makes it a reliable reference for the server side.

A self-hosted server has a clear limit. You control the software, but your traffic exits through a single IP address tied to your VPS account, so it offers no shared pool of addresses and no global server choice. A commercial service with a no-logs policy and servers in many countries serves a different purpose. If you plan to route a whole household through a tunnel, VPN and your home network and VPN routers are useful next reads.

FAQ

Is OpenVPN 100% free?

OpenVPN's community edition is free and open-source, but the software alone does not give you a VPN service. You still need a server to connect to, which means either hosting one yourself or paying a provider for access.

Can the FBI track a VPN?

A VPN hides your traffic from your ISP and local network, but it does not make you untraceable to every party. Whether anything can be disclosed depends on what the provider stores, which is why a strict no-logs policy and RAM-only servers matter. For a broader discussion, see VPN and anonymity.

Why avoid some VPN providers on Linux?

Avoid providers with no Linux support, unclear logging practices or closed, unaudited clients. Check that the service offers WireGuard or OpenVPN profiles, publishes a clear no-logs policy and does not cap bandwidth in a way that pushes you to disconnect.


Start by installing wireguard-tools and confirming that your kernel and NetworkManager are current, since that single step prepares your system for any manual configuration. When you are ready for a tunnel that combines AES-256 encryption, an automatic kill switch, split tunnelling and a strict no-logs policy, ZioFree VPN Monthly provides unlimited bandwidth and access to all servers. ZioFree is built to keep your browsing private from ISPs, advertisers and hackers, so you can get started now and protect your Linux machine today.

Protect your online privacy with ZioFree

Encrypted, no-logs VPN access on all your devices.

Get Started Now