I have a VPC with several ec2 instances. Each one has a public ip + is able to communicate with each other over local 10.0.0.0 network + have internet access over internet gateway.
I need to put only several of those instances behind NAT Gateway with Elastic IP assigned to it, so when they connect to a certain outside service, they have the same public ip.
The problem is that I can't find a way to put only certain members of VPC behind this NAT Gateway. I can edit routing table for the VPC in general & that's it.
I couldn't find a way to create another VPC & include only certain members of the first VPC into it.
So what is the best way to do that?
P.S. it is a NAT Gateway, not a NAT instance.
So i have created a new subnet for the VPC, created a new network interface & attached it to one of the instances: The instance got the new ip from this subnet & the new route was created automatically:
# route Kernel IP routing table Destination Gateway Genmask Flags Metric Ref Use Iface default ip-10-0-1-1.ec2 0.0.0.0 UG 0 0 0 eth0 default ip-10-0-200-1.e 0.0.0.0 UG 10001 0 0 eth1 10.0.1.0 * 255.255.255.0 U 0 0 0 eth0 10.0.200.0 * 255.255.255.0 U 0 0 0 eth1 instance-data.e * 255.255.255.255 UH 0 0 0 eth0