This topic describes how to use Transit Routers (TRs) to implement interconnectivity between two VPCs (vpc01 and vpc02) under Account A and another VPC (vpc03) under Account B in the same region. After connecting, both vpc01 and vpc02 can communicate with vpc03 via TR, but vpc01 and vpc02 cannot mutually communicate, as shown below.
Prerequisites
- You have created three Virtual Private Clouds (VPCs) and their subnets. For procedure, see Building an IPv4 VPC.
tip
Ensure that neither VPC contains conflicting subnets. That is, no duplicate or overlapping CIDR blocks exist.
- You have created Elastic Compute Service (ECS) instances in the three VPCs. For procedure, see Buying ECS instances.
Routing planning
A single TR instance can use the same route table to forward traffic from multiple network instances that share a common destination. Thus, in this example, the TR uses one route table for forwarding from vpc01/vpc02 to vpc03, and a separate route table for the return path from vpc03 to vpc01/vpc02. This design necessitates at least two route tables, as illustrated in the following diagram.
Configuration procedures
- Create a TR instance: Create a TR instance to host the TR service.
- Create a TR custom route table: Create a custom route table to receive and forward network traffic along with the TR system route table.
- Create a network instance attachment and configure routing: Create two network instance attachments to connect the two VPCs under the same account. Configure association forwarding and route learning for those attachments.
- View TR and VPC routes: Check that the routes of the TR instance and two VPCs meet expectations.
- Verification: Run ping to verify the connectivity between ECS instances in different VPCs to ensure that the VPCs are connected and isolated as expected.
Configuration procedures
Step 1: Configure a TR instance (Account A)
Ⅰ. Create a TR instance
- In the top menu bar, select the target project and region.
- Click Create TR and configure related parameters based on the table below.
- Click Create to complete the action.
tip
When you create a TR instance, the system automatically creates a system route table for it. Record the name of this system route table: rtb-sys. The following uses rtb-sys as an example.
Ⅱ. Create a TR custom route table
- Click the name of the target TR instance.
- In the section below Basic information, select the Route Table tab.
- Click Create Route Table to the right of Route Table List, and type in rtb-set as the route table name.
- Click Create to complete the action.
Ⅲ. Create a network instance attachment and configure routing
Create two network instance attachments using the following steps. These will connect the TR instance to vpc01 and vpc02 under Account A separately.The configurations for these attachments are specified in the configuration table's Example value (Attach vpc01) and Example value (Attach vpc02) columns.
- In the section below Basic information, select the Intra-region attachment tab.
- Click Create attachment, and complete the basic configuration for the network instance attachment based on the table below.
- Complete the route configuration for the network instance attachment based on the table below.
- Click Buy now to complete the action.
Ⅳ. View TR and VPC routes
- View routes of TR route tables (rtb-sys and rtb-set) in sequence.
- Currently, no routes exist in rtb-sys.
- The routes in rtb-set are listed in the following table.
- View routes of the vpc01 and vpc02 route tables in sequence to confirm no changes.
- Since the routes in rtb-sys are automatically published to the vpc01 and vpc02 route tables, routes in the vpc01 and vpc02 route tables are unchanged.
Step 2: Create instance sharing (Account A)
- Click the account avatar in the upper right corner.
- Select Tools > Resource.
- In the left-side navigation pane, select Resource sharing > Shared by me.
- In the top menu bar, select your target region.
- On the Shared unit tab, click Create shared unit and configure the parameters based on the table below.
- Click Next to associate sharing permissions.
- TR sharing permissions are system-defined and cannot be modified. For default supported actions, see Instructions.
- Click Next to associate shared users.
- Click Next to confirm that the resources, associated permissions, and shared users are correct.
- Click Confirm to complete the action.
Step 3: Accept sharing invitation (Account B)
- In the top menu bar, select the region to which the shared TR belongs.
- Click Accept to the right of the shared unit to complete the action.
- Click Accept to the right of the shared TR instance to confirm the sharing information.
- Click Accept to complete the action.
- Upon acceptance, the status of this shared TR instance updates from Pending acceptance to Accepted.
Step 4: Create a network instance attachment and configure routing (Account B)
- On the TR instance list page, click the name of the shared TR instance.
- In the section below Basic information, select the Intra-region attachment tab.
- Click Create attachment, and complete the basic configuration based on the table below.
- Complete the route configuration based on the table below.
- Click Buy now to complete the action.
- View routes of TR route tables (rtb-sys and rtb-set) in sequence.
- The routes in rtb-set remain unchanged.
- The routes in rtb-set are listed in the following table.
- View routes in the vpc01, vpc02 and vpc03 route tables in sequence, as shown in the table below.
- Since the network instance attachment does not enable association forwarding, no routes exist in the vpc03 route table.
- Because vpc01 and vpc02 route tables automatically learn routes from rtb-sys, the routes in vpc01 and vpc02 route tables are shown in the table below.
Step 5: Configure association forwarding for the TR custom route table (Account A)
- Click the name of the target TR instance.
- In the section below Basic information, select the Route Table tab.
- Click the name of the TR custom route table (rtb-set) and select the Association forwarding tab.
- Click Create association forwarding and select the network instance attachment (vpc03).
- Click Create to complete the action.
- View routes of TR route tables (rtb-sys and rtb-set) in sequence to confirm no changes.
- View the route entries of vpc03, as shown in the table below.
Result validation
The following verification steps take a Linux-based ECS as an example:
- Execute the ping command to connect the private IP addresses of respective ECS instances in vpc02 and vpc03, verifying network connectivity.
- The ECS instances in vpc01 and vpc02 are mutually isolated and cannot ping each other.
- The ECS instances in vpc01 and vpc03 can mutually communicate and can ping successfully.
- Similarly, remotely log in to the ECS instances in vpc02 and vpc03 to verify connectivity between vpc02, vpc03, and another VPC.