I am setting up a VPN Server to move all resources behind VPN on AWS, which includes moving multiple VPCs.
The simple setup is:
I have a separate VPC (
VPC1) running VPN Server and another VPC (
VPC2) with an EC2 machine.
Let's assume the following CIDRs for VPCs & VPN.
- VPC1: 10.1.0.0/16
- VPC2: 10.2.0.0/16
- VPN: 10.8.0.0/24
Everything is working fine within VPC1.
Now I have enabled VPC Peering between
VPC2, but I am not able to access EC2 machine running in
VPC2 unless I mask the VPN CIDR as following.
iptables -t nat -A POSTROUTING -s 10.8.0.0/24 -o eth0 -j MASQUERADE
But doing so, I lose the source IP of the request. All requests are forwarded as requested by VPN machine.
Let me know if any other information/clarification is required.