How to set up a VPN on Linux in 3 easy ways
Even a secure operating system like Linux can take advantage of the benefits provided by a virtual private network (VPN), so it’s a good idea to set up a VPN on your Linux device. But why do you need a VPN on Linux, and how do you install it? Let’s find out.
Table of Contents
Table of Contents
Why do you need a VPN for Linux?
Reasons to set up a VPN are the same no matter which OS you use – VPN security and privacy benefits apply to Linux, Windows, Android, and other operating systems.
- A VPN encrypts your internet traffic, protecting your sensitive data from man-in-the-middle attacks and other types of hacking. When using IP forwarding on Linux, a VPN adds an extra layer of security by ensuring that all data routed through your system is encrypted and safe from external threats.
- VPN encryption keeps your online activity hidden from government surveillance and prevents data harvesting by your ISP.
- A VPN helps to evade online censorship when traveling.
- Sometimes you can also use a VPN to find better deals when booking flights online or shopping.
- Leading VPNs like NordVPN provide extra security and privacy features like Threat Protection.
What do you need for a Linux VPN setup?
For a successful Linux VPN setup, you’ll need:
- Computer (especially Linux) skills and the understanding of what a VPN is
- A device running Linux. NordVPN supports most Debian-based and RHEL-based systems
- Sudo (administrator) privileges and the root password
- An active VPN subscription
- OpenVPN configuration files (if you decide to use the OpenVPN app or Network Manager for the setup)
You can also change your DNS settings and check for DNS leaks beforehand.
And don’t forget that configuration interfaces and thus instructions may differ depending on which Linux distribution you have.
How to set up a VPN on Linux
When you have everything you need, you have a few ways to set up a VPN on a Linux device:
- installing a VPN client
- installing the OpenVPN application
- adding OpenVPN configuration in the Network Manager
How to set up a VPN on Linux with the VPN client
If your VPN provider has a native application for Linux, installing it is the simplest way to set up a VPN on Linux.
NordVPN’s client works on Debian, Ubuntu, Raspberry Pi computers, Elementary OS, and Linux Mint. Setting it up is pretty straightforward:
- Download the NordVPN configuration package.
- Open “Terminal” and type in the following command to install the NordVPN repository on your system:
sudo apt-get install /pathToFile/nordvpn-release_1.0.0_all.deb
You’ll need to replace “pathToFile” with the location of the NordVPN package that you’ve just downloaded. If it ended up in the “Downloads” folder, the command would look like this:sudo apt-get install ~/Downloads/nordvpn-release_1.0.0_all.deb
- Type in your password to begin the installation.
- Once the installation finishes, update the package list with the following command:
sudo apt-get update
- Install the NordVPN client:
sudo apt-get install nordvpn
- Initiate the login to your Nord account:
nordvpn login
- Your command line will show a link for logging in via your browser. Follow the link to the Nord Account page and enter your credentials. You may also need to use an authenticator app for multi-factor authentication.
- Once you’re logged in on the browser, you can connect to a NordVPN server to establish a VPN connection:
nordvpn connect
NordVPN will choose the most suitable and fastest VPN server for you. If you want to connect to a specific country or server, you can find the table with commands toward the end of this article.
If you’re still having trouble, check our video instructions:
You can also find instructions for different distributions here, visit our help page, or contact customer support.
How to set up a VPN on Linux with the OpenVPN application
If you want to configure NordVPN the old-fashioned way, you’re welcome to check out our detailed tutorial. To sum up the process:
- Install OpenVPN and configure it on your computer.
- Download our OpenVPN configuration files into your OpenVPN directory.
- Make sure you configured everything correctly, and select your NordVPN server if you did.
- Finally, establish an OpenVPN connection and connect to the internet through NordVPN.
How to set up a VPN on Linux with Network Manager
It’s also possible to set up a VPN on Linux using Network Manager. Detailed instructions with screenshots are here, and the TL;DR version follows:
- Download our OpenVPN configuration files.
- Update your system and the Network manager.
- Import OpenVPN configuration files in the VPN settings.
- Connect to the VPN server, which settings you’ve just imported.
How to set up your own Linux VPN server
You may be wondering, “Can I create my own VPN on Linux?”
It’s Linux – of course, you can.
You can set up your VPN server by installing OpenVPN, adjusting ports and protocols, changing DNS settings to redirect the traffic through your VPN, and taking further steps. The instructions are complicated and deserve a separate article.
But if you only want to encrypt and route your traffic through another device, there’s a simpler way. You can use NordVPN’s Meshnet feature.
With Meshnet, you can use your own Linux server or computer as your VPN server.
Instead of connecting to a VPN server managed by a VPN provider, you connect to your or your friend’s Linux device from another device linked by Meshnet. The devices connect to each other via an encrypted tunnel and use each other’s IP addresses. You can even access your files remotely this way.
NordVPN Linux app commands
Using NordVPN on Linux is pretty straightforward too. Here are the commands you’ll need most often:
Command | What it does |
---|---|
nordvpn login | Logs you in |
nordvpn connect / nordvpn c | Connects you to NordVPN server |
nordvpn disconnect / d | Disconnects you from NordVPN server |
nordvpn connect country code server number (e.g. nordvpn connect uk715) | Connects you to a specific NordVPN server |
nordvpn set / nordvpn s | Sets a configuration option |
nordvpn set threatprotectionlite on or off | Enables or disables Threat Protection |
nordvpn set killswitch on or off | Enables or disables Kill Switch |
nordvpn set meshnet on or off | Enables or disables Meshnet |
nordvpn settings | Lists the current settings |
nordvpn status | Shows your connection status |
nordvpn refresh | Refreshes the server list |
nordvpn countries | Displays the country list |
nordvpn logout | Logs the user out of their NordVPN |
nordvpn help / nordvpn h | Shows a list of commands (like how to turn on Threat Protection) or help for one specified command |
How to choose a VPN for Linux?
If you don’t have a VPN subscription, you’ll need one for a Linux VPN setup. Here’s how to choose the best VPN provider:
- Choose a premium VPN provider. Free VPNs can log your data to sell it for profit. They have to make money in some way, and if it’s not from subscriptions, you can expect the worst.
- Make sure the VPN has many servers in different countries. More servers mean more options for you when connecting to a particular country. It also impacts the connection speed because providers with fewer servers can have a lot more users connected to the same server.
- Pay attention to security protocols. VPN services use different VPN protocols for encrypting your connection. Some protocols are better for security, while others are better for offering a fast connection. For example, OpenVPN is considered to be the most secure protocol among the experts, while NordVPN’s NordLynx is the best for speed. You should choose a VPN service and protocols that meet your browsing needs.
- Check the extra features. Premium VPN providers offer additional features that can be useful or even replace the need for some other tools. For example, NordVPN’s Threat Protection Pro prevents malware infection and blocks trackers and ads. Meanwhile, you can join virtual LAN parties or access files stored on remote devices if you use Meshnet.