Updated on 2025-08-19 GMT+08:00

Creating a Supplementary Network Interface

Function

Supplementary network interfaces can be attached to an elastic network interface to allow a cloud server to have more network interfaces for flexible and high-availability network configuration.

Calling Method

For details, see Calling APIs.

URI

POST /v3/{project_id}/vpc/sub-network-interfaces

Table 1 Path Parameters

Parameter

Mandatory

Type

Description

project_id

Yes

String

Definition:

ID of the project that a supplementary network interface belongs to. For details about how to obtain a project ID, see Obtaining a Project ID.

Range:

N/A

Request Parameters

Table 2 Request body parameters

Parameter

Mandatory

Type

Description

dry_run

No

Boolean

Definition:

Whether to only check the request.

Constraints:

N/A

Range:

  • true: A check request will be sent and no supplementary network interface will be created. Check items include mandatory parameters, request format, and constraints. If the check fails, an error will be returned. If the check succeeds, response code 202 will be returned.

  • false: A request will be sent and a supplementary network interface will be created.

Default Value:

false

sub_network_interface

Yes

CreateSubNetworkInterfaceOption object

Definition:

Request body for creating a supplementary network interface.

Constraints:

N/A

Range:

N/A

Default Value:

N/A

Table 3 CreateSubNetworkInterfaceOption

Parameter

Mandatory

Type

Description

virsubnet_id

Yes

String

Definition:

ID of the virtual subnet that a supplementary network interface is located.

Constraints:

The value is in UUID format with hyphens (-).

Range:

N/A

Default Value:

N/A

vlan_id

No

String

Definition:

VLAN ID of a supplementary network interface.

Constraints:

The VLAN IDs of supplementary network interfaces attached to the same network interface must be unique.

Range:

1 to 4094

Default Value:

N/A

parent_id

Yes

String

Definition:

ID of the elastic network interface that a supplementary network interface is attached to.

Constraints:

The value must be an existing elastic network interface ID.

Range:

N/A

Default Value:

N/A

description

No

String

Definition:

Description of a supplementary network interface.

Constraints:

The value can contain 0 to 255 characters and cannot contain angle brackets (< or >).

Range:

N/A

Default Value:

N/A

ipv6_enable

No

Boolean

Definition:

Whether IPv6 is enabled for a supplementary network interface.

Constraints:

N/A

Range:

  • true: IPv6 is enabled.

  • false: IPv6 is disabled.

Default Value:

false

private_ip_address

No

String

Definition:

Private IPv4 address of a supplementary network interface.

Constraints:

The value must be in the virtual subnet. If this parameter is left blank, an IP address will be randomly assigned from the virtual subnet.

Range:

N/A

Default Value:

N/A

ipv6_ip_address

No

String

Definition:

Private IPv6 address of a supplementary network interface.

Constraints:

The value must be in the virtual subnet. If this parameter is left blank, an IP address will be randomly assigned from the virtual subnet.

Range:

N/A

Default Value:

N/A

security_groups

No

Array of strings

Definition:

IDs of the security groups that a supplementary network interface is associated with. For example, "security_groups": ["a0608cbf-d047-4f54-8b28-cd7b59853fff"].

Constraints:

If this parameter is not specified in the request, the supplementary network interface is automatically associated with the default security group after being created.

Range:

N/A

Default Value:

N/A

project_id

No

String

Definition:

ID of the project that a supplementary network interface belongs to.

Constraints:

This parameter can only be set to the tenant ID of the current tenant. If this parameter is not specified, the project ID of the current tenant is used by default.

Range:

N/A

Default Value:

N/A

allowed_address_pairs

No

Array of AllowedAddressPair objects

Definition:

IP/MAC address pair list of a supplementary network interface. For details, see the AllowedAddressPair object list.

Constraints:

  • Configure a dedicated security group if a large CIDR block (subnet mask less than 24) is configured for parameter allowed_address_pairs.

  • In the hardware SDN networking plan, the ip_address attribute value cannot be in CIDR format.

