Enabling Mutual Access Between Servers in Overlapping Subnets on the Cloud
Scenarios
The existing network architecture of the on-premises data center needs to be migrated to the cloud without any changes. In addition, servers in two overlapping CIDR blocks in the on-premises data center can access each other.
Department A and department B in the same on-premises data center have an overlapping subnet. Workloads of the two departments need to be migrated to a cloud without changing CIDR blocks of their subnets. In addition, the overlapping subnets of the two departments should be able to communicate with each other after the migration.
Solution Architecture
- Department A and department B of two subsidiaries use the same CIDR block (192.168.0.0/24), so two VPCs with the same CIDR block are created on the cloud.
- The department A and B servers both used 192.168.0.3, so they were respectively assigned 10.1.0.11 and 10.2.0.22, as transit addresses. These transit addresses enabled the two servers to communicate with each other.
Manually configure the following routes to ensure traffic forwarding:
- VPC (department A) to the private NAT gateway A
- Transit VPC1 to the VPC peering connection
- Transit VPC2 to the VPC peering connection
- VPC (department B) to the private NAT gateway B
Solution Advantages
CIDR blocks of department A and department B are kept unchanged after on-premises workloads are migrated to the cloud.
Resource and Cost Planning
Resource |
Parameter |
CIDR Block/IP Address |
Subnet Name |
Description |
---|---|---|---|---|
VPC (CN-Hong Kong) |
vpc-departmentA |
192.168.0.0/24 |
subnet-A |
VPC that workloads of department A are migrated to |
vpc-departmentB |
192.168.0.0/24 |
subnet-B |
VPC that workloads of department B are migrated to |
|
vpc-transit1 |
10.1.0.0/24 |
ext_sub_T1 |
Transit VPC required by the private NAT gateway of department A |
|
vpc-transit2 |
10.2.0.0/24 |
ext_sub_T2 |
Transit VPC required by the private NAT gateway of department B |
|
Transit IP address (vpc-transit) |
transit IP-DepartmentA |
10.1.0.11 |
N/A |
IP address used by department A to provide services accessible from other departments. Department B can use this IP address to access servers in department A. |
Transit IP address-DepartmentB |
10.2.0.22 |
N/A |
IP address used by department B to provide services accessible from other departments. Department A can use this IP address to access servers in department B. |
|
ECS (CN-Hong Kong) |
ecs-departmentA |
192.168.0.3 |
N/A |
Server of department A, which can communicate with the server of department B |
ecs-departmentB |
192.168.0.3 |
N/A |
Server of department B, which can communicate with the server of department A |
|
Private NAT gateways |
private-nat-A |
N/A |
N/A |
Private NAT gateway configured in vpc-departmentA |
private-nat-B |
N/A |
N/A |
Private NAT gateway configured in vpc-departmentB |
Prerequisites
- A Huawei Cloud account is available.
- Your account is not in arrears and the account balance is sufficient to pay for the resources involved in this best practice.
- A private NAT gateway is available.
Procedures
- Creating VPCs
- Creating ECSs
- Assigning Transit IP Addresses
- Buying a Private NAT Gateway and Adding Rules
- Configuring a Route from a Server to a Private NAT Gateway
- Configuring a VPC Peering Connection Between vpc-transit1 and vpc-transit2
- Verifying Communication Between the Server in Departments A and that in Department B
Creating VPCs
- Go to the Create VPC page.
- On the Create VPC page, configure the VPC for department A based on Table 1 and click Create Now.
- Region: Select CN-Hong Kong.
- Name: Set it to vpc-departmentA.
- IPv4 CIDR Block: Set it to 192.168.0.0/24.
- Subnet Name: Set it to subnet-A.
- IPv4 CIDR Block: Retain the default value.
- For parameters not mentioned, retain their default values or configure them as prompted.
Figure 2 Create VPC
- Repeat the above steps to create all required VPCs in Table 1.
- Region: Select CN-Hong Kong.
- Name: Set it to vpc-departmentB.
- IPv4 CIDR Block: Set it to 192.168.0.0/24.
- Subnet Name: Set it to subnet-B.
- IPv4 CIDR Block: Retain the default value.
- For parameters not mentioned, retain their default values or configure them as prompted.
Figure 3 Creating a VPC
Creating ECSs
- Under Compute, select Elastic Cloud Server. On the Elastic Cloud Server page displayed, click Create ECS.
- Based on Table 1, configure basic information about the ECS of department A and click Next: Configure Network.
- Billing Mode: Select Pay-per-use.
- Region: Select CN-Hong Kong.
- Specifications: You can select ECS specifications based on your project requirements. This example uses c6.large.2 as an example.
- Image: Select Public image. This example uses a CentOS 8.0 image.
- For parameters not mentioned, retain their default values or configure them as prompted.
- Configure network information for the ECS of department A.
- Network: Select VPC vpc-departmentA, select Manually specify IP address, and set the IP address to 192.168.0.3 planned in Table 1.
- Security Group: Select Sys-FullAccess. In this example, we will select a security group that allows all inbound and outbound traffic as the test security group, but you can select a different security group based on service requirements if needed.
- EIP: Select Not required.
- For parameters not mentioned, retain their default values or configure them as prompted.
- Click Next: Configure Advanced Settings.
- Configure the ECS name, password, and other information.
- ECS Name: Set it to ecs-departmentA.
- Login Mode: Select Password and enter a password.
- For parameters not mentioned, retain their default values or configure them as prompted.
- Click Next: Confirm.
- Confirm the ECS information, read the agreement and select the Agreement option, and click Submit to finish the ECS creation for department A.
- In the ECS list, locate the ECS for department A and click Remote Login in the Operation column. In the displayed dialog box, click Log In under Other Login Modes.
- Log in to the ECS as user root and check whether the private IP address of the ECS is the one you planned.
ifconfig
- Repeat 1 through 9 to create other ECSs as planned.
Assigning Transit IP Addresses
- On the management console, under Networking, select NAT Gateway. In the left navigation pane, choose Private NAT Gateways. Click the Transit IP Addresses tab.
- Click Assign Transit IP Address.
- In the Assign Transit IP Address dialog box, assign a transit IP address for department A based on Table 1.
- Transit VPC: Select vpc-transit1.
- Transit Subnet: Select ext_sub_T1.
- Transit IP Address: Select Manual.
- IP Address: Enter 10.1.0.11.
- Click OK.
- Repeat 1 through 4 to assign a transit IP address (10.2.0.22) for department B.
- Transit VPC: Select vpc-transit2.
- Transit Subnet: Select ext_sub_T2.
- Transit IP Address: Select Manual.
- IP Address: Enter 10.2.0.22.
Buying a Private NAT Gateway and Adding Rules
- Go back to the Private NAT Gateways page and click Buy Private NAT Gateway in the upper right corner.
- Configure parameters for creating a private NAT gateway for department A.
- Region: Select CN-Hong Kong.
- Name: Set it to private-nat-A.
- VPC: Select vpc-departmentA.
- For parameters not mentioned, retain their default values or configure them as prompted.
- Click Buy Now.
- On the Private NAT Gateways tab, click the name of the private NAT gateway on which you need to add a DNAT rule.
- Switch to the DNAT Rules tab and click Add DNAT Rule.
- Configure DNAT rule parameters and click OK.
- Port Type: Select All ports.
- Transit Subnet: Select ext_sub_T1.
- Transit IP Address: Enter 10.1.0.11.
- Instance Type: Select Server and the ECS of department A.
- Go back to the Private NAT Gateways page and click Buy Private NAT Gateway in the upper right corner.
- Configure parameters for creating a private NAT gateway for department B.
- Region: Select CN-Hong Kong.
- Name: Set it to private-nat-B.
- VPC: Select vpc-departmentB.
- For parameters not mentioned, retain their default values or configure them as prompted.
- Click Buy Now.
- On the Private NAT Gateways tab, click the name of the private NAT gateway on which you need to add a DNAT rule.
- Switch to the DNAT Rules tab and click Add DNAT Rule.
- Configure DNAT rule parameters and click OK.
- Port Type: Select All ports.
- Transit Subnet: Select ext_sub_T2.
- Transit IP Address: Select 10.2.0.22.
- Instance Type: Select Server and the ECS of department B.
Configuring a Route from a Server to a Private NAT Gateway
- Choose Networking > Virtual Private Cloud. In the navigation pane on the left, choose Route Tables.
- Click rtb-vpc-departmentA. On the Summary page, click Add Route.
- Configure a route for the server in department A to access the private NAT gateway of department A and click OK.
- Destination: Enter 0.0.0.0/0. (In actual operations, configure this parameter based on service requirements.)
- Next Hop Type: Select NAT gateway.
- Next Hop: The system automatically displays the private NAT gateway of department A.
- Go back to the Route Tables page, click rtb-vpc-departmentB, and click Add Route.
- Configure a route for the server in department B to access the private NAT gateway of department B and click OK.
- Destination: Set it to 0.0.0.0/0.
- Next Hop Type: Select NAT gateway.
- Next Hop: The system automatically displays the private NAT gateway of department B.
Configuring a VPC Peering Connection Between vpc-transit1 and vpc-transit2
- Under Networking, select Virtual Private Cloud. In the navigation pane on the left, choose VPC Peering Connections.
- Click Create VPC Peering Connection.
- Configure transit VPC1 as the local VPC and transit VPC2 as the peer VPC. Configure the following parameters and click OK.
- Name: Set it to peering-TtoT.
- Local VPC: Select vpc-transit1.
- Peer VPC: Select vpc-transit2.
- For parameters not mentioned, retain their default values or configure them as prompted.
- Go back to the VPC Peering Connections page. In the navigation pane on the left, choose Route Tables.
- Click rtb-vpc-transit1. On the Summary page, click Add Route.
- Configure the route from vpc-transit1 to peering-TtoT and click OK.
- Destination: Set it to 0.0.0.0/0.
- Next Hop Type: Select VPC peering connection.
- Next Hop: The system automatically displays the VPC peering connection.
- Repeat 5 and 6 (selecting rtb-vpc-transit2) to configure the route from vpc-transit2 to the VPC peering connection.
Verifying Communication Between the Server in Departments A and that in Department B
- Under Compute, select Elastic Cloud Server. Log in to ecs-departmentA and ecs-departmentB using VNC, respectively.
- On ecs-departmentA, verify that it can access the server in department B:
ping 10.2.0.22
- On ecs-departmentB, verify that it can access the server in department A:
ping 10.1.0.11
The servers in the overlapping subnets can now communicate with each other through the private NAT gateway.
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot