Skip to content

🔒 This project demonstrates secure Site-to-Site VPN connection ⚡ between AWS server and On-Premise server (Simulated via Azure VM), showcasing hybrid/multi-cloud ☁️architecture with detailed StrongSwan IPsec configuration, tunnel setup and practical examples for establishing cross-cloud private communication.

Notifications You must be signed in to change notification settings

AbhayGhante/aws-azure-site-to-site-vpn

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 

Repository files navigation

AWS Site-to-Site VPN Connection With On-Premise Server ⛓️‍💥

This project demonstrates the implementation of a Site-to-Site VPN connection between AWS and an on-premises server (Simulated via Azure Cloud), creating a secure hybrid/multi-cloud architecture. This setup enables seamless communication between cloud environments while maintaining security and network isolation.

🏗️ Architecture Overview

Archietecture Diagram

The implementation creates a secure tunnel between:

  • AWS VPC: 200.0.0.0/16 CIDR block
  • Azure VM (On-Premises Simulation): 100.0.0.0/16 CIDR block

Phase 1️⃣: Azure On-Premises Server Setup

Step 1: Create Resource Group rg-s2s

Resource Group Creation Screenshot

Step 2: Deploy Virtual Machine

Deploy the VM that will simulate our on-premises server.

Configuration Details:

  • VM Name: vm-s2s
  • Username: user-s2s
  • Virtual Network: vnet-s2s (100.0.0.0/16)
  • Subnet: subnet-s2s (100.0.0.0/16)
  • OS: Any Linux Machine (Amazon Linux in my case)

VM Subnet Creation Screenshot VM Created

Phase 2️⃣: AWS VPC Infrastructure Setup

Step 1: Create Virtual Private Cloud (VPC)

  • VPC Name: vpc-s2s
  • IPv4 CIDR: 200.0.0.0/16

VPC Creation Screenshot

Step 2: Create Subnet

  • Subnet Name: subnet-s2s
  • VPC: vpc-s2s
  • Subnet IPv4 CIDR: 200.0.0.0/16

Subnet Creation Screenshot

Step 3: Rename Route Table

Rename the automatically created route table.

  • Route Table Name: rt-s2s
  • Associated VPC: vpc-s2s

Route Table Rename Screenshot

Step 4: Associate Subnet with Route Table

Link route table to our subnet subnet-s2s using edit subnet association option.

Subnet Association Screenshot

Phase 3️⃣: VPN Gateway Configuration

Step 1: Create Virtual Private Gateway

  • VPGW Name: vpgw-s2s

Virtual Private Gateway Setup Screenshot Virtual Private Gateway Setup Screenshot

Step 2: Attach VPGW to VPC

Connect the Virtual Private Gateway to our VPC vpc-s2s.

VPG Attachment Screenshot

Step 3: Update Route Table

Add routing rules to direct traffic on virtual private gateway to on-premise server.

  • Destination: 100.0.0.0/16
  • Target: Virtual Private Gateway (vpgw-s2s)

Route Table Update Screenshot Route Table Update Screenshot

Step 4: Create Customer Gateway

Configuration Parameters:

  • Name: cgw-s2s
  • IP Address: [On-Prem/Azure VM Public IP]

Customer Gateway Creation Screenshot Azure VM Public IP Screenshot Customer Gateway Creation Screenshot

Step 5: Create Site-to-Site VPN Connection

Configuration Parameters:

  • Target Gateway: Virtual Private Gateway (vpgw-s2s)
  • Customer Gateway: cgw-s2s
  • Static IP Prefix: 100.0.0.0/16

VPN Connection Screenshot VPN Connection Screenshot

Step 6: Download VPN Configuration

Once the VPN connection is established, download the configuration file as per the vpn client, which is strongswan in my case.

VPN Config Download Screenshot

Phase 4️⃣: StrongSwan VPN Client Setup

Step 1: Install StrongSwan

SSH into the Azure VM and install the StrongSwan client.

Connect to Azure VM:
ssh user-s2s@[AZURE_VM_PUBLIC_IP]

Install StrongSwan:

sudo apt update
sudo apt install strongswan -y

StrongSwan Installation Screenshot

Step 2: Enable IP Forwarding

Configure the system to forward IP packets.

Edit sysctl configuration:

sudo nano /etc/sysctl.conf

Uncomment the following line:

net.ipv4.ip_forward = 1

Enable IP Forwarding Screenshot

Save and verify changes:

sudo sysctl -p

Step 3: Configure VPN Tunnels

Modify the downloaded VPN configuration file with correct subnet information.

Configuration Updates For Both Tunnel:

  • leftsubnet: 100.0.0.0/16 (On-Prem/Azure Network Subnet)
  • rightsubnet: 200.0.0.0/16 (AWS VPC Subnet)

VPN Config Modification Screenshot

Step 4: Update IPsec Configuration

Edit the IPsec configuration file:

sudo nano /etc/ipsec.conf

Configuration changes:

  • Uncomment uniqueids = no
  • Add updated tunnels configurations from downloaded file.

IPsec Configuration Screenshot

Note: Screenshot has mistake in showing the name of subnet, leftsubnet is of Azure and rightsubnet is of AWS.

Step 5: Configure IPsec Secrets

Add the pre-shared keys for both tunnels given in configuration file.

Edit IPsec secrets file:

sudo nano /etc/ipsec.secrets

Paste keys from 4th section of each tunnel in configuration file.

IPsec Secrets Configuartion Screenshot

Step 6: Reload Strongswan & IPSec

Restart and verify services.

Restart StrongSwan service:

sudo systemctl restart strongswan-starter
sudo systemctl status strongswan-starter

Restart IPsec service:

sudo service ipsec restart
sudo service ipsec status

IPSec Service Status Screenshot

Phase 5️⃣: Connection Verification

Step 1: Verify Tunnel Status On Azure

Check the on-premise tunnel status:

sudo ipsec status

On-Prem Tunnel Status Screenshot

Both the tunnels show established! 🤩

Step 2: Verify Tunnel Status on AWS

Check the VPN connection status in AWS VPN tunnel details.

AWS Tunnel Status Screenshot

Both the tunnels are up! 🚀

📩 Ping Test

Step 1: Deploy Test EC2 Instance

Create an EC2 instance in the AWS VPC for connectivity testing.

EC2 Configuration:

  • Instance Name: ec2-s2s
  • VPC: vpc-s2s
  • Subnet: subnet-s2s
  • Security Group: Default or Create Custom New
  • Security Group Rules:
    • Target: All ICMP
    • Source: security-group / CIDR Block of On-Prem Server

EC2 Instance Deployement Screenshot

Step 2: Test Connectivity

Verify The Connection By Pinging Each Other's Private IP.

AWS Private IP Connectivity Test Screenshot

✅ Conclusion!

I have successfully implemented Site-to-Site VPN connection between AWS and On-Premise Infrastructure (Simulated via Azure VM) with following achievements:

  • Established secure hybrid cloud connectivity
  • Implemented multi-cloud networking architecture
  • Demonstrated cross-cloud private communication
  • Configured IPsec VPN tunnels

Also, This Setup Can Be Furthur Improved by Utilising Transit Gateway for Multi-VPC Setup.

📝 References

About

🔒 This project demonstrates secure Site-to-Site VPN connection ⚡ between AWS server and On-Premise server (Simulated via Azure VM), showcasing hybrid/multi-cloud ☁️architecture with detailed StrongSwan IPsec configuration, tunnel setup and practical examples for establishing cross-cloud private communication.

Topics

Resources

Stars

Watchers

Forks