Steps to Creating VPC with Public and Private Subnet's

  1. Create VPC
  2. Create Public and Private Subnet's
  3. Create Internet Gateway and Attach it to your VPC
  4. Create Route Tables and route the internet Gateway and add public subnet in subnet associations
  5. Create EC2 for public and private subnet
  6. (Create EC2 instance for app server with public subnet and create EC2 instance for DB server with Private subnet)
  7. Try to connect DB server via app server also test some other network you can able to access DB server without the help of app server 
 
 
 

 

 

Before you create VPC, you need Pre-plan for the below CIDR IP Ranges:

VPC CIDR IP Range: 192.168.0.0/16

Public CIDR IP Range: 192.168.1.0/24

Private CIDR IP Range: 192.168.2.0/24

 

Step: 1

Go to your VPCs and Create VPC

 

 

 

 

 

 

 


 Once you created VPC: Route Table and Network Table, Security Group created by default.


Step: 2

Create Public Subnet & Create Private Subnet

Public CIDR IP Range: 192.168.1.0/24

Private CIDR IP Range: 192.168.2.0/24

 

Created Public Subnet:

 

 

 

Created Private subnet:
 
 
 
 
Now we have created Public and Private Subnet


Subnet created but available IP showing 251

By default AWS reserved 4 IP’s

 



Step: 3

Next we are going to create internet GW and attach to our VPC.

Note: one VPC only one Internet gateway will attach. Cant multiple

Internet Gateway: The Amazon VPC side of a connection to the public Internet.

 

 

 

Once created Internet Gateway new we need to attach our VPC


 

VPC

Attach an internet gateway to a VPC to enable the VPC to communicate with the internet. Specify the VPC to attach below.

 




Step: 4


Create Route Tables and route the internet Gateway and add public subnet in subnet Associations
 
Create route
A route table specifies how packets are forwarded between the subnets within your VPC, the internet, and your VPN connection.

 




Step to route the internet Gateway

 

 

Route the internet gateway for IPV4 and IPV6




Public subnet to associate in Subnet associations 



 



Step: 6

Now enable auto assign IP address public subnet 

 

 

 

 

 

 

 


 

Note: Amazon reserves the first four (4) IP addresses and the last one (1) IP address of every subnet for IP networking purposes

192.168.0.0 Network Address

192.168.0.1 - Reserved by AWS for the VPC router

192.168.0.2 -Reserved by AWS the IP address of the DNS server

192.168.0.3 -Reserved by Aws for future use

192.168.0.255: network broadcast address, we do not support broadcast in a VPC, and therefore we reserved this address

You not enable auto assign public IP means you can’t able to access app server and DB server basically in private subnet. You access you DB server via app server 

 

 

 



Step: 7

Creation of EC2 Instances

Create two EC2 instances as Public EC2 and private EC2

 



Create App server in private subnet
 
 
 
 
 
 
Create DB server in Public subnet

 
 
 
 
 


Check above screenshot Public IP not available for DB server, its showing only private IP so we can able to access this server via app server with the help of private IP there is no internet connectivity for DB server.

Step: 8

Try to connect DB server via app server also test some other network you can able to access DB server without the help of app server 


Step: 9

VPC Clean up activity

Terminate the entire instance related to our VPC

Detach and delete internet Gateway. Before that NAT Gateway and endpoint should delete in case you have created

Delete VPC and Make sure not deleted our default VPC. If you delete default VPC and you have to contact amazon supporting team for create default VPC.
 


 

 



Post a Comment

Previous Post Next Post