Creates an Elastic Network Interface (ENI).

Description

  • The default status of a new ENI is Available (Available).

  • An ENI can be only attached to the VPC-Connected instance that is in the same zone of the ENI.

  • Because an ENI can be only attached to one instance, you must detach the ENI from the instance before you attach it to another instance.

  • The properties of the ENI are not changed whatever instance the ENI is attached. Moreover, network traffic is redirected to the new instance if the instance to which the ENI is attached changes.

  • By default, one account can own up to 100 ENIs in one region. For a higher quota, open a ticket.

Request parameters

Name Type Required Description
Action String Yes The name of this interface.  Value: CreateNetworkInterface
RegionId String Yes ID of the region of the instance. ID of the region in which the instance is located. For more information, see Regions and zones, or call DescribeRegions to obtain the latest region list.
VSwitchId String Yes VSwitch ID of the specified VPC. Specifies the switch ID for the VPC.
SecurityGroupId String Yes The ID of the security group that the ENI joins. The security group and the ENI must be in a same VPC.
PrimaryIpAddress String No The primary private IP address of the ENI.  The specified IP address must have the same Host ID as the VSwitch. If no IP addresses are specified, a random network ID is assigned for the ENI.
NetworkInterfaceName String No Name of your ENI.
  • It is a string of [2, 128]  Chinese or English characters. It must begin with a letter and can contain numbers, underscores (_), colons (:), or hyphens (-).
  • The ENI name is displayed in the console.
  • It cannot begin with http:// or https://.
  • If this parameter is not specified, its name is null by default.
Description String No Description of your ENI.
  • It is a string of [2, 256] English or Chinese characters.
  • It cannot begin with http:// or https://.
  • If this parameter is not specified, it is null by default.
ClientToken String No Guarantees the idempotence of the request.  The value is generated by the client. It must be unique among all requests and can contains a maximum of 64 ASCII characters.  For more information, see How to ensure idempotence.

Response parameters

Name Type Description
NetworkInterfaceId String ID of your Network Interface.

Examples

Request example
https://ecs.aliyuncs.com/?Action=CreateNetworkInterface
&RegionId=cn-hangzhou
&VSwitchId=[vswitchid]
&SecurityGroupId=sg-c0003exxxxx
&<Common Request Parameters> 
Response example

XML format

<CreateNetworkInterfaceResponse>
    <RequestId>04F0F334-1335-436C-A1D7-6C044FExxxxx</RequestId>
    <NetworkInterfaceId>eni-eniIxxxxx</NetworkInterfaceId>
</CreateNetworkInterfaceResponse>
JSON format
{
    "RequestId": "04F0F334-1335-436C-A1D7-6C044FExxxxx",
    "NetworkInterfaceId": "eni-enixxxxx"
}

Error codes

The following error codes are specific to this interface. For more error codes, visit the API error center.

Error code Error message HTTP status code Meaning
MissingParameter The input parameter that is mandatory for processing this request is not supplied. 400 You must specify the required parameter.
UnsupportedParameter The parameters is unsupported. 400 The specified parameter does not exist. Alternatively, the specified parameter is not supported.
Abs.InvalidAccount.NotFound The Account is not found or AK is expired. 403 The specified Alibaba Cloud account does not exist. Alternatively, your AccessKey expired.
Forbidden.NotSupportRAM This action does not support accessed by RAM mode. 403 A RAM User is limited to access the resource.
Forbidden.SubUser The specified action is not available for you. 403 A RAM User is limited to access the resource.
InvalidOperation. availabilityzonemismatch The VPC VSwitch of the specified ENI and ECS instance are not in the same availability zone. 403 The specified VSwitchId, ENI, and InstanceId are not in the same zone.
InvalidOperation.VpcMismatch The VPC of the specified ENI and security group are not in the same VPC. 403 The specified ENI and SecurityGroupId are not in the same VPC.
InvalidSecurityGroupId.NotVpc The specified securitygroupid not in VPC. 403 The specified SecurityGroupId is not in a VPC.
MaxEniCountExceeded The number of ENI exceeds the limit per region. 403 The maximum number of ENI in the specified region is exceeded.
SecurityGroupInstanceLimitExceed The maximum number of instances in a security group is exceeded. 403 The maximum number of instance in the specified SecurityGroupId is exceeded.
InvalidEcsId.NotFound The specified EcsId is not found. 404 The specified InstanceId does not exist.
InvalidSecurityGroupId.NotFound The specified SecurityGroupId is not found. 404 The specified SecurityGroupId does not exist.
InvalidVSwitchId.NotFound The specified VSwitchId is not found. 404 The specified VSwitchId does not exist.