Create Your Own VPN app

Iot Lab KIIT
5 min readAug 25, 2022

Follow these steps to make your own VPN server.

A Virtual Private Network better known as a VPN, gives you online privacy and anonymity by creating a private network from a public internet connection. VPNs mask your internet protocol (IP) address so your online actions are virtually untraceable.

We are going to use Pritunl along with AWS ec2 for the server side. Pritunl is an open source VPN server and management panel. It will provide us with a safe tunnel for data to pass through the internet from your computer or phone.

pritunl home page

Following are Steps to get started:-

  1. Create a virtual machine on cloud.

Firstly we need to create a virtual machine on AWS cloud in order to set up our Pritunl server on it. You need to have a running aws account. If you don’t have one, you can simply register yourself here for a free tier account.

After signing in visit the ec2 management console. In there click on the Launch instances button on the top right corner.

ec2 management console

Now select a virtual machine. We are going to go ahead with the Ubuntu Server 20.04 LTS (HVM). You can search for ubuntu in the search box and select the ubuntu 20.04 LTS version.

creating new instance

After this, let the instance type as default i.e. one eligible for free tier. Now click on next and set Configure instance, Add Storage and Add tags as defaults. In the Configure Security Group, set as given in the image below.

configuring security group

Click on create a new security group and by clicking on add rule set it to all traffic and change the source to anywhere. Select review and launch. Review all the details and click on launch. Select a key pair if you don’t have one, create a new key pair from there itself. Select Launch, now your instance will be ready and running in a few minutes.

2. Install Pritunl on the Virtual machine.

Now that you have your virtual machine set up and running. You need to make a connection between the vm and your local machine. We are going to do that via SSH. Open your IntelliJ IDEA and navigate to the tools section in the toolbar and inside that look for Start SSH Session. When you click on that, a dialogue box will appear in which you need to fill in the following details. In the Host, fill the public IP of the virtual machine. Enter the User name as Ubuntu. Use your key pair as the Authentication type and locate your private key file stored earlier.

SSH Session

Starting the session will open a terminal through which you can install Pritunl on your virtual machine. Open the terminal and run the following commands line by line.

Once you get Pritunl installed, you will automatically get redirected to the Pritunl web console where initially you need to get the Pritunl setup key. You can get that by using the pritunl setup-key on your terminal. Paste the string you get on the web console.

Get setup key

Now you need to login with username and password. You can get the default username and password by running the following commands. The default username is pritunl you can get the default password by sudo pritunl default-password. You can login and change your password and username once you are logged in through the settings.

pritunl dashboard

3. Getting the server up and running

You should first create your own organization from the console. To create an organization click Add Organisation from the Organisation page in the web console.

Add organization

Then click Add User where an email address and the user pin can be included if you choose to. Also select the organization you just created for the user.

Add user

Now you need to create a server. Go to the Servers page and click Add Server. By default a random UDP port and random VPN network will be selected.

Add user

Once the server is created, click Attach Organization to and attach the organization you created earlier to the server. Then click Start Server to start the VPN server. Once your server is started it will look like this…

Server Up and running

4. Deploying the VPN

You can deploy your VPN on a desktop or a phone. Firstly go to the user section on the console and download the user config file by clicking on the download button. The user config file is a .tar file which contains a .ovpn file. You can use this .ovpn file to connect to your server.

In order to deploy your VPN on the desktop you can use the pritunl client . After downloading the desktop app you need to import the .ovpn file and click on connect. You may also be asked to enter the username and password of your user profile.

To deploy your VPN on an android device you can use the Open VPN app or refer to this GitHub repository.

Ps: Don’t forget to stop the server and the instance as per the limits.

Congratulations you have successfully deployed your own made VPN server.

Written by: Akhouri Priyashi

--

--