Deja, šio puslapio turinio jūsų pasirinkta kalba nėra.

Jūsų IP:nėra informacijos

·

Jūsų statusas: nėra informacijos

Pereiti prie pagrindinio turinio

Linux VPN setup: A step-by-step guide for easy installation

Using a VPN on Linux, like NordVPN, keeps your internet traffic more secure on any network. And it’s easier to set one up than you might think. In this guide, you'll learn how to set up a Linux VPN across all major distributions, including Ubuntu, Kali, Fedora, Arch, and Pi-based versions. We’ll walk you through five ways to set up a Linux VPN using NordVPN as an example, complete with visuals to make the process easier. You’ll also find out how to check your Linux operating systems, fix common issues, and choose the setup that works best for you.

2025-08-11

Skaitymo trukmė: 13 min.

How does the VPN setup process differ across Linux distributions? 

Linux gives you tons of control, but that also means that the process of setting up a VPN for Linux can look a bit different depending on the distribution you're using. Each distro serves different users and has its own package management system, default tools, and user environments. All those differences affect how you set up and manage a VPN (virtual private network).

Desktop-oriented distros like Ubuntu come with handy graphical tools. But when you're working with more security-focused distributions like Kali or Raspberry Pi, which often don’t have full desktop environments, you need more hands-on, command-line solutions. Figuring out your distro first makes it easier to pick the right setup.

To help you get started faster, here’s a quick breakdown of popular Linux distributions and the best VPN setup methods for each:

Linux distribution

OpenVPN

IKEv2/IPSec

Network Manager

VPN app

Ubuntu/Debian

Fedora/RHEL


Kali Linux

Arch Linux

Raspberry Pi OS

Security-focused distros

How to check which Linux distribution you are using

You can install a VPN client on a Linux device in different ways, and the one you’d choose depends largely on your technical skill level and personal preference. However, the Linux distribution you have matters too, since how to set up a VPN on Kali Linux can differ quite a bit from doing it on Ubuntu or Raspberry Pi. No worries if you’re not sure. Finding out only takes a minute:

  1. 1.Open the terminal by clicking “Ctrl” + “Alt” + “T” on your keyboard or by finding the “Terminal” app icon in your system menu or desktop.
  2. 2.In the “Terminal” window, run a command that would show the information on your Linux distribution. The most common are:
cat /etc/os-release Hostnamectl
Linux VPN setup step 1

Setting up OpenVPN connections on Linux

OpenVPN is one of the most reliable and widely supported protocols used to set up a VPN for Linux. It's open source, secure, and works great on almost any distribution. While it requires a few commands to set up a VPN server on Linux, connecting to NordVPN via Linux Terminal is straightforward and repeatable once you’ve done it once.

We’ll walk you through the process step by step below, but you can also follow along with this video tutorial:

1. Install OpenVPN

Open your terminal (“Ctrl” + “Alt” + “T”). Before installing OpenVPN, make sure to disable IPv6 to avoid DNS leaks or connectivity issues. Once ready, install the VPN client with the following command: 

sudo apt install openvpn

You may be asked for your system password to continue.

Linux VPN setup step 2

2. Download VPN configuration files

Go to the OpenVPN configuration directory:

cd /etc/openvpn
Linux VPN setup step 3

Then, download the OpenVPN configuration archive by running:

sudo wget https://downloads.nordcdn.com/configs/archives/servers/ovpn.zip
Linux VPN setup step 4

If you get an SSL certificate error, you can fix it by running:

sudo apt install ca-certificates

To open the files, you’ll need to unzip them — so make sure the “unzip” package is installed. If you haven’t already installed it, you can do so with:

sudo apt install unzip

Extract the files using this command:

sudo unzip ovpn.zip
Linux VPN setup step 5

After the extraction, you can delete the archive with:

sudo rm ovpn.zip

3. Configure the VPN

Once unzipped, you’ll have two folders — one for UDP-based connections and one for TCP-based connections. To go into one of the folders, use either of these commands:

cd /etc/openvpn/ovpn_udp/ cd /etc/openvpn/ovpn_tcp/
Linux VPN setup step 6

To run a VPN on Linux, you’ll need a server. Now you could choose one from all available servers. To see them, run the following command:

ls -al

However, for the best performance, we suggest using the recommended server. To find which one it is, log in to your Nord account and go to “NordVPN” > “Advanced settings” > “Set up NordVPN manually” > “Server recommendation.”

Linux VPN setup step 7

4. Connect to the VPN

Run this command to start the VPN:

sudo openvpn /etc/openvpn/ovpn_udp/us2957.nordvpn.com.udp.ovpn