Range:

N/A

Default Value:

N/A

Table 4 AllowedAddressPair

Parameter

Mandatory

Type

Description

ip_address

No

String

Definition:

IP address.

Constraints:

Configure a dedicated security group if a large CIDR block (subnet mask less than 24) is configured for parameter allowed_address_pairs.

Range:

Single IP address, for example, 192.168.21.25

A CIDR block, for example, 192.168.21.0/24

Default Value:

N/A

mac_address

No

String

Definition:

MAC address.

Constraints:

N/A

Range:

N/A

Default Value:

N/A

Response Parameters

Status code: 201

Table 5 Response body parameters

Parameter

Type

Description

request_id

String

Definition:

Request ID.

Range:

N/A

sub_network_interface

SubNetworkInterface object

Definition:

Response body for creating a supplementary network interface.

Range:

N/A

Table 6 SubNetworkInterface

Parameter

Type

Description

id

String

Definition:

ID of a supplementary network interface. After a supplementary network interface is created, a supplementary network interface ID is generated, which uniquely identifies the supplementary network interface.

Range:

The value is in UUID format with hyphens (-).

virsubnet_id

String

Definition:

ID of the virtual subnet that a supplementary network interface is located.

Range:

The value is in UUID format with hyphens (-).

private_ip_address

String

Definition:

Private IPv4 address of a supplementary network interface.

Range:

N/A

ipv6_ip_address

String

Definition:

Private IPv6 address of a supplementary network interface.

Range:

N/A

mac_address

String

Definition:

MAC address of a supplementary network interface.

Range:

The value is a valid MAC address assigned by the system randomly.

parent_device_id

String

Definition:

Device ID of the host network interface that a supplementary network interface is attached to.

Range:

The value is in UUID format with hyphens (-).

parent_id

String

Definition:

ID of the elastic network interface that a supplementary network interface is attached to.

Range:

The value is in UUID format with hyphens (-).

description

String

Definition:

Description of a supplementary network interface.

Range:

The value can contain 0 to 255 characters and cannot contain angle brackets (< or >).

vpc_id

String

Definition:

ID of the VPC that a supplementary network interface belongs to.

Range:

The value is in UUID format with hyphens (-).

vlan_id

Integer

Definition:

VLAN ID of a supplementary network interface.

Range:

1 to 4094

security_groups

Array of strings

Definition:

IDs of the security groups that a supplementary network interface is associated with. For example, "security_groups": ["a0608cbf-d047-4f54-8b28-cd7b59853fff"].

Range:

If this parameter is not specified in the request, the supplementary network interface is automatically associated with the default security group after being created.

tags

Array of ResponseTag objects

Definition:

Tags of a supplementary network interface, including tag keys and tag values, which can be used to classify and identify resources. For details, see the tag objects.

Range:

N/A

project_id

String

Definition:

ID of the project that a supplementary network interface belongs to.

Range:

N/A

created_at

String

Definition:

Time when a supplementary network interface was created.

Range:

The value is a UTC time in the format of yyyy-MM-ddTHH:mm:ssZ.

allowed_address_pairs

Array of AllowedAddressPair objects

Definition:

IP/MAC address pair list of a supplementary network interface. For details, see the AllowedAddressPair object list.

Range:

N/A

state

String

Definition:

Status of a supplementary network interface.

Range:

  • NORMAL: The supplementary network interface is attached to an elastic network interface.

  • UNBOUND: The supplementary network interface is not attached to an elastic network interface.

instance_id

String

Definition:

ID of the cloud service instance that a supplementary network interface is attached to, for example, RDS instance ID.

Range:

N/A

instance_type

String

Definition:

Type of the cloud service instance that a supplementary network interface is attached to, for example, RDS.

Range:

N/A

scope

String

Definition:

Public network egress information of the site where a supplementary network interface works.

Range:

  • center: default value, indicating the central AZ.

  • AZ ID: a specific AZ

