How to Create VPC Peering Connection Same Region in AWS

vpc peering connection same region

In this article, I will show you the steps to create a VPC peering connection same region in AWS environment in same region.

AWS VPC Peering Connection Same Region

How to Create VPC

1- Login to your AWS account and go to the AWS Services tab and then select VPC under Networking & Content Delivery.

aws resource manager services

1st VPC

2- Under Virtual Private Cloud select Your VPCs
Click on Create VPC.

aws create vpc

3- Create VPC wizard,
Name tag – VPC1.
IPv4 CIDR block – 10.0.0.0/16.
Tenancy – default
Click Create

aws create vpc-

4- Click close.

the following vpc was created

Create 2nd VPC

1- Click create VPC

aws create vpc

2- Name tag – VPC2.
IPv4 CIDR block – 192.168.0.0/16.
Tenancy – default
Click Create

aws create vpc-

3- Click close

the following vpc was created

4- Now you can see two VPC created.

aws your VPCs

Create Subnet in AWS

1- Select Subnets and then choose Create Subnet.

subnets aws

2- Name tag – VPC1-Subnet.
VPC – choose VPC that we have created earlier.
Availability Zone – Select one zone.
IPv4 CIDR block – type a valid CIDR. (For example – 10.0.0.0/24)
Click Create.

create subnet aws

3- Click close

following subnets successfully created

2nd Subnet

1- Choose create subnet.

subnet amazon management console

2- Name tag – VPC2-Subnet.
VPC – choose the VPC that we have created earlier.
Availability Zone – Select one zone.
IPv4 CIDR block – type a valid CIDR. (For example – 192.168.0.0/24)
Click Create.

create subnet aws

3- Click close

following subnets successfully created

4- Subnets successfully created.

subnet amazon management console

Create Internet Gateway

1- Choose Internet Gateways new option and then click on Create Internet Gateway.

aws create internet gateway

2- Enter a name (VPC-IGW) in the Name tag text box and then click create an internet gateway.

aws create internet gateway name

3- The internet gateway has been created is in a detached state. Now we want to attach it to our VPC.

In the action menu select Attach to VPC.

aws internet gateway detached

4- Select your VPC1 from the drop-down list and then click Attach internet gateway.

attach internet gateway

5- The internet gateway changes to attached state.

internet gateway status attached

2nd Internet gateway

1- Click create internet gateway.

aws create internet gateway

2- Enter a name (VPC2-IGW) in the Name tag text box and then click create an internet gateway.

aws create internet gateway name

3- The internet gateway has been created is in a detached state. Now we want to attach it to your VPC.

Select Attach to VPC.

aws internet gateway detached

4- Select your VPC2 from the drop-down list and then click Attach internet gateway.

attach internet gateway

5- The internet gateway changes to attached state.

internet gateway status attached

Create Route Table

1st Route Table

1- Select Route Tables.
Click on Create route table.

create route table

2- Name tag – Type a name for your route table (VPC1-Route).
VPC – Select your VPC1, and then select Create.

create route table name

3- Click Close

route table was created

2nd Route Table

1- Click create route table.

create route table

2- Name tag – Type a name for your route table (VPC2-Route).
VPC – Select your VPC2, and then select Create.

create route table name

3- Click Close

route table was created

4- Two routes successfully created.

create route table

CREATING VPC PEERING CONNECTION

1- Under virtual private cloud, click on peering connections.

create route table

2- Click on create peering connection button.

create peering connection aws

3- Type a name for the peering connection
VPC (Requester) select the VPC1 from the drop-down list.

create peering connection requester

4- We have created the two VPC’s under the same AWS region.
Select another VPN to peer with VPC2

create peering connection accepter

5- After selecting VPC (Requester) and VPC (Accepter) click create peering connection.

create peering connection aws

6- Click OK.

create peering connection success

7- Now peering connection is created and in pending status.

create peering connection pending

Accepting Connection

8- Click on Action menu and then click accept request.

