Setting up a VPN on Ubuntu is simpler than on most Linux distributions, because Ubuntu’s GNOME desktop includes a built-in VPN panel, and Surfshark is the VPN we recommend for readers in Pakistan, with 80% off for our users — its graphical Ubuntu app gives you a kill switch and a choice of WireGuard or OpenVPN in a few clicks.
Ubuntu gives you four routes to a working VPN: a provider’s native app, the GNOME Settings VPN panel, OpenVPN in the terminal, and WireGuard through wg-quick or NetworkManager. The GNOME panel is the route most Ubuntu users should try first, because it is already installed, needs no command line, and gives you a simple on-off toggle in the top bar.
This guide walks through each method on Ubuntu 22.04 and 24.04, the two long-term support releases most readers run. It covers the permissions Ubuntu requires, how to verify the connection actually works, and how to remove a VPN profile cleanly. The steps were checked against provider documentation and current Ubuntu guides in November 2026.
Before you begin, you need an active VPN subscription from a provider that supports Ubuntu, and a machine running a supported release. Free VPN apps on Ubuntu are rare and usually limited, and a provider without an Ubuntu app or configuration files cannot be set up at all, so confirm Ubuntu support before you pay.
You also need administrator access, because installing packages and changing network settings both require sudo. On a standard Ubuntu desktop, the first user account created during installation has sudo already. If you are setting up a VPN on a work computer, ask the administrator before you change network settings.
The Short Answer: How to Set Up a VPN on Ubuntu
Install your provider’s native Ubuntu app if one exists, sign in, pick a server and connect. If your provider has no Ubuntu app, open Settings, then Network, click the + button next to VPN, choose Import from file, and select your provider’s .ovpn or .conf file. Then verify the new IP address and run a DNS leak test.
The native app is the easiest route because it handles the kill switch, DNS protection and protocol choice for you. The GNOME Settings panel is the next easiest, because it is built into Ubuntu and needs no extra download for WireGuard. Manual OpenVPN and WireGuard setups in the terminal suit servers and people who want full control.
Whichever method you choose, do not skip verification. A VPN that looks connected but leaks your real IP address or DNS requests gives you no protection at all. The verification section near the end of this guide takes two minutes and confirms the tunnel is actually working.
If you only need a VPN on one Ubuntu desktop and your provider ships a graphical app, stop reading after Method 1. The GNOME panel and terminal methods exist for providers without an app, for servers, and for people who prefer Ubuntu’s built-in tools.
Before You Start: Ubuntu Versions and Requirements
Check your Ubuntu version first, because provider apps list minimum versions. Surfshark’s Linux app supports Ubuntu 20.04 and newer with NetworkManager 1.20 or later, and NordVPN’s client supports Ubuntu 22.04 and newer. The GNOME Settings VPN panel works on Ubuntu 20.04, 22.04 and 24.04, so the built-in route is available even on older releases.
Ubuntu 24.04 moved the network icon into the quick settings menu in the top-right corner, while Ubuntu 20.04 and 22.04 show it in the top bar. The Settings path itself is the same on all three releases: Settings, then Network, then the VPN section. If a menu looks different on your machine, use the Settings search box to find the VPN panel.
Make sure your system is up to date before you install anything. Run sudo apt update and sudo apt upgrade in a terminal, and restart if the update includes a new kernel. An out-of-date system can fail to install a provider’s repository or load the WireGuard kernel module, which needs kernel 5.6 or later.
Download configuration files only from your provider’s official website or account dashboard. A configuration file from a forum or a random download site can point your traffic at a server you do not control, which defeats the purpose of a VPN. If your provider does not publish OpenVPN or WireGuard files, ask its support team before you look elsewhere.
- An active subscription with a provider that supports Ubuntu
- Administrator (sudo) access on the machine
- Ubuntu 22.04 or 24.04 LTS, or 20.04 LTS for the built-in panel route
- Your provider’s app installer, or its OpenVPN (.ovpn) or WireGuard (.conf) files
- A few minutes and a way to check your IP address in a browser or terminal
Method 1: Install Your Provider’s Ubuntu App
A native app is the fastest route on Ubuntu. You install a package from your provider, sign in, pick a server and connect, and the app handles the tunnel, the kill switch and DNS protection. Providers that ship a Linux client include Surfshark, NordVPN, Proton VPN, ExpressVPN and Private Internet Access, though the exact features differ between them.
Install Surfshark on Ubuntu
Surfshark ships a graphical Ubuntu app, installed from its own repository with a one-line script. Download the installer from Surfshark’s official downloads page, run it in a terminal with sudo, and the app appears in your applications menu. Sign in with your Surfshark account, choose a server, and connect.
The Surfshark Ubuntu app supports both WireGuard and OpenVPN, and it includes a kill switch you can turn on in the app settings. Because it is a graphical app rather than a command-line client, it suits desktop users who want a point-and-click connection. Updates arrive through Ubuntu’s package manager once the repository is installed.
For readers in Pakistan, Surfshark is also the provider we recommend overall, and our Surfshark pricing guide for Pakistan explains the long-term price and the 30-day money-back guarantee. The Ubuntu app is included in the same subscription, so one account covers your Ubuntu desktop and your other devices.
Surfshark — our recommended VPN for Pakistan
One subscription covers every device in your home, and the same account works on Ubuntu, Windows, Android, iPhone and macOS.
Install NordVPN on Ubuntu
NordVPN ships a native Linux client with official packages for Ubuntu, installed from its own repository. Download the installer from NordVPN’s official Linux download page, install the repository package, and then install the client with sudo apt install nordvpn. The client is command-line first, with a graphical interface added in recent releases.
After installation, add your user account to the nordvpn group with sudo usermod -aG nordvpn $USER, then log out and back in so the group change takes effect. Sign in with nordvpn login, connect with nordvpn connect, and check the status with nordvpn status. NordLynx, NordVPN’s implementation built on WireGuard, is the default protocol, and OpenVPN remains available.
NordVPN’s client includes a built-in kill switch and autoconnect, each enabled with a single command. If you prefer a graphical app, check NordVPN’s download page for the current Ubuntu interface, because the graphical client is newer than the command-line one and its availability varies by Ubuntu release.
If your provider has no Ubuntu app at all, do not install a random client from the Ubuntu Software store or a forum. Use the GNOME panel or terminal methods below with configuration files from the provider itself. A third-party client can work, but it is unsupported, and your provider’s support team cannot help you when it breaks.
Method 2: Add a VPN in GNOME Settings
Ubuntu’s GNOME desktop has a built-in VPN panel, and it is the route most Ubuntu users should try first. It needs no provider app and no extra download for WireGuard, and it puts a simple toggle in the top bar. You need your provider’s .ovpn or .conf configuration file, and your VPN username and password.
OpenVPN needs a plugin before the panel will offer it. Install it with sudo apt install network-manager-openvpn network-manager-openvpn-gnome, then log out and back in so the option appears. WireGuard needs no plugin at all, because NetworkManager has supported it natively since version 1.16, which every supported Ubuntu release already includes.
Download the configuration file for the server you want from your provider’s website or account dashboard. Most providers publish one file per server or per country, so pick a server close to Pakistan, such as Singapore or the United Arab Emirates, for the best speed. Save the file in your Downloads folder.
- Open Settings, then Network, and find the VPN section.
- Click the + button next to VPN and choose Import from file.
- Select the .ovpn or .conf file you downloaded and confirm the import.
- Enter your VPN username and password when prompted, then press Add.
- Toggle the VPN on from the network menu in the top bar.
Your provider’s VPN username and password are usually service credentials, not your website login. Many providers generate them separately in the account dashboard, so check there if your normal login fails. Ubuntu stores the imported connection and its credentials, so you only enter them once.

