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 an Elastic Compute Service (ECS) instance in the VPC network, and associate an Elastic IP address (EIP) with the ECS instance to allow the instance to access the Internet.

Prerequisites

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

Step 1: Create a VPC network and a VSwitch

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

  1. Log on to the VPC console.
  2. On the top of the page, select a region for the VPC network.

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

  3. On the VPCs page, click Create VPC.
  4. In the Create VPC dialog box that appears, set the following parameters of the VPC network and VSwitches, and 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 the primary IPv4 CIDR block for the VPC. 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 as the primary IPv4 CIDR block of the VPC. The CIDR block mask must be 8 to 24 bits in length. In this example, select 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 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.

    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 (-). It 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.
    Zone Resource Displays the cloud instances that can be created in the selected zone.

    The cloud instances that can be created vary according to the zone and the time. The purchase page displays whether the cloud instances are available for purchase. Currently, the purchase page only displays ECS, RDS, and SLB instances.

    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 specified VPC network, follow these steps:

  1. Log on to the VPC console.
  2. In the left-side navigation pane, click VSwitches.
  3. On the top of the page, select a region where the Switch belongs. In this topic, select China (Qingdao).
  4. On the VSwitches page, find the VSwitch that you want to manage, click Purchase > ECS Instance in the Actions column for the VSwitch.
  5. On the Custom Launch page that appears, set the parameters of the ECS instance, and click Create Instance.
    The parameters are set as follows in this example:
    • 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. Go back to the ECS console to view the ECS instance that you have created.
    View details of an ECS instance

Step 3: Create an Elastic IP address and associate it with the ECS instance

An Elastic IP address (EIP) can be purchased and held independently from other services. You can associate an EIP with an ECS instance in a VPC network to allow the ECS instance to access the Internet.

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 that appears, click Create EIP.
  4. On the Elastic IP page, set the parameters of the EIP, and click Buy Now to complete the payment.
    For more information, see Create a new Elastic IP address.
  5. On the Elastic IP Addresses page, find the EIP that you want to manage, and click Bind in the Actions column for the EIP.
  6. In the Bind Elastic IP Address dialog box that appears, set the following parameters and click OK.
    • Instance Type: Select ECS instance.
    • ECS Instance: Select the ECS instance to which the specified EIP is bound.

Step 4: Test Internet connectivity

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

  1. Log on to the ECS instance to which the specified EIP is bound.
  2. Run the ping command to test network communications between the ECS instance and the Internet.
    Test Internet connectivity