AWS VPC Peering

Search for a command to run...

No comments yet. Be the first to comment.
"ddrescue got your data off the dying drive. Now what? This is where you actually get it back." š The Big Picture First A lot of people think ddrescue restores data. It doesn't ā not directly. Here
"Your hard drive is making a clicking sound. Your stomach drops. Don't panic ā ddrescue has your back." š¤ What Even Is ddrescue? Imagine your hard drive is a library. Some books are fine. Some are
Most teams treat SELinux as an obstacle. The teams that thrive in production treat it as a superpower. Here's everything you need to know to move from frustrated to fluent. If you've ever Googled a
Application Load Balancer? A load balancer serves as the single point of contact for clients. The load balancer distributes incoming application traffic across multiple targets, such as EC2 instances, in multiple Availability Zones. This increases th...

In this Lab you will get the idea of the following: Created an Amazon EC2 launch template Created an Amazon EC2 Auto Scaling launch configuration Configured scaling policies and created auto Scaling group to scale in and scale out the number of se...

A virtual private cloud (VPC) is a virtual network dedicated to your AWS account. It is logically isolated from other virtual networks in the AWS Cloud. You can launch AWS resources, such as Amazon EC2 instances, into your VPC.
A VPC peering connection is a networking connection between two VPCs that enables you to route traffic between them using private IPv4 addresses or IPv6 addresses. Instances in either VPC can communicate as if they are within the same network. You can create a VPC peering connection between your VPCs or a VPC in another AWS account. The VPCs can be in different Regions (also known as an inter-Region VPC peering connection).
There is no charge to create a VPC peering connection. All data transfer over a VPC Peering connection within an Availability Zone (AZ) is free. Charges apply for data transfer over VPC Peering connections that cross Availability Zones and Regions.

Note: In this lab session we are going to create two different instances and try to connect the private IP of one instance by using another instance.
Goto Your VPCs and Create vpc1:
Resources to create VPC only
Name tag - optional eg. vpc1
IPv4 CIDR eg. 10.0.0.0/16
Create VPC with all other default
Goto Subnets and create subnet for vpc1 as:
VPC ID select vpc1
Scroll down to Subnet settings
Subnet name vpc1subnet
Availability Zone anyone your choice eg. us-east-1a
IPv4 CIDR block: 10.0.0.0/24
and Create subnet
Goto Internet gateways and Create internet gateway as:
In Internet gateway setting
Name tag: IGvpc1
Create internet gateway
Click on the popup Attach to VPC
Available VPCs -> select a VPC : vpc1
Attach internet gateway
Goto Route tables and create a route table for vpc1
Route table settings
Name: route_vpc1
VPC: Select vpc1
Create route table
Goto Your VPCs and Create vpc2:
Resources to create VPC only
Name tag - optional eg. vpc2
IPv4 CIDR eg. 194.0.0.0/16
Create VPC with all other default
Goto Subnets and create subnet for vpc2 as:
VPC ID select vpc2
Scroll down to Subnet settings
Subnet name vpc2subnet
Availability Zone anyone your choice eg. us-east-1b
IPv4 CIDR block: 194.0.0.0/24
and Create subnet
Goto Internet gateways and Create internet gateway as:
In Internet gateway setting
Name tag: IGvpc2
Create internet gateway
Click on the popup Attach to VPC
Available VPCs -> Select a VPC : vpc2
Attach internet gateway
Goto Route tables and create a route table for vpc2
Route table settings
Name: route_vpc2
VPC: Select vpc2
Create route table
Goto Peering connections by scrolling down on the left side of the bar
Click on Create peering connection
Peering connection settings
Name: peerVPC
VPC ID (Requester): Select vpc1
VPC ID (Accepter): Select vpc2
Create peering connection
Select peerVPC -> Actions -> Accept request
Goto Route tables
Select route_vpc1
Click on Subnet associations -> Edit subnet associations
vpc1subnet and Save associationsClick on Routes -> Edit routes -> Add route
Destination: 0.0.0.0/0 Targe: Internet Gateway -> (IGvpc1)
Destination: 194.0.0.0/16 Targe: Peering Connection -> (peerVPC)

Similarly, Select route_vpc2
Click on Subnet associations -> Edit subnet associations
vpc2subnet and Save associationsClick on Routes -> Edit routes -> Add route
Destination: 0.0.0.0/0 Targe: Internet Gateway -> (IGvpc2)
Destination: 10.0.0.0/16 Targe: Peering Connection -> (peerVPC)

For First Instance
Launch instances
Name: server1
select the existing key or create new
Network settings -> Edit
VPC: Select vpc1
Subnet: vpc1subnet
Auto-assign public IP: enable
Leave Create a security group checked
Leave all default and Launch instance
For Second Instance
Launch instances
Name: server2
select the existing key or create new
Network settings -> Edit
VPC: Select vpc2
Subnet: vpc2subnet
Auto-assign public IP: desable
Leave Create a security group checked
Add security group rule
Type: All traffic
Source type: Anywhere
[ Note: It is not good practice to set the type All traffic just for basic understanding ]
Leave all default and Launch instance
After the Status check 2/2 checks passed
Select the EC2 instance with private IP i.e. server2 and copy private IP
Then, Select the EC2 instance with public IP i.e. server1
And Click on Connect at the top, again Connect


Here, perform the following commands:
sudo su
ping <private-ip-you-copied>
CTRL+C to exit 