AWS VPC Peering Between Two Different VPCs: Step-by-Step Practical Guide

2026-12-03来源 dev.toEnglish
AWS VPC Peering Between Two Different VPCs: Step-by-Step Practical Guide

Step 1: Create Two VPCs

First, create two separate VPCs in the AWS Management Console.and
im going with vpc&more option.by using this option at a time it creates
private and public subnets, internet gateway and routetable.

->Create VPC-1 with CIDR block 10.0.0.0/16.

->Create VPC-2 with CIDR block 20.0.0.0/16

Make sure both VPCs are created in the required AWS Region

Step 2: Create a VPC Peering Connection

Open the AWS VPC Console.

Navigate to Peering Connections.

Click Create Peering Connection.

Select VPC-1 as the Requester VPC.

Select VPC-2 as the Accepter VPC.

Click Create Peering Connection.

Step 3: Accept the Peering Request

Open Peering Connections.

Select the newly created connection.

Choose Actions.

Click Accept Request.

Verify that the status changes to Active.

Step 4: Update Route Tables

Update the route tables associated with the subnets containing your EC2 instances.

In VPC-1:
Destination: 20.0.0.0/16
Target: VPC Peering Connection ID

In VPC-2:
Destination: 10.0.0.0/16
Target: VPC Peering Connection ID

Save the route changes.

Step 5: Launch EC2 Instances

Launch EC2 instances in the subnets where you want to test communication.

NOTE: launch ec2 instance with different vpc's.

-> After instance are ready.
-> switch to root user (su -i)
-> apt update -y
-> apt install nginx -y
-> cd /usr/share/nginx/html
-> rm index.html & create a file index.html insert any data.
-> The nginx application is in stopped state. we need to start application
by using "systemctl start nginx".

"same steps do in 2nd instance"

Step 6: Test Connectivity
-> Now go to ec2 instance1
curl 20.0.7.225 --> this is ec2 "instance2" private ip
-> Now go to ec2 instance2
curl 10.0.8.191 --> this is ec2 "instance1" private ip

原文:https://www.a8q9.cn/en/article/aws-vpc-peering-between-two-different-vpcs-step-by-step-practical-guide-5da6ee.html

相关文章