Free VPN for 1 Year 
Tags: privacy, aws, productivity, programming
Published: 2020-12-06 10:41:20

In this article, I am going to setup a free VPN server and I will use this server for my personal use for 1 year. 

Prerequisite: 
Setup AWS account(which comes with a Free Tier Eligibility for 12 months)


Now before starting you need to decide in which region you want to host the VPN server

![Screenshot 2020-12-06 at 1.14.02 PM](https://dev-to-uploads.s3.amazonaws.com/i/kud4cwnl9i4ucurykg3z.png)

You can check latency across different regions and decide accordingly, and if you have any certain reasons like in my case, some of the Anime on Netflix is only allowed in USA regions so I decided to host my VPN server in the US 😛

## Let’s start
![Screenshot 2020-12-06 at 12.37.50 PM](https://dev-to-uploads.s3.amazonaws.com/i/q8b57lthwv8zydmjuz7m.png)

1. Open EC2 service in AWS
2. Change region from the top to the region where you want to host the VPN server
3. Click on Launch Instance
 

![Screenshot 2020-12-06 at 12.39.14 PM](https://dev-to-uploads.s3.amazonaws.com/i/hnkecv0o7pia1dxprs8k.png)

Next, it will ask you to choose AMI,

We will be using ubuntu machine which already has OpenVPN server installed, so you need to select **AWS Marketplace** and search **OpenVPN**, then you have to select **OpenVPN access server** which has **Free tier eligible** tag


![Screenshot 2020-12-06 at 12.41.30 PM](https://dev-to-uploads.s3.amazonaws.com/i/5aqk74ohgrkz3s8gf224.png)

 
> OpenVPN is a free and Open Source VPN, but it’s a commercial service but although we can be allowed to open two VPN accounts for free without being charged anything using the Bring Your Own License(BYOL) option and that’s the essence of the page being displayed here.



![Screenshot 2020-12-06 at 12.41.47 PM](https://dev-to-uploads.s3.amazonaws.com/i/bau3qcv063fhtkm1jznc.png)

Choose an Instance Type
1. Select t2.micro which has `Free tier eligible` tag
2. Click on "Review and Launch"

![Screenshot 2020-12-06 at 12.42.39 PM](https://dev-to-uploads.s3.amazonaws.com/i/8f6xvl4mou18f9hny8z6.png)

Select Launch

![Screenshot 2020-12-06 at 12.43.04 PM](https://dev-to-uploads.s3.amazonaws.com/i/7p1r9bpv5qen6pjclnyo.png)

Now you will see a pop-up like above
1. Choose `Create a new key pair`
2. Type key pair name(which can be any string)

3. **Download key pair(Note: It is important to Save this file properly, you will need this file to ssh to this machine)**  

4. Click Launch Instance

![Screenshot 2020-12-06 at 12.43.48 PM](https://dev-to-uploads.s3.amazonaws.com/i/dp87kgwik9dcj3iu7w9u.png)

![Screenshot 2020-12-06 at 12.44.53 PM](https://dev-to-uploads.s3.amazonaws.com/i/awnjo0v2cyflny09nnkm.png)

Now connect to this instance by choosing to connect

![Screenshot 2020-12-06 at 12.45.25 PM](https://dev-to-uploads.s3.amazonaws.com/i/cnilvm4i3z97ful0ljgv.png)

In the SSH-client tab, you will see how to connect to this machine using SSH

![Screenshot 2020-12-06 at 12.53.48 PM](https://dev-to-uploads.s3.amazonaws.com/i/sbdkmudbjchmvz6amgy0.png)

1. Open terminal or PowerShell
2. Change the permission of the private key file if required
3. Now SSH to the machine as a root user in order to configure the admin side of the VPN
```
ssh -i "/<path_of_the_file>/<your-key-pair>" root@<your-public-instance-domain>
```

![Screenshot 2020-12-06 at 1.00.24 PM](https://dev-to-uploads.s3.amazonaws.com/i/g3bp369lffdqwzpwxj80.png)

Press yes and enter

![Screenshot 2020-12-06 at 1.02.33 PM](https://dev-to-uploads.s3.amazonaws.com/i/m3nvfrm2ofq7o0tfkqsk.png)

Now keep pressing enter if you want to have a default setting for VPN

After it's done you’ll see an instruction to no longer login as root but as user `openvpnas` which is created by default.


![Screenshot 2020-12-06 at 1.04.20 PM](https://dev-to-uploads.s3.amazonaws.com/i/62sak1nwkqd0wmz5xh8j.png)

Now SSH to the instance again, but not as root but as user “openvpnas” using the command below:
```
ssh -i "/<path_of_the_file>/<your-key-pair>" openvpnas@<your-public-instance-domain>
```


Now you have to create a password for this user so that you can access the admin and client page of the OpenVPN portal
```
sudo passwd openvpn
```


![Screenshot 2020-12-06 at 1.05.12 PM](https://dev-to-uploads.s3.amazonaws.com/i/iy1j6qboio192nd001q9.png)

Now get the public IP of the instance and type in the browser
like below:
`http://<public IP address>:943/admin`

Enter username -> `openvpn`, password -> <as you set in the previous step>

Click sign in

![Screenshot 2020-12-06 at 1.05.28 PM](https://dev-to-uploads.s3.amazonaws.com/i/ns3fz2e4212lccznzts3.png)

Agree on T&C

![Screenshot 2020-12-06 at 1.05.47 PM](https://dev-to-uploads.s3.amazonaws.com/i/ezym09jrrfx33kq7f1wt.png)
 


Now on this page, select `VPN setting`
![Screenshot 2020-12-06 at 1.06.21 PM](https://dev-to-uploads.s3.amazonaws.com/i/dn71kykteavq5a3omu82.png)
 
 
Scroll down and find `Should client Internet traffic be routed through the VPN?` and enable this

![Screenshot 2020-12-06 at 1.06.29 PM](https://dev-to-uploads.s3.amazonaws.com/i/qpyjpz1wf4qqgiov90yt.png)
 

Scroll down and save the settings

![Screenshot 2020-12-06 at 1.06.38 PM](https://dev-to-uploads.s3.amazonaws.com/i/5769epodsqttwb2lgc6t.png)
 

When you change the settings, you’ll need to update the server, so click on “Update Running Server”


![Screenshot 2020-12-06 at 1.07.05 PM](https://dev-to-uploads.s3.amazonaws.com/i/3l1x89zrl3qucj4cyuhf.png)


Now to connect to this VPN, go to a new tab in browser and type
`http://<public IP address>:943/`


![Screenshot 2020-12-06 at 1.07.20 PM](https://dev-to-uploads.s3.amazonaws.com/i/wfynd39jxaw9y8wbtdv8.png)
 
Choose a device for which you want to download OpenVPN client

![Screenshot 2020-12-06 at 1.08.42 PM](https://dev-to-uploads.s3.amazonaws.com/i/vnynz15dchzd6ga719w5.png)
I downloaded for mac device and installed it now open the app and click on + icon

![Screenshot 2020-12-06 at 1.08.59 PM](https://dev-to-uploads.s3.amazonaws.com/i/7giq53rbkae8bunjzzqh.png)
 
Now enter the public IP address of the ec2 machine
![Screenshot 2020-12-06 at 1.09.18 PM](https://dev-to-uploads.s3.amazonaws.com/i/cik98zml4iy12u26ujzh.png)

Enter username and password(It is same that you used to login for admin panel) 
Congrats, Now you have successfully connected to the VPN

You can also check your IP by googling `what is my IP`



Thanks