create peering connection accept

9- Click on the Yes, Accept button.

accept vpc peering connection

10- VPC peering connection has been established successfully.

accept vpc peering connection request

11- Now peering connection is in active status.

create peering connection active aws

Routing of public subnets

Now you need to configure the routing for our subnets. Enable traffic from the subnets to Internet via the internet gateway attached to the VPC.

1- Select VPC1-Route, Select Routes tab and then click Edit routes.

edit routes aws

2- Click Add route.

edit routes target aws

3- Click on Add rules button for destination enter 0.0.0.0/0 (all packets for the internet) and then for targets select the Internet Gateway.

edit routes target

4- Select (VPC1-IGW) have created as in the earliest.

edit routes target aws

5- Click on Add button again type 192.168.0.0/24.
Under Target select peering connection

edit routes target aws

6- Select peering VPC1-VPC2 and then click save routes.

edit routes target aws

7- Click close.

routes successfully edited aws

8- Successfully route edited.

create route table aws

9- Choose Subnet Associations and then choose Edit Subnet associations.

edit subnet associations

10- Select your subnet (VPC1-Subnet) and then click Save.

edit subnet associations save

11- Select VPC2-Routes, select Route tab and then click Edit routes.

edit routes aws

12- Click Add route.

edit routes table aws

13- Click on Add rules button for destination type 0.0.0.0/0 (all packets for the internet) and for targets select the Internet Gateway.

edit routes target aws

14- Select (VPC2-IGW) have created as in the earliest.

edit routes target aws

15- Click on Add button again type 10.0.0.0/24.
Under Target select peering connection

edit routes target aws

16- Select peering VPC1-VPC2 and then click save routes.

edit routes target aws

17- Click close

route successfully edited

Successfully route edited

18- Select VPC2-Route, select Subnet Associations, and then click on Edit Subnet associations.

edit subnet associations-

19- Select your first subnet (VPC2-Subnet) and then click Save.

edit subnet associations save

Create Instance

1- Choose service tab, click on EC2 under compute.

aws management console

2- Choose instance tab and then click on Launch Instance button.

aws launch instance

3- Select Microsoft Windows Server 2019.

aws instance choose ami

4- Select General purpose t2 micro
Click Next : Configure Instance details

aws choose instance type

5- Network – select VPC (VPC1).
Subnets – select VPC1-Subnet.
Auto Assign Public IP – select Enable.
Click on Next : Add Storage.

aws configure instance details

6- Click Next : Add Tags.

aws add storage

7- Here we have tagged the instance (VPC-Server1)
Click on Next : Configure Security Groups

aws add tags

8- Create a new Security Group.
Security group name – VPC-Security
Select Protocols RDP, ALL ICMP – Ipv4, Select Source Anywhere
Click on Review and Launch

aws configure security group

9- Review details, parameters and then click launch.

aws review instance launch

10- Select Create a new key pair
Type a name to your key (VPC Peering key)
Click on download key pair and then save it in your secured folder

aws key pair name

11- After downloading and saving your key, click launch instance.

aws key pair name

Now we need to create a second EC2 instance

Network – VPC2
Subnet – VPC2-Subnet
Auto-assign Public IP – Enable

second vm

Add Tag
Name – VPC-Server2

12 second vpc

Testing VPC Peering Connection Same Regions

1- Choose VPC-Server1 and then choose connect.

aws instance connect

2- Choose Get Password

get password aws

3- Click on choose file, select your key pair and then click decrypt password.

key pair choose file aws

4- Copy password and then click on download remote desktop file.
And login to VPC1-Server.

get password aws

5- Search Firewall & network Protection and open it.

windows server search bar

6- Disable firewall and network protection.

firewall network protection

7- VPC-Server1 desktop.
Run command prompt and then ping VPC-Server2 IP address.

ec2 instance desktop

8- VPC-Server2 desktop.
Run command prompt and then ping VPC-Server IP address

ec2 instance desktop

Comments

Leave a Reply