This topic describes how to create a Virtual Private Cloud (VPC) with an IPv4 CIDR block. After you create a VPC, you can create an Elastic Compute Service (ECS) instance in the VPC, and associate an Elastic IP address (EIP) with the ECS instance to allow it Internet access.

Prerequisites

To deploy cloud resources in a VPC, you must complete network planning. For more information, see Plan a VPC network.

Step 1: Create a VPC and a VSwitch

To create a VPC and a VSwitch, follow these steps:

  1. Log on to the VPC console.
  2. In the top navigation bar, select the region of the VPC.

    The VPC must be in the same region as the cloud resources that you want to deploy. In this topic, China (Qingdao) is selected.

  3. On the VPCs page, click Create VPC.
  4. On the Create VPC page, configure the VPC and the VSwitch according to the following information, and then click OK.
    Configuration Description
    VPC
    Region The region in which the VPC is created.
    Name Enter a name for the VPC.

    The name must be 2 to 128 characters in length and can contain letters, numbers, underscores (_), and hyphens (-). It must start with a letter.

    IPv4 CIDR Block Select an IPv4 CIDR block. Options:
    • Default CIDR Block: Select 192.168.0.0/16, 172.16.0.0/12, or 10.0.0.0/8.
    • Custom CIDR Block: Select 192.168.0.0/16, 172.16.0.0/12, 10.0.0.0/8, or their subnets. The CIDR block mask must be 8 to 24 bits in length. In this example, enter 192.168.0.0/16. If you want to use a public CIDR block as the CIDR block of the VPC, open a ticket.
    Notice After a VPC is created, you cannot change its IPv4 CIDR block.
    Description Enter a description for the VPC.

    The description must be 2 to 256 characters in length and cannot start with http:// or https://.

    VSwitch
    Name Enter a name for the VSwitch.

    The name must be 2 to 128 characters in length and can contain letters, numbers, underscores (_), and hyphens (-). The name must start with a letter.

    Zone Select the zone to which the VSwitch belongs. In a VPC, VSwitches in different zones can communicate with each other through the internal network.
    IPv4 CIDR Block Enter the IPv4 CIDR block of the VSwitch. Note the following when you specify the IPv4 CIDR block:
    • The CIDR block of a VSwitch must be a subset of the CIDR block of the VPC.

      For example, if the CIDR block of the VPC is 192.168.0.0/16, the CIDR block of the VSwitch in the VPC can be any CIDR block between 192.168.0.0/17 and 192.168.0.0/29.

    • The first IP address and the last three IP addresses in the VSwitch CIDR block are reserved.

      For example, if the VSwitch CIDR block is 192.168.1.0/24, the IP addresses 192.168.1.0, 192.168.1.253, 192.168.1.254, and 192.168.1.255 are reserved.

    • If the VSwitch needs to communicate with VSwitches in other VPCs or with on-premises data centers, make sure that the CIDR blocks involved do not conflict with each other.
    Notice After the VSwitch is created, you cannot modify its CIDR block.
    Number of Available Private IPs Displays the number of available IP addresses.
    Description Enter a description for the VSwitch.

    The description must be 2 to 256 characters in length and cannot start with http:// or https://.

Step 2: Create an ECS instance

To create an ECS instance in the VPC, follow these steps:

  1. Log on to the VPC console.
  2. In the left-side navigation pane, click VSwitches.
  3. In the top navigation bar, select the region of the VSwitch. In this topic, select China (Qingdao).
  4. On the VSwitches page, find the target VSwitch, and then choose Purchase > ECS Instance in the Actions column.
  5. On the Custom Launch page, configure the ECS instance, and then click confirm to pay.
    The networking parameters are set as follows:
    • Network Type: Select the created VPC and VSwitch.
    • Public IP Address: Leave this box unchecked.
    • Security Group: Use the Default Security Group.
  6. Go back to the ECS console to view the created ECS instance.
    View details of an ECS instance

Step 3: Create an EIP and associate it with the ECS instance

An EIP is a public IP address resource that can be purchased and held independently. You can associate an EIP with an ECS instance in a VPC to allow the ECS instance Internet access.

To create an EIP and associate it with the ECS instance, follow these steps:

  1. Log on to the VPC console.
  2. In the left-side navigation pane, click Elastic IP Addresses.
  3. On the Elastic IP Addresses page, click Create EIP.
  4. On the Elastic IP page, configure the EIP, and then click Buy Now to complete the payment.
    For information about EIP billing, see Pay-as-you-go.
  5. On the Elastic IP Addresses page, find the target EIP, and then click Bind in the Actions column.
  6. On the Bind Elastic IP Address page, complete the following configurations, and then click OK.
    • Instance Type: Select ECS Instance.
    • ECS Instance: Select the ECS instance to be associated with the EIP.

Step 4: Test Internet connectivity

To test the network connectivity of the ECS instance, follow these steps:

  1. Log on to the ECS instance associated with the EIP.
  2. Use the ping command to test public network communication.
    Test Internet connectivity