Whether you want to protect your privacy, bypass geo-restrictions, or secure your connection on public WiFi, setting up a VPN on Ubuntu is easier than you think. In 2026, VPNs have become an essential tool for developers and everyday users alike.
In this guide, we’ll show you how to set up a VPN on Ubuntu using three different methods — OpenVPN, WireGuard, and a GUI-based VPN client.
Why Use a VPN on Ubuntu?
- 🔒 Privacy — hides your IP address and online activity
- 🌍 Bypass geo-restrictions — access content from any country
- 🛡️ Security — encrypts your internet connection
- 💻 Remote work — securely access your company’s network
- ☕ Public WiFi protection — stay safe on unsecured networks
Method 1 — OpenVPN (Most Popular)
OpenVPN is the most widely used VPN protocol on Linux. It’s open-source, highly secure, and supported by virtually every VPN provider.
Step 1 — Install OpenVPN
bash
sudo apt update
sudo apt install openvpn -y
Step 2 — Download VPN Configuration Files
Get your .ovpn configuration files from your VPN provider (ProtonVPN, Mullvad, NordVPN, etc.)
Step 3 — Connect to VPN
bash
sudo openvpn --config /path/to/your-config.ovpn
You’ll be prompted for your VPN username and password.
Step 4 — Verify Connection
bash
# Check your IP address
curl ifconfig.me
If the IP address has changed, your VPN is working! ✅
Auto-connect on Boot
bash
sudo cp your-config.ovpn /etc/openvpn/client.conf
sudo systemctl enable openvpn@client
sudo systemctl start openvpn@client
Method 2 — WireGuard (Fastest VPN Protocol)
WireGuard is the newest and fastest VPN protocol available. It’s simpler, faster, and more secure than OpenVPN — and it’s built into the Linux kernel since version 5.6.
Step 1 — Install WireGuard
bash
sudo apt install wireguard -y
Step 2 — Generate Keys
bash
# Generate private key
wg genkey | tee privatekey | wg pubkey > publickey
# View your keys
cat privatekey
cat publickey
Step 3 — Create Configuration File
bash
sudo nano /etc/wireguard/wg0.conf
Add this configuration:
ini
[Interface]
PrivateKey = YOUR_PRIVATE_KEY
Address = 10.0.0.2/24
DNS = 1.1.1.1
[Peer]
PublicKey = SERVER_PUBLIC_KEY
Endpoint = server-ip:51820
AllowedIPs = 0.0.0.0/0
PersistentKeepalive = 25
Step 4 — Start WireGuard
bash
# Start VPN
sudo wg-quick up wg0
# Stop VPN
sudo wg-quick down wg0
# Enable on boot
sudo systemctl enable wg-quick@wg0
Step 5 — Check Status
bash
sudo wg show
Method 3 — GUI Method (Easiest for Beginners)
If you prefer a graphical interface, Ubuntu’s built-in Network Manager makes it easy to set up a VPN without using the terminal.
Using GNOME Network Manager
- Go to Settings → Network
- Click the + button next to VPN
- Select your VPN type (OpenVPN, WireGuard, etc.)
- Enter your VPN credentials
- Toggle the VPN switch to connect
Install OpenVPN Plugin for Network Manager
bash
sudo apt install network-manager-openvpn-gnome -y
Then restart Network Manager:
bash
sudo systemctl restart NetworkManager
Now you can import .ovpn files directly through the GUI.
Best Free VPN Options for Ubuntu in 2026
| VPN | Protocol | Speed | Data Limit |
|---|---|---|---|
| ProtonVPN | OpenVPN/WireGuard | Fast | Unlimited |
| Windscribe | OpenVPN/WireGuard | Good | 10GB/month |
| Mullvad | WireGuard | Very Fast | Paid only |
| hide.me | OpenVPN | Good | 10GB/month |
Recommendation: ProtonVPN is the best free VPN for Ubuntu — it offers unlimited bandwidth on the free plan and has excellent Linux support.
Troubleshooting Common VPN Issues on Ubuntu
VPN connects but no internet:
bash
# Check DNS settings
cat /etc/resolv.conf
# Flush DNS cache
sudo systemd-resolve --flush-caches
Permission denied error:
bash
sudo chmod 600 /etc/wireguard/wg0.conf
OpenVPN authentication failed:
- Double-check your username and password
- Make sure your
.ovpnfile is correct - Try downloading fresh config files from your VPN provider
WireGuard interface already exists:
bash
sudo wg-quick down wg0
sudo wg-quick up wg0
VPN Kill Switch on Ubuntu
A kill switch automatically disconnects your internet if the VPN drops — preventing your real IP from being exposed.
bash
# Add kill switch rules with UFW
sudo ufw default deny outgoing
sudo ufw default deny incoming
sudo ufw allow out on wg0
sudo ufw allow in on wg0
# Allow local network
sudo ufw allow out on eth0 to 192.168.1.0/24
sudo ufw enable
Final Thoughts
Setting up a VPN on Ubuntu is straightforward once you know which method to use. For most users, WireGuard is the best choice in 2026 — it’s the fastest, most modern, and easiest to configure.
Key takeaways:
- OpenVPN is the most compatible and widely supported
- WireGuard is the fastest and most modern protocol
- Network Manager GUI is the easiest option for beginners
- ProtonVPN is the best free option for Ubuntu users
Are you using a VPN on Ubuntu? Share your setup in the comments! 👇
Found this helpful? Check out our Linux & Ubuntu category for more Linux tutorials!