Replace “us2957.nordvpn.com.udp.ovpn” with the “.ovpn” file that matches your chosen server and protocol. For example, to use a TCP-based server instead, you might run:

sudo openvpn /etc/openvpn/ovpn_tcp/us2957.nordvpn.com.tcp.ovpn
Linux VPN setup step 8

When prompted, enter your NordVPN service credentials. To find them, log in to your Nord account, go to “NordVPN” > Set up NordVPN manually” > “Service credentials.”

Linux VPN setup step 9

That’s it — you’ve now successfully established a connection with a VPN client. The VPN will be running as long as the “Terminal” window is open. Press “Ctrl” + “C” to close the window and disconnect from the VPN.

Setting up IKEv2/IPSec connections on Linux

A similar and equally effective option is setting up a VPN connection using IKEv2/IPSec. Many Linux users favor this protocol because of its speed and stability. It’s ideal for maintaining a consistent connection, especially on mobile or frequently changing networks. To set up a VPN server on Linux with IKEv2/IPSec, most people use StrongSwan, a widely used open-source implementation that is compatible with most major VPN providers.

1. Install StrongSwan for IKEv2/IPsec

Install the required StrongSwan package with the following command:

sudo apt install strongswan
Linux VPN setup step 10

Additionally, install all extra StrongSwan plugins needed for advanced VPN functionality:

sudo apt install strongswan libcharon-extra-plugins
Linux VPN setup step 11

2. Configure VPN settings

Open and edit the “ipsec.secrets” file using your NordVPN service credentials. To do that, run this command:

sudo nano /etc/ipsec.secrets

In the file, add this line (replace “USERNAME” with your actual NordVPN service username and “PASSWORD” with the password in double quotes):

USERNAME : EAP "PASSWORD"
Linux VPN setup step 12

To find your service credentials, log in to your Nord account, go to “NordVPN” > Set up NordVPN manually” > “Service credentials.”

Linux VPN setup step 13

Now, you’ll need to edit the configuration file. To open it, run the following command:

sudo nano /etc/ipsec.conf

Add the following configuration to the file:

conn NordVPN         keyexchange=ikev2         dpdaction=clear         dpddelay=300s         eap_identity="USERNAME"         leftauth=eap-mschapv2         left=%defaultroute         leftsourceip=%config         right=SERVER         rightauth=pubkey         rightsubnet=0.0.0.0/0         rightid=%SERVER         rightca=/etc/ipsec.d/cacerts/NordVPN.pem         type=tunnel         auto=add

Replace “USERNAME” with your NordVPN service one in the double quotes and “SERVER” with your chosen NordVPN server hostname. To find the recommended server, log in to your Nord account, and go to “NordVPN” > “Advanced settings” > “Set up NordVPN manually” > “Server recommendation.”

Linux VPN setup step 14-1

Use the following command to edit the constraints file, and change the line in the file from “load = yes” to “load = no”:

sudo nano /etc/strongswan.d/charon/constraints.conf
Linux VPN setup step 14

Then, download the NordVPN certificate by running:

sudo wget https://downloads.nordcdn.com/certificates/root.pem -O /etc/ipsec.d/cacerts/NordVPN.pem
Linux VPN setup step 15

3. Restart the VPN service

To apply your changes, just restart ipsec:

sudo ipsec restart
Linux VPN setup step 16

4. Connect to the VPN

Use the following command for the VPN to start working:

sudo ipsec up NordVPN
Linux VPN setup step 17-1

To disconnect, just run: 

sudo ipsec down NordVPN

Setting up a VPN using Network Manager

If you prefer using something with a graphical interface over the command line, connecting to NordVPN via Linux Network Manager is a great alternative to a terminal-based VPN setup.

With Network Manager, you can configure a VPN for Linux once and connect every time with a single click. Here’s how you can set it up.

1. Install the Network Manager plugin

First, update your system and install the necessary OpenVPN plugin for Network Manager with:

sudo apt install network-manager-openvpn-gnome
Linux VPN setup step 18

To use Network Manager as your VPN manager, you’ll also have to download the OpenVPN configuration file package from NordVPN and extract the contents into a folder of your choice. You can also run the following commands to do the same:

sudo wget https://downloads.nordcdn.com/configs/archives/servers/ovpn.zip sudo unzip ovpn.zip

2. Open network settings

In the top-right corner, click your network icon. Then, click on the “Settings” icon and go to the “Network” tab. Under the VPN section, click the “+” button to add a new connection.

Linux VPN setup step 19-1

3. Add VPN connection

In the pop-up, choose “Import from file…” Find the folder containing the extracted configuration files and select the file of your preferred server.

Linux VPN setup step 20

Go to the “Identity” tab and enter your NordVPN service login details. To find them, log in to your Nord account, go to “NordVPN” > Set up NordVPN manually” > “Service credentials.”

