Articles → AWS → NAT Gateway In AWS

NAT Gateway In AWS






What Is NAT Gateway?





How To Create NAT Gateway?




  1. Create a private subnet
  2. Create a new route table
  3. Associate the subnet with the route table
  4. Launch 2 EC2 Linux instances
  5. Enable OpenSSH Authentication Agent service
  6. Log in to the Linux instance using the SSH utility
  7. Ping Google
  8. Create a NAT gateway
  9. Add an entry of NAT gateway in the route table
  10. Ping Google again



Create A Private Subnet




Picture showing the private subnet created in AWS console
Click to Enlarge


Create A New Route Table




Picture showing a new route table created in AWS console
Click to Enlarge


Associate The Subnet With The Route Table




Picture showing associating the route table with private network
Click to Enlarge


Launch 2 EC2 Linux Instances




Picture showing the 2 Linux EC2 instances created in AWS console
Click to Enlarge


Enable Openssh Authentication Agent Service




Picture showing changing the Openssh Authentication Agent Service startup type as Manual
Click to Enlarge



ssh-agent.exe



Login To The Linux Instance Using SSH Utility




ssh-add -k karan.pem




Picture showing the ssh-add command for adding the private key in SSH authentication agent
Click to Enlarge



ssh -A ec2-user@<Public IP address of EC2 instance>


Picture showing connecting the Linux virtual machine using ssh utility
Click to Enlarge



ssh ec2-user@<Private IP of EC2 instance>


Picture showing connecting to second EC2 instance using SSH utility
Click to Enlarge


Ping Google




ping google.com




Picture showing the error when pinging Google.com
Click to Enlarge


Create A NAT Gateway




Picture showing the NAT Gateways menu in VPC dashboard
Click to Enlarge



Picture showing the Create NAT gateway button for adding the new NAT Gateway
Click to Enlarge



FieldValue
NameAny custom name of NAT gateway
SubnetSelect the Public subnet
Elastic IP allocation IDSelect the elastic IP. If elastic IP does not exists then click on the “Allocate Elastic IP” button to create it


Picture showing the screen to create NAT Gateway
Click to Enlarge




Add An Entry Of NAT Gateway In Route Table




Picture showing the screen to add network gateway as route in route table
Click to Enlarge


Ping Google Again




Picture showing the ping to Google successfully
Click to Enlarge




Posted By  -  Karan Gupta
 
Posted On  -  Wednesday, July 27, 2022

Query/Feedback


Your Email Id
 
Subject
 
Query/FeedbackCharacters remaining 250