All Products
Search
Document Center

Elastic Compute Service:CreateNetworkInterface

Last Updated:Apr 11, 2024

Creates an elastic network interface (ENI).

Operation description

Usage notes

Take note of the following items:

  • This operation is a synchronous operation. After an ENI is created, it immediately enters the Available (Available) state and can be attached to an Elastic Compute Service (ECS) instance.
  • If NetworkInterfaceId is empty in the response, no ENI is created. Call the operation again to create an ENI.
  • An ENI can be attached only to a single instance that resides in a virtual private cloud (VPC).
  • When an ENI is detached from an instance and attached to another instance, the attributes of the ENI remain unchanged and network traffic is redirected to the new instance.
  • If you want to assign IPv6 addresses when you create an ENI, make sure that IPv6 is enabled for the vSwitch with which you want to associate the ENI. For more information, see What is an IPv6 gateway?
  • A quota is imposed on the number of ENIs that can be created per Alibaba Cloud region per account. You can view the quota in the ECS console. For more information, see View and increase resource quotas.

For information about examples on how to call this operation, see Create an ENI.

Debugging

OpenAPI Explorer automatically calculates the signature value. For your convenience, we recommend that you call this operation in OpenAPI Explorer.

Authorization information

There is currently no authorization information disclosed in the API.

Request parameters

ParameterTypeRequiredDescriptionExample
RegionIdstringYes

The region ID of the instance. You can call the DescribeRegions operation to query the most recent region list.

cn-hangzhou
Tagobject []No

The tags to add to the ENI.

KeystringNo

The key of tag N to add to the ENI. Valid values of N: 1 to 20. The tag key cannot be an empty string. The tag key can be up to 128 characters in length and cannot start with acs: or aliyun. It cannot contain http:// or https://.

TestKey
ValuestringNo

The value of tag N to add to the ENI. Valid values of N: 1 to 20. The tag value can be an empty string. The tag value can be up to 128 characters in length. It cannot start with acs: or contain http:// or https://.

TestValue
ResourceGroupIdstringNo

The ID of the resource group to which you want to assign the ENI. You can call the ListResourceGroups operation to query the most recent resource group list.

rg-bp67acfmxazb4ph****
VSwitchIdstringYes

The ID of the vSwitch with which to associate the ENI. Private IP addresses are assigned to the ENI from within the CIDR block of the vSwitch.

vsw-bp1s5fnvk4gn2tws03****
PrimaryIpAddressstringNo

The primary private IP address of the ENI.

The specified IP address must be an idle IP address within the CIDR block of the vSwitch with which to associate the ENI. If this parameter is not specified, an idle IP address is assigned from within the vSwitch CIDR block at random.

172.17.**.**
SecurityGroupIdstringNo

The ID of the security group to which to assign the ENI. The security group and the ENI must belong to the same VPC.

Note You must specify SecurityGroupId or SecurityGroupIds.N but not both.
sg-bp1fg655nh68xyz9i****
NetworkInterfaceNamestringNo

The name of the ENI. The name must be 2 to 128 characters in length, and can contain letters, digits, colons (:), underscores (_), and hyphens (-). It must start with a letter and cannot start with http:// or https://.

This parameter is empty by default.

testNetworkInterfaceName
DescriptionstringNo

The description of the ENI. The description must be 2 to 256 characters in length and cannot start with http:// or https://.

This parameter is empty by default.

testDescription
VisiblebooleanNo
Note This parameter is no longer used.
null
InstanceTypestringNo
Note This parameter is no longer used.
null
BusinessTypestringNo
Note This parameter is no longer used.
null
SecondaryPrivateIpAddressCountintegerNo

The number of private IP addresses to be automatically created by ECS. Valid values: 1 to 49.

1
QueueNumberintegerNo

The number of queues supported by the ENI. Valid values: 1 to 2048.

When you attach the ENI to an instance, make sure that the value of this parameter is less than the maximum number of queues per ENI that is allowed for the instance type. To view the maximum number of queues per ENI allowed for an instance type, you can call the DescribeInstanceTypes operation and then check the return value of MaximumQueueNumberPerEni.

