How to Set Up a VPN on Linux in 2022

In comparison to other operating systems, Linux appears to be a more privacy-friendly option out of the box. However, you still need a VPN if you wish to prevent tracking and safeguard your privacy. That's why we'll show you how to set up a VPN on Linux in several ways.

There are many ways to install a Linux VPN, but it all comes down to 3 methods. You can use a VPN app (a command-line-based app in most cases) supplied by your VPN service, stick to Ubuntu’s Network Manager, or rely on Linux's Terminal to set up an OpenVPN connection.

If you wish to automate your VPN protection, we recommend using a native app, the easiest way to go. Ubuntu's Network Manager also does a great job of simplifying the process of installing a VPN on Linux. Lastly, the method involving the Terminal is best-suited for more advanced users.

Ready to learn how to install any VPN on Linux? If you are, keep reading!

How to Set Up a VPN on Linux

Finally, here are the 3 best ways to set up a VPN on your Linux machine:

Method #1: Use a Native Linux VPN Application

You need a VPN that provides a Linux application to go through this method. Various types of apps exist, but you'll most likely get to use a command-line-based app. Here's exactly what you need to do:

1. Subscribe to a VPN that offers a native Linux app. We recommend ExpressVPN. (You can try it risk-free for 30 days.)

2. After you subscribe, return to the home page of ExpressVPN's website.

3. Select "My Account" and provide your credentials to access your online dashboard.

Signing In to ExpressVPN Website

4. Pick "Linux" on the right-hand side in the "Set Up Your Devices" section.

5. Pick your version of Linux and hit the "Download" button.

Choosing a Version of ExpressVPN for Linux

Those using Debian or Mint versions of Linux should select "Ubuntu." To check whether you use a 32- or 64-bit Linux, launch the Terminal and enter "uname -m" or "arch."

6. Locate the ExpressVPN installation file and right-click on it.

7. Select Open with Another Application > Software Install > Select.

Installing ExpressVPN on Linux

8. Use the "Install" button and authenticate your Linux account.

Linux User Authentication

9. Once the installation is done, open a Terminal window and type in "expressvpn."

ExpressVPN Basic Command Linux

10. Then, use the command you'll see below.

cd ~/Downloads/
CD Downloads Command on Linux

11. Based on whether you use Ubuntu, Fedora, or Arch Linux, run one of the commands below:

DEBIAN / UBUNTU / MINT: sudo dpkg -i [installer filename]
FEDORA: sudo dnf install [installer filename]
ARCH: sudo pacman -U [installer filename]
Installation Path ExpressVPN on Linux

12. Then, activate the VPN app using the appropriate command, as shown below.

expressvpn activate
Activate Command ExpressVPN on Linux

