Routing: VPC Peering


VPC Fundamentals
What is a VPC?
VPC Security and Control
VPC Connectivity
VPC Sharing using the AWS Resource Access Manager
Feature Spotlight:
Start course
3h 12m

In this section of the AWS Certified Advanced Networking - Specialty learning path, we introduce you to the various networking and VPC services currently available in AWS that are relevant to the ANS-C01 exam.

Learning Objectives

  • Identify and describe the various networking services available in AWS
  • Describe how to configure an Amazon Virtual Private Cloud (VPC)
  • Understand how to control network traffic via Security Groups and Network Access Control Lists (NACLs)
  • Describe options for VPC connectivity, subnets, and routing
  • Understand how to share VPC resources using the AWS Resource Access Manager (RAM)
  • Identify how to evaluate the configuration of VPC resources using the VPC Reachability Analyzer


The AWS Certified Advanced Networking - Specialty certification has been designed for anyone with experience designing, implementing, and operating complex AWS and hybrid networking architectures. Ideally, you’ll also have some exposure to the nuances of AWS networking, particularly regarding the integration of AWS services and AWS security best practices. Many exam questions will require advanced level knowledge of many AWS services, including AWS networking services. The AWS Cloud concepts introduced in this course will be explained and reinforced from the ground up.


Hello, and welcome to this lecture. We're on to cover some example scenarios of routine configurations in different VPC peering solutions.

For connectivity to exist between VPCs over a peered connection, abbreviated as a pcx, then specific routing must be set up on each side of the peer in the relevant subnets of the VPC to allow each VPC to know where to route traffic to.

Setting up routing on peered VPCs can only exist if the IP CIDR blocks do not overlap in any way. In each peered subnet that you want to communicate with, you must ensure that the route table being used in that subnet has a static route to either the peered VPC CIDR block or the CIDR block of the subnet in the peered VPC.

From this diagram, you can see that we have two subnets in each VPC. In VPC 1, we have a subnet A and B, and in VPC 2, subnet C and D. Subnet A in this VPC 1 has a static route in the table with a destination of the CIDR block of VPC 2 and a target of pcx-abcd1234, which is the peered gateway between the two VPCs.

Subnet B in the same VPC does not have a route pointing to the pcx. Similarly, in VPC 2, subnet C also has a route to VPC 1's CIDR block by the pcx, and subnet D does not. In this scenario, subnet A and VPC 1 has a route to the entire IP address space of VPC 2, and subnet C and VPC 2 has a route to the entire IP address space of VPC 1.

Therefore, these two subnets have a route to each other to enable connectivity. Although VPC 1 can route to the entire IP address space of VPC 2, which would include subnet D, subnet D does not have a route in its routing table to enable traffic to route to VPC 1. This is also true for VPC 2 communicating with subnet B.

For every subnet that requires connectivity to a peered VPC, a route must exist in the route table for that subnet pointing to the pcx. Let's now look at another example configuration of peering connections between VPCs. This time between three VPCs.

The peering connection between these VPCs offers connectivity to all VPCs from every other VPC. VPC 1 can communicate with 2 and 3, VPC 2 can communicate with 1 and 3, and VPC 3 can communicate with 1 and 2. In this scenario, three different peering connections are in place. As such, different pcx's are used to connect the same VPC from every other VPC. For example, the route table in VPC 3 uses pcx-wxyz6789 to communicate with VPC 1, whereas VPC 2 uses pcx-abcd1234 to communicate with VPC 1.

Care must be taken when configuring your route tables to ensure you use the correct pcx to route your traffic to peered VPCs in a multiple VPC peering scenario such as this. One final example of VPC peering. Again with three VPCs, but this time, not all the VPCs can communicate with all others plus two of the VPCs have identical CIDR blocks.

So, let's take a look at the routing in this scenario. Both VPC 1 and 3 have a peering with VPC 2. You will notice that VPC 1 and VPC 3 have identical VPC CIDR blocks as well as the same subnet CIDR range. The route table for the subnet in VPC 1 is set up correctly to point to VPC 2 via the correct target of the pcx.

However, the route table of the subnet in VPC 2 poses a problem. It states that for any traffic destined for the network, then use the pcx which points to VPC 3 only. So, if a request comes from VPC 1 and a response is required, the response will be sent to VPC 3. Currently, VPC peering does not support unicast reverse path forwarding, which checks the source IP of packets and routes response packets back to the correct source.

To resolve this, you could rely on the longest periphics match roll when looking at route priorities. The route table of the subnet could be changed to the following to include a new route. Now if any traffic from VPC 1 in the subnet was destined for VPC 2, VPC 2 would respond correctly using the correct pcx of pcx-abcd1234, as this route has the longest periphics match.

For any other traffic on the network, it will route to VPC 3. You could be more specific with your route table on VPC 2 to route to different subnets within VPC 1 and VPC 3 as shown on the route tables.

Coming up in the next lecture, I'm going to look at routing configuration when using a virtual product gateway for VPN connectivity.


About the Author
Learning Paths

Stuart has been working within the IT industry for two decades covering a huge range of topic areas and technologies, from data center and network infrastructure design, to cloud architecture and implementation.

To date, Stuart has created 150+ courses relating to Cloud reaching over 180,000 students, mostly within the AWS category and with a heavy focus on security and compliance.

Stuart is a member of the AWS Community Builders Program for his contributions towards AWS.

He is AWS certified and accredited in addition to being a published author covering topics across the AWS landscape.

In January 2016 Stuart was awarded ‘Expert of the Year Award 2015’ from Experts Exchange for his knowledge share within cloud services to the community.

Stuart enjoys writing about cloud technologies and you will find many of his articles within our blog pages.