This parameter is left empty by default. If you do not specify this parameter, the default number of queues per ENI for the instance type of an instance is used when you attach the ENI to the instance. To view the default number of queues per ENI for an instance type, you can call the DescribeInstanceTypes operation and then check the return value of SecondaryEniQueueNumber.

1
ClientTokenstringNo

The client token that is used to ensure the idempotence of the request. You can use the client to generate the token, but you must make sure that the token is unique among different requests. The token can contain only ASCII characters and cannot exceed 64 characters in length. For more information, see How to ensure idempotence.

123e4567-e89b-12d3-a456-426655440000
NetworkInterfaceTrafficModestringNo

The communication mode of the ENI. Valid values:

  • Standard: uses the TCP communication mode.
  • HighPerformance: uses the remote direct memory access (RDMA) communication mode with Elastic RDMA Interface (ERI) enabled.
Note This parameter can have a value of HighPerformance only when the ENI is attached to a c7re RDMA-enhanced instance. The maximum number of ENIs in RDMA mode that can be attached to a c7re instance is determined based on the instance type. The c7re instance family is in invitational preview in Beijing Zone K. For more information, see Overview of instance families.

Default value: Standard.

Standard
QueuePairNumberintegerNo
Note This parameter is in invitational preview and is not publicly available.
22
SecurityGroupIdsarrayNo

The ID of security group N to which to assign the ENI. The security group and the ENI must belong to the same VPC. The valid values of N are determined based on the maximum number of security groups to which an ENI can be assigned. For more information, see Limits .

**

You must specify SecurityGroupId or SecurityGroupIds.N but not both.````

stringNo

The ID of security group N to which to assign the ENI. The security group and the ENI must belong to the same VPC. The valid values of N are determined based on the maximum number of security groups to which an ENI can be assigned. For more information, see Limits .

**

You must specify SecurityGroupId or SecurityGroupIds.N but not both.````

sg-bp1fg655nh68xyz9i****
PrivateIpAddressarrayNo

Secondary private IP addresses to assign to the ENI. The IP addresses must be idle IP addresses in the CIDR block of the vSwitch with which to associate the ENI. Valid values of N: 0 to 10.

Note To assign secondary private IP addresses to the ENI, you can specify the PrivateIpAddress.N or SecondaryPrivateIpAddressCount parameter, but not both.
stringNo

Secondary private IP address N to assign to the ENI. This IP address must be an idle IP address within the CIDR block of the vSwitch with which to associate the ENI. Valid values of N: 0 to 10.

Note To assign secondary private IP addresses to the ENI, you can specify the PrivateIpAddress.N or SecondaryPrivateIpAddressCount parameter, but not both.
172.17.**.**
Ipv6AddressarrayNo

IPv6 addresses to assign to the ENI. Valid values of N: 1 to 10.

Example: Ipv6Address.1=2001:db8:1234:1a00::****

Note To assign IPv6 addresses to the ENI, you must specify the Ipv6Addresses.N or Ipv6AddressCount parameter, but not both.
stringNo

IPv6 address N to assign to the ENI. Valid values of N: 1 to 10.

Example: Ipv6Address.1=2001:db8:1234:1a00::****

Note To assign IPv6 addresses to the ENI, you must specify the Ipv6Addresses.N or Ipv6AddressCount parameter, but not both.
2001:db8:1234:1a00::****
Ipv6AddressCountintegerNo

The number of IPv6 addresses to randomly generate for the ENI. Valid values: 1 to 10.

Note To assign IPv6 addresses to the ENI, you must specify the Ipv6Addresses.N or Ipv6AddressCount parameter, but not both.
1
Ipv4PrefixarrayNo

IPv4 prefixes to assign to the ENI. Valid values of N: 1 to 10.

Note To assign IPv4 prefixes to the ENI, you must specify the Ipv4Prefix.N or Ipv4PrefixCount parameter, but not both.
stringNo

IPv4 prefix N to assign to the ENI. Valid values of N: 1 to 10.

