> ## Documentation Index
> Fetch the complete documentation index at: https://cloud-architect.ipoint-labs.com/llms.txt
> Use this file to discover all available pages before exploring further.

# How to setup a free VPN server in AWS

> Hands-on lab · 45m

Launch this lab in the IP Lab Portal, then follow the steps below in the AWS console.

<a className="ip-lab-portal-btn" href="https://labs.intellectualpoint.com/labs/how-to-setup-a-free-vpn-server-in-aws" target="_blank" rel="noreferrer">
  Open IP Lab Portal
</a>

## Overview

### Lab details

1. This lab walks you through the steps to launch and configure an EC2 Instance using OpenVPN AMI and how to connect to the VPN.
2. You will practice using OpenVPN Amazon Machine Images to launch Amazon EC2 Instances.
3. Duration: **60 minutes**
4. AWS Region: **US East (N. Virginia) us-east-1**

### Introduction

#### What is an EC2?

* AWS defines it as Elastic Compute Cloud.
* It’s a virtual environment where “you rent” to have your environment created, without purchasing.
* Amazon refers to these virtual machines as Instances.
* Preconfigured templates can be used to launch instances. These templates are referred to as images. Amazon provides these images in the form of AMIs (Amazon Machine Images).
* Allows you to install custom applications and services.
* Scaling of infrastructure i.e., up or down is easy based on the demand you face.
* AWS provides multiple configurations of CPU, memory, storage, etc., through which you can pick the flavor that's required for your environment.
* No limitation on storage. You can pick the storage based on the type of the instance that you are working on.
* Temporary storage volumes are provided, which are called Instance Store Volumes.  Data stored in this gets deleted once the instance is terminated.
* Persistent storage volumes are available and are referred to as EBS (Elastic Block Store) volumes.
* These instances can be placed at multiple locations which are referred to as Regions and Availability Zones (AZ).
* You can have your Instances distributed across multiple AZs i.e., within a single Region, so that if an instance fails, AWS automatically remaps the address to another AZ.
* Instances deployed in one AZ can be migrated to another AZ.
* To manage instances, images, and other EC2 resources, you can optionally assign your metadata to each resource in the form of tags.
* A Tag is a label that you assign to an AWS resource.  It contains a key and an optional value, both of which are defined by you.
* Each AWS account comes with a set of default limits on the resources on a per-region basis.
* For any increase in the limit, you need to contact AWS.
* To work with the created instances, we use Key Pairs.

### Architecture diagram

<img src="https://mintcdn.com/ip-cloud-architect-pathway/O4tXcjEIp2L-crIL/images/labs/how-to-setup-a-free-vpn-server-in-aws/001.png?fit=max&auto=format&n=O4tXcjEIp2L-crIL&q=85&s=095592e757ee2e8a99da8f493ef6b1fb" alt="" width="2796" height="1892" data-path="images/labs/how-to-setup-a-free-vpn-server-in-aws/001.png" />

### Task details

1. Sign in to the AWS Management Console
2. Launching an EC2 Instance
3. SSH into EC2 Instance
4. Initialize the VPN Server
5. Connect to the VPN
6. Validation of the lab
7. Deleting AWS Resources

### Launching the lab environment

1. To launch the lab environment, Click on the **Launch lab** button.
2. Please wait until the cloud environment is provisioned. It will take less than a minute to provision.
3. Once the Lab is started, you will be provided with an **IAM username**, **Password**, **Access** **Key**, and **Secret** **Access** **Key**.

<Note>
  You can only start one lab at any given time
</Note>

## Lab guide

### Lab steps

#### Task 1: Sign in to the AWS Management Console

1. Click on the **Open console** button, and you will get redirected to AWS Console in a new browser tab.
2. On the AWS sign-in page,

   * Leave the Account ID as default. Never edit/remove the 12-digit Account ID present in the AWS Console. Otherwise, you cannot proceed with the lab.
   * Now copy your **User Name** and **Password** in the Lab Console to the **IAM Username and Password** in the AWS Console and click on the **Sign-in** button.
3. Once Signed In to the AWS Management Console, make the default AWS Region as **US East (N. Virginia) us-east-1.**

#### Task 2: Launching an EC2 Instance

In this task, we are going to create and launch an EC2 Instance with the required configurations.

1. Make sure you are in the **N.Virginia** Region.
2. Navigate to **EC2** by clicking on the **Services** menu at the top, then click on **EC2** under **Compute** section.
3. Navigate to **Instances** on the left panel and click on the **Launch Instances** button.
4. Enter Name as **MyVPNServer**
5. **Choose an Amazon Machine Image (AMI):**

   * Click on **Browse more AMIs.**

     <img src="https://mintcdn.com/ip-cloud-architect-pathway/O4tXcjEIp2L-crIL/images/labs/how-to-setup-a-free-vpn-server-in-aws/002.png?fit=max&auto=format&n=O4tXcjEIp2L-crIL&q=85&s=6d64ff6ae13d6a64bdc18ef133e742b1" alt="" width="1222" height="477" data-path="images/labs/how-to-setup-a-free-vpn-server-in-aws/002.png" />

