Setting Up AWS VPC NAT Gateway

Spread the love


Hi,

In this post of devOpsJourney , you will see how to setup “VPC NAT Gateway in AWS”.

If there is a requirement when you want to enable private subnet to initiate outbound traffic to the Internet and at the same time you also want to prevent the instances from receiving inbound traffic initiated by someone on the Internet. You can use a network address translation (NAT) instance in a public subnet in your VPC.

Now AWS has made it very easy by launching VPC NAT Gateway. With this feature now you don’t need to setup NAT Instance manually in public subnet. Instead you can follow VPC NAT Gateway wizard, and setup NAT Instance on the fly. Also there is no need to manage and scale gateway.

Here are the steps :

 

Step 1: Go to VPC and click on NAT Gateway on left Menu Panel.

1

 

 

 

Step 2 : Select the Public Subnet in which you want to launch the Gateway and Assign a Elastic IP. Create a new Elastic IP if you don’t have .

2

 

Step 3: It should look like similar to this. Click on Create a NAT Gateway.

3

 

Step 4 : Once Clicked it will take few moments to create.

 

4

Step 5: Wait till status become available.

4-2

 

Step 6 : Update the Route Table attached to your Private subnet.

5

 

 

 

 

 

 

 

 

Step 7 : Mention the Gateway Id in Target.

6

 

 

 

 

 

 

 

 

Step 8 : It should look like similar to this once saved.

7

Step 9 : Now in order to test VPC NAT Gateway, Launch two Instance – one in public subnet and one in Private Subnet. Public Subnet Instance will work as Jump Host for Private Subnet Instance as you can not login directly to Private Subnet Instance.

8

 

Step 10 : Login to Instance in Public Subnet.

9

 

 

 

 

 

 

 

 

 

 

 

Step 11 : Now Login to Private Subnet Instance using its Private IP.

10

 

 

 

 

 

 

 

 

 

 

 

Step 12 : Try to ping an URL .

11

 

 

 

 

 

 

 

 

 

 

 

Step 13 : Try to wget the Index Page.

12

 

 

 

 

 

 

 

 

 

 

 

 

We are able to ping the URL and Download the content from Private Subnet Instance. Hence this VPC NAT Gateway is working for us.

So In this way , we can setup VPC NAT Gateway in AWS and can access internet in Private Subnet Instances behind NAT.

This was all about our post. Let us know if you have any questions, suggestions, feedback. We ‘ll surely look into this.




Thanks.

— Ishant
Share with your network.

2 comments

Leave a Reply

Your email address will not be published. Required fields are marked *