Note To assign IPv4 prefixes to the ENI, you must specify the Ipv4Prefix.N or Ipv4PrefixCount parameter, but not both.
hide
Ipv4PrefixCountintegerNo

The number of IPv4 prefixes to assign to the ENI. Valid values: 1 to 10.

Note To assign IPv4 prefixes to the ENI, you must specify the Ipv4Prefix.N or Ipv4PrefixCount parameter, but not both.
hide
Ipv6PrefixarrayNo

IPv6 prefixes to assign to the ENI. Valid values of N: 1 to 10.

Note To assign IPv6 prefixes to the ENI, you must specify the Ipv6Prefix.N or Ipv6PrefixCount parameter, but not both.
stringNo

IPv6 prefix N to assign to the ENI. Valid values of N: 1 to 10.

Note To assign IPv6 prefixes to the ENI, you must specify the Ipv6Prefix.N or Ipv6PrefixCount parameter, but not both.
hide
Ipv6PrefixCountintegerNo

The number of IPv6 prefixes to assign to the ENI. Valid values: 1 to 10.

Note To assign IPv6 prefixes to the ENI, you must specify the Ipv6Prefix.N or Ipv6PrefixCount parameter, but not both.
hide
DeleteOnReleasebooleanNo

Specifies whether to release the ENI when the associated instance is released. Valid values:

  • true
  • false
true

Response parameters

ParameterTypeDescriptionExample
object
Statusstring

The state of the ENI.

Available
Typestring

The type of the ENI.

Secondary
VpcIdstring

The ID of the VPC to which the ENI belongs.

vpc-bp1j7w3gc1cexjqd****
NetworkInterfaceNamestring

The name of the ENI.

my-eni-name
MacAddressstring

The media access control (MAC) address of the ENI.

00:16:3e:12:**:**
NetworkInterfaceIdstring

The ID of the ENI.

eni-bp14v2sdd3v8htln****
ServiceIDlong

The ID of the distributor to which the ENI belongs.

12345678910
OwnerIdstring

The ID of the account to which the ENI belongs.

123456****
ServiceManagedboolean

Indicates whether the user of the ENI is an Alibaba Cloud service or a distributor.

true
VSwitchIdstring

The ID of the vSwitch to which the ENI is connected.

vsw-bp16usj2p27htro3****
RequestIdstring

The request ID.

473469C7-AA6F-4DC5-B3DB-A3DC0DE3C83E
Descriptionstring

The description of the ENI.

testDescription
ResourceGroupIdstring

The ID of the resource group to which the ENI belongs.

rg-2ze88m67qx5z****
ZoneIdstring

The zone ID of the ENI.

cn-hangzhou-e
PrivateIpAddressstring

The private IP address of the ENI.

172.17.**.**
SecurityGroupIdsarray

The IDs of the security groups to which the ENI belongs.

string

The ID of the security group.

sg-bp18kz60mefsicfg****
PrivateIpSetsobject []

The private IP addresses.

PrivateIpAddressstring

The private IP address of the instance.

172.17.**.**
Primaryboolean

Indicates whether the private IP address is the primary private IP address.

true
Tagsobject []

The tags of the ENI.

TagValuestring

The tag value.

TestValue
TagKeystring

The tag key.

TestKey
Ipv6Setsobject []

The IPv6 addresses assigned to the ENI.

Ipv6Addressstring

The IPv6 address assigned to the ENI.

2001:db8:1234:1a00::****
Ipv4PrefixSetsobject []

The IPv4 prefixes assigned to the ENI.

Ipv4Prefixstring

The IPv4 prefix assigned to the ENI.

hide
Ipv6PrefixSetsobject []

The IPv6 prefixes assigned to the ENI.

Ipv6Prefixstring

The IPv6 prefix assigned to the ENI.

hide

Examples

Sample success responses

JSONformat

