Create Custom VPC IN AWS

  • Amazon Virtual Private Cloud (Amazon VPC) enables you to launch AWS resources into a virtual network that you've defined. This virtual network closely resembles a traditional network that you'd operate in your own data center, with the benefits of using the scalable infrastructure of AWS.

    • Amazon VPC is the networking layer for Amazon EC2.

The following are the key concepts for VPCs:

Virtual private cloud (VPC) — A virtual network dedicated to your AWS account.

Subnet — A range of IP addresses in your VPC.

Route table — A set of rules, called routes, that are used to determine where network traffic is directed.

Internet gateway — A gateway that you attach to your VPC to enable communication between resources in your VPC and the internet.

CIDR block —Classless Inter-Domain Routing. An internet protocol address allocation and route aggregation methodology.

  • So We will going to create VPC With the Below Network value 10.0.0.0/16

    Create vpc

VPC settings

VPC only; ipv4 cidr block 10.0.0.0/16;

  • create vpc

  • now see vpc created

  • When you create a VPC a Route Table, Network ACL, and Security Group are automatically created.

  • Subnets or Internet Gateways are NOT automatically created, so we’ll create those below.

Create subnets

we create a two subnets one is private and public

  • The below values i have assigned to my subnet.

  • Public-Subnet Availability zone : ap-south-1a IPv4 CIDR block : 10.0.1.0/24

    Private-Subnet Availability zone : ap-south-1b IPv4 CIDR block : 10.0.2.0/24

  • create public subnet

  • vpc id custom-vpc

  • subnet 1 of 1

  • create subnet

  • public subnet created

  • now create private subnet

  • subnet name

  • create subnet

  • two subnets are created

Create internet gateway

  • Now we want to Create Internet gateway and attach it to custom VPC so that the VPC Will get the internet.

  • attach to vpc

  • attach internet gateway

    • create a route table

    • Now we want to create route table to route the traffic between subnets,internetgateway to public.

route table settings

    • Now we need to give the Route Table (Custom Route) a route to the internet. Edit routes.

edit routes

  • edit routes

  • And add new route sourece is 0.0.0.0/0 to Newley created Internet gateway.

      • Lets associate a subnet we want to have internet access by going to the Subnet Associations and clicking on Edit.

here associate only public

  • Now Our Public Subent have internet access and private subnet not having the internet access.
  • After in edit subnet settings modify the auto assign public ip settings to our public subnet.

save

  • That's all Guys We have Successfully create one Full Functional Customized VPC

  • Test The Custom VPC

    • Now we will going to check our Custom VPC is working Properly or have any issue on the connectivity.

    • For that We are going to launch Two EC2 Instance on that VPC.

  • One instance in Public Subnet other one is private subnet.

  • Public Subnet associated Instance

  • Here I Have selected Custom VPC and choose public subnet.

Here I Have selected Custom VPC and choose private subnet.

  • now see two instance are created

  • see public subnet instance

  • then connect private instance via public instance

  • i copied .pem to public instance

    • Now i am connected the public instance via ssh and then connect private instance from that.

working fine