You can also create a connection manually instead of importing a file. In the same VPN panel, choose the connection type, such as OpenVPN or WireGuard, and fill in the gateway, certificates and credentials by hand. Manual entry suits a connection with unusual settings, but importing a file is faster and less error-prone for most people.
One limitation to know in advance: the GNOME panel sets up no kill switch by default. If the tunnel drops, your traffic can continue over the unprotected connection until you notice. If a kill switch matters to you, use a provider app instead, or add a firewall rule that blocks traffic outside the tunnel.
Method 3: Set Up OpenVPN in the Ubuntu Terminal
The terminal route suits servers, remote machines and people who prefer commands to menus. It uses the same OpenVPN configuration files as the GNOME panel, but it runs the connection directly instead of handing it to NetworkManager. You need the openvpn package and your provider’s .ovpn file. Our OpenVPN explained guide covers how the protocol itself works.
Install the client with sudo apt install openvpn, then download the .ovpn file for the server you want. Start the connection with sudo openvpn –config /path/to/file.ovpn, and enter your VPN username and password when prompted. The terminal stays open while the tunnel runs, and closing it or pressing Ctrl+C disconnects the VPN.
OpenVPN can run over UDP or TCP. UDP is faster and suits most users, while TCP on port 443 passes through networks that block other VPN traffic, because it looks like ordinary secure web traffic. If your connection fails on UDP, try the TCP configuration file for the same server before you change anything else.
To run OpenVPN in the background, start it with sudo systemctl, or use the NetworkManager import in Method 2 instead. The terminal route gives you the clearest error messages when a connection fails, which is why support teams often ask you to try it while diagnosing a problem.
Method 4: Set Up WireGuard on Ubuntu
WireGuard is built into the Linux kernel from version 5.6, so every supported Ubuntu release already includes it. A manual setup needs only the wireguard-tools package and a configuration file from your provider. It is fast, light on the processor, and simple to configure, which is why most providers now offer WireGuard files alongside OpenVPN. Our WireGuard VPN explained guide covers how the protocol itself works.
Install the tools with sudo apt install wireguard, then download the .conf file from your provider and save it as /etc/wireguard/wg0.conf. Protect it with sudo chmod 600 /etc/wireguard/wg0.conf so only root can read the private key inside it, because anyone with that key can use your connection.
Start the tunnel with sudo wg-quick up wg0, and check it with sudo wg show. To start the tunnel automatically at boot, run sudo systemctl enable wg-quick@wg0. Stop it with sudo wg-quick down wg0. Each configuration file is one server, so switching servers means downloading another file and bringing up a different interface.
You can also import a WireGuard file into the GNOME panel instead of using wg-quick. Run sudo nmcli connection import type wireguard file /etc/wireguard/wg0.conf, or use the graphical import in Method 2, and the connection appears as a toggle in the top bar. The graphical route suits desktops, while wg-quick suits servers with no desktop at all.
WireGuard has no built-in kill switch in the wg-quick setup, and it keeps no connection log you can inspect in a graphical app. If the tunnel drops, your traffic can leak, so check the connection with sudo wg show after any network change. For a desktop user who wants a kill switch, the provider app or GNOME panel route is usually the better choice.
Permissions and Sudo on Ubuntu
Almost every step in this guide needs administrator rights. Installing packages, writing to /etc/wireguard, importing system connections and changing network settings all require sudo, so a standard user account without sudo cannot set up a VPN. On a normal Ubuntu desktop, the account created during installation has sudo already.
Some providers add their own permission step. NordVPN requires your user to join the nordvpn group, as shown in Method 1, and the group change only takes effect after you log out and back in. If a command fails with a permission error after installation, check the provider’s documentation for a group or permission step you missed.
Never run a VPN installer or a setup script as root from an untrusted source. Download installers only from the provider’s official website, check that the download page uses HTTPS, and prefer Ubuntu’s package manager over a script you found in a forum. A malicious installer runs with full administrator rights.
Keep your configuration files private. A .conf file contains a private key, and an .ovpn file can contain certificates and credentials, so store them with restrictive permissions and never share them. If a configuration file leaks, generate a new one from your provider and delete the old one.
How to Verify Your VPN Connection on Ubuntu
Verification takes two minutes and confirms the tunnel actually works. First, check your IP address before you connect by running curl ifconfig.me in a terminal, or by opening an IP checker in a browser. Note the address and the country it reports, then connect the VPN and check again.
After connecting, the IP address should change to your provider’s server, and the reported country should match the server you chose. If the address is unchanged, the tunnel is not carrying your traffic, even if the app or the top-bar toggle says connected. Disconnect, try a different server, and check again.
Next, run a DNS leak test in your browser and confirm the DNS servers shown belong to your VPN provider or a privacy-focused resolver, not your internet provider. A DNS leak exposes the websites you visit even when your IP address is hidden, so this check matters as much as the IP address check.
Finally, test a website or service that depends on your new location. If you connected to a server in Singapore, a location checker should report Singapore, and a service that blocks your real location should now work. If the location is wrong, you may be connected to a different server than the one you selected.

