How to do VPC PEERING in the same Region?

Blue futuristic stream Data Communication flying into digital technologic animation 3D rendering
Reading Time: 3 minutes

VPC Peering :

Using a VPC peering connection, you can accelerate data transit. A networking connection between two VPCs known as a VPC peering relationship must be established in order to route traffic using private IPv4 or IPv6 addresses. Through the use of a VPC, instances can communicate with one another as if they were on the same network. A VPC in your own account or a VPC in another AWS account can be connected through a VPC peering arrangement. The VPCs could be found anywhere (also known as an inter-region VPC peering connection).

You can also utilize a VPC peering connection to give resources from one of your VPCs to other VPCs.

Inter-Region VPC peering is the process of establishing connections between VPCs in several AWS regions.

Route Table:

Each route is given a destination and a target in a table. For example, to enable your subnet to access the internet via an internet gateway, add the following route to your subnet route table. The end destination of the route is 0.0.0.0/0, which denotes all IPv4 addresses. The target is the internet gateway that is linked to your VPC.

Internet Gateways:

As an internet gateway, you can use your personal computer to connect to an EC2 instance in AWS. An internet gateway is used as a target in your VPC route tables for traffic that can be routed via the internet. For IPv4 connections, the internet gateway also performs network address translation.

Steps:

  • Create 2 Vpc in the same region.
  • Create 2 subnets in the same region.
  • Create 2 INTERNET Gateways and attach them with your VPC.
  • Create Route Table (Edit Route table and subnet for each of them).

Create 2 VPC for peering

Select the address type and CIDR.
Create a route table for both the vpc1 & vpc2 attach them with the selecting criteria and also attach the subnet in the route table which is created with the VPC for machine1 or machine2.
Create an Internet gateway and attach them with Vpc the State should be seen as attached.
NOW go to peering connection and see the DNS setting as there would be one Request VPC and one Acceptor VPC which will send the data and which will accept the data.
If it’s still not accepted click on the action and send for ACCEPT REQUEST now the acceptor will accept the request.
Now, create two EC2 instances to see the connection between both of them.

Select a network for your vpc1 or vpc2; do not select the default one because the subnet will be modified automatically afterward. Also, TURN ON AUTO-ASSIGN PUBLIC IP and CREATE AN ECC2 INSTANCE.

Once it is connected, ping the Private IPv4 addresses on your console.
Ping the second machine once more. Once it is connected, it will PING the second machine’s Private IPv4 addresses.

Both produce the ideal Ping outcome.

Happy Learning!

Reference: https://aws.amazon.com/vpc/