This topic describes how to create a Virtual Private Cloud (VPC) network with an IPv4 CIDR block. After you create a VPC network, you can create Elastic Compute Service (ECS) instances in the VPC network, and associate elastic IP addresses (EIPs) with the ECS instances to enable the ECS instances to access the Internet.

Prerequisites

To deploy cloud resources in a VPC network, you must first set up network connections. For more information, see Plan and design a VPC.

Step 1: Create a VPC network and a VSwitch

To create a VPC network and a VSwitch, perform the following steps:

  1. Log on to the VPC console.
  2. In the top navigation bar, select the region where you want to deploy the VPC network.

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

  3. On the VPCs page, click Create VPC.
  4. In the Create VPC dialog box, set the following parameters of the VPC network and the VSwitch, and click OK.
    Parameter Description
    VPC
    Region The region where the VPC is to be deployed.
    Name Enter a name for the VPC.

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

    IPv4 CIDR Block Select the primary IPv4 CIDR block for the VPC. The following setting methods are supported:
    • Recommended CIDR Block: Enter 192.168.0.0/16, 172.16.0.0/12, or 10.0.0.0/8.
    • Custom CIDR Block: Enter 192.168.0.0/16, 172.16.0.0/12, 10.0.0.0/8, or a subset of these CIDR blocks as the primary IPv4 CIDR block of the VPC. The subnet mask must be 8 to 24 bits in length. For example, enter 192.168.0.0/16. If you want to use a public CIDR block as the CIDR block of the VPC, submit a ticket.
    Notice After you create a VPC, you cannot change its primary IPv4 CIDR block. However, you can add a secondary IPv4 CIDR block to the VPC. For more information, see Add a secondary IPv4 CIDR block.
    Description Enter a description for the VPC network.

    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, Chinese characters, digits, underscores (_), and hyphens (-). It must start with a letter or a Chinese character.

    Zone Select a zone to deploy the VSwitch. VSwitches within a VPC can communicate with each other across zones over the private network.
    Zone Resources Displays the types of cloud resources that you can create in the zone.

    The supported cloud resources vary, depending on the zone and the time when you want to create cloud resources. The buy page displays which cloud instances are available. Currently, you can check the availability of ECS, RDS, and SLB instances on the buy page.

    IPv4 CIDR Block Enter an IPv4 CIDR block for the VSwitch.
    Note the following limits when you specify an IPv4 CIDR block:
    • The CIDR block of a VSwitch must be a subset of the CIDR block of the VPC this VSwitch resides in.

      For example, if the CIDR block of a VPC is 192.168.0.0/16, the CIDR block of a VSwitch in the VPC must be a segment from 192.168.0.0/17 to 192.168.0.0/29.

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

      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 a VSwitch needs to communicate with the VSwitches in other VPCs or on-premises data centers, you must make sure that the CIDR blocks involved do not conflict with each other.
    Notice After you create a VSwitch, 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 created VPC network, perform the following 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 where the VSwitch is deployed. China (Qingdao) is selected in this topic.
  4. On the VSwitches page, find the target VSwitch, and choose Create > ECS Instance in the Actions column.
  5. On the Custom Launch tab, set the following parameters of the ECS instance.
    For more information about how to configure an ECS instance, see Create an instance by using the provided wizard.
    • Network Type: Select the VPC network and VSwitch that you have created.
    • Public IP Address: Clear the check box.
    • Security Group: Use the default security group.
  6. Click Create Order and complete the payment.
  7. Log on to the ECS console. In the left-side navigation pane, click Instances. On the Instances page, view details of the created ECS instance.
    View details of the 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 as an independent resource. You can associate EIPs with ECS instances in a VPC network to enable the ECS instances to access the Internet.

To create an EIP and associate it with the ECS instance, perform the following steps:

  1. Log on to the VPC console.
  2. In the left-side navigation pane, choose Elastic IP Addresses > Elastic IP Addresses.
  3. On the Elastic IP Addresses page, click Create EIP.
  4. On the Elastic IP page, set the parameters of the EIP, click Buy Now, and complete the payment.
    For more information, see Create a new EIP.
  5. On the Elastic IP Addresses page, find the target EIP, and click Bind Resource in the Actions column.
  6. In the Bind Elastic IP Address to Resources dialog box, set the following parameters and click OK.
    • Instance Type: Select ECS Instance from the drop-down list.
    • Binding mode: Select a mode in which the EIP is associated with the ECS instance.

      Only Normal is supported.

    • Select an instance to bind: Select the ECS instance to be associated.

Step 4: Test the network connectivity

To test the network connectivity of the ECS instance, perform the following steps:

  1. Log on to the ECS instance that is associated with the EIP.
  2. Run the ping command to test the network connectivity between the ECS instance and the Internet.
    The test result indicates that the ECS instance can access the Internet. Test the network connectivity