Sub topic 16
When VPC address ranges overlap
This chapter assumes you know CIDR notation, VPC route tables, and the basics of Transit Gateway and PrivateLink from the earlier chapters.
Why overlap breaks routing
A route table matches a destination to one target. If two VPCs both use 10.0.0.0/16, a route for 10.0.0.0/16 cannot mean both. Each VPC also has a local route for its own range, and the local route always wins. Traffic meant for the other VPC never leaves.
AWS enforces this in several places:
- VPC peering rejects a request when the two VPC CIDRs overlap.
- A transit gateway route table cannot hold two attachments propagating the same CIDR to the same destination. Static routes with identical prefixes also conflict, and the gateway routes to only one of them.
- Propagation of an overlapping CIDR into a shared route table makes routing ambiguous, so keep overlapping attachments in separate route tables.
Option 1: Avoid it with address planning
The cheapest fix is to prevent overlap. Allocate ranges from one central plan, such as Amazon VPC IP Address Manager (IPAM), which can hand out non-overlapping CIDRs to accounts. For an existing VPC, you can add a secondary CIDR block, but you cannot change the primary one.
Option 2: Expose a service with PrivateLink
PrivateLink does not route between networks. The consumer's interface endpoint is a set of network interfaces with addresses from the consumer's own subnets. The consumer talks to those local addresses. The provider sees traffic coming from its Network Load Balancer. Neither side needs to know the other's CIDR, so overlapping ranges do not matter.
aws ec2 create-vpc-endpoint \
--vpc-endpoint-type Interface \
--vpc-id vpc-0aaa1111bbb22222c \
--service-name com.amazonaws.vpce.us-east-1.vpce-svc-0123456789abcdef0 \
--subnet-ids subnet-0aaa1111 subnet-0bbb2222 \
--security-group-ids sg-0123456789abcdef0This works even if the provider VPC and consumer VPC are both 10.0.0.0/16. The cost is scope: PrivateLink is one-directional and carries traffic for one service, not general network access.
Option 3: Translate addresses
When you need network-level connectivity, you can place a NAT layer between the overlapping networks. One common design is a private NAT gateway, which translates source addresses to a non-overlapping range from a routable subnet. Traffic then crosses the transit gateway using the translated addresses.
Another approach is to give the overlapping VPC a second, unique CIDR block. Put the NAT gateway and the transit gateway attachment in subnets from that unique range.
Choosing an approach
| Situation | Best fit |
|---|---|
| You are designing new VPCs | Plan CIDRs with IPAM |
| One service must be reached from an overlapping VPC | PrivateLink |
| Full two-way network access is required | Private NAT with unique ranges |
Exercise
Two VPCs both use 10.0.0.0/16. A team needs its application in VPC A to call one API hosted in VPC B. Which approach is simplest, and why does it work?
Show answer
Publish the API as a PrivateLink endpoint service behind a Network Load Balancer in VPC B, and create an interface endpoint in VPC A. The endpoint's network interfaces use addresses from VPC A's own subnets, so no route between the two ranges is needed and the overlap does not matter.