[Lab] Amazon VPC - Using NAT Instance & NAT Gateway

This is a continuation to the lab ‘Creating and Using Amazon VPC – Part 1’. We will use NAT instance and NAT gateway to allow the private server to access internet in a secure way.

 

Steps:

  1. Launch a new EC2 instance as NAT instance

    1. Select an AMI with NAT configuration (e.g. one that starts with amzn-ami-vpc-nat from community AMIs).

    2. Select our VPV and select our public subnet.

    3. Create / Select a security group with HTTP and HTTPS. Can reuse the same security group used for the public instance and add HTTPS.

      1. HTTPS is not actually required, but good to have as per Amazon recommendation.

  2. Once instance is started disable Source/Destination check for the instance under Actions > Networking.  

  3. Go to VPC Dashboard > Route Tables and select default Route table for our VPC (not the public route table we created).

    1. Click Edit

    2. Provide a route out entry: Destination as 0.0.0.0/0, Target as our NAT instance.

    3. Click save

  4. SSH into private instance through the public instance (as we did in previous lab).

  5. Try running: yum update  -y

    1. Update should be successful.

  6. Terminate the NAT instance

  7. Try installing mysql: yum install mysql –y

    1. It will get stuck at download packages as there is no valid route out.

  8. Go to VPC Dashboard and go to NAT Gateways

    1. Click Create NAT Gateway

    2. Provide public subnet

    3. Click on Create New Elastic IP (May reuse if you already have on in pool)

    4. Click Create a NAT Gateway

    5. On success, it will show a message that: In order to use your NAT Gateway, ensure that you edit your route tables to include a route with a target of <nat-gateway-name>.

  9. Go to Route Tables and select default Route table for our VPC (not the public route table we created).

    1. Click Edit

    2. Delete the obsolete entry for NAT instance (status should be Black Hole).

    3. Provide a route out entry: Destination as 0.0.0.0/0, Target as our NAT gateway.

    4. Save

  10. Try installing mysql: yum install mysql –y

    1. It should install mysql successfully.

Learn Serverless from Serverless Programming Cookbook

Contact

Please first use the contact form or facebook page messaging to connect.

Offline Contact
We currently connect locally for discussions and sessions at Bangalore, India. Please follow us on our facebook page for details.
WhatsApp (Primary): (+91) 7411174113
Phone (Escalations): (+91) 7411174114

Business newsletter

Complete the form below, and we'll send you an e-mail every now and again with all the latest news.

About

CloudMaterials is my blog to share notes and learning materials on Cloud and Data Analytics. My current focus is on Microsoft Azure and Amazon Web Services (AWS).

I like to write and I try to document what I learn to share with others. I believe that knowledge is useless unless you share it; the more you share, the more you learn.

Recent comments

Photo Stream