Table of contents
VPN stands for Virtual private network this is a technology that allows us to establish a secure connection between the client(our machine) and the internet here we are routing our internet traffic through an encrypted tunnel to a server
Types of VPN -
Mobile VPN - used for personal devices (such as mobile, tables) exp-public hotspots, wifi etc
Site-to-Site VPN - used to connect to two or more networks over the internet (such as router-to-router) exp-Business having different branches, offices or data
Remote Access VPNs-used to connect to private networks over the internet while establishing a connection of tunnel
Public VPNs used for personal use encrypt your internet traffic change your IP exp-Public wifi, online Gaming
How VPN Works?
whenever we send some request to our internet our ISP provider receives the request and redirects it to our destination(Mac address)
but when we are associated with any VPN it redirects the traffic to that private server or remote server before sending the information to the destination
Create a VPN Server
Prerequisites - How to create VPC on AWS
Step -1 Update your system
create an ec2 instance of Ubuntu server 20.04
Run this command
sudo apt update && sudo apt -y full-upgrade
Step-2 Add Pritunl and MongoDB repositories and Public keys
Add Pritunl and MongoDB repositories and public keys
echo "deb http://repo.pritunl.com/stable/apt $(lsb_release -cs) main" | sudo tee /etc/apt/sources.list.d/pritunl.list
MongoDB repository
sudo tee /etc/apt/sources.list.d/mongodb-org-6.0.list << EOF deb https://repo.mongodb.org/apt/ubuntu $(lsb_release -cs)/mongodb-org/6.0 multiverse EOF
add Public keys
curl -fsSL https://www.mongodb.org/static/pgp/server-6.0.asc|sudo gpg --dearmor -o /etc/apt/trusted.gpg.d/mongodb-6.gpg curl -fsSL https://raw.githubusercontent.com/pritunl/pgp/master/pritunl_repo_pub.asc|sudo gpg --dearmor -o /etc/apt/trusted.gpg.d/pritunl.gpg sudo apt update
Step-3 Install Pritunl and MongoDB
Install Pritunl and MongoDB with this command
sudo apt --assume-yes install pritunl mongodb-org
start and Enable Pritunl mong-DB
sudo systemctl start pritunl mongod sudo systemctl enable pritunl mongod
Step-4 Configure Pritunl on Ubuntu ec2 instance
check your Pritunl and whether MongoDB is running or not
sudo systemctl status pritunl mongod
Permit your ec2 instance and allows traffic
Copy your Public IP address and Paste it into your browser
You will see that page
Run this command to get your setup-key
sudo pritunl setup-key
You will get your key here
Once you enter your key it will prompt you your username and password
type the command given below and you will get your username and password
sudo pritunl default-password
Log in with your private credentials Set your new password and save it
Now go to your Dashboard and Add users Click on Users
Click on Add Organization
Click on a server Add Server
Attach Organization
Step-5 Configure Pritunl Client on Ubuntu Run these commands to your ec2 VPN server or Local machine
sudo tee /etc/apt/sources.list.d/pritunl.list << EOF deb https://repo.pritunl.com/stable/apt $(lsb_release -cs) main EOF curl -fsSL https://raw.githubusercontent.com/pritunl/pgp/master/pritunl_repo_pub.asc|sudo gpg --dearmor -o /etc/apt/trusted.gpg.d/pritunl.gpg sudo apt update sudo apt install pritunl-client-electron
Once the client is installed go to the server and download the profile
after importing the profile you will see
Now connect your Client with your pritunl server
In your Public VPN server try to access Private ec2 of VPC
Try to Access it from your local machine
Conclusion -
we can access our private ec2 instance from our local Machine as well as through my VPN server Creating a VPN tunnel between my VPN server and the internet