Updated on 2024-04-18 GMT+08:00

Creating a Supplementary Network Interface

Scenarios

The number of elastic network interfaces that can be attached to each ECS is limited. If this limit cannot meet your requirements, you can use supplementary network interfaces.

Notes and Constraints

  • Supplementary network interfaces and its elastic network interface must be in the same VPC but can belong to different subnets and security groups.
  • Before using a supplementary network interface, you need to create a VLAN sub-interface on its ECS NIC and configure routes. For details, see Configuring a Supplementary Network Interface.

Creating a Supplementary Network Interface

  1. Log in to the management console.
  2. Click in the upper left corner and select the desired region and project.
  3. Click in the upper left corner and choose Network > Virtual Private Cloud.

    The Virtual Private Cloud page is displayed.

  4. In the upper right corner of the page, click Create Supplementary Network Interface.
  5. Configure the parameters based on Table 1.
    Table 1 Parameter descriptions

    Parameter

    Description

    Example Value

    Network Interface

    Elastic network interface that the supplementary network interface to be attached to.

    Select an elastic network interface from the drop-down list.

    --(172.16.0.145)

    VPC

    VPC that the supplementary network interface belongs to. You do not need to set this parameter.

    vpc-A

    Subnet

    Select the subnet for the supplementary network interface.

    subnet-A01

    Description

    (Optional) Enter the description of the supplementary network interface in the text box as required.

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

    -

    Quantity

    Number of supplementary network interfaces to be created. The value ranges from 1 to 20.

    1

    Private IP Address

    Whether to assign a private IPv4 address to the supplementary network interface.

    This parameter cannot be deselected in the current version.

    -

    IPv4 Address

    Select a virtual IP address assignment mode.

    • Automatically assign IP address: The system assigns an IP address automatically.
    • Manually specify IP address: The system assigns an IP address that you specify.

      If you select Manually specify IP address, enter a private IPv4 address.

    Automatically assign IP address

    Security Group

    Select the security group that the supplementary network interface belongs to.

    sg-001

  6. Click OK.

    After a supplementary network interface is created, you need to create a VLAN sub-interface on the ECS NIC and configure routes. For details, see Configuring a Supplementary Network Interface.

Configuring a Supplementary Network Interface

After a supplementary network interface is created, you need to create a VLAN sub-interface and configure a private IP address and default routes for the interface.

You need to obtain the information about the supplementary network interface, as shown in Table 2.

Table 2 Supplementary network interface information

Information

How to Obtain

Description

VLAN

Management console

Obtain the value from the supplementary network interface list.

For details, see Viewing Basic Information About a Supplementary Network Interface.

MAC address

Private IP address

Gateway

Obtain the value from the details page of the subnet that the supplementary network interface belongs to.

The following describes how to create a VLAN sub-interface on eth0 of an ECS (CentOS 8.2 is used as an example. For details about other OSs, see the OS documentation).

In this example:

  • VLAN: 2110
  • Private IP address: 192.168.0.2/24
  • Gateway: 192.168.0.1
  • MAC address: fa:16:3e:a1:b2:**

Procedure

  1. Log in to the ECS.

  2. Create a VLAN sub-interface for eth0.

    ip link add link eth0 name eth0.2110 type vlan id 2110

  3. Create a namespace ns2110.

    ip netns add ns2110

  4. Add the VLAN sub-interface eth0.2110 to the namespace ns2110.

    ip link set eth0.2110 netns ns2110

  5. Change the MAC address of the VLAN sub-interface to fa:16:3e:a1:b2:**.

    ip netns exec ns2110 ifconfig eth0.2110 hw ether fa:16:3e:a1:b2:**

  6. Enable the VLAN sub-interface.

    ip netns exec ns2110 ifconfig eth0.2110 up

  7. Configure the private IP address 192.168.0.2/24 for the VLAN sub-interface.

    ip netns exec ns2110 ip addr add 192.168.0.2/24 dev eth0.2110

  8. Configure the default route for the VLAN sub-interface. 192.168.0.1 is the gateway of the subnet that the supplementary network interface works.

    ip netns exec ns2110 ip route add default via 192.168.0.1

Verification

  1. Access other private IP addresses in the same VPC from the namespace to check whether the configuration on the supplementary network interface takes effect.

    ip netns exec ns2110 ping a.b.c.d

    Figure 1 Success example
    Figure 2 Failure example