" How to Access the Internet via NAT Gateway in AWS VPC."
TABLE OF CONTENTS
Introduction
Setup VPC
Create Subnets
Create an Internet Gateway (IGW)
Setup Route tables
Create a NAT Gateway
Update Private Route Table
Launch Instances
Testing
Conclusion
Introduction
In this post, we'll show you how to set up a NAT Gateway in AWS VPC to allow instances in a private subnet to access the internet.
Setup VPC
Go to the VPC Dashboard in AWS Management Console.
Click "Create VPC."
Create Subnets
Create an Internet Gateway
In the VPC Dashboard, click "Internet Gateways."
Click "Create internet gateway."
Setup Route tables
Public Route Table
Click "Routes" and then "Edit routes."
Add a route with destination '0.0.0.0/0' & target as Internet Gateway
Associate this route table with Public Subnet.
Private Route Table
Click "Routes" and then "Edit routes."
Add a route with destination 0.0.0.0/0 and target as the NAT Gateway.
Associate this route table with Private Subnet.
Create a NAT Gateway
In the VPC Dashboard, click "NAT Gateways."
Click "Create NAT Gateway.".
Select Public Subnet and allocate an Elastic IP, and click "Create NAT Gateway."
Update Private Route Table
In the VPC Dashboard, click "Route Tables."
Select Private Route Table & Click "Routes," and then "Edit routes."
Add a route with destination 0.0.0.0/0 and target as the created NAT Gateway.
Launch Instances
Testing
SSH into the instance in Public Subnet to ensure it has internet access & SSH into the instance in Private Subnet through Public Subnet to test internet access (e.g. ping 8.8.8.8)
Conclusion
Setting up a NAT Gateway in AWS VPC allows your instances in private subnets to securely access the internet. This guide simplifies the process, ensuring your resources can communicate efficiently.
Subscribe to my newsletter
Read articles from Ravindra Mahato directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by
Ravindra Mahato
Ravindra Mahato
I am actively seeking a DevOps role and am currently available for new opportunities. With hands-on experience and project involvement in Docker, Kubernetes (K8s), CI/CD, Jenkins, AWS, and DevOps practices, I am equipped with the skills to drive efficient and scalable infrastructure solutions. I am eager to contribute my expertise and continue learning in a dynamic DevOps environment. If you have any openings or know of relevant positions, feel free to connect with me on LinkedIn to explore opportunities and learn more about my skills and experiences.