Binding and Configuring CVMs

Last Updated At: 2025-10-21 09:10:00

I. Binding CVMs

  1. You can log in to the VPC console and click IP And Network Card > ENI in the left-side directory to open the Elastic Network Interface list page.

  2. You can find the row of the Elastic Network Interface (ENI) that needs to be bound and configured and click Bind CVM in the operation column.

    Note:

    It only supports binding to CVMs in the same availability zone as the ENI.


3. In the pop-up box, you can select the CVMs you want to bind and click OK to bind.

II. Configuring CVMs

Configuration Steps Under Linux

Note:

The following steps take CentOS 7 and above as an example.

  1. You can log in to the CVMs as an administrator and execute the following command:

    cd /etc/sysconfig/network-scripts/
    
  2. You can create a NI configuration file ifcfg-eth1.

  3. You can enter the following command:

    cp ifcfg-eth0 ifcfg-eth1
    
  4. You can enter the command to modify the configuration file content.

    vim ifcfg-eth1
    
  5. You can press i to switch to the edito mode and modify the configuration file content to:

    DEVICE='eth1'
    NM_CONTROLLED='yes'
    ONBOOT='yes'
    IPADDR='192.168.1.62' # Fill in the IP on the ENI according to the actual situation.
    NETMASK='255.255.255.192' # Fill in the subnet mask according to the actual situation.
    #GATEWAY='192.168.1.1' # Fill in according to the actual situation. Because the gateway is defined in the eth0 file, the gateway is not written here to avoid gateway conflicts.
    

    Note:

    To view the IP and subnet mask of an ENI, please refer to the appendix below.

  6. After modification, You can save the configuration file and exit (press Esc in vim's last line mode, enter wq! and press Enter).

  7. You can enter the following command to restart the network service:

    systemctl restart network
    
  8. You can check and confirm whether the IP is correctly configured.

  9. You can enter the following command to view the IP:

    ip addr
    
  10. You can confirm that the secondary NI and the IP on it are visible, as shown in the following figure.


11. You can configure routes based on actual service conditions.
After configuration according to the above steps, the Linux image still sends packets from the primary NI by default. You can determine which NI a message enters and returns from as per the policy routing.

  1. You can create two route tables.
echo "10 t1" >> /etc/iproute2/rt_tables
echo "20 t2" >> /etc/iproute2/rt_tables
  1. You can add a default route to both route tables.
ip route add default dev eth0 via 192.168.1.1 table 10
ip route add default dev eth1 via 192.168.1.1 table 20

Note:

In the above two commands,

192.168.1.1

You need to replace them with the gateway of the subnet to which the primary NI belongs and that of the subnet to which the secondary NI belongs.

  1. You can configure the policy route.
ip rule add from 192.168.1.5 table 10
ip rule add from 192.168.1.62 table 20

Note:

  • In the above two commands, IP should be replaced with the IP on the primary network card, and the IP on the auxiliary network card, respectively.
  • After restarting the network, you need to reconfigure the routes.

  1. The configuration is now completed. You can use the CVMs in the same subnet to ping the private IP. If it works, it means that the private network address is successfully pinged. If there is no other CVMs, you can bind the public IP to the private IP of the secondary NI and ping the public IP to verify whether the private IP is bound.

Configuration Steps Under Windows

Situation I:
If DHCP is set in the Windows operating system, the secondary NI and the IP on it can be automatically recognized without configuration.

Situation II:
If DHCP is not set in the Windows operating system, the private IP shall be configured in the operating system. The directions are as follows:

  1. You can log in to the cloud console and bind the ENI to the CVMs.

  2. In the operating system, You can manually fill in the IP information (according to the actual situation).

  3. You can check the manually entered IP.

  4. You can use the CVMs in the same subnet to ping the private IP. If it works, it means that the private network address is successfully pinged. If there is no other CVMs, you can bind the public IP to the private IP of the secondary NI and ping the public IP to verify whether the private IP is bound.

III. Appendix

Viewing the IP on the ENI

  1. You can log in to the VPC console and click IP And Network Card > ENI in the left-side directory to open the Elastic Network Interface list page.
  2. You can click the ENI ID to go to the details page.
  3. You can select the IPv4 Address Management tab to view the IP on the ENI, that is, the private IP.

Viewing the Subnet Mask on the ENI

  1. You can log in to the VPC console and click IP And Network Card > ENI in the left-side directory to open the Elastic Network Interface list page.
  2. You can click the ENI ID to go to the details page and view the subnet mask on the ENI.

As shown in the figure below, the number of CIDR bits of the subnet is /24, that is, the subnet mask of the ENI is:

255.255.255.0

The correspondence between the number of CIDR bits and the subnet mask is shown in the following table.

Number of CIDR Bits Subnet Mask
/28 255.255.255.240
/27 255.255.255.224
/26 255.255.255.192
/25 255.255.255.128
/24 255.255.255.0
/23 255.255.254.0
/22 255.255.252.0
/21 255.255.248.0
/20 255.255.240.0
/19 255.255.224.0
/18 255.255.192.0
/17 255.255.128.0
/16 255.255.0.0

Viewing Gateway

If you have not changed other settings, the gateway is the first IP of the subnet IP range. For example, the subnet IP range is 192.168.1.0/24, and then the gateway is 192.168.1.1. If you are not sure which subnet IP range the ENI belongs to, you can:

  1. You can log in to the VPC console and click IP And Network Card > ENI in the left-side directory to open the Elastic Network Interface list page.
  2. You can click the ENI ID to enter the details page and view the subnet IP range to which the ENI belongs, such as the first IP of the subnet IP range in the following figure.