Help Center> Virtual Private Cloud> Getting Started> Setting Up an IPv4 Network
Updated on 2023-06-26 GMT+08:00

Setting Up an IPv4 Network

This topic describes how to create a VPC with an IPv4 CIDR block and bind an EIP to an ECS in the VPC to allow the ECS to access the Internet. Figure 1 shows the configuration process.

Figure 1 Setting up an IPv4 network

Step 1: Create a VPC

Before creating your VPCs, determine how many VPCs, the number of subnets, and what IP address ranges you will need. For details, see Network Planning.

In the instructions presented here, our sample VPC is named vpc-test and its default subnet called subnet-01.

  1. Log in to the management console.
  2. On the console homepage, under Networking, click Virtual Private Cloud.
  3. Click Create VPC.

    The Create VPC page is displayed.

  4. On the Create VPC page, set parameters as prompted.

    A default subnet will be created together with a VPC and you can also click Add Subnet to create more subnets for the VPC.

    Figure 2 Creating a VPC and subnet
    Table 1 VPC parameter descriptions

    Parameter

    Description

    Example Value

    Region

    Regions are geographic areas that are physically isolated from each other. The networks inside different regions are not connected to each other, so resources cannot be shared across different regions. For lower network latency and faster access to your resources, select the region nearest you.

    CN-Hong Kong

    Name

    The VPC name.

    The name can contain a maximum of 64 characters, which may consist of letters, digits, underscores (_), hyphens (-), and periods (.). The name cannot contain spaces.

    VPC-test

    CIDR Block or IPv4 CIDR Block

    The CIDR block of the VPC. The CIDR block of a subnet can be the same as the CIDR block for the VPC (for a single subnet in the VPC) or a subset of the CIDR block for the VPC (for multiple subnets in the VPC).

    The following CIDR blocks are supported:

    • 10.0.0.0/8-24
    • 172.16.0.0/12-24
    • 192.168.0.0/16-24

    This parameter will be CIDR Block in regions where IPv4/IPv6 dual stack is not supported, and IPv4 CIDR Block if IPv4/IPv6 dual stack is supported.

    192.168.0.0/16

    Enterprise Project

    The enterprise project to which the VPC belongs.

    An enterprise project facilitates project-level management and grouping of cloud resources and users. The name of the default project is default.

    For details about creating and managing enterprise projects, see the Enterprise Management User Guide.

    default

    Tag

    The VPC tag, which consists of a key and value pair. You can add a maximum of 10 tags to each VPC.

    • Key: vpc_key1
    • Value: vpc-01

    Description

    Supplementary information about the VPC. This parameter is optional.

    The VPC description can contain a maximum of 255 characters and cannot contain angle brackets (< or >).

    N/A

    Table 2 Subnet parameter descriptions

    Parameter

    Description

    Example Value

    Name

    The subnet name.

    The name can contain a maximum of 64 characters, which may consist of letters, digits, underscores (_), hyphens (-), and periods (.). The name cannot contain spaces.

    subnet-01

    CIDR Block

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

    This parameter is displayed only in regions where IPv4/IPv6 dual stack is not supported.

    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 is displayed only in regions where IPv4/IPv6 dual stack is supported.

    192.168.0.0/24

    IPv6 CIDR Block

    Specifies whether to set IPv6 CIDR Block to Enable.

    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.

    This parameter is displayed only in regions where IPv4/IPv6 dual stack is supported.

    -

    Associated Route Table

    The default route table to which the subnet will be associated. You can change the route table to a custom route table on the Subnets page.

    Default

    Advanced Settings

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

    Retain the default settings.

    Gateway

    The gateway address of the subnet.

    This IP address is used to communicate with other subnets.

    192.168.0.1

    DNS Server Address

    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

    Domain Name

    Enter domain names (), separated with spaces. A maximum of 254 characters are allowed. A domain name can consist of multiple labels (max. 63 characters each).

    To access a domain name, you only need to enter the domain name prefix. ECSs in the subnet automatically match the configured domain name suffix.

    If the domain names are changed, ECSs newly added to this subnet will use the new domain names.

    If an existing ECS in this subnet needs to use the new domain names, restart the ECS or run a command to restart the DHCP Client service or network service.

    NOTE:
    The command for updating the DHCP configuration depends on the ECS OS. The following commands are for your reference.
    • Restart the DHCP Client service: service dhcpd restart
    • Restart the network service: service network restart

    test.com

    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.
    • Limited: Set the DHCP lease time. The unit can be day or hour.
    • Unlimited: The DHCP lease time does not expire.

    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 days

    NTP Server Address

    The IP address of the NTP server. This parameter is optional.

    You can configure the NTP server IP addresses to be added to the subnet as required. The IP addresses are added in addition to the default NTP server addresses. If this parameter is left empty, no IP address of the NTP server is added.

    Enter a maximum of four valid IP addresses, and separate multiple IP addresses with commas. Each IP address must be unique. If you add or change the NTP server addresses of a subnet, you need to renew the DHCP lease for or restart all the ECSs in the subnet to make the change take effect immediately. If the NTP server addresses have been cleared out, restarting the ECSs will not help. You must renew the DHCP lease for all ECSs to make the change take effect immediately.

    192.168.2.1

    Tag

    The subnet tag, which consists of a key and value pair. You can add a maximum of 10 tags to each subnet.

    • Key: subnet_key1
    • Value: subnet-01

    Description

    Supplementary information about the subnet. This parameter is optional.

    The subnet description can contain a maximum of 255 characters and cannot contain angle brackets (< or >).

    N/A

    Table 3 VPC tag key and value requirements

    Parameter

    Requirements

    Example Value

    Key

    • Cannot be left blank.
    • Must be unique for each VPC and can be the same for different VPCs.
    • Can contain a maximum of 36 characters.
    • Can contain letters, digits, underscores (_), and hyphens (-).

    vpc_key1

    Value

    • Can contain a maximum of 43 characters.
    • Can contain letters, digits, underscores (_), periods (.), and hyphens (-).

    vpc-01

    Table 4 Subnet tag key and value requirements

    Parameter

    Requirements

    Example Value

    Key

    • Cannot be left blank.
    • Must be unique for each subnet.
    • Can contain a maximum of 36 characters.
    • Can contain letters, digits, underscores (_), and hyphens (-).

    subnet_key1

    Value

    • Can contain a maximum of 43 characters.
    • Can contain letters, digits, underscores (_), periods (.), and hyphens (-).

    subnet-01

  5. Confirm the current configuration and click Create Now.

