Steps to Creating VPC with Public and Private Subnet's
- Create VPC
- Create Public and Private Subnet's
- Create Internet Gateway and Attach it to your VPC
- Create Route Tables and route the internet Gateway and add public subnet in subnet associations
- Create EC2 for public and private subnet
- (Create EC2 instance for app server with public subnet and create EC2 instance for DB server with Private subnet)
- 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
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
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
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