security_enabled

Boolean

Definition:

Whether the security option is enabled for a supplementary network interface. If the option is not enabled, the security group does not take effect.

Range:

N/A

Table 7 ResponseTag

Parameter

Type

Description

key

String

Definition:

Tag key.

Range:

  • A tag key can contain a maximum of 128 Unicode characters and cannot be left blank.

  • Each tag key of a resource must be unique.

  • The value can contain:

    • Letters

    • Digits

    • Special characters: underscores (_), hyphens (-)

    • Chinese characters

value

String

Definition:

Tag value.

Range:

  • Each value can contain a maximum of 255 Unicode characters and can be left blank.

  • The value can contain:

    • Letters

    • Digits

    • Special characters: underscores (_), hyphens (-), periods (.)

    • Chinese characters

Table 8 AllowedAddressPair

Parameter

Type

Description

ip_address

String

Definition:

IP address.

Constraints:

Configure a dedicated security group if a large CIDR block (subnet mask less than 24) is configured for parameter allowed_address_pairs.

Range:

Single IP address, for example, 192.168.21.25

A CIDR block, for example, 192.168.21.0/24

Default Value:

N/A

mac_address

String

Definition:

MAC address.

Constraints:

N/A

Range:

N/A

Default Value:

N/A

Example Requests

Create a supplementary network interface. Set its virtual subnet ID to 08278e6c-61ca-46c1-9fc3-0d4f6c12f193, elastic network interface ID to 637748df-2986-4350-8303-95d259580fb3, and associated security group to 6727c950-9f01-47a2-a7aa-7d3686c4c95b.

POST https://{Endpoint}/v3/8c6fb137a48a428aaf9a0229dca4edb3/vpc/sub-network-interfaces

{
  "sub_network_interface" : {
    "virsubnet_id" : "08278e6c-61ca-46c1-9fc3-0d4f6c12f193",
    "parent_id" : "637748df-2986-4350-8303-95d259580fb3",
    "security_groups" : [ "6727c950-9f01-47a2-a7aa-7d3686c4c95b" ]
  }
}

Example Responses

Status code: 201

Normal response to the POST operation. For more status codes, see Status Codes.

{
  "sub_network_interface" : {
    "id" : "1f5fca65-6a75-47c8-942b-db1bbb81a22a",
    "project_id" : "8c6fb137a48a428aaf9a0229dca4edb3",
    "virsubnet_id" : "08278e6c-61ca-46c1-9fc3-0d4f6c12f193",
    "private_ip_address" : "192.168.0.219",
    "ipv6_ip_address" : "2407:c080:1200:2038:53a4:ad1c:ef34:f4ef",
    "mac_address" : "fa:16:3e:26:7e:59",
    "parent_device_id" : "285b2e45-2968-4f4c-8992-54e0d4c8da1d",
    "security_enabled" : true,
    "security_groups" : [ "6727c950-9f01-47a2-a7aa-7d3686c4c95b" ],
    "allowed_address_pairs" : [ ],
    "vpc_id" : "c10e1e02-9db2-4bd0-89ef-52536952627e",
    "instance_id" : "",
    "instance_type" : "",
    "description" : "",
    "parent_id" : "637748df-2986-4350-8303-95d259580fb3",
    "vlan_id" : 551,
    "state" : "NORMAL",
    "tags" : [ ],
    "scope" : "center",
    "created_at" : "2025-02-10T08:17:16Z"
  },
  "request_id" : "f0893730b622bf32beea6fa5b387a5dc"
}

SDK Sample Code

The SDK sample code is as follows.

Create a supplementary network interface. Set its virtual subnet ID to 08278e6c-61ca-46c1-9fc3-0d4f6c12f193, elastic network interface ID to 637748df-2986-4350-8303-95d259580fb3, and associated security group to 6727c950-9f01-47a2-a7aa-7d3686c4c95b.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
package com.huaweicloud.sdk.test;