Linux VPN setup step 21

4. Connect to the VPN

Go back to the Network Manager and toggle the VPN switch to connect to a NordVPN server. Once connected, the switch will turn green. To disconnect, toggle the switch off.

Linux VPN setup step 22

Setting up a VPN app on Linux

If you’re after the easiest way to get a VPN for Linux up and running, a dedicated app is the way to go. 

Not everyone loves the command line — and it’s perfectly okay! Having both options is a big plus when you're figuring out how to choose an online VPN service that actually fits your style of working. NordVPN has a native Linux app with two options: a command-line version for terminal users and a GUI (graphical user interface) for those who prefer it. Our Linux app works on most major distros and desktop environments.

We’ll walk through the steps on how to install our official Linux app below, but you can also follow along with this video:

1. Download the VPN app

To download VPN software on Linux, you can choose between two installation methods depending on whether you want the GUI or the CLI version.

To install the graphical NordVPN app version, open your terminal and enter:

sh <(wget -qO - https://downloads.nordcdn.com/apps/linux/install.sh) -p nordvpn-gui

To install the CLI version of the app, you can use the following command in the terminal:

sh <(curl -sSf https://downloads.nordcdn.com/apps/linux/install.sh)
Linux VPN setup step 23

2. Install the VPN app

After you run the command, the installation will start automatically. After the installation is complete:

  • If you chose the GUI version, look for the NordVPN icon in your applications menu or desktop environment and launch it from there.
  • If you're using the CLI version, it will be ready to use directly from your terminal.

3. Log in to your account

Next, log in to your NordVPN account. In the GUI app, simply enter your Nord account email and password. In the CLI version, use the login command in the terminal:

nordvpn login

Open the link provided in the output on your preferred browser and finish the login process there. Then, follow the instructions to open the app again.

Linux VPN setup step 24

4. Connect to the VPN

To connect to a VPN server in the GUI, just click on “Quick Connect.” In the CLI version, run the connection command to establish a secure connection with the recommended server:

nordvpn connect

Once connected, you’ll be able to browse the internet more securely.

Linux VPN setup step 25

You can also change various settings, including your preferred VPN protocol, in the GUI's settings menu or with the available NordVPN CLI settings commands, which we’ll cover next. For the fastest and most secure connection, you can switch to the VPN WireGuard protocol by enabling NordLynx in the app’s settings.

Useful NordVPN Linux commands for setup and management

Using NordVPN on Linux is pretty straightforward, too. Here’s a helpful cheat sheet for getting the most out of NordVPN on Linux:

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 [server name] (for example: nordvpn connect uk715)

Connects you to a specific NordVPN server

nordvpn set / nordvpn s

Sets a configuration option

nordvpn set threatprotectionlite on or off

Turns Threat Protection on or off

nordvpn set killswitch on or off

Enables or disables Kill Switch

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

Troubleshooting VPN setup on Linux

Even though getting a VPN to work on Linux is no rocket science, sometimes you can hit snags in the process. Maybe the app doesn’t behave as expected, or the connection keeps dropping — either way, it can be frustrating when the setup doesn't go as planned. Luckily, it’s usually something simple you can fix quickly. Below are some common problems Linux users face during VPN setup, and how to solve them quickly.

VPN connection fails

Sometimes, the VPN won’t connect at all. This issue can happen due to incorrect login details, outdated software, or network conflicts.

To solve the issue, first log out and log back in to your VPN account. Then make sure your app is up to date. Restarting your computer or your network manager can also sometimes help fix this issue.

Slow VPN connection

If your VPN is connected but feels sluggish, the server you’re using might be overloaded or too far away. Switch to a different VPN server — closer is usually faster. Also, try changing your VPN protocol.

Can’t access websites after connecting to VPN

If you’re connected, but some websites won’t load, it can be caused by DNS or firewall settings. Try clearing your DNS cache and checking that your firewall isn’t blocking traffic while the VPN is active.

Unable to connect to OpenVPN

If you’re setting up OpenVPN manually and it won’t connect, the issue could be with your configuration files or simply because of wrong login credentials.

Make sure you’ve downloaded the correct “.ovpn” files and placed them in the right folder. Double-check your OpenVPN installation and that your username and password are correct. Don’t forget to run the connection command with “sudo” for proper admin permissions.

Online security starts with a click.

Stay safe with the world’s leading VPN

FAQ

Aurelija Skebaite | NordVPN

Aurelija Skebaite

Aurelija is passionate about cybersecurity and wants to make the online world safer for everyone. She believes the best way to learn is by doing, so she approaches cybersecurity topics from a practical standpoint and aims to help people protect themselves online.