{
  "Status": "Available",
  "Type": "Secondary",
  "VpcId": "vpc-bp1j7w3gc1cexjqd****",
  "NetworkInterfaceName": "my-eni-name",
  "MacAddress": "00:16:3e:12:**:**",
  "NetworkInterfaceId": "eni-bp14v2sdd3v8htln****",
  "ServiceID": 12345678910,
  "OwnerId": "123456****",
  "ServiceManaged": true,
  "VSwitchId": "vsw-bp16usj2p27htro3****",
  "RequestId": "473469C7-AA6F-4DC5-B3DB-A3DC0DE3C83E",
  "Description": "testDescription",
  "ResourceGroupId": "rg-2ze88m67qx5z****",
  "ZoneId": "cn-hangzhou-e",
  "PrivateIpAddress": "172.17.**.**",
  "SecurityGroupIds": {
    "SecurityGroupId": [
      "sg-bp18kz60mefsicfg****"
    ]
  },
  "PrivateIpSets": {
    "PrivateIpSet": [
      {
        "PrivateIpAddress": "172.17.**.**",
        "Primary": true
      }
    ]
  },
  "Tags": {
    "Tag": [
      {
        "TagValue": "TestValue",
        "TagKey": "TestKey"
      }
    ]
  },
  "Ipv6Sets": {
    "Ipv6Set": [
      {
        "Ipv6Address": "2001:db8:1234:1a00::****"
      }
    ]
  },
  "Ipv4PrefixSets": {
    "Ipv4PrefixSet": [
      {
        "Ipv4Prefix": "hide"
      }
    ]
  },
  "Ipv6PrefixSets": {
    "Ipv6PrefixSet": [
      {
        "Ipv6Prefix": "hide"
      }
    ]
  }
}

Error codes