import com.huaweicloud.sdk.core.auth.ICredential;
import com.huaweicloud.sdk.core.auth.BasicCredentials;
import com.huaweicloud.sdk.core.exception.ConnectionException;
import com.huaweicloud.sdk.core.exception.RequestTimeoutException;
import com.huaweicloud.sdk.core.exception.ServiceResponseException;
import com.huaweicloud.sdk.vpc.v3.region.VpcRegion;
import com.huaweicloud.sdk.vpc.v3.*;
import com.huaweicloud.sdk.vpc.v3.model.*;

import java.util.List;
import java.util.ArrayList;

public class CreateSubNetworkInterfaceSolution {

    public static void main(String[] args) {
        // The AK and SK used for authentication are hard-coded or stored in plaintext, which has great security risks. It is recommended that the AK and SK be stored in ciphertext in configuration files or environment variables and decrypted during use to ensure security.
        // In this example, AK and SK are stored in environment variables for authentication. Before running this example, set environment variables CLOUD_SDK_AK and CLOUD_SDK_SK in the local environment
        String ak = System.getenv("CLOUD_SDK_AK");
        String sk = System.getenv("CLOUD_SDK_SK");
        String projectId = "{project_id}";

        ICredential auth = new BasicCredentials()
                .withProjectId(projectId)
                .withAk(ak)
                .withSk(sk);

        VpcClient client = VpcClient.newBuilder()
                .withCredential(auth)
                .withRegion(VpcRegion.valueOf("<YOUR REGION>"))
                .build();
        CreateSubNetworkInterfaceRequest request = new CreateSubNetworkInterfaceRequest();
        CreateSubNetworkInterfaceRequestBody body = new CreateSubNetworkInterfaceRequestBody();
        List<String> listSubNetworkInterfaceSecurityGroups = new ArrayList<>();
        listSubNetworkInterfaceSecurityGroups.add("6727c950-9f01-47a2-a7aa-7d3686c4c95b");
        CreateSubNetworkInterfaceOption subNetworkInterfacebody = new CreateSubNetworkInterfaceOption();
        subNetworkInterfacebody.withVirsubnetId("08278e6c-61ca-46c1-9fc3-0d4f6c12f193")
            .withParentId("637748df-2986-4350-8303-95d259580fb3")
            .withSecurityGroups(listSubNetworkInterfaceSecurityGroups);
        body.withSubNetworkInterface(subNetworkInterfacebody);
        request.withBody(body);
        try {
            CreateSubNetworkInterfaceResponse response = client.createSubNetworkInterface(request);
            System.out.println(response.toString());
        } catch (ConnectionException e) {
            e.printStackTrace();
        } catch (RequestTimeoutException e) {
            e.printStackTrace();
        } catch (ServiceResponseException e) {
            e.printStackTrace();
            System.out.println(e.getHttpStatusCode());
            System.out.println(e.getRequestId());
            System.out.println(e.getErrorCode());
            System.out.println(e.getErrorMsg());
        }
    }
}

Create a supplementary network interface. Set its virtual subnet ID to 08278e6c-61ca-46c1-9fc3-0d4f6c12f193, elastic network interface ID to 637748df-2986-4350-8303-95d259580fb3, and associated security group to 6727c950-9f01-47a2-a7aa-7d3686c4c95b.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# coding: utf-8

import os
from huaweicloudsdkcore.auth.credentials import BasicCredentials
from huaweicloudsdkvpc.v3.region.vpc_region import VpcRegion
from huaweicloudsdkcore.exceptions import exceptions
from huaweicloudsdkvpc.v3 import *

