0
votes

I have a VPC with a public subnet and an internet gateway.

Route table is configured to route 0.0.0.0/0 with Internet Gateway. Currently instances has access to the internet and are accessible from the outside via instance public IP address.

What I am trying to achieve is :

  • instances in the public subnet should still be accessible from the internet via instance public IP address
  • but all outbound traffic from instance should be routed through a single point and all outbound traffic should have a single IP address.

I am aware that I could configure route table to use NAT for 0.0.0.0/0 and all outbound traffic will have a NAT's IP address, but in this case instances are not accessible from the outside via instance public IP.

1

1 Answers

2
votes

The normal way to achieve this is by deploying your EC2 instances in a private subnet behind a load balancer for ingress traffic and then to use a NAT Gateway for the egress traffic from the EC2 instances to the rest of the world.