Setup a VPN on Ubuntu 22.04 (Jammy Jellyfish) - Step by step guide ?

A VPN which stands for 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.

Here at LinuxAPT, we shall look into the different ways in which you can set up a VPN on your Ubuntu.


Ways of setting up a VPN on Ubuntu:

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


a. Setup VPN Using Command Line Method

You can follow the below steps to install and set-up of VPN in Ubuntu using the CLI method.

1. Perform System Update

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


2. Check the IP Address

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

$ ip addr show


3. Install OpenVPN on the system

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


4. Check Connection

Now, Run the following "Ping" command to ping the OpenVPN server:

$ ping –c 4 10.8.0.1


5. Add or Remove clients

Now, use the below script file to either add or remove clients or revoke existing clients:

$ sudo ./openvpn-ubuntu-install.sh


What are the commands to start/stop/restart OpenVPN via Command Line ?

i. You can use the below command to start OpenVPN:

$ sudo systemctl start openvpn@server.service

ii. You can use the below command to stop OpenVPN:

$ sudo systemctl stop openvpn@server.service

iii. You can run the below command to restart OpenVPN:

$ sudo systemctl restart openvpn@server.service

iv, You can use the below command to display the status of OpenVPN:

$ sudo systemctl status openvpn-server@server.service


b. Setup VPN Using GUI Method

Here, you can follow the steps to install and set-up of VPN in Ubuntu using the CLI method.

1. From 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.


2. From 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.


3. Choose a VPN

After clicking on the "+" option, select the type of VPN connection you have among the list of VPN connections. Here, we choose an OpenVPN connection.


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.


[Need help in fixing Linux VPN configuration issues ? We can help you. ]

This article covers VPNs in Linux systems and how the basically work. In fact, OpenVPN is extremely popular and a full-featured SSL VPN (Virtual Private Network) software which implements OSI layer 2 or 3 secure network extension using the SSL/TLS protocol.

Related Posts