if __name__ == "__main__":
    # The AK and SK used for authentication are hard-coded or stored in plaintext, which has great security risks. It is recommended that the AK and SK be stored in ciphertext in configuration files or environment variables and decrypted during use to ensure security.
    # In this example, AK and SK are stored in environment variables for authentication. Before running this example, set environment variables CLOUD_SDK_AK and CLOUD_SDK_SK in the local environment
    ak = os.environ["CLOUD_SDK_AK"]
    sk = os.environ["CLOUD_SDK_SK"]
    projectId = "{project_id}"

    credentials = BasicCredentials(ak, sk, projectId)

    client = VpcClient.new_builder() \
        .with_credentials(credentials) \
        .with_region(VpcRegion.value_of("<YOUR REGION>")) \
        .build()

    try:
        request = CreateSubNetworkInterfaceRequest()
        listSecurityGroupsSubNetworkInterface = [
            "6727c950-9f01-47a2-a7aa-7d3686c4c95b"
        ]
        subNetworkInterfacebody = CreateSubNetworkInterfaceOption(
            virsubnet_id="08278e6c-61ca-46c1-9fc3-0d4f6c12f193",
            parent_id="637748df-2986-4350-8303-95d259580fb3",
            security_groups=listSecurityGroupsSubNetworkInterface
        )
        request.body = CreateSubNetworkInterfaceRequestBody(
            sub_network_interface=subNetworkInterfacebody
        )
        response = client.create_sub_network_interface(request)
        print(response)
    except exceptions.ClientRequestException as e:
        print(e.status_code)
        print(e.request_id)
        print(e.error_code)
        print(e.error_msg)

Create a supplementary network interface. Set its virtual subnet ID to 08278e6c-61ca-46c1-9fc3-0d4f6c12f193, elastic network interface ID to 637748df-2986-4350-8303-95d259580fb3, and associated security group to 6727c950-9f01-47a2-a7aa-7d3686c4c95b.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
package main

import (
	"fmt"
	"github.com/huaweicloud/huaweicloud-sdk-go-v3/core/auth/basic"
    vpc "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/vpc/v3"
	"github.com/huaweicloud/huaweicloud-sdk-go-v3/services/vpc/v3/model"
    region "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/vpc/v3/region"
)

func main() {
    // The AK and SK used for authentication are hard-coded or stored in plaintext, which has great security risks. It is recommended that the AK and SK be stored in ciphertext in configuration files or environment variables and decrypted during use to ensure security.
    // In this example, AK and SK are stored in environment variables for authentication. Before running this example, set environment variables CLOUD_SDK_AK and CLOUD_SDK_SK in the local environment
    ak := os.Getenv("CLOUD_SDK_AK")
    sk := os.Getenv("CLOUD_SDK_SK")
    projectId := "{project_id}"

    auth := basic.NewCredentialsBuilder().
        WithAk(ak).
        WithSk(sk).
        WithProjectId(projectId).
        Build()

    client := vpc.NewVpcClient(
        vpc.VpcClientBuilder().
            WithRegion(region.ValueOf("<YOUR REGION>")).
            WithCredential(auth).
            Build())

    request := &model.CreateSubNetworkInterfaceRequest{}
	var listSecurityGroupsSubNetworkInterface = []string{
        "6727c950-9f01-47a2-a7aa-7d3686c4c95b",
    }
	subNetworkInterfacebody := &model.CreateSubNetworkInterfaceOption{
		VirsubnetId: "08278e6c-61ca-46c1-9fc3-0d4f6c12f193",
		ParentId: "637748df-2986-4350-8303-95d259580fb3",
		SecurityGroups: &listSecurityGroupsSubNetworkInterface,
	}
	request.Body = &model.CreateSubNetworkInterfaceRequestBody{
		SubNetworkInterface: subNetworkInterfacebody,
	}
	response, err := client.CreateSubNetworkInterface(request)
	if err == nil {
        fmt.Printf("%+v\n", response)
    } else {
        fmt.Println(err)
    }
}

For SDK sample code of more programming languages, see the Sample Code tab in API Explorer. SDK sample code can be automatically generated.

Status Codes

Status Code

Description

201

Normal response to the POST operation. For more status codes, see Status Codes.

Error Codes

See Error Codes.