DEV Community

Osman Akin for AWS Community Builders

Posted on

AWS VPN (Client VPN) with VGW

A Virtual Private Network (VPN) apparently is a private secure connection between two devices that is achieved using encryption over a public network, typically the internet.

We will be working on 2 project:

  1. AWS Client VPN - Client-to-Site(AWS Cloud).
  2. AWS Site-to-Site - On-premises/cloud-to-site(AWS Cloud).

What is AWS Client VPN? AWS Client VPN is a managed client-based VPN service that enables you to securely access AWS resources and resources in your on-premises network - AWS Documentation.

Project 1:
In this task, we will be working with AWS client VPN.

Outlines:

  • I have my Windows 10 Laptop on-premises.
  • I have a windows server in a private subnet in us-east-2 (Ohio).
  • We will need SSL for mutual authentication, this can be created using EasyRSA on cmd and upload to AWS Certificate Manager (ACM)
  • I have my VPC created which consist of 2 subnet and 2 route table (private and public).
  • I have my server launched in the private subnet which can't be accessed from the internet.

STEPS:
**Login to your AWS account and search VPC, click on VPC.
On the left hand side. Expand Virtual Private Network (VPN)

  • Click on Virtual Private Gateway (VGW)** Image description
  • Under VGW. Click create virtual private gateway Image description
  • Once created. click on Action then select Attach to VPC. Image description
  • Under state "Attaching", refresh and wait for few minute and state shows "Attached". Image description On the left hand side. Expand Virtual Private Network (VPN) Click on Customer Gateway. Image description Click create Customer Gateway.
  • Input your ASN or leave default
  • Enter your public IP address for customer device. Image description Create customer gateway. Image description

Create certificates and keys and upload them to ACM
The following procedure installs Easy-RSA 3.x software and uses it to generate server and client certificates and keys and upload them to ACM.

Copy the link and open in your broswer. Download the latest EasyRSA zip file for your windows and extract it..

https://github.com/OpenVPN/easy-rsa/releases
Image description

Open a command prompt and navigate to the location that the EasyRSA-3.x folder was extracted to.
Image description
Open the EasyRSA-Start.bat via CMD or Naviha=gate to the EasyRSA folder.
Image description
Run the following command to open the EasyRSA 3 shell.

  • Initialize a new PKI environment. # ./easyrsa init-pki Image description
  • To build a new certificate authority (CA), run this command and follow the prompts. # ./easyrsa build-ca nopass Image description
  • Generate the server certificate and key. # ./easyrsa build-server-full server nopass Image description
  • Generate the client certificate and key. # ./easyrsa build-client-full client1.domain.tld nopass Image description

You can optionally repeat this step for each client (end user) that requires a client certificate and key.

Exit the EasyRSA 3 shell.

I will create a custom folder by using the mkdir command, then copy the server certificate plus key and the client certificate plus key to the custom folder.

C:\Program Files\EasyRSA-3.x> mkdir C:\custom_folder
C:\Program Files\EasyRSA-3.x> copy pki\ca.crt C:\custom_folder
C:\Program Files\EasyRSA-3.x> copy pki\issued\server.crt C:\custom_folder
C:\Program Files\EasyRSA-3.x> copy pki\private\server.key C:\custom_folder
C:\Program Files\EasyRSA-3.x> copy pki\issued\client1.domain.tld.crt C:\custom_folder
C:\Program Files\EasyRSA-3.x> copy pki\private\client1.domain.tld.key C:\custom_folder
C:\Program Files\EasyRSA-3.x> cd C:\custom_folder

Image description
Upload the server certificate plus key and client certificate plus key to ACM. Be sure to upload them in the same Region in which you intend to create the Client VPN endpoint.

On the Search Bar, search for ACM, click on ACM.
Image description
On ACM page, click on import a certificate.
Image description

I will navigate to my computer folder where i have the certificates and key, open with notepad to copy the details then paste on ACM.
Image description
First. I will copy and paste the server cert, key and ca into ACM and import
Image description
Done. Next. i will copy the client cert, key and ca into ACM and import.
Image description
Both Certificates are on ACM and can be seen under list of certificates.
Image description

Let's create the AWS Client VPN Endpoints
Image description

Click create client VPN Endpoint.

Input the information like client IP address - private ip address that will be allocated to the client devices
I selected mutual authentication using server and client certificate we created earlier via EasyRSA and ACM.
You can select user-based authentication if you have active directory setup.
I will recommend you enable split-tunnel. you can also enable connection logs for monitoring client connectivity and troubleshooting.
Image description
Image description
Once you've filled the correct information. click create
Image description

While the status state is pending-association.
Under Target network association. Click on associate target network
Image description
Select the VPC where you have your server. and select the subnet then associate the target network.
Image description

Under Association rules. Click on add association rule.
Image description
Enter the destination network, in my case i used the private subnet IPv4 CIDR address where my servers are located.
Image description
Once added, your client vpn endpoint status should now be "Available".

Now head over to your private route table, under Route Propagation click on edit route propagation
Image description
Enable Propagation for the virtual private gateway and save.
Image description

Now. Let's Download the Client configuration.
Image description
Once downloaded, open the downloaded-client-config.ovpn file as notepad.
Scroll to the end of the page inbetween and reneg-sec 0 input the cert and key.
Image description
e.g



client1.domain.tld cert


client1.domain.tld private key

reneg-sec 0
You copy and paste the client certificate and key then save the notepad.
Download OpenVPN or AWS VPN Client
Image description
click on manage profiles, then Add Profile. Input a display name and attach the .ovpn file.
Image description

Click Add Profile and connect.
Image description
The welcome Banner configured and VPN connected.
Image description
using ipconfig and see the IP address we configured for client IPV4
Image description

Now let access our server in the AWS cloud residing in a private subnet(us-east-2b)

I will be connection via RDP port 3389 to my window server
Image description
Image description
Now i am successfully logged in and can perform task on the server.
Image description

You can have more than one server in the private subnet and access everyone of them via AWS VPN Client.

Ciao! Thank you so much for reading and i hope my write up is informational. I will be writing on AWS Site-to-Site VPN real soon.

For more steps and guidelines. You can check out AWS Document: https://docs.aws.amazon.com/vpn/latest/clientvpn-user/user-getting-started.html#install-client

Top comments (0)