13. Enter your ExpressVPN activation code (from your online dashboard on the VPN's site).

14. Decide if you'd like to share anonymized diagnostic reports by pressing Y (YES) or N (NO).

Activating ExpressVPN on Linux

15. That's it! You've now successfully installed ExpressVPN on your Linux machine.

16. To start using ExpressVPN, you need to open a new Terminal window.

17. To connect to the nearest server, use the "expressvpn connect" command.

expressvpn connect
Command for Connecting to ExpressVPN on Linux

18. To check all ExpressVPN locations, use the "expressvpn list all" command.

expressvpn list all

19. Once ready to disconnect, use the "expressvpn disconnect" command.

expressvpn disconnect
Command for Disconnecting from ExpressVPN on Linux

20. To check other ExpressVPN commands, type in "man expressvpn."

man expressvpn
Command for Revealing ExpressVPN Manual in Linux

There's also a way to use ExpressVPN via a graphical user interface (GUI) on Linux. If you want to make that happen, install ExpressVPN's extension for Chrome or Firefox - AFTER you install the VPN app on Linux (as explained above).

To learn more, here's how to install ExpressVPN on Chrome and Firefox. We'll again remind you that you have to install ExpressVPN's Linux app first.

Method #2: Set up a Linux VPN via Terminal (OpenVPN)

This method requires you to use a VPN that supports the OpenVPN protocol. Furthermore, your chosen VPN should provide you with OVPN files, which are needed to set up new connections manually on Linux. Here are the steps you need to take:

1. Get a VPN that gives you access to its OVPN files, like ExpressVPN.

2. After you subscribe, go back to ExpressVPN's home page. Click "My Account."

3. Access your ExpressVPN online dashboard using your credentials.

Signing In to ExpressVPN Website

4. Select "Set Up Other Devices." Then, pick "Manual Configuration."

5. Make sure to pick "OpenVPN" on the right-hand side.

ExpressVPN OpenVPN Files

6. You'll need now see your OpenVPN username and password. Make a note of those.

7. Just below, select any location (server) you want and download its OVPN file.

8. You now need to continue based on if you use Ubuntu, Debian, or Fedora. Check below.

Steps for Ubuntu

9. Launch a new Terminal window.

10. Input the command you can see just below.

$ sudo apt install openvpn openvpn-systemd-resolved

11. To launch OpenVPN, you need to point to your OVPN file, like so:

$ sudo openvpn --config /[path to file]/my_expressvpn_[server location].ovpn --script-security 2 --up /etc/openvpn/update-systemd-resolved --down /etc/openvpn/update-systemd-resolved --dhcp-option 'DOMAIN-ROUTE .' --down-pre

You need to replace the [path to file] section in the command above based on the location of the OpenVPN file you previously downloaded.

Activating OpenVPN Linux Ubuntu

12. Provide your OpenVPN username and password.

13. It should say "Initialization Sequence Completed" once your session becomes active.

Linux Ubuntu VPN Final Command

14. To keep your connection active, leave the Terminal window running in the background.

Steps for Debian

9. Launch a new Terminal window.

10. Go with the following command:

$ sudo apt install openvpn resolvconf

11. Enter your password. Confirm with "Y" to continue.

12. Use the following command to launch OpenVPN:

$ sudo openvpn --config /[path to file]/my_expressvpn_[server location].ovpn --script-security 2 --up /etc/openvpn/update-resolv-conf --down /etc/openvpn/update-resolv-conf

You need to replace the [path to file] section in the command above based on the location of the OpenVPN file you previously downloaded.

Activating VPN Linux Debian

13. Provide your OpenVPN username and password.

14. Terminal will now say, "Initialization Sequence Completed."

Linux Debian VPN Final Command

15. As long as the Terminal window is open, your VPN connection will remain active.

Steps for Fedora

9. Launch a new Terminal window and input the command you see below.

$ sudo dnf install openvpn

10. Use the series of commands found below to configure your DNS:

$ sudo cp /usr/share/doc/openvpn/contrib/pull-resolv-conf/client.{up,down} /etc/openvpn/
$ sudo chmod +x /etc/openvpn/client.{up,down}
$ sudo sed -i -e 's|bresolvconfb|ignore-&|' /etc/openvpn/client.{up,down}

11. Then, launch OpenVPN on your Fedora Linux machine using the following command:

$ sudo openvpn --config /[path to file]/my_expressvpn_[server location].ovpn --script-security 2 --up /etc/openvpn/client.up --down /etc/openvpn/client.down

You need to replace the [path to file] section in the command above based on the location of the OpenVPN file you previously downloaded.

12. Provide your OpenVPN username and password.

13. You should see the following message: "Initialization Sequence Completed."

14. Keep your VPN session active by keeping the Terminal window open.

Method #3: Configure a Linux VPN via Ubuntu Network Manager

Ubuntu’s Network Manager is a utility for controlling your Web connectivity. As such, it supports installing and managing VPN connections. However, you'll need a VPN that allows you to set up OpenVPN connections manually. So, here’s how to set up a VPN on Linux via Network Manager.

1. Pick a VPN that supports OpenVPN connections on Linux, such as ExpressVPN.

2. Once you subscribe, return to ExpressVPN's home page. Click "My Account."

3. Provide your credentials and access your ExpressVPN online dashboard.

Signing In to ExpressVPN Website

4. Using the top-placed banned, click "Set Up Other Devices."

5. Pick "Manual Configuration" and select the "OpenVPN" tab.

6. Note your OpenVPN username and password.

ExpressVPN OpenVPN Files

7. Then, pick a server and download its OpenVPN configuration file.

8. On your Ubuntu machine, navigate to Settings > Network.

Network Settings Ubuntu

9. Click on the "+" sign next to "VPN." Then, pick "Import From File."

Network Manager VPN on Ubuntu
Importing OVPN File Ubuntu

10. Select the recently downloaded OpenVPN file and hit "Open."

Opening OVPN File on Ubuntu Linux

11. Fill out the fields under "Authentication" in the following way:

  • Type: Select "Password with Certificates (TLS)."
  • User Name: Input your OpenVPN username (not your ExpressVPN username).
  • Password: Input your OpenVPN password (not your ExpressVPN password).
Advanced Button Network Manager Ubuntu

12. Click on "Advanced," visible in the bottom-right corner.

13. Fill out the fields in the "General" tab in the following way:

  • Use Custom Gateway Port: Check this box and enter "1195."
  • Data Compression: Check this box and pick "LZO."
  • Use Custom Tunnel Maximum Transmission Unit (MTU): Select, then enter "1500."
  • Use Custom UDP Fragment Size: Select, then enter "1300."
  • Restrict Tunel TCP Maximum Segment Size (MSS): Select this box.
  • Randomize Remote Hosts: Select this box.
OpenVPN Advanced Options General Tab on Linux

14. Next, click the "Security" tab. Select the following options:

  • Cipher: Pick "AES-256-CBC."
  • HMAC Authentication: Select "SHA-512."
OpenVPN Security Options Linux

15. Select the "TLS Authentication" tab. Enter the following details:

  • Key File: Locate the "ta.key" file you downloaded earlier (from the VPN's site).
  • Key Direction: Select "1."
TLS Authentication in Linux

16. Finally, click "OK" to create your VPN connection.

17. To connect, use the toggle on the right side of your newly created VPN connection.

Connecting to VPN Connection in Ubuntu

18. Once you connect, your Linux machine will indicate that your VPN session is active.

Ubuntu VPN Session Active

19. To disconnect, go to Settings > Network and disable your active VPN session.

20. You can also add more servers following the instructions found above.

Final Thoughts

You don't have to be an IT expert to use Linux, as this guide hopefully shows. So, when it comes to setting up a VPN on Linux, you have various options in front of you. However, no matter what path you choose, you'll first need to sign up for the best VPN for Linux you can find.

Based on many years of testing VPNs, we believe that ExpressVPN should be your pick. It's by far the most capable VPN available. And also, it comes without any risks whatsoever. With that said, feel free to try ExpressVPN risk-free for 30 days.

Ultimately, we'll recommend our central guide on setting up a VPN. Use the provided link to learn how to get started with VPNs on even more devices.

FAQ

Can I Use a VPN on Linux?

Yes, you can use a VPN on practically any version (distribution) of Linux. You can choose between installing a native Linux app or configuring your VPN manually.

Does Linux Have a Built-In VPN?

Some Linux distributions (like Ubuntu) have a built-in VPN client. That allows you to set up a VPN connection - but only if you have access to VPN servers.

That means you need to be a subscriber to a VPN service to use Linux's built-in VPN client. That tool won't let you connect to VPN servers on its own.

Does Ubuntu Have a VPN?

Yes, Ubuntu has a built-in VPN client. It's called "Network Manager," and you can find it by navigating to "Settings" on your Ubuntu machine.

Keep in mind that we're talking about a VPN client in this case. That means you need to be a subscriber to a commercial VPN service to establish connections. Our recommendation is to subscribe to ExpressVPN.

How Do I Enable a VPN on Ubuntu?

You can enable a VPN on Ubuntu by installing a native VPN app. You can also set up a VPN manually using the "Network Manager" tool, which comes built-in.

Another way to enable a VPN on Ubuntu is to use a Web browser extension (like Chrome or Firefox, for example). However, keep in mind that extensions don't typically bring the highest possible level of encryption.

How to Use OpenVPN on Linux?

While some Linux distributions allow you to set up OpenVPN connections without third-party tools, other distros require you to install an OpenVPN client.

If you scroll up, you'll see the instructions on using Linux's Terminal to set up OpenVPN connections on distributions like Ubuntu, Fedora, and Debian.

Does Linux Have a Free VPN?

Linux doesn't have a free VPN by default. However, you can install third-party VPN services that promise to encrypt your connection free of charge.

Still, we highly recommend you avoid free VPNs. They're typically quite limited, forcing your Web connection speed to drop dramatically. Also, they don't bring the highest level of encryption, which means you'll risk exposing your data online.

Our guide to the best VPN deals shows you many budget-friendly options, so make sure to take a good and thorough look.

How to Install a Free VPN on Linux?

You can install a free VPN on Linux just like you'd install a premium one. That means you can rely on using a native Linux app - if that's what your chosen free VPN offers.

For more information, please scroll up to check our guide on how to set up a VPN on Linux. Keep in mind that our recommendation is ExpressVPN, a premium VPN that respects your privacy and security in a way no free VPN can.

You've reached the end of our guide on how to set up a VPN on Linux. If you have any questions, let us know via the comments section below. Thank you for reading!

Latest
How to Watch European Beach Volleyball Championships 2022 Online From Anywhere
The 2022 European Championships are in full swing, and the European Beach Volleyball Championships are about to reach crunch time. With 128...
How to Watch Homicide Hunter: Never Give Up Online From Anywhere
Lt. Joe Kenda enthralled audiences with tales from the hundreds of murder cases he investigated throughout the 9 seasons of Homicide Hunter....
How to Watch Hotties Online From Anywhere: Stream the Blind Date Food Competition Series
If you like blind date reality shows as much as cooking competitions and extremely spicy food, you'll most probably love this new...
For a better user experience we recommend using a more modern browser. We support the latest version of the following browsers: For a better user experience we recommend using the latest version of the following browsers: Chrome, Edge, Firefox, Safari
[class^="wpforms-"]
[class^="wpforms-"]
[class^="wpforms-"]
[class^="wpforms-"]