The networks of the Virtual Private Cloud (VPC) and the on-premises data center are isolated and cannot mutually communicate. This section describes how to achieve interconnection between a data center and Elastic Compute Service (ECS) within a VPC via Direct Connect (DC) using static routes.
Prerequisites
- You have created a VPC (named vpc) and its subnets. For procedure, see Creating a VPC.
tip
The subnet CIDR block of the VPC must not overlap or conflict with that of the data center. All existing route entries at the data center side must not conflict with subnet routes after being added to a DC Connection
- The data center to be interconnected has gateway devices supporting static routes.
Background
An enterprise wants its on-premises data center to access an ECS within a VPC through Direct Connect.
- Data center configuration: The subnet CIDR block is 172.16.1.0/24, the interconnect IP is 10.0.0.2, and the IP address of an active server is 172.16.1.10.
- VPC configuration: The subnet CIDR block is 192.168.1.0/24, the interconnect IP is 10.0.0.1, and the private IP address of the ECS is 192.168.1.10.
Procedure
Step 1: Create a DC Connection
Activate one DC Connection. For procedure, see Creating a Direct Connect Connection. In this example, the DC Connection used is DAS237_port101_conn under Project-test in China (Beijing). Step 2: Create a DC Gateway
- Click Create DC Gateway to create a DC Gateway with the following configuration.
- Click Buy now to complete the action.
- Click Go to console to return to the Direct Connect Gateway console. You can view the new DC Gateway (dcg-01) in the DC Gateway list.
Step 3: Create a Virtual Interface
- In the top menu bar, select your target region.
- Click Create DC Virtual Interface.
- Configure the Virtual Interface based on the table below.
- Click Create to complete the action.
Step 4: Add a static route
- On the details page, select the Routing information tab.
- Click Add static route entry, and configure the route.
- Click Add to complete configuration.
Step 5: Create a Cloud Enterprise Network
- Configure the CEN based on the table below and load vpc.
- Click Create to complete the action. The ID of the new CEN is cen-rr9sri7****1hx58031.
Step 6: Load the DC Gateway to the CEN
- In the list of the CEN console, click the name of the target instance (cen-test).
- In the Network Instances tab, click Attach Network Instance.
- The Attach Network Instance window pops up. Configure the relevant parameters
Step 7: Add a rule to the ECS security group
- In the top menu bar, select the region: China (Beijing).
- In the left-side navigation pane, click Instances. On the instance page, choose Main private IP address from the dropdown in the search box, and type 192.168.1.10 to search for the target ECS.
- Click the name of the target ECS, and then click the Security Group tab.
- Click the security group name. In the Access rules tab, click Add rule under the Inbound rule tab.
- See the figure below to add an inbound rule that allows access from the CIDR block of the data center.
Step 8: Configure routing for the data center
In the data center, configure a route from the data center to the VPC, which means setting the destination address as the VPC and the next hop as the cloud gateway peer IP (10.0.0.1) for the route.
Log in to the on-premises gateway (the gateway IP is 10.0.0.2) and configure a route from the on-premises data center to the VPC based on the following commands.
ip route 192.168.1.0 255.255.255.0 10.0.0.1
tip
- If your testing device is not the same as your on-premises gateway device, you need to configure routing between them.
- Routing configuration commands may vary for gateway devices from different vendors. For specific configurations, consult your device vendor.
Step 9: Test connectivity
- In the command window of the on-premises data center, execute the ping command to ping Cloud gateway peer IP typed at the creation of the DC Gateway. In this example, ping 10.0.0.1 to verify connectivity to the DC gateway.
- After confirming the DC communicates properly, execute the ping command in the command window of the on-premises data center, ping the IP address of an ECS within the VPC. In this example, ping 192.168.1.10 to verify connectivity to the ECS within the VPC.