- curl ifconfig.me — shows your current public IP address
- curl ifconfig.me/country — shows the country of that address
- sudo wg show — shows an active WireGuard tunnel and its handshake
- nmcli connection show –active — lists active NetworkManager connections including VPNs
- Settings, then Network — shows the VPN toggle and its connection state
- A browser DNS leak test — confirms your DNS requests stay inside the tunnel
How to Remove a VPN Profile on Ubuntu
Removing a VPN profile is straightforward, but the steps depend on how you set it up. For a provider app, uninstall the package with Ubuntu’s package manager, for example sudo apt remove surfshark-vpn, and then remove the provider’s repository if you do not want its updates. Check the provider’s documentation for the exact package name.
For a GNOME panel connection, open Settings, then Network, find the VPN section, click the gear icon next to the connection, and choose Remove. From the terminal, run nmcli connection delete with the connection name you gave it. Either route deletes the stored credentials as well.
For a WireGuard setup, stop the tunnel with sudo wg-quick down wg0, disable the boot service with sudo systemctl disable wg-quick@wg0, and delete /etc/wireguard/wg0.conf. If you installed wireguard-tools only for the VPN, you can remove the package too, though it does no harm to leave it installed.
After removal, check your IP address again to confirm you are back on your normal connection. A profile that is only partly removed can leave a stale DNS setting or a routing rule behind, and the IP check is the fastest way to confirm the machine is clean.
Troubleshooting Common Ubuntu VPN Problems
If the app installs but will not connect, check that your subscription is active and that you are using the right credentials. OpenVPN setups often need service credentials from the account dashboard rather than your website password, and a wrong password produces a connection failure with no useful error message.
If the connection works on one network but not another, the network is probably blocking VPN traffic. Try OpenVPN over TCP port 443, which looks like ordinary web traffic, or switch to a different server. Some office and university networks block VPN protocols deliberately, and no setting on your machine can override that.
If the tunnel connects but websites do not load, the problem is usually DNS. Check that your DNS settings point at your provider’s resolver, restart NetworkManager with sudo systemctl restart NetworkManager, and test again. A stale DNS cache from before the connection can also cause this, and a restart clears it.
| Problem | Likely Cause | Fix |
|---|---|---|
| App installs but will not connect | Wrong credentials or expired subscription | Use service credentials; check account status |
| Connection fails on one network only | Network blocks VPN traffic | Try OpenVPN TCP 443 or another server |
| Connected but websites do not load | DNS not routed through the tunnel | Restart NetworkManager; check DNS settings |
| Permission denied on a command | Missing sudo or user group | Use sudo; join the provider group and log back in |
| No OpenVPN option in Settings | Plugin not installed | Install network-manager-openvpn-gnome |
| Tunnel drops and traffic leaks | No kill switch in manual setup | Use a provider app or add a firewall rule |
If the VPN toggle appears but will not stay on, the imported file may be missing a certificate or a credential. Re-download the configuration file from your provider, re-enter the service credentials, and import it again. A file edited by hand is the usual cause when the toggle flips straight back off.
If nothing works, test the same provider on another device, such as your phone, on the same network. If the phone connects and Ubuntu does not, the problem is the Ubuntu setup. If neither connects, the problem is the network or the provider, and your provider’s support team is the next step.
Limitations: Ubuntu VPN Setup and the Pakistan Context
A VPN on Ubuntu protects your network traffic, but it does not make you anonymous, and it does not protect you from malware, phishing or a compromised account. It also does not change your device fingerprint, so a website that tracks you by other means can still recognise you. Use a VPN as one layer of protection, not the whole defence.
Some providers limit their Ubuntu app compared with Windows or Mac. Features such as split tunnelling, a graphical server map or obfuscated servers may be missing or command-line only, and the exact feature list changes with each release. Check the provider’s Ubuntu page before you subscribe for a specific feature.
In Pakistan, VPN use has faced registration requirements from the PTA at times, and local rules have changed before. Keep your provider’s app updated, follow current PTA guidance, and do not assume that a connection problem is always a fault in your setup. A network-level restriction can look exactly like a broken configuration.
Finally, Ubuntu upgrades can break a VPN setup. A release upgrade can remove a plugin, change a repository, or replace a configuration file, so re-check the connection after every upgrade to a new Ubuntu release. Replace configuration files when your provider publishes new ones, and reinstall the provider app if the upgrade removed it.
Flagged: the minimum Ubuntu versions listed in this guide come from provider download pages as read by an independent roundup in October 2026, not from a fresh check of each provider’s site. Confirm the supported versions on your provider’s download page before installing, because they change with new releases.
Surfshark — our recommended VPN for Pakistan
Every Surfshark plan comes with a 30-day money-back guarantee, so you can test the Ubuntu app from your own connection in Pakistan before committing.
Our Verdict: Which Ubuntu VPN Setup Should You Choose?
For most Ubuntu desktop users, the native app is the right choice. It is the fastest to install, the easiest to use, and the only method that gives you a kill switch and DNS protection without extra work. Surfshark is our pick for Pakistan, with 80% off for our users, and its graphical Ubuntu app covers the releases most readers use.
Choose the GNOME Settings panel when your provider has no Ubuntu app, or when you want a built-in toggle without installing extra software. Choose the terminal routes when you run a server, want the clearest error messages, or prefer a configuration you can read and audit line by line. Both manual methods work, but both need you to handle the kill switch yourself.
Whichever method you pick, verify the connection after setup, and re-check it after every Ubuntu upgrade. A VPN that is installed but not verified is a guess, and on Ubuntu the verification takes two minutes. Set it up once, check it properly, and it will run quietly in the background.
Frequently Asked Questions
Which VPN Setup Methods Does Ubuntu Support?
Ubuntu supports four main methods: a provider’s native app, the built-in GNOME Settings VPN panel, OpenVPN through the terminal, and WireGuard through wg-quick or NetworkManager. The native app is easiest, the GNOME panel needs no extra software for WireGuard, OpenVPN needs the network-manager-openvpn plugin, and WireGuard needs the wireguard-tools package.
Which App or OS Version Requirements Matter?
You need Ubuntu 20.04 or newer for most provider apps, administrator access, and a provider that supports Ubuntu. Surfshark’s app supports Ubuntu 20.04 and newer with NetworkManager 1.20 or later, while NordVPN’s client supports Ubuntu 22.04 and newer. The GNOME Settings VPN panel works on Ubuntu 20.04, 22.04 and 24.04, and WireGuard needs kernel 5.6 or later.
How Do I Verify the Connection on Ubuntu?
Check your IP address with curl ifconfig.me before and after connecting: the address and country should change to your provider’s server. Then run a browser DNS leak test to confirm your DNS requests stay inside the tunnel, and check the active connection in Settings, then Network, or with nmcli connection show –active.



