AWS VPC Peering

AWS VPC Peering

This time we are going to see how the peering is done. totally a practical blog.

Image a scenario where we have App & web server in once region and DB in different region , our task is to make them communicate with each other

Step 1 In “ N.Virginia” Region

VPC → Create VPC → VPC & More → “App_server” → 10.0.0.0/16 (ipv4) → Number of Availability Zones = 1 (by default its us-east-1a) → No. of public subnet=1 → No. of private subnet = 0 → create VPC

Step 2 In “ N.Virginia” Region , we will create another VPC

VPC → Create VPC → VPC & More → “Web_server” → 172.16.0.0/16 (ipv4) → Number of Availability Zones = 1 (choose us-east-1b) → No. of public subnet=1 → No. of private subnet = 0 → create VPC

PS Note = IP address should not be same when you are creating VPC in same region , that why we changed it for web server

Step 3 Go to SG and copy the VPC ID of both the VPC and In SG → Inbound Rules → Delete the already existing Inbound rule and add new rule it should look like below. for both the VPC one by one

In real time you are not supposed to all All Traffic

Step 4 : Now create 2 EC2 Instance one we need to attach with App_server VPC and another attach with Web_server vpc, Enable the auto assign IP address.

Step 5 : Now in “Ohio” Region , we need to create VPC there, as per above steps

CIDR shoud be = 192.168.0.0/16

Also All all Inbound traffic in SG for this VPC. And Create a EC2 Instance using this VPC in Ohio region

Step 6 : Now come back to N.Virgina Region and SSH in both of the boxes, and try to Ping each other using Private IP. You will see they are not reachable

Here we are now going to implement Peering

Step 7 : Go to VPC → Peering Connection → create Peering → Give some name → VPC ID (Requestor) = App_server → VPC ID(Acceptor) = Web_server → create Peering connection

Then Accept the request

Step 8 :: Once this is done go to Roue table, becuase Route tables helps in traffic flow, it know which incoming traffic , should b routed in which Location

Go to Route → App_server-rtb-public → Routes

Same we need to edit the Web_server route tables

Go to Route → Web_server-rtb-public → Routes

Step 9 :: Now again login to both the boxes App_server and Web_server and try to ping each other they should be able to ping each other now

Quickly we will see how to setup Peering in different region

Step 10 : Go to Ohio Region →VPC → Peering Connection → Create Peering connection , follow below snapshot

Below is the snap of request send from Ohio to N.Virgia VPC for App Server

Go to VPC → Peering connection → Refresh the page and you will see the pending request, accept it

Step 11 : Once the Peering connetion is accepted again we need to got to

VPC → Route → App_server-rtb-public

Add CIDR block of Ohio EC2 instance 192.168.0.0/16

Add the Peering ID of the Ohio region , it should look like below

Same we need to do in Ohio Region Router tables for Db_server

Route → Db_server-rtb-public

Once this is done we can see the App and DB server are able to ping one and other

Similary, same steps we need to follow to make connection for Web_server and DB server

Thanks for reading it till here, try to implement this . Happy Learning !!!