HTTP status codeError codeError messageDescription
400MissingParameter%sA parameter is not specified.
400UnsupportedParameter%sThe parameter is not supported.
400InvalidParameter%sThe specified parameter is invalid.
400InvalidInstanceID.Malformed%sThe specified InstanceId parameter is invalid.
400InvalidOperation.InvalidEcsState%s-
400InvalidOperation.InvalidEniState%s-
400InvalidOperation.DetachPrimaryEniNotAllowed%s-
400Forbidden.RegionId%sThe service is unavailable in the current region.
400Duplicate.TagKeyThe Tag.N.Key contain duplicate key.The specified tag key already exists. Tag keys must be unique.
400InvalidTagKey.MalformedThe specified Tag.n.Key is not valid.The specified Tag.N.Key parameter is invalid.
400InvalidTagValue.MalformedThe specified Tag.n.Value is not valid.The specified tag value is invalid.
400InvalidOperation.EniCountExceededThe maximum number of eni in a enterprise security group is exceeded.-
400IncorrectVSwitchStatusThe current status of vSwitch does not support this operation.-
400JoinedGroupLimitExceed%sThe maximum number of security groups to which the specified resource can be added has been reached. For more information, see the return value of the %s placeholder in the error message.
400InvalidParameter.SecurityGroupIdRepeated%s-
400InvalidSecurityGroupId.SingleIdAndMultiIdConflict%s-
400InvalidPrivateIpAddress.DuplicatedSpecified private IP address is duplicated.-
400InvalidParameter.Conflict%sThe specified parameter is invalid. Check whether parameter conflicts exist. %s is a variable. An error message is dynamically returned based on call conditions.
400QuotaExceeded.PrivateIpAddressThere is no enough private ip in the specified VSwitch.-
400IncorrectVSwitchStatusThe current status of virtual switch does not support this operation.The specified vSwitch is in the Pending state and cannot be deleted.
400InvalidEniQueueSize.RegionOrUserNotSupportedThe specified parameter RxQueueSize or TxQueueSize is not supported in this region, or this account is not in the whitelist of using eni QueueSize.You are not authorized to specify the length of NIC queues or cannot specify the length of NIC queues in the current region.
400InvalidParameter.EniQueueSizeThe specified parameter TxQueueSize and RxQueueSize are not equal or exceed limit.The specified parameter TxQueueSize and RxQueueSize are not equal or exceed limit.
403InvalidOperation.NotSupportThe specified region is not support to allocate ipv6 when create network interface.-
403InvalidUserType.NotSupported%sYour account does not support this operation.
403Abs.InvalidAccount.NotFound%sYour Alibaba Cloud account does not exist or your AccessKey pair has expired.
403Forbidden.NotSupportRAM%sRAM users are not authorized to perform this operation.
403Forbidden.SubUser%sYou are not authorized to manage this resource. Contact the owner of the Alibaba Cloud account for authorization.
403InValidParameter%sThe specified parameter is invalid.
403MaxEniCountExceeded%sThe maximum number of ENIs that can be managed has been reached.
403EniPerInstanceLimitExceeded%sThe maximum number of ENIs that can be attached to the specified instance has been reached.
403InvalidOperation.AvailabilityZoneMismatch%sThe operation is invalid.
403InvalidOperation.VpcMismatch%sThe operation is invalid. Check whether the VPC in the operation corresponds to other parameters.
403SecurityGroupInstanceLimitExceed%s-
403InvalidSecurityGroupId.NotVpc%sThe specified SecurityGroupId parameter is invalid and the network type of the security group is not VPC.
403InvalidOperation.InvalidEniType%s-
403InvalidVSwitchId.IpNotEnough%sThe number of available IP addresses on the specified vSwitch is insufficient.
403InvalidVSwitchId.IpInvalid%sThe specified private IP address is invalid.
403QuotaExceed.Tags%sThe number of specified tags exceeds the upper limit. %s is a variable. An error message is dynamically returned based on call conditions.
403EnterpriseGroupLimited.MutliGroupTypeThe specified instance can't join multi SecurityGroup types.-
403InvalidIp.Address%s-
403InvalidIp.IpRepeated%sThe specified IP address already exists.
403MaxEniPrivateIpsCountExceeded%sThe maximum number of secondary private IP addresses that can be assigned to the specified ENI has been exceeded. For more information, see the return value of the %s placeholder in the error message.
403InvalidOperation.ResourceManagedByCloudProduct%sYou cannot modify security groups managed by cloud services.
403InvalidOperation.TrunkingIsNotAllowed%s-
403InvalidParameter.InvalidEniQueueNumber%s-
403InvalidOperation.MaxEniQueueNumberExceeded%s-
403InvalidOperation.ExceedInstanceTypeQueueNumber%sThe maximum number of queues for all ENIs on an instance has been exceeded. For more information, see the return value of the %s placeholder in the error message.
403InvalidOperation.BoundingEniSlaveQuotaExceedThe slave eni quota above bounding eni exceeds.-
403InvalidParameter.EniTrafficMode%s-
403InvalidOperation.HighPerformanceTrafficModeIsNotAllowed%s-
403InvalidParameter.QueuePairNumberMustEmpty%s-
403InvalidParameter.InvalidQueuePairNumber%s-
403InvalidParameter.EniTrafficModeThe eni business type not support HighPerformance traffic mode.-
403InvalidParams.NetworkInterfaceName%s-
403InvalidIp.IpPrefixMaskNotSameThe ip prefixes %s are illegal which mask must be same.The IP address prefix masks are not the same.
403InvalidIp.IpPrefixMaskInvalidThe ip prefixes mask %s is illegal which must be between %s and %s.The IP address prefix mask is invalid and is not within the valid range.
403InvalidIp.IpPrefixMaskIllegalThe ip prefix mask is illegal.The IP address prefix mask is invalid.
403InvalidIp.IpPrefixIllegalThe ip prefixes %s is/are illegal.The IP address prefix is invalid and is not in the CIDR format.
403InvalidIp.IpPrefixMustInReserveSegmentThe ip prefix must in vswitch reserve segment.The IP address prefix is invalid and is not in the reserved CIDR block of the vSwitch.
403InvalidIp.IpPrefixNotAvailableThe ip prefix is/are not available.The IP address prefix is not available.
403InvalidIp.IpPrefixNotStrictThe ip prefix must be strict cidr format.The IP address prefix is invalid and is not in the CIDR format.
403InvalidVSwitchId.IpPrefixNotEnoughThe specified vSwitch has not enough ip prefix.The number of IP address prefixes in the specified vSwitch is insufficient.
403InvalidOperation.Ipv4CountExceeded%sThe operation is valid because the maximum number of IPv4 addresses has been reached.
403InvalidOperation.Ipv6CountExceeded%sThe operation is valid because the maximum number of IPv6 addresses has been reached.
404InvalidEcsId.NotFound%sThe specified instance ID does not exist.
404InvalidEniId.NotFound%sThe specified ENI ID does not exist.
404InvalidVSwitchId.NotFound%sThe specified vSwitch does not exist.
404InvalidSecurityGroupId.NotFound%sThe specified security group ID does not exist.
404InvalidResourceGroup.NotFoundThe ResourceGroup provided does not exist in our records.The specified resource group does not exist.
404InvalidVSwitchId.NotFoundThe specified VSwitchId is not found.-
404InvalidOperation.MaxEniIpv6IpsCountExceededThe ipv6 address count exceed limitation.-
404InvalidOperation.VSwitchIpv6DisabledThe specified VSwitch does not support Ipv6 feature.The specified VSwitch does not support IPv6.
404InvalidOperation.EnableIpv6FailedThe specified VSwitch does not support Ipv6 feature.-
404InvalidOperation.AddressAlreadyAllocatedThe specified ipv6 has been already allocated.-
404InvalidOperation.AddressNotInVSwitchCidrThe specified ipv6 does not match VSwitch cidr scope.-
404InvalidOperation.EniTrafficModeNotSupportIpv6The High Performance traffic mode does not support Ipv6.-
404InvalidOperation.MaxEniIpv6IpsCountExceeded%s-
404InvalidOperation.AddressAlreadyAllocatedThe specified ip address has been already allocated.The specified IP address is already in use.
404InvalidOperation.SlaveEniMustHaveBondingEniCreate slave eni must have bonding eni first.-
404InvalidOperation.VSwitchCidrReservationNotExistThe specified vSwitch has no cidr reservation.-
500InternalErrorThe request processing has failed due to some unknown error, exception or failure.An internal error has occurred. Try again later.
500InvalidOperation.RegionNotSupportIpPrefixThe current region does not support ip prefix.You cannot assign IP address prefixes in this region.