* Search for **Openvpn** in the search box.
* Click on the **Select** button of the **OpenVPN Access Server**

  <img src="https://mintcdn.com/ip-cloud-architect-pathway/O4tXcjEIp2L-crIL/images/labs/how-to-setup-a-free-vpn-server-in-aws/003.png?fit=max&auto=format&n=O4tXcjEIp2L-crIL&q=85&s=9796e1809e4fecb19c60ebca200fab3e" alt="" width="1222" height="485" data-path="images/labs/how-to-setup-a-free-vpn-server-in-aws/003.png" />
* Click on **subscribe on the instance launch.**

<img src="https://mintcdn.com/ip-cloud-architect-pathway/O4tXcjEIp2L-crIL/images/labs/how-to-setup-a-free-vpn-server-in-aws/004.png?fit=max&auto=format&n=O4tXcjEIp2L-crIL&q=85&s=0deb9c99a22d18fb2859a60cca3dffec" alt="" width="1336" height="682" data-path="images/labs/how-to-setup-a-free-vpn-server-in-aws/004.png" />

* Click on the **Continue** button in the popup window.

6. Choose an Instance Type: Enter **t2.micro**

<img src="https://mintcdn.com/ip-cloud-architect-pathway/O4tXcjEIp2L-crIL/images/labs/how-to-setup-a-free-vpn-server-in-aws/005.png?fit=max&auto=format&n=O4tXcjEIp2L-crIL&q=85&s=3c894bcd53eeacf6989aeef176f49a68" alt="" width="1222" height="227" data-path="images/labs/how-to-setup-a-free-vpn-server-in-aws/005.png" />

**Note: Make sure only t2.micro is selected, Else it won't be allowed to launch the EC2 Instance.**

7. **Key Pair:** Choose **Create a new key Pair** hyperlink.

* Key pair name: Enter **MyVPNKey**
* Key Pair Type: Select **RSA**
* Private key file format: Select **.pem**
* Click on the **Create key pair** button to download the key to your local machine.

  <img src="https://mintcdn.com/ip-cloud-architect-pathway/O4tXcjEIp2L-crIL/images/labs/how-to-setup-a-free-vpn-server-in-aws/006.png?fit=max&auto=format&n=O4tXcjEIp2L-crIL&q=85&s=7650d264a0943071af1abc28b9381c9b" alt="" width="1154" height="1118" data-path="images/labs/how-to-setup-a-free-vpn-server-in-aws/006.png" />

8. Under Network Settings:

* The following ports will be automatically enabled :

  <img src="https://mintcdn.com/ip-cloud-architect-pathway/O4tXcjEIp2L-crIL/images/labs/how-to-setup-a-free-vpn-server-in-aws/007.png?fit=max&auto=format&n=O4tXcjEIp2L-crIL&q=85&s=67784ba601a9d46b2b85a56146304358" alt="" width="1222" height="646" data-path="images/labs/how-to-setup-a-free-vpn-server-in-aws/007.png" />

9. Now click on the **Launch Instances** button.
10. Launching a VPN Server may take a few minutes, you may see a message saying that the **Subscription** may take an hour to complete.
11. Scroll down and click on **View Instances** or click to navigate to the instance page
12. **Launch Status:** Your instance is now launching, wait for the complete initialization of the instance till the status changes to **Running.**

<img src="https://mintcdn.com/ip-cloud-architect-pathway/O4tXcjEIp2L-crIL/images/labs/how-to-setup-a-free-vpn-server-in-aws/008.png?fit=max&auto=format&n=O4tXcjEIp2L-crIL&q=85&s=bb6c1e637e05bea2b05e48f7e110819d" alt="" width="1222" height="166" data-path="images/labs/how-to-setup-a-free-vpn-server-in-aws/008.png" />

13. Now click on the **instance ID** and copy the IPv4 Public IP of this instance and place it in your text editor.

<img src="https://mintcdn.com/ip-cloud-architect-pathway/O4tXcjEIp2L-crIL/images/labs/how-to-setup-a-free-vpn-server-in-aws/009.png?fit=max&auto=format&n=O4tXcjEIp2L-crIL&q=85&s=ee13474b6449809c0e975f6b412f2012" alt="" width="1222" height="357" data-path="images/labs/how-to-setup-a-free-vpn-server-in-aws/009.png" />

#### Task 3: SSH into EC2 Instance

* Please note, that the username is **root.** Change the hostname or username to **openvpnas**.
* Please follow the steps to [SSH into EC2 Instance](/aws-cp/support/ssh-into-ec2-instance).

