Score:0

How to setup a NAT Gateway together with a VPN in AWS

us flag

I have a VPN setup following this guide. I connect to the VPN from my Mac and I can confirm that both, my Mac as well as EC2 instances do have access to internet. However, for this to work, all my EC2 instances need to have a public static v4 IP. And I don't really want them to have a public IP for these EC2 instances but I do want internet connection. Of course, if I create a EC2 instance without public IP, then I have no internet connection from such instance.

From what I have been reading, I need a NAT Gateway. The problem is that I am not sure how to setup this in combination with the VPN setup I have.

Currently, this is what I have:

  • I have a VPC with IPv4 CIDR 172.31.0.0/16 and 3 subnets 172.31.32.0/20, 172.31.0.0/20 and 172.31.16.0/20
  • The VPC has an internet gateway attached.
  • I have a Client VPN endpoints with Client CIDR 10.0.0.0/22 and it has one of the subnets associated as "Target network associations". The one with 172.31.0.0/20.
  • The endpoint has a security group which does have a Outbound rules to allow all traffic.
  • The endpoint has a "Authorization rules" to allow all the VPC and Destination CIDR 172.31.0.0/16 and another rule for destination 0.0.0.0/0.
  • The endpoint has a "Route table" to allow all traffic for the selected subnet (172.31.0.0/20)

Any help would be appreciated.

Tim avatar
gp flag
Tim
Please edit your question to add a diagram if you want detailed help, lists of IPs and configurations is more difficult to understand. Generally though, you set up your NAT Gateway in a public subnet and route private IPs to the VPN and all other IPs to the NAT Gateway.
palvarez avatar
ki flag
As said before, generally, you would configure your public subnet with route 0.0.0.0/0 to your IGW, and a NAT; while your private subnet with route 0.0.0.0/0 to the NAT and 10.0.0.0/22 to the VPN.
Score:0
us flag

I got an answer on another forum and I thought it was worth sharing it here.

I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.