Step 2: Buy an ECS

On the management console, under Compute, click Elastic Cloud Server, and then click Buy ECS.

Configure the network as follows:

Figure 3 Network configuration
Figure 4 Network configuration
  • Network: Select the created VPC vpc-test and subnet subnet-01.
  • Security Group: Select the default security group Sys-default. Table 5 lists the default security group rules.
    You can also create a security group and add rules to it.
    Table 5 Rules in the default security group

    Direction

    Priority

    Action

    Protocol

    Port/Range

    Source/Destination

    Description

    Outbound

    100

    Allow

    All

    All

    Destination: 0.0.0.0/0

    Allows all outbound traffic.

    Inbound

    100

    Allow

    All

    All

    Source: Current security group name

    Allows communications among ECSs within the same security group on any port.

    Inbound

    100

    Allow

    TCP

    22

    Source: 0.0.0.0/0

    Allows all IP addresses to access Linux ECSs over SSH.

    Inbound

    100

    Allow

    TCP

    3389

    Source: 0.0.0.0/0

    Allows all IP addresses to access Windows ECSs over RDP.

  • EIP: Select Not required.

Step 3: Buy an EIP and Bind It to an ECS

The EIP service provides independent public IP addresses and bandwidth for Internet access. You can buy an EIP and bind it to an ECS to allow the ECS to access the Internet.

If you already have an EIP that has not been bound to any resource, you can directly bind the EIP to the ECS.

Buying an EIP

  1. Log in to the management console.
  2. On the console homepage, under Networking, click Virtual Private Cloud.
  3. Choose Elastic IP and Bandwidth > EIPs.
  4. Click Buy EIP.
  5. Set parameters as prompted.
    Figure 5 Buying an EIP
    Table 6 Parameter descriptions

    Parameter

    Description

    Example Value

    Billing Mode

    The following billing modes are available:

    • Yearly/Monthly
    • Pay-per-use

    Pay-per-use

    Region

    Regions are geographic areas that are physically isolated from each other. The networks inside different regions are not connected to each other, so resources cannot be shared across different regions. For lower network latency and faster access to your resources, select the region nearest you.

    CN-Hong Kong

    EIP Type

    • Dynamic BGP: Dynamic BGP provides automatic failover and chooses the optimal path when a network connection fails.
    • Static BGP: Static BGP offers more routing control and protects against route flapping, but an optimal path cannot be selected in real time when a network connection fails.

    Dynamic BGP

    Billed By

    This parameter is available when you set Billing Mode to Pay-per-use.

    • Bandwidth: You specify a maximum bandwidth and pay for the amount of time you use the bandwidth. This is suitable for scenarios with heavy or stable traffic.
    • Traffic: You specify a maximum bandwidth and pay for the total traffic you use. This is suitable for scenarios with light or sharply fluctuating traffic.
    • Shared Bandwidth: The bandwidth can be shared by multiple EIPs. This is suitable for scenarios with staggered traffic.

    Bandwidth

    Bandwidth

    The bandwidth size in Mbit/s.

    5

    Bandwidth Name

    The name of the bandwidth.

    bandwidth-test

    Required Duration

    This parameter is available only when Billing Mode is set to Yearly/Monthly.

    1 month

    Quantity

    The number of EIPs you want to assign.

    The quantity must be specified if the Billing Mode is set to Pay-per-use.

    1

    Tag

    The EIP tag that consists of a key and value pair.

    The tag key and value must meet the requirements listed in Table 7.

    • Key: Ipv4_key1
    • Value: 192.168.12.10

    Enterprise Project

    The enterprise project that the EIP belongs to.

    An enterprise project facilitates project-level management and grouping of cloud resources and users. The name of the default project is default.

    For details about creating and managing enterprise projects, see the Enterprise Management User Guide.

    default

    Table 7 EIP tag requirements

    Parameter

    Requirement

    Example Value

    Key

    • Cannot be left blank.
    • Must be unique for each EIP.
    • Can contain a maximum of 36 characters.
    • Can contain letters, digits, underscores (_), and hyphens (-).

    Ipv4_key1

    Value

    • Can contain a maximum of 43 characters.
    • Can contain letters, digits, underscores (_), periods (.), and hyphens (-).

    3005eip

  6. Click Next.

Binding the EIP

  1. In the EIP list, locate the target EIP and click Bind.
    Figure 6 Bind
  2. Select the ECS.
    Figure 7 Bind EIP

  3. Click OK.

Verifying the Result

After an EIP is bound to the ECS, you can access the ECS from the Internet. You can perform the following steps to verify the access:
  • Log in to the ECS using SSH or the RDP file through the EIP. For details, see Logging In to an ECS.
  • Ping the EIP of the ECS from the Internet.

Ensure that the security group of the ECS allows the ICMP traffic (ping) and the access from specific ports, such as port 22 (SSH) and port 3389 (RDP).