<img src="https://mintcdn.com/ip-cloud-architect-pathway/O4tXcjEIp2L-crIL/images/labs/how-to-setup-a-free-vpn-server-in-aws/010.png?fit=max&auto=format&n=O4tXcjEIp2L-crIL&q=85&s=c909e306f9bf47ff3bfeacc49c4a791a" alt="" width="955" height="219" data-path="images/labs/how-to-setup-a-free-vpn-server-in-aws/010.png" />

#### Task 4: Initialize the VPN Server

1. Please enter 'yes' to indicate your argument \[no]: Enter **yes**
2. Will this be the primary Access Server node?

   * Press ENTER for default \[yes]: Click the **\[enter]** button.
3. Please specify the network interface and IP address to be

   * Press Enter for default \[1]: Click the **\[enter]** button.
4. What public/private type/algorithms do you want to use for the OpenVPN CA?

   * Press ENTER for default \[rsa]: Click the **\[enter]** button.
5. What key size do you want to use for the certificates?

   * Press ENTER for default \[2048]: Click the **\[enter]** button.
6. What public/private type/algorithms do you want to use for the self-signed web certificate?

   * Press ENTER for default \[rsa]: Click the **\[enter]** button.
7. What key size do you want to use for the certificates?

   * Press ENTER for default \[2048]: Click the **\[enter]** button.
8. Please specify the port number for the Admin Web UI.

   * Press ENTER for default \[943]: Click the **\[enter]** button.
9. Please specify the TCP port number for the OpenVPN Daemon

   * Press ENTER for default \[443]: Click the **\[enter]** button.
10. Should client traffic be routed by default through the VPN?

    * Press ENTER for default \[no]: Click the **\[enter]** button.
11. Should client DNS traffic be routed by default through the VPN?

    * Press ENTER for default \[no]: Click the **\[enter]** button.
12. Should private subnets be accessible to clients by default?

    * Press ENTER for default \[yes]: Click the **\[enter]** button.
13. Do you wish to log in to the Admin UI as "openvpn"?

    * Press ENTER for default \[yes]: Click the **\[enter]** button.
    * Type a password for the 'openvpn' account: Enter **Whizvpn123@** and press **\[enter]** and then enter the same password to confirm the password.
14. Please specify your Activation key (or leave blank to specify later): Click the **\[enter]** button.

<img src="https://mintcdn.com/ip-cloud-architect-pathway/O4tXcjEIp2L-crIL/images/labs/how-to-setup-a-free-vpn-server-in-aws/011.png?fit=max&auto=format&n=O4tXcjEIp2L-crIL&q=85&s=8237665d12c85d89dccbb7d20a93418b" alt="" width="1148" height="349" data-path="images/labs/how-to-setup-a-free-vpn-server-in-aws/011.png" />

