What is a VPN? Why do you need to set up your own VPN?
A VPN (Virtual Private Network) simply creates a private network and tunnel your network traffic through the private network. The VPN masks your IP address and protects your privacy on the internet. Today there are lots of VPN services so you may think that setting up your own VPN is a waste of time. However, there are some advantages of setting up your own VPN.
- When you use a third-party VPN, your traffic will go through a third-party service provider and their network provider. When you use your own VPN, you don’t need a third-party service provider
- Setting up your own VPN is cost-effective when compared to other VPN subscriptions. There are free VPN providers but the speed and availability of locations are limited.
- Setting up your own VPN is a learning experience for you.
Now it’s time to learn to set up your own VPN
To create a VPN on the cloud, first, you have to create an AWS account and log in. You will get 1-year free amazon cloud services. When you log in goes to services and under compute click on EC2. So, you may think what is EC2? Simply, it’s an Amazon service that lets us deploy a virtual machine on the cloud.
Now Click on the ‘launch instance’ button and from the coming page you can select an Amazon Machine Image (AMI). For our VPN, first, you have to click on AWS marketplace and search for ‘OPENVPN’ and select the free tier eligible OPENVPN then next page you can see the charges for each instance but we need a free instance so just click on continue.
On the next page, we have to choose an instance type that is free tier eligible. Then click on ‘REVIEW AND LAUNCH’ button. Then click on launch once more on the next page.
Now you have to create a new key pair. From the drop-down select ‘create new key pair option’ and give it a key pair name and download the key pair. This is the only time you will be able to download the keypair so do it and keep it safe. We use this key pair to connect to our VPN. After download, click on ‘LAUNCH INSTANCES’ button and wait for the instance to initiate.
If it is taking too long you can go back to the instance page where you will be able to see your instance.
Now right-click on the instance and click on ‘CONNECT’. This will show you how to connect with your VPN server.
Now you can copy the SSH command from the example because it will work for most users
Now open your terminal on your PC and paste the command. As you can see the command will look for the keypair therefore make sure you change the directory in the command prompt to the one where you saved your keypair.
Now type yes to accept the agreement and then keep click on enter until you get the following
As you can see it’s asking us to login as ‘openvpnas’ rather than ‘root’ so we put the same SSH command but change the ‘root’ part to ‘openvpnas’. Click enter and you can see that you are logged in as openvpnas.
Now you have to use the command sudo passwd openvpn to change the password. You can give any password you like.
Now go back to the AWS instance page and copy the IPv4 public IP address.
Then open a new tab in your browser and type https://yourip:943/admin. You will be able to see the openvpn login page as below.
Login with your username as openvpn and password is the one you created earlier. Click on agree and you will be able to go to the overview page. When you reach the page first you have to click on the vpn settings on the right side and scroll down and you will see a routing setting where you have to select the ‘should client internet traffic be routed through the VPN’ to ‘YES’ and scroll all the way down and save the settings and go up and click on ‘UPDATE RUNNING SERVER’.
Now it’s time to connect to our VPN. For that first use the same URL that we used to login to the admin portal. Instead of the admin part just type https://yourip:943 then again you have to login with your credentials. Now you can see a web page where you can download the VPN client from the page.
After installing the software on your PC or Android device open it and click on the connect option and enter your username and password and you will connect to your own VPN.
Now you set up a VPN server on AWS and all your traffic is private and secured.
Leave a Reply