How to Create VPC, Subnets, Internet Gateway and Nat Gateway

1. Go to VPC Dashboard under AWS console after you log in.



2. Creating VPC.
Click on Create VPC on VPC dashboard.
Now provide the details as per the requirements.
Here I have Given Name Tag as “Pranav-VPC”.
CIDR block as 192.168.0.0/24 i.e. total 254 host IP’s possible.
Remaining field kept default as it is. 



3. Creating subnets.
Here I am going to create two subnets, one is for Public facing servers and the other one is for Private servers.
First, create a Public subnet with the details as follows.
Name Tag: Public-1a (Depends on you)
VPC: Select VPC created in above step
Availability Zone: us-east-1a (Depends on you)
CIDR block: 192.168.0.0/25 i.e. 128 host IP’s are possible starting from 192.168.0.0 - 192.168.0.127 



Now we create a Private subnet with the details as follows.
Name Tag: Private-1a (Depends on you)
VPC: Select VPC created in the previous step
Availability Zone: us-east-1a (Depends on you)
CIDR block: 192.168.0.64/25 i.e. 128 host IP’s are possible starting from 192.168.0.128 - 192.168.0.255




For More detailed subnet calculation refer http://www.subnet-calculator.com/ 

4. Creating Route tables.
When we create VPC, a default route table associated with that VPC gets created automatically and it is the main route table for that VPC.
Let’s name it as a “Private-RT”.



Create one more route table and name it as “Public-RT”
Associate this route table with our VPC “Pranav-VPC”.



5. Subnet association with route tables.
Under Route tables select “Public-RT”, go to Subnet Associations tab and select public subnet to associate with it.



Similarly select route table “Private-RT”, go to Subnet Associations tab and select private subnet to associate with it.



6. Creating Internet Gateway.
Internet Gateway will be used to route internet bound traffic from the VPC to the internet. 
Go to the Internet Gateway on left side of the dashboard.
Click on Create Internet Gateway and provide Name tag as say “Pranav-IGW”


After creation, click on to Attach to VPC in order to attach the Internet Gateway to VPC say “Pranav-VPC”.  



7. Associating Internet GW with a public subnet.
A public subnet is considered public when there is a route available in the associated route table to the Internet Gateway.
Go to the Route Tables on left side of the Dashboard.
Select Public subnet i.e. “Public-RT” in this case.
Go to the Routes tab and click on add another route.
Add 0.0.0.0/0 at the Destination field and select Internet GW i.e. “Pranav-IGW” at the Target field and then save.


8. Creating NAT Gateway.
Network address translation (NAT) gateway enables instances in a private subnet to connect to the Internet or other AWS services, but prevent the Internet from initiating a connection with those instances.
Go to the “Nat Gateways” on the left side of the VPC Dashboard, click on Create Nat Gateway.
Provide the necessary details, like subnet and Elastic IP, and create the NAT Gateway. 





9. Associating NAT Gateway with a private subnet.
Now go to the “Private-RT” route table and add the route for the traffic destined for the Internet toward the gateway. 





No comments:

Post a Comment