What is VPN ? How to connect with Internet using VPN

What is VPN ? How to connect with Internet using VPN

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 -

  1. Mobile VPN - used for personal devices (such as mobile, tables) exp-public hotspots, wifi etc

  2. 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

  3. Remote Access VPNs-used to connect to private networks over the internet while establishing a connection of tunnel

  4. Public VPNs used for personal use encrypt your internet traffic change your IP exp-Public wifi, online Gaming

    How VPN Works?

    1. whenever we send some request to our internet our ISP provider receives the request and redirects it to our destination(Mac address)

    2. 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

  1. create an ec2 instance of Ubuntu server 20.04

  2. Run this command

  3.     sudo apt update && sudo apt -y full-upgrade
    

Step-2 Add Pritunl and MongoDB repositories and Public keys

  1. 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
    
  2. 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
    
  3. 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

    1. Install Pritunl and MongoDB with this command

       sudo apt --assume-yes install pritunl mongodb-org
      
    2. start and Enable Pritunl mong-DB

       sudo systemctl start pritunl mongod
       sudo systemctl enable pritunl mongod
      

      Step-4 Configure Pritunl on Ubuntu ec2 instance

      1. check your Pritunl and whether MongoDB is running or not

         sudo systemctl status pritunl mongod
        
    3. Permit your ec2 instance and allows traffic

    4. Copy your Public IP address and Paste it into your browser

      You will see that page

    5. Run this command to get your setup-key

       sudo pritunl setup-key
      
    6. You will get your key here

  1. Once you enter your key it will prompt you your username and password

  2. type the command given below and you will get your username and password

     sudo pritunl default-password
    

  1. Log in with your private credentials Set your new password and save it

  1. Now go to your Dashboard and Add users Click on Users

  1. Click on Add Organization

  2. Click on a server Add Server

  1. 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
    
    1. Once the client is installed go to the server and download the profile

  1. after importing the profile you will see

    1. Now connect your Client with your pritunl server

    2. In your Public VPN server try to access Private ec2 of VPC

  1. 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