Create VPC NAT Gateway, NAT Gateway is a high-availability AWS manageable service that makes it easily to connect to the Internet from instances inside a private subnet in an Amazon (VPC) Virtual Private Cloud. Previous, you needed to launch a NAT instance to enable NAT for instances in a private subnet.
Create VPC NAT Gateway in AWS
To know about NAT Gateway please visit AWS
How to Create VPC
1- Log in with AWS account and select AWS Services tab and then select VPC under Networking & Content Delivery.
2- Virtual Private Cloud – select Your VPCs
Select Create VPC.
3- Create VPC wizard,
Name tag – My-VPC
IPv4 CIDR block – 10.0.0.0/16.
Tenancy – default
Click Create.
4- Click Close.
5- Now you can see two VPC created.
How to Create Subnet in AWS
1st Subnet
1- Select Subnets and then select Create Subnet.
2- Name tag – PublicSubnet.
VPC – Select the VPC (My-VPC) that you created earlier.
Availability Zone – Select Availability zone.
IPv4 CIDR block – type a valid CIDR block. (For example – 10.0.0.0/24)
Click Create.
3- Click Close.
4- Subnet successfully created
2nd Subnet
Select Create Subnet
5- Name tag – PrivateSubnet.
VPC – select the VPC (My-VPC) that you created earlier.
Availability Zone – Select Availability zone.
IPv4 CIDR block – Type a valid CIDR block. (For example – 10.0.2.0/24)
Click Create.
6- Click Close.
7- Subnet successfully created.
Create Internet Gateway
1- Select Internet Gateways new and then click Create Internet Gateway.
2- Enter a name in the Name tag text box and then click create internet gateway.
3- Internet gateway successfully created and in a detached state. Now we need to attach it to your VPC.
Choose Attach to a VPC button, or in the action menu select Attach to VPC.
4- Select your VPC (My-VPC) from the drop-down list and then click Attach internet gateway.
5- The internet gateway changes to attached state.
Create VPC NAT Gateway in AWS
Create a Route Table
1st Route Table
1- Select Route Tables.
Click on Create route table.
2- Name tag – Type a name for your route table (Public-Route)
VPC – Select your VPC (My-VPC), and then select Create.
3- Click Close.
4- Route Table successfully created.
2nd route table
Click Create route table
5- Name tag – Type a name for your route table (Private-Route)
VPC – Select your VPC (My-VPC), and then select Create.
6- Click Close.
7- Subnet successfully created.
Routing of Public Subnets
Now you need to configure the routing for our public subnets. Enable traffic from the public subnets to Internet by utilize the internet gateway attached to the VPC.
Public-Route
1- Select Public-Route, select Subnet Associations, and then click on Edit Subnet associations.
2- Select your first public subnet (PublicSubnet) from the list and navigate to its Summary section and then click Save.
3- Select Routes tab and then click Edit routes.
4- Now the traffic from instances in the public subnets intended to the Internet shell be redirected to the Internet Gateway.
Then you redirected to the Route Table in the Virtual Private Cloud.
Add route for the Route Table – one for the traffic to the Internet to be routed using the Internet Gateway.
Click Add rules for destination type 0.0.0.0/0 (all packets for the internet) and for targets select the Internet Gateway.
5- Select (VPC-IGW) have created as in the earliest and then click save routes.
6- Click close.
Private-Route
7- Select Private-Route, select Subnet Associations, and then click on Edit subnet associations.
8- Select PrivateSubnet and then click save.
9- Successfully edit routes.
Create Instance
1st EC2 Instance
1- Choose service tab and then click on EC2 under compute.
2- Select instance on your left side and then click on Launch Instance button.
3- Select Microsoft Windows Server 2019.
4- Choose the type of instance you require based on your requirements.
Click Next : Configure Instance Details.
5- Network – select VPC (My-VPC).
Subnets – select PublicSubnet.
Auto Assign Public IP – select Enable.
Click on Next : Add Storage.
6- Click Next : Add Tags.
7- Here we have tagged the instance (Public Instance)
Click on Next : Configure Security Groups
8- Create a new Security Group.
Security group name – VPC-Securit
Choose Protocols RDP, HTTP, HTTPS and then Select Source Anywhere
Click on Review and then Launch.
9- Review instance details, parameters and then click launch.
10- Select Create a new key pair
Type a name to your key (Private-key)
Click download key pair and save it in your secured folder
11- After downloading key pair and saving your key, click launch instance.
12- Click view instances.
2nd EC2 instance
Network – My-VPC
Subnet – PrivateSubnet
Auto-assign Public IP – Disable
14- Tow Instance created.
How to login with AWS Instance
1- Select Public Instance and then click connect.
2- Select Get Password.
3- Select choose file and select your key pair and then click decrypt password.
4- Copy password and click on download remote desktop file.
5- Successfully login with Public Instance.
6- Search remote desktop connection and then select it.
7- Go back to your instances and choose Private Instance
Copy Private IP.
8- Paste in remote desktop connection and then click connect.
9- Inter your private instance credential and then click ok.
10- Private Instance server desktop.
Test the internet is working.
Type pint 8.8.8.8 and hit enter.
How to Create a NAT Gateway
1- Go back to your VPCs and select NAT Gateways.
2- Select Create NAT Gateway.
3- Select PublicSubnet.
4- Click on Allocate Elastic IP address.
5- Elastic IP Allocation ID created click on Create a NAT Gateway.
6- Click Close.
7- NAT Gateway is in pending status.
8- Select Route Tables
Select Private-Route
Select routes tab and then click on Edit routes.
9- Click Add route and type 0.0.0.0/0
Under target from drop-down menu select NAT Gateway.
10- Select newly create NAT Gateway and then click save routes.
11- Click Close.
12- Route table successfully edited.
14- Now NAT Gateway is in available status.
Go back your private instance and you can see it start pinging.
Leave a Reply
You must be logged in to post a comment.