Tech Junkie Blog - Real World Tutorials, Happy Coding!: Iaas With AWS: VPC With Public And Private Subnets, Create NAT Gateway For Private Subnet

Monday, October 26, 2020

Iaas With AWS: VPC With Public And Private Subnets, Create NAT Gateway For Private Subnet

 In the previous post  we created a public and private subnet in our VPC.  In this post we are going to create a NAT gateway so that our private instances can access the internet.  That's useful when there's a need to update the instance.  For example if we ping right now there will be 100% package lost in our private instance because we cannot get to the internet.  After we attach the instance to the NAT gateway we will be able to ping google.

It would go on for a while but eventually it would say the package is lost.

Now let's create our NAT Gateway, it is important that we delete the NAT Gateway if it's not in use because you have to pay for it.

Go to the VPC dashboard and click on "NAT Gateways" link, then select "Create NAT Gateway" button.

You can give it a name if you want, but you have to assign it a public subnet and click on the "Allocate Elastic IP" to assign an Elastic IP to the NAT Gateway which it needs, click on "Create NAT Gateway" button at the bottom when finished.d

A new NAT gateway is created, now we have to route it in the private subnet routing table.

Click on the "Route Tables" and select the private subnet routing table, click on the "Routes" tab and click on "Edit routes" button

Type in the "Destination" field to allow all traffic in the private subnet and select the "Target" as the NAT Gateway

Click on "Save routes" button.  Now if you go back to the private instance in the private subnet you should be able to ping meaning you can get to the internet. No package is lost!

Now you can run yum update on the instance in the private subnet, which is probably more useful then pinging


  1. This was a great article. It is very helpful and informative. Thanks for sharing such kind of article.
    Keep up sharing such kind of article about DIgital Marketing.

  2. Thank you for sharing good knowledge and information it's very helpful and understanding.. as I have been looking for this information for a long time. Regards सटका मटका


Search This Blog