VPN server under Docker

Run your own VPN server under Docker with OpenVPN Access Server

In this tutorial, I will be setting up an Open VPN server under Docker with CloudSigma. With CloudSigma’s cloud locations spread all over the globe, you can create a server in any of them and access the content from there.

Creating the machine

First, I am creating a machine with the following resources:
20 GHz CPU
16 GB RAM
20 GB SSD
I am mounting the disk with Ubuntu 18.04 image available in CloudSigma’s library.

Ubuntu 18.04 : Pre-installed 64bit with VirtIO drivers, superuser, Python 2.7.15, Pip 18.0, OpenSSL 1.1.0i, Cloud-init and latest updates until 2018-09-30.

Updating all existing repos and packages on the machine.

Now that our system is up to date, I will move towards installing Docker. For more info on Docker, please check here.

Installing Docker

I can install Docker executing the following commands:

 

OpenVPN

Now that Docker is successfully installed, I can start with getting OpenVPN Access Server working on it. Following is the command for creating a new Docker container of OpenVPN Access Server with the specified configuration.

 

The following commands are mentioned on Docker image’s page.
Where openvpn-as should store configuration files:

For GroupID:

Used for UserID:

For Timezone setting:

Setting interface for openvpn-as default is eth0:

IMPORTANT, for most users, needs to operate in host mode:

IMPORTANT, will not operate unless in privileged mode:

To get group id and user id, execute the following command:

I am mentioning the timezone as CET.

For interface, execute the following command:

The interface would generally be ens3 or eth0. For my system, it is ens3.

After adding all these things, I am executing the following command:

Since we don’t have the image already in our system, the image will be pulled from the server. The output would be:

Starting up the container with this command:

Log in

Now that I have started it, I will go to the admin panel of the access server.

Going to the URL: https://<<YourIpAddress>>:943/admin

PenVPN LogIn Screen

It will ask for the username and password which by default is:
Username: admin
Password: password

OpenVPN Access Server License Agreement

Now that I have logged in, it asks whether I accept the EULA (End User License Agreement). Clicking on Agree and moving to the admin dashboard.

VPN server under Docker

It is recommended to change the password of the admin account for security purposes. I am changing it, using the following command:

Configuring the DNS

Now that our server is up and running, we would want to configure the DNS in it. For more info on Domain Name Servers (DNS), please click here.

One of the fastest DNS servers is Google’s. I am going to configure that in my OpenVPN Access Server, so my clients are able to roam around websites easily.

I am going to the VPN settings and under DNS settings, I will enable “Have clients use specific DNS servers.”

VPN Settings

Next, I will enter the following addresses in the DNS Server columns:
Primary DNS Server: 8.8.8.8
Secondary DNS Server: 8.8.8.4

DNS Settings

Save Settings and Click on “Update Running Server.” It will update the running Server.

Now that I’ve configured the server successfully, I can move towards connecting to the VPN through my system.

Accessing the client UI on: https://<<YourIpAddress>>:943.

Enter the admin username, password of the admin or create a new user from the admin panel’s User Management section.

Once I log into it, it will give me various options for different OS. I select Windows and download the Client software.

OpenVPN Connect app

Now that it’s installed, I can start it from Start Menu or it will come automatically. From the system tray, I can connect to the VPN using the account I set up earlier.

Connect to OpenVPN

And I am connected to the VPN. Et Voila! This is how you create a VPN server under Docker.