Creating a Subnet for an Existing VPC
Scenarios
A subnet is a unique CIDR block with a range of IP addresses in a VPC. All resources in a VPC must be deployed on subnets.
When creating a VPC, you need to create at least one subnet. If one subnet cannot meet your requirements, you can create more subnets for the VPC.
Notes and Constraints
After a subnet is created, some reserved IP addresses cannot be used. For example, in a subnet with CIDR block 192.168.0.0/24, the following IP addresses are reserved by default:
- 192.168.0.0: Network ID. This address is the beginning of the private IP address range and will not be assigned to any instance.
- 192.168.0.1: The gateway address of the subnet.
- 192.168.0.253: Reserved for the system interface. This IP address is used by the VPC for external communication.
- 192.168.0.254: DHCP service address.
- 192.168.0.255: Network broadcast address.
The preceding default IP addresses are only examples. The system will assign reserved IP addresses based on how you specify your subnet.
Procedure
- Log in to the management console.
- Click in the upper left corner and select the desired region and project.
- Click in the upper left corner and choose Networking > Virtual Private Cloud.
The Virtual Private Cloud page is displayed.
- In the navigation pane on the left, choose Virtual Private Cloud > Subnets.
- Click Create Subnet.
The Create Subnet page is displayed.
- Set the parameters as prompted.
Table 1 Subnet parameter descriptions Parameter
Description
Example Value
Region
The region where VPC is located.
EU-Dublin
VPC
The VPC for which you want to create a subnet.
vpc-test
Subnet Name
The subnet name. The name:- Can contain 1 to 64 characters.
- Can contain letters, digits, underscores (_), hyphens (-), and periods (.).
subnet-01
AZ
An AZ is a geographic location with independent power supply and network facilities in a region. AZs are physically isolated, and AZs in the same VPC are interconnected through an internal network.
Each region contains multiple AZs. If one AZ is unavailable, other AZs in the same region continue to provide services.- By default, all instances in different subnets of the same VPC can communicate with each other and the subnets can be located in different AZs. For example, if you have a VPC with two subnets, A01 in AZ 1 and A02 in AZ 2. Subnet A01 and A02 can communicate with each other by default.
- A cloud resource can be in a different AZ from its subnet. For example, a cloud server in AZ 1 can be in a subnet in AZ 3. If AZ 3 becomes faulty, cloud servers in AZ 1 can still use the subnet in AZ 3, and your services are not interrupted.
For details, see Region and AZ.
AZ1
IPv4 CIDR Block
The IPv4 CIDR block of the subnet. This parameter is displayed only in regions where IPv4/IPv6 dual stack is supported.
A subnet is a unique CIDR block with a range of IP addresses in a VPC. Comply with the following principles when planning subnets:
- Planning CIDR block size: After a subnet is created, the CIDR block cannot be changed. You need to properly plan the CIDR block in advance based on the number of IP addresses required by your service.
- The subnet CIDR block size cannot be too small. Ensure that the number of available IP addresses in the subnet meets service requirements. Remember that the first and last three addresses in a subnet CIDR block are reserved for system use. For example, in subnet 10.0.0.0/24, 10.0.0.1 is the gateway address, 10.0.0.253 is the system interface address, 10.0.0.254 is used by DHCP, and 10.0.0.255 is the broadcast address.
- The subnet CIDR block cannot be too large, either. If you use a CIDR block that is too large, you may not have enough CIDR blocks available later for new subnets, which can be a problem when you want to scale out services.
- Avoid CIDR block conflicts if you need to connect two VPCs or connect a VPC to an on-premises data center.
If the subnet CIDR blocks at both ends of the network conflict, create a subnet.
If the VPC has a secondary CIDR block, you can select the primary or the secondary CIDR block that the subnet will belong to based on service requirements.
10.0.0.0/24
IPv6 CIDR Block (Optional)
The IPv6 CIDR block of the subnet. This parameter is displayed only in regions where IPv4/IPv6 dual stack is supported.
If you select this option, the system automatically assigns an IPv6 CIDR block to the created subnet. Currently, the IPv6 CIDR block cannot be customized. IPv6 cannot be disabled after the subnet is created.
For details, see IPv4 and IPv6 Dual-Stack Network.
N/A
Associated Route Table
The default route table with which the subnet will be associated. A route table contains a set of routes that are used to control the traffic routing for your subnets in a VPC. Each VPC comes with a default route table. Subnets in the VPC are then automatically associated with the default route table. The default route table ensures that subnets in a VPC can communicate with each other.
If the default route table cannot meet your requirements, you can create a custom route table and associate subnets with it. Then, the default route table controls inbound traffic to the subnets, while the custom route table controls outbound traffic from the subnets. For details, see Creating a Custom Route Table.
N/A
Advanced Settings (Optional) > Gateway
The gateway address of the subnet. Click to expand the configuration area and set this parameter.
Retain the default value unless there are special requirements.
10.0.0.1
Advanced Settings (Optional) > DNS Server Address
The DNS server addresses. Click to expand the configuration area and set this parameter.
Huawei Cloud private DNS server addresses are entered by default. This allows ECSs in a VPC to communicate with each other and also access other cloud services using private domain names without exposing their IP addresses to the Internet.
You can change the default DNS server addresses if needed. This may interrupt your access to cloud services.
You can also click Reset on the right to restore the DNS server addresses to the default value.
A maximum of two DNS server IP addresses can be configured. Multiple IP addresses must be separated using commas (,).
100.125.x.x
Advanced Settings (Optional) > IPv4 DHCP Lease Time
The period during which a client can use an IP address automatically assigned by the DHCP server. Click to expand the configuration area and set this parameter.
The period during which a client can use an IP address automatically assigned by the DHCP server. After the lease time expires, a new IP address will be assigned to the client.- Limited: Set the DHCP lease time. The unit can be day or hour.
- Unlimited: The DHCP lease time does not expire.
If the time period is changed, the new lease time takes effect when the instance (such as an ECS) in the subnet is renewed next time. You can wait for the instance to be renewed automatically or manually modify the lease time. If you want the new lease time to take effect immediately, manually renew the lease or restart the ECS.
N/A
Advanced Settings (Optional) > Tag
The subnet tag. Click to expand the configuration area and set this parameter.
Add tags to help you quickly identify, classify, and search for your subnets.
For details, see Managing Subnet Tags.
- Key: subnet_key1
- Value: subnet-01
Advanced Settings > Description
Supplementary information about the subnet. Click to expand the configuration area and set this parameter.
Enter the description about the subnet in the text box as required.
The subnet description can contain a maximum of 255 characters and cannot contain angle brackets (< or >).
N/A
- Click Create Now.
Return to the subnet list and view the new subnet.
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.