15. Now login as administrator, open Google Chrome and paste the following URL

    * Syntax : https\://\<IPv4 Public IP>:943/admin/
    * Example: [https://3.239.61.27:943/admin/](https://3.239.61.27:943/admin/)
    * Now you will get a Warning message **Your connection isn't private**, this is because we are not using any SSL certificate for this connection.

<img src="https://mintcdn.com/ip-cloud-architect-pathway/O4tXcjEIp2L-crIL/images/labs/how-to-setup-a-free-vpn-server-in-aws/012.png?fit=max&auto=format&n=O4tXcjEIp2L-crIL&q=85&s=08d208afb40a7fd3ff90c5762eff467a" alt="" width="1222" height="707" data-path="images/labs/how-to-setup-a-free-vpn-server-in-aws/012.png" />

* Click on the **Advanced** Button and see if you have a **proceed to website** option then click on the link.
* If you see the below message instead, then type **thisisunsafe** on the keyboard and the page will automatically reload.

<img src="https://mintcdn.com/ip-cloud-architect-pathway/O4tXcjEIp2L-crIL/images/labs/how-to-setup-a-free-vpn-server-in-aws/013.png?fit=max&auto=format&n=O4tXcjEIp2L-crIL&q=85&s=e6e2cc1fec3af1082b05eff26c799e11" alt="" width="627" height="89" data-path="images/labs/how-to-setup-a-free-vpn-server-in-aws/013.png" />

* You will see a login page like this :

  <img src="https://mintcdn.com/ip-cloud-architect-pathway/O4tXcjEIp2L-crIL/images/labs/how-to-setup-a-free-vpn-server-in-aws/014.png?fit=max&auto=format&n=O4tXcjEIp2L-crIL&q=85&s=0d1b486753c4c0a7cb80cb9ea27464df" alt="" width="988" height="944" data-path="images/labs/how-to-setup-a-free-vpn-server-in-aws/014.png" />

16. Login to the VPN Admin page :

    * Username: Enter **openvpn**
    * Password: Enter **Whizvpn123@**
    * Now click on the **Sign in** button.
17. Now On the License Agreement page click on the **Agree** button.
18. Click on the **VPN Server** option in the left-side menu.
19. To make sure all the internet traffic goes through the VPN, Under **Network Settings**

    * Under **Interface**, make sure you have selected **All Interfaces**, if not select **All Interfaces** and click **Save** on the right corner.

      <img src="https://mintcdn.com/ip-cloud-architect-pathway/O4tXcjEIp2L-crIL/images/labs/how-to-setup-a-free-vpn-server-in-aws/015.png?fit=max&auto=format&n=O4tXcjEIp2L-crIL&q=85&s=a4d6fc980b56eaf147076ac9534bf059" alt="" width="1222" height="567" data-path="images/labs/how-to-setup-a-free-vpn-server-in-aws/015.png" />

#### Task 5: Connect to the VPN

1. Open a new tab in the Google Chrome browser.
2. Paste the url **https\://**\<IPv4 Public IP>**/** Example : [https://100.26.97.202/](https://100.26.97.202/)
3. Login to the VPN User Page :

   * Username: Enter **openvpn**
   * Password: Enter **Whizvpn123@**
   * Now click on the **Sign in** button.
4. Now, based on which operating system you are using, download the VPN connector and install it on your local machine.
5. Open the OpenVPNConnector application and if you see **Onboarding Tour,** just close it.
6. Now again, agree to the terms and conditions.
7. You will be able to see a pre-configured VPN profile, turn on this connection.

<img src="https://mintcdn.com/ip-cloud-architect-pathway/O4tXcjEIp2L-crIL/images/labs/how-to-setup-a-free-vpn-server-in-aws/016.png?fit=max&auto=format&n=O4tXcjEIp2L-crIL&q=85&s=461494f5688ab7a8354db9a70ab9b245" alt="" width="397" height="119" data-path="images/labs/how-to-setup-a-free-vpn-server-in-aws/016.png" />

8. Now again enter the username and password.

   * Username: Enter **openvpn**
   * Password: Enter **Whizvpn123@**
   * Click on the **OK** button.
9. Now you are connected to the VPN

<img src="https://mintcdn.com/ip-cloud-architect-pathway/O4tXcjEIp2L-crIL/images/labs/how-to-setup-a-free-vpn-server-in-aws/017.png?fit=max&auto=format&n=O4tXcjEIp2L-crIL&q=85&s=e96768c469c96310cb37f0514f070f08" alt="" width="385" height="122" data-path="images/labs/how-to-setup-a-free-vpn-server-in-aws/017.png" />

10. Now you can start browsing using a VPN connection.

> ##### DO You Know?
>
> OpenVPN is widely used and trusted by organizations and individuals worldwide for its robust security features, including encryption, authentication, and data integrity. It provides a flexible and scalable solution for establishing secure connections, making it suitable for various use cases, such as remote access to corporate networks, securing public Wi-Fi connections, and creating secure communication channels between different cloud environments.

#### Task 6: Validation Test

1. Once the lab steps are completed, please click on the **Check my work** button on the left side panel.
2. This will validate the resources in the AWS account and display whether you have completed this lab successfully or not.
3. Sample output :

<img src="https://mintcdn.com/ip-cloud-architect-pathway/O4tXcjEIp2L-crIL/images/labs/how-to-setup-a-free-vpn-server-in-aws/018.gif?s=e41566d07601a20d11235fe9a87f9499" alt="" width="1000" height="565" data-path="images/labs/how-to-setup-a-free-vpn-server-in-aws/018.gif" />

#### Task 7: Delete AWS Resources

##### 7.1 Delete EC2 Instance

1. Make sure you are in the **US East (N. Virginia)** Region.
2. Navigate to **EC2** by clicking on the **Services** menu at the top, then click on **EC2** under **Compute** section.
3. Now **Select** the EC2 instance that you have created, click on **Instance State,** and click on the **Terminate** **instance** option.
4. Click on the **Terminate** button and your EC2 will start terminating.

### Completion and conclusion

1. You have successfully created and launched the Amazon EC2 Instance.
2. You have successfully logged into an EC2 instance by SSH.
3. You have successfully Initialized the VPN Server.
4. You have successfully connected to the VPN.

### End lab

1. Sign out of AWS Account.
2. You have successfully completed the lab.
3. Once you have completed the steps, click on **End lab** in the IP Lab Portal and wait till the process is completed

## What gets checked

When you press **Check my work**, the platform verifies each of these:

* **Launch an EC2 Instance** — Check whether an EC2 Instance is launched or not.

## Related help

* [SSH into EC2 Instance](/aws-cp/support/ssh-into-ec2-instance)
