Updated on 2022-08-18 GMT+08:00

(Optional) Creating a Subnet for the VPC

Scenarios

A VPC comes with a default subnet. If the default subnet cannot meet your requirements, you can create one.

The subnet is configured with DHCP by default. When an ECS using this VPC starts, the ECS automatically uses DHCP to obtain an IP address.

The method to visit the subnet module varies by region.

  • In some regions, you can perform operations on subnets on the Subnets tab of the VPC details page. This is used as the example of the operation procedure in this section.
  • In some regions, under Network on the console homepage, click Virtual Private Cloud. On the displayed network console, click Subnets in the navigation pane on the left, then you can perform operations on the subnet.

Procedure

  1. Log in to the management console.
  1. On the console homepage, under Network, click Virtual Private Cloud.
  2. In the navigation pane on the left, click Virtual Private Cloud.
  3. On the Virtual Private Cloud page, locate the VPC for which a subnet is to be created and click the VPC name.
  4. On the displayed Subnets tab, click Create Subnet.
  5. Configure the required parameters.

    Table 1 Parameter descriptions

    Parameter

    Description

    Example Value

    VPC

    The VPC for which you want to create a subnet.

    This parameter is available only when Subnets is displayed in the navigation pane.

    -

    Name

    The subnet name.

    The name can contain a maximum of 64 characters, including only letters, digits, underscores (_), hyphens (-), and periods (.). Spaces are not allowed.

    Subnet

    CIDR Block

    The CIDR block for the subnet. This value must be within the VPC CIDR block.

    192.168.0.0/24

    IPv4 CIDR Block

    The CIDR block for the subnet. This value must be within the VPC CIDR block.

    This parameter will be displayed if you have applied for the IPv6 OBT.

    192.168.0.0/24

    IPv6 CIDR Block

    Specifies whether to enable IPv6.

    This parameter will be displayed if you have applied for the IPv6 OBT. After the IPv6 function is enabled, 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.

    -

    Advanced Settings

    Click the drop-down arrow to set advanced settings for the subnet, including Gateway and DNS Server Address.

    Default

    Gateway

    The gateway address of the subnet.

    This IP address is used to communicate with other subnets.

    192.168.0.1

    DNS Server Address

    DNS server addresses allow ECSs in a VPC subnet to communicate with each other using private domain names. You can also directly access cloud services through private DNS servers.

    If you want to use other public DNS servers for resolution, you can change the default DNS server addresses.

    100.125.x.x

    DHCP Lease Time

    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. Unit: Day/Hour

    If a DHCP lease time is changed, the new lease automatically takes effect when half of the current lease time has passed. To make the change take effect immediately, restart the ECS or log in to the ECS to cause the DHCP lease to automatically renew.

    365

  6. Click OK.

Notes

When a subnet is created, there are five reserved IP addresses, which cannot be used. For example, in a subnet with CIDR block 192.168.0.0/24, the following IP addresses are reserved:

  • 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: Gateway address.
  • 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.

If you set Advanced Settings to Custom during subnet creation, the reserved IP addresses may be different from the default ones, but there will still be five of them. The specific addresses depend on your subnet settings.