1
votes

Lets assume I have a VPC (172.16.0.0/16) with Public (172.16.0.0/24) and Private (172.16.1.0/24) subnets. Also I have one Internet Gateway (172.16.0.1/24) and one NAT Gateway (172.16.1.x/24). Note that the last bit is x, as IP address is assigned dynamically.

When I spawn an instances in the public subnet the default gateway is configured like so:

default via 172.16.0.1 dev eth0

When I spawn an instance in the private subnet I would like that instance had the default gateway configured like so:

default via 172.16.1.x dev eth0

Note: x in the last bit of the IP should match NAT-GW IP address.

At present I have to manually configure routing, thus change default gateway and add explicit route to other subnet:

default via 172.16.1.x dev eth0
172.16.0.0/24 via 172.16.1.1 dev eth0

Things like these should be possible to configure via DHCP, but aws DHCP seems to have a very limited set of settings.

EDIT - Route Tables:

Private subnet

172.16.0.0/16 local Active No
0.0.0.0/0 nat-id Active No

Public subnet

172.16.0.0/16 local Active No
0.0.0.0/0 igw-id Active No
1
Did you create your VPC manually or using the wizard in the dashboard?helloV
I'm not sure how it was created, I'm just taking it over from someone else. What difference does it make anyway?NarūnasK
It makes a lot a difference. You wouldn't be asking questions like this.helloV

1 Answers

1
votes

I would guess that your routing table for the private subnets needs some attention and may need to be directed to a NAT instance to allow passage to the public internet. What do the route tables for your private subnets looks like? This should help you out as well - http://docs.aws.amazon.com/AmazonVPC/latest/UserGuide/VPC_Scenario2.html

Thanks, //P