For a list of error codes, visit the Service error codes.

Change history

Change timeSummary of changesOperation
2024-02-28The Error code has changedsee changesets
Change itemChange content
Error CodesThe Error code has changed.
    Error Codes 403 change
    delete Error Codes: 400
    delete Error Codes: 404
    delete Error Codes: 500
2024-01-24The Error code has changed. The request parameters of the API has changedsee changesets
Change itemChange content
Error CodesThe Error code has changed.
    Error Codes 400 change
    delete Error Codes: 403
    delete Error Codes: 404
    delete Error Codes: 500
Input ParametersThe request parameters of the API has changed.
    Added Input Parameters: TxQueueSize
    Added Input Parameters: RxQueueSize
2023-10-09The Error code has changed. The request parameters of the API has changedsee changesets
Change itemChange content
Error CodesThe Error code has changed.
    delete Error Codes: 400
    delete Error Codes: 403
    delete Error Codes: 404
    delete Error Codes: 500
Input ParametersThe request parameters of the API has changed.
    Added Input Parameters: DeleteOnRelease
2023-04-26The Error code has changedsee changesets
Change itemChange content
Error CodesThe Error code has changed.
    Error Codes 404 change
    delete Error Codes: 400
    delete Error Codes: 403
    delete Error Codes: 500
2021-07-05The Error code has changed. The request parameters of the API has changed. The response structure of the API has changedsee changesets
Change itemChange content
Error CodesThe Error code has changed.
    Error Codes 404 change
    delete Error Codes: 400
    delete Error Codes: 403
    delete Error Codes: 500
Input ParametersThe request parameters of the API has changed.
    Added Input Parameters: Ipv6Address
    Added Input Parameters: Ipv6AddressCount
Output ParametersThe response structure of the API has changed.