Categories: TutorialsUbuntu

How to Setup a VPN on Ubuntu

A VPN abbreviated as Virtual Private Network enables a private network to be extended across a public network. It allows users to send and receive data as if their computer equipment were physically linked to the private network. For example, suppose you need to connect to your workplace’s local network while on a business trip. You’d find an internet connection (maybe at a motel) and then connect to your company’s VPN. Although it looks like you are directly linked to the network at work, you are connected to the network via the hotel’s internet connection. VPN connections are normally encrypted to prevent unauthenticated users from accessing the local network to which you’re connected.

Methods to Setup a VPN on Ubuntu

There are two ways in which you can set up a VPN on your Ubuntu:

  • Setup VPN Using Command Line Method
  • Setup VPN Using GUI (Graphical User Interface) Method

A brief description of both approaches is detailed below:

Method 1: Setup VPN Using Command Line Method

The following are the steps involved in the installation and set-up of VPN in Ubuntu using the CLI method:

Step 1: Update System

To ensure that all your Ubuntu packages are up to date, update your operating system using the following command:

$ sudo apt update

Then to upgrade your operating system, use the following command:

$ sudo apt upgrade

Step 2: Check the IP Address

You can check your system’s IP address using the following command:

$ ip addr show

Step 3: Installation of OpenVPN

You can install OpenVPN using the following command:

$ wget https:// git.io/vpn –O openvpn-ubuntu-install.sh

Now we’ll use the “chmod” command to change the permissions on the script file:

$ chmod –v +x openvpn-ubuntu-install.sh

Then, using the following mentioned script file, install OpenVPN:

$ sudo ./openvpn-ubuntu-install.sh

Step 4: Check Connection

Run the following “Ping” command to ping the OpenVPN server:

$ ping –c 4 10.8.0.1

Step 5: Addition or removal of clients

By using the following mentioned script file, you can either add or remove clients or revoke existing clients:

$ sudo ./openvpn-ubuntu-install.sh

Commands to start/stop/restart OpenVPN

Using the following mentioned command, you can start OpenVPN:

$ sudo systemctl start openvpn@server.service

Using the following mentioned command, you can stop OpenVPN:

$ sudo systemctl stop openvpn@server.service

Using the following command, you can restart OpenVPN:

$ sudo systemctl restart openvpn@server.service

Using the following mentioned command, you can display the status of OpenVPN:

$ sudo systemctl status openvpn-server@server.service

Method 2: Setup VPN Using GUI Method

The following are the steps involved in the installation and set-up of VPN in Ubuntu using the CLI method:

Step 1: Settings Icon

Open the Ubuntu Activities (depicted by a nine-dot symbol) in the left corner of the screen, then seek for and select the “Settings” option:

Step 2: Network Icon

After tapping the “settings” button, the Network Settings Menu will appear. Go to “Network” in the settings options. To add a new VPN connection, click the Add button at the bottom of the left-hand list of VPN interfaces.

Step 3: Choose a VPN

After clicking on the “+” option, select the type of VPN connection you have among the list of VPN connections. In my case, I’m choosing an OpenVPN connection:

Step 4: Add VPN

After selecting the VPN, add details about the VPN. Once you’ve completed filling out the VPN connection details, click Add:

You can see that after setting up the information, the connection is being added. All you have to do is turn it “on” to connect to the VPN. You may be required to enter a password before the connection is established. After entering the password, you will be able to connect to the VPN. Again, to remove the VPN, you can switch the button off.

Conclusion

This article provides a basic understanding of VPNs and how they work. This article also covers the two distinct methods for setting up VPN in Ubuntu Linux. These methods include command line and graphical user interface (GUI) approaches. In addition, the CL method includes several commands that can be used to set up a VPN in Ubuntu.

Ubuntu Server Admin

Recent Posts

🚀 Deploy Elastic Stack on Ubuntu VPS (5 Minute Quick-Start Guide)

Here’s the guide to deploy Elastic Stack on Ubuntu VPS, with secure access, HTTPS proxying,…

1 day ago

🚀 Deploy Nagios on Ubuntu VPS

This guide walks through deploying Nagios Core on an Ubuntu VPS, from system prep to…

1 day ago

Shoryuken Has a New Maintainer, and v7.0.0 Is Almost There

After a decade under Pablo Cantero's stewardship, Shoryuken has a new maintainer - me. I'm…

5 days ago

A better way to provision NVIDIA BlueField DPUs at scale with MAAS

MAAS 3.7 has been officially released and it includes a bunch of cool new features.…

2 weeks ago

Ruby Floats: When 2.6x Faster Is Actually Slower (and Then Faster Again)

Update: This article originally concluded that Eisel-Lemire wasn't worth it for Ruby. I was wrong.…

2 weeks ago

MicroCeph: why it’s the superior MinIO alternative (and how to use it)

Recently, the team at MinIO moved the open source project into maintenance mode and will…

2 weeks ago