When two VPCs share overlapping CIDR blocks, standard routing breaks down — traffic destined for the peer VPC matches a local system route and never leaves the originating VPC. This guide shows how to add secondary CIDR blocks, deploy VPC NAT gateways for address translation, and connect the VPCs through a transit router so instances on both sides can communicate without re-addressing either VPC.
How it works
Why overlapping CIDR blocks block communication
When ECS instances in two VPCs with overlapping CIDR blocks try to communicate, routing fails in one of two ways:
VPC CIDR as destination — Traffic matches the local system route first and stays inside the originating VPC. It never reaches the peer VPC.
vSwitch CIDR as destination — You cannot add a custom route whose destination CIDR block is the same as or more specific than an existing system route.
Solution overview
The solution separates address spaces into two categories:
Overlapping (non-routable) ranges — The existing VPC CIDR blocks that conflict. Traffic cannot be routed directly between VPCs using these addresses.
Non-overlapping (routable) ranges — Secondary CIDR blocks you add to each VPC. These conflict-free ranges serve as the routable address space for NAT gateways and transit routing.
Three components work together to resolve the conflict:
Secondary CIDR blocks — Add non-overlapping secondary CIDR blocks to both VPCs. NAT gateways live in these ranges and use them as translation addresses.
VPC NAT gateways — Deploy one VPC NAT gateway per VPC, each in a vSwitch belonging to the secondary CIDR block. Source Network Address Translation (SNAT) rules translate outbound source IPs; Destination Network Address Translation (DNAT) rules translate inbound destination IPs.
Transit router — Attach both VPCs to a Cloud Enterprise Network (CEN) transit router to enable private connectivity between the two secondary CIDR blocks.
Address mapping
The table below shows how addresses are translated at each hop. All post-translation addresses come from the non-overlapping secondary CIDR blocks.
Network | Original address | Translated address |
VPC_A (ECS_A) | 192.168.0.86 | 172.16.0.89 (via SNAT) |
VPC_B (ECS_B) | actual private IP | 10.0.0.53 (via DNAT) |
Traffic path
The following example traces a request from ECS_A (private IP: 192.168.0.86) to ECS_B, accessed at the NAT IP address 10.0.0.53.
ECS_A sends a packet. The custom route table bound to its vSwitch forwards the packet to VPC_NATGW_A.
The SNAT rule on VPC_NATGW_A replaces the source IP with the NAT IP address 172.16.0.89.
The system route table in VPC_A forwards the packet to the transit router (TR). TR delivers it to VPC_B, then to VPC_NATGW_B.
The DNAT rule on VPC_NATGW_B translates the destination IP to ECS_B's private IP. Traffic reaches ECS_B.
On the return path, the session mapping table reverts the original private IP address. Then routing delivers the packet to ECS_A.
Prerequisites
Before you begin, make sure you have:
Two VPCs with overlapping CIDR blocks in the same region and account
Permissions to create VPC resources, VPC NAT gateways, and CEN instances
Non-overlapping secondary CIDR block ranges reserved for each VPC (for example, 172.16.0.0/24 for VPC_A and 10.0.0.0/24 for VPC_B)
NAT rule plan
Review the complete NAT rule configuration before starting. Having this plan upfront makes it easier to verify that each step is correct.
Rule | Type | Direction | Internal mapping | External (NAT IP) | Scope |
VPC_NATGW_A SNAT | SNAT | Outbound from VPC_A | 192.168.x.x (VPC_A CIDR) | 172.16.0.89 | Specify VPC |
VPC_NATGW_B DNAT | DNAT | Inbound to VPC_B | ECS_B private IP | 10.0.0.53 | Specific port (TCP 22) |
This example uses SSH (TCP port 22) as the verification method. Adjust port settings to match your actual service.
Step 1: Configure secondary CIDR blocks
Add secondary CIDR blocks to both VPCs:
Open the VPC console and select the region where your VPCs reside.
Click the ID of the target VPC, select the CIDR Block Management tab, and click Add Secondary IPv4 CIDR Block. Repeat for both VPC_A and VPC_B.
Create vSwitches in the secondary CIDR block range for each VPC. Open the Create vSwitch page and set the following:
Field
Value
VPC
VPC_A (repeat for VPC_B)
IPv4 CIDR block
Select the secondary IPv4 CIDR block you added
Step 2: Configure VPC NAT gateways
Create one VPC NAT gateway per VPC, then add SNAT and DNAT entries.
Create VPC NAT gateways
Open the VPC NAT gateway purchase page and create a gateway for each VPC:
Field | Value |
Region | The region where the VPC resides |
Network and Zone | VPC_A (or VPC_B); select the vSwitch created from the secondary CIDR block |
Configure SNAT entries
SNAT rules translate the source IP of outbound packets to the NAT IP address, making traffic from VPC_A appear to originate from the secondary CIDR block.
Open the VPC NAT gateway list page and select the region where your VPC NAT gateways reside.
In the SNAT Management column of VPC_NATGW_A, click Actions > Create SNAT Entry and set the following:
Field
Value
SNAT Entry
Specify VPC
Select NAT IP Address
The private IP of VPC_NATGW_A
Configure DNAT entries
DNAT rules translate the destination IP of inbound packets, mapping the NAT IP address to a specific ECS instance inside VPC_B.
On the VPC NAT gateway list page, click DNAT Management in the Actions column of VPC_NATGW_B. Click Create DNAT Entry and set the following:
Field
Value
Select NAT IP Address
The private IP of VPC_NATGW_B
Select Private IP Address
The ECS instance in VPC_B that needs to be accessed
Port Settings
Specific Port: frontend port 22, backend port 22, Protocol TCP
Adjust the DNAT entry to match your service's protocol and port.
Step 3: Connect the VPCs
Connect both VPCs to a CEN transit router so traffic can flow between the secondary CIDR blocks.
This example connects VPCs in the same account and region using an intra-region connection. For VPCs in different regions or accounts, see Inter-region VPC peering and Cross-account VPC peering. Check supported regions and zones before you begin.
Create CEN connections
Open the Cloud Enterprise Network (CEN) Management Console and click Create CEN Instance. Select Create CEN Only, then click OK.
After the CEN instance is created, click Create Connection > Intra-region and set the following for VPC_A:
Field
Value
Network Type
Virtual private cloud (VPC)
Region
The region where the VPC resides
Resource Owner ID
Your Account
Networks
VPC_A
vSwitch
Select at least two zones. Include the vSwitch where VPC_NATGW_A is located.
Advanced Settings
Select all
Click Continue To Create Connection and repeat the same configuration for VPC_B.
Configure route tables
A VPC NAT gateway handles address translation only — it does not control traffic flow. Route tables determine whether traffic reaches the NAT gateway and where it goes after translation.
Create custom route tables and bind them to vSwitches:
Open the Route Tables page and select your region.
Click Create Route Table for each VPC:
Field
Value
VPC
VPC_A (repeat for VPC_B)
Associated Resource Type
vSwitch
In the Associated Resource column of the new route table, click Bind and select the vSwitch that contains the ECS instance.
Add route entries:
Click the route table ID, open the Custom Route tab, click Add Route Entry, and configure routes according to the following table:
VPC | Route table | Destination CIDR block | Next hop |
VPC_A | System route table | 10.0.0.0/24 | Transit router |
VPC_A | Custom route table | 10.0.0.0/24 | VPC_NATGW_A |
VPC_B | System route table | 172.16.0.0/24 | Transit router |
VPC_B | Custom route table | 172.16.0.0/24 | VPC_NATGW_B |
The custom route table entries direct traffic from ECS instances to the VPC NAT gateway first (for address translation). The system route table entries then forward the translated traffic through the transit router to the peer VPC.
Step 4: Verify the connection
Log in to ECS_A and run the following commands:
# SSH into ECS_B through the NAT IP address of VPC_NATGW_B
# Make sure ECS_B's security group allows inbound TCP traffic on port 22
ssh root@10.0.0.53
# View the network interface controller (NIC) IP address to confirm the source IP used for the connection
ifconfigA successful connection confirms that ECS_A reached ECS_B through the NAT IP address 10.0.0.53 (VPC_NATGW_B), using the NAT IP address 172.16.0.89 (VPC_NATGW_A) as the translated source.

Billing
Service | Charges |
Instance fee + capacity unit (CU) fee | |
Intra-region: connection fee + traffic processing fee. Inter-region: additional cross-region bandwidth fee |