Many of us rely on public WiFi to connect to the internet; however, the security of these networks can be questionable, with sniffing, eavesdropping and man-in-the-middle attacks possible. A Virtual Private Network (VPN) can provide a safe and secure connection whenever you need one, whether you’re at home, at work, or on the move. In this guide, we’ll discuss the steps necessary to connect to a VPN on Ubuntu.
Step 1: Install and Configure VPN Client
The first step to connecting to a VPN on Ubuntu is to install and configure the VPN client. There are a number of different VPN clients available for Linux, all with their own unique features and benefits. For this tutorial, we’ll be using the open source VPN client, OpenVPN.
OpenVPN is a flexible, open-source software application that connects your computer to a VPN server. VPN connections are encrypted so that any information transferred is protected, ensuring that nobody, including network service providers, can read your emails, browse your web browser history, or steal your banking details. Using OpenVPN is pretty easy – just open the application, enter your server’s credentials, and you’re good to go. You can even set up automatic login so that you can connect to the VPN simply by entering your username and password.
OpenVPN is a powerful tool and an excellent choice for anyone looking for a secure and private connection. To get started with OpenVPN on Ubuntu, use the following commands:
sudo apt-get install openvpn
The software will then be installed on your computer. You can verify this by opening the application and verifying that the openvpn daemon (svnoe) is running. You can do this by entering the following command at the terminal:
ps aux | grep openvpn
You should see the following output:
root 1592 0.0 0.1 53224 1776? Ss Apr01 21:04 /usr/sbin/openvpn --daemon --log-file=/var/log/openvpn[...]
OpenVPN is now installed on your computer, and it needs to be configured so that it links with your server. You can do this by entering the following commands at the terminal:
sudo cp ~/Downloads/openvpn/config/easy-rsa/2.0/easy-rsa.conf /etc/openvpn/
sudo sed -i's/^[[:space:]]*port #[[:space:]]*//' /etc/openvpn/easy-rsa.conf
This will change the port in the openvpn config file from 1194 to a custom port number between 49152 and 65535. You can then run the following command to start the VPN:
sudo service openvpn start
You can find the IP address of your server by entering the following command at the terminal:
dig @server.opvnapi.org nslookup
You should then see the IP address of your server. In the example below, it shows:
You can also test whether or not the VPN is functioning correctly by connecting to it via a different device or computer. If you’re able to connect, then your VPN is configured correctly and you can continue to the next step.
Step 2: Install and Configure Server
The second step to connecting to a VPN on Ubuntu is to install and configure the VPN server. Most large networks will have multiple VPN servers available for clients to connect to. When choosing a VPN server, make sure that you’ve looked into the software’s authentication methods as well as the strength of the encryption scheme used. We recommend choosing a VPN server that uses industry-standard AES-256 encryption – any less and your privacy could be at risk. Strong authentication methods, like smart cards or multi-factor authentications, can ensure that only you can access the VPN server’s contents.
If you have access to the server’s terminal, you can run the following command to list the available VPN servers:
You should get a response from the VPN server, indicating that it is alive and available. If you don’t, then there’s a chance that it’s not configured or that the IP address has changed. One of the following commands will list the VPN servers available:
- Server Address
- IP Address
- Port Number
- % Connected
- % Connected Since
- % Available
- % Available Since
Once you’ve located the IP address of a suitable VPN server, you can download the software to install it on your Ubuntu system. Remember to use a VPN server that’s been tested for your computer’s operating system.
The following commands will download and install the VPN server software from the repos:
sudo apt-get install openvpn
You can now start the VPN server by entering the following command at the terminal:
sudo service openvpn start
If everything has gone according to plan, you should now see an active VPN server listening on your default network interface. You can test this by connecting to it via a different device or computer. If you’re able to connect, then your VPN is configured correctly and you can continue to the next step. Otherwise, you might need to check whether or not your VPN server is accessible or reachable from your current location.
Step 3: Configure OpenVPN Client
The third and final step to connecting to a VPN on Ubuntu is to configure the OpenVPN client. The client is what you use to connect to the server – the program that allows you to authenticate and establish an encrypted connection to the VPN server. There are a few different ways to configure OpenVPN clients, but we recommend using the web interface, as it’s much easier to use than the traditional text-based interfaces. You can access the web interface by entering the following URL in your web browser:
- Server IP address
- TLS username
- TLS password
- Port number
- Connect to VPN
- Summary of Connected Networks
- Summary of Active Sessions
- Configure VPN Client
One of the first things you want to do is to check the OpenVPN settings on the server itself. The following screen should look something like this:
The screenshot above is from a server that’s running OpenVPN 2.3.3. To access the web interface, use the following URL:
For example, if the IP address of your server is 192.168.1.22 and the port number is 1194, then the URL would be:
You’ll then be presented with a login page, as seen below:
Enter your username and password, and then click the Login button. You’ll then be presented with a menu, as seen below: