CreateNetworkInterface_云服务器 ECS_API文档

插件下载了解更多
VS Code 插件
安装插件之前,确保已安装 VS Code安装插件之前,确保已安装 VS Code
Alibaba Cloud Developer Toolkit is a collection of extensions that can help access Alibaba Cloud services in Visual Studio Code.
JetBrains 插件
安装插件之前,确保已安装 JetBrains IDE安装插件之前,确保已安装 JetBrains IDE
The Alibaba Cloud Developer Toolkit for JetBrains makes it easier to access Alibaba Cloud services.

接口说明

调用该接口时,请注意:

  • 该接口为同步接口,新创建的弹性网卡为可用(Available)状态,可以直接进行附加操作。
  • 若创建接口返回结果中NetworkInterfaceId为空,请再次尝试创建弹性网卡。
  • 一张弹性网卡只能附加到一台专有网络的实例。
  • 弹性网卡重新附加到另一台实例时,其属性不变,网络流量也会重定向到新的实例。
  • 创建弹性网卡时,调用该接口最多可以分配 49 个辅助私网 IP 地址。
  • 创建弹性网卡时,如果您需要设置 IPv6 地址,则需要确保指定的交换机开通了 IPv6。更多信息,请参见什么是 IPv6 网关
  • 一个账号在一个阿里云地域内创建弹性网卡有数量限制。可在 ECS 管理控制台查看资源配额。具体操作,请参见查看和提升资源配额

请求示例

创建一张弹性网卡
RegionId:  cn-hangzhou,   //设置华东 1(杭州)地域。
SecurityGroupId:  sg-bp10jztp6b0sdsyl****,   //设置安全组 ID。
VSwitchId:  vsw-bp19wo63nleroq22g****,   //设置虚拟交换机 ID。
创建一张弹性网卡,并指定主私网 IP 地址
RegionId:  cn-hangzhou,   //华东 1(杭州)地域。
SecurityGroupId:  sg-bp10jztp6b0sdsyl****,   //安全组 ID。
VSwitchId:  vsw-bp19wo63nleroq22g****,   //虚拟交换机 ID。
PrimaryIpAddress:  192.168.0.*,   //主私网 IP 地址。

流控信息

请求速率为1500/60(s)。

授权信息

如下是此API对应的授权信息,用于RAM权限策略语句的Action元素中,为RAM用户或RAM角色授予调用此API的权限。请通过 RAM 访问控制设置,使用方法可参考访问控制帮助文档

具体说明如下:展开详情

操作访问级别资源类型条件关键字关联操作
ecs:CreateNetworkInterface
Create
NetworkInterface
acs:ecs:{#regionId}:{#accountId}:eni/*
SecurityGroup
acs:ecs:{#regionId}:{#accountId}:securitygroup/{#securitygroupId}
VSwitch
acs:vpc:{#regionId}:{#accountId}:vswitch/{#vswitchId}
vpc:IsDefaultVSwitch
vpc:IsDefaultVpc
vpc:VPC
vpc:tag
vpc:tag
vpc:tag

请求参数

字段名称字段详情
RegionIdstring

要创建的弹性网卡所在地域的 ID。您可以调用 DescribeRegions 查看最新的阿里云地域列表。

示例值:cn-hangzhou参考取值来源:
    DescribeRegions
Tagarray<object>

弹性网卡的标签列表。

子级条数 <= 20
ResourceGroupIdstring

资源组 ID。您可以调用 ListResourceGroups 查询资源组信息。

示例值:rg-bp67acfmxazb4ph****
VSwitchIdstring

弹性网卡的交换机 ID。弹性网卡的私网 IP 地址在交换机的 IP 地址段内的空闲地址中取值。展开详情

示例值:vsw-bp1s5fnvk4gn2tws03****
PrimaryIpAddressstring

弹性网卡的主私网 IP 地址。展开详情

示例值:172.17.**.**
SecurityGroupIdstring

加入一个安全组。安全组和弹性网卡必须在同一个专有网络 VPC 中。展开详情

示例值:sg-bp1fg655nh68xyz9i****参考取值来源:
    CreateSecurityGroup
    DescribeSecurityGroups
NetworkInterfaceNamestring

弹性网卡名称。长度为 2~128 个字符,支持 Unicode 中 letter 分类下的字符(其中包括英文、中文等),ASCII 数字(0-9)。可以包含半角冒号(:)、下划线(_)、半角句号(.)或者短划线(-)。展开详情

示例值:testNetworkInterfaceName参考取值来源:
    DescribeNetworkInterfaces
Descriptionstring

弹性网卡的描述信息。长度为 2~256 个英文或中文字符,不能以http://https://开头。展开详情

示例值:testDescription
Visibleboolean
说明 该参数已废弃。
示例值:null
InstanceTypestring

弹性网卡类型。取值范围:展开详情

示例值:Secondary参考取值来源:
    DescribeInstanceTypes
    CreateInstance
BusinessTypestring
说明 该参数已废弃。
示例值:null
SecondaryPrivateIpAddressCountinteger<int32>

指定私有 IP 地址数量,让 ECS 为您自动创建 IP 地址。取值范围:1~49。

示例值:1取值 >= 1
QueueNumberinteger<int32>

弹性网卡队列数。取值范围:1~2048展开详情

示例值:1取值 >= 1
ClientTokenstring

保证请求幂等性。从您的客户端生成一个参数值,确保不同请求间该参数值唯一。ClientToken 只支持 ASCII 字符,且不能超过 64 个字符。更多信息,请参见如何保证幂等性

示例值:123e4567-e89b-12d3-a456-426655440000
NetworkInterfaceTrafficModestring

弹性网卡的通讯模式。取值范围:展开详情

示例值:Standard参考取值来源:
    DescribeNetworkInterfaces
QueuePairNumberinteger<int32>

RDMA 网卡队列数。展开详情

示例值:22
SecurityGroupIdsarray<string>

加入一个或多个安全组。安全组和弹性网卡必须在同一个专有网络 VPC 中。N 的取值范围与弹性网卡能够加入安全组配额有关,更多信息,请参见使用限制展开详情

示例值:sg-bp1fg655nh68xyz9i****子级条数 <= 51
PrivateIpAddressarray<string>

从弹性网卡所属交换机的 CIDR 地址段内的空闲地址中选择一个或多个辅助私有 IP 地址。N 的取值范围:0~10。展开详情

示例值:172.17.**.**子级条数 <= 10
Ipv6Addressarray<string>

为弹性网卡指定一个或多个 IPv6 地址。支持设置最多 10 个 IPv6 地址,即 N 的取值范围:1~10。展开详情

示例值:2001:db8:1234:1a00::****子级条数 <= 20
Ipv6AddressCountinteger<int32>

为弹性网卡指定随机生成的 IPv6 地址数量。取值范围:1~10。展开详情

示例值:1取值 >= 1
Ipv4Prefixarray<string>

为弹性网卡指定一个或多个 IPv4 前缀。N 的取值范围:1~10。展开详情

子级条数 <= 10
Ipv4PrefixCountinteger<int32>

为弹性网卡指定一个或多个 IPv4 前缀。取值范围:1~10。展开详情

示例值:1取值 <= 10
Ipv6Prefixarray<string>

为弹性网卡指定一个或多个 IPv6 前缀。N 的取值范围:1~10。展开详情

子级条数 <= 10
Ipv6PrefixCountinteger<int32>

为弹性网卡指定一个或多个 IPv6 前缀。取值范围:1~10。展开详情

示例值:1取值 <= 10
DeleteOnReleaseboolean

释放实例时是否保留网卡。取值范围:展开详情

示例值:true
TxQueueSizeinteger<int32>

弹性网卡出方向队列深度。展开详情

示例值:8192
RxQueueSizeinteger<int32>

弹性网卡入方向队列深度。展开详情

示例值:8192
NetworkInterfaceTrafficConfigobject

弹性网卡通讯参数集合。

ConnectionTrackingConfigurationobject

网络连接跟踪配置信息集合。展开详情

EnhancedNetworkobject
说明 参数暂未开放使用。
SourceDestCheckboolean
说明 该参数正在邀测中,暂未开放使用。
示例值:false

返回参数

字段名称字段详情
Statusstring

弹性网卡的状态。

示例值:Available
Typestring

弹性网卡的类型。

示例值:Secondary
VpcIdstring

网卡所属的专有网络 VPC ID。

示例值:vpc-bp1j7w3gc1cexjqd****
NetworkInterfaceNamestring

弹性网卡的名称。

示例值:my-eni-name
MacAddressstring

弹性网卡的 MAC 地址。

示例值:00:16:3e:12:**:**
NetworkInterfaceIdstring

弹性网卡 ID。

示例值:eni-bp14v2sdd3v8htln****
ServiceIDinteger<int64>

弹性网卡对应的虚商 ID。

注意 请注意,该值为 Long 类型,在某些语言中可能存在精度丢失的风险,请小心使用。
示例值:12345678910
OwnerIdstring

弹性网卡的所属账号 ID。

示例值:123456****
ServiceManagedboolean

该弹性网卡的使用者是否为云产品或虚商。

示例值:true
VSwitchIdstring

VPC 的交换机 ID。

示例值:vsw-bp16usj2p27htro3****
RequestIdstring

请求 ID。

示例值:473469C7-AA6F-4DC5-B3DB-A3DC0DE3C83E
Descriptionstring

弹性网卡的描述信息。

示例值:testDescription
ResourceGroupIdstring

资源组 ID。

示例值:rg-2ze88m67qx5z****
ZoneIdstring

可用区 ID。

示例值:cn-hangzhou-e
PrivateIpAddressstring

弹性网卡的私网 IP 地址。

示例值:172.17.**.**
SecurityGroupIdsobject
PrivateIpSetsobject
Tagsobject
Ipv6Setsobject
Ipv4PrefixSetsobject
Ipv6PrefixSetsobject
SourceDestCheckboolean
说明 该参数正在邀测中,暂未开放使用。
示例值:false

返回示例

错误返回示例

错误码

全局错误码
HTTP 状态码错误码错误信息操作
400
MissingParameter
%s诊断
400
UnsupportedParameter
%s诊断
400
InvalidParameter
%s诊断
400
InvalidInstanceID.Malformed
%s诊断
400
InvalidOperation.InvalidEcsState
%s诊断
400
InvalidOperation.InvalidEniState
%s诊断
400
InvalidOperation.DetachPrimaryEniNotAllowed
%s诊断
400
Forbidden.RegionId
%s诊断
400
Duplicate.TagKey
The Tag.N.Key contain duplicate key.诊断
400
InvalidTagKey.Malformed
The specified Tag.n.Key is not valid.诊断
400
InvalidTagValue.Malformed
The specified Tag.n.Value is not valid.诊断
400
JoinedGroupLimitExceed
%s诊断
400
InvalidParameter.SecurityGroupIdRepeated
%s诊断
400
InvalidSecurityGroupId.SingleIdAndMultiIdConflict
%s诊断
400
InvalidParameter.Conflict
%s诊断
400
InvalidConnectionTrackingConfiguration.RegionOrUserNotSupported
The specified parameter ConnectionTrackingConfiguration is not supported in this region, or this account is not in the whitelist of using network interface ConnectionTrackingConfiguration.诊断
400
InvalidOperation.EniCountExceeded
%s.诊断
400
InvalidPrivateIpAddress.Duplicated
The specified private IP address "%s" is duplicated.诊断
400
IncorrectVSwitchStatus
The operation is not allowed in the current VSwitch state. Expecting state includes "Created Available", but current state is "%s".诊断
400
InvalidEniQueueSize.RegionOrUserNotSupported
The specified parameter "RxQueueSize" or "TxQueueSize" is not supported in this region or this account is not allowed to use ENI QueueSize.诊断
400
InvalidParameter.EniQueueSize
The specified parameter "TxQueueSize" and "RxQueueSize" are not equal or the value must be 8192 or 16384.诊断
400
InvalidParameter.EniConnectionTrackingConfiguration
The specified ENI connection tracking configuration "%s" must be between %s and %s.诊断
400
QuotaExceeded.PrivateIpAddress
There are not enough private IPs in the specified VSwitch.诊断
400
Throttling
Request was denied due to request throttling.诊断
400
InvalidVSwitch.IllegalStatus
The operation is not allowed in the current VSwitch state. Expecting state includes "Created", but current state is "%s".诊断
401
InvalidOperation.SecurityGroupNotAuthorized
The specified security group is not authorized to operate.诊断
403
InvalidUserType.NotSupported
%s诊断
403
Abs.InvalidAccount.NotFound
%s诊断
403
Forbidden.NotSupportRAM
%s诊断
403
Forbidden.SubUser
%s诊断
403
InValidParameter
%s诊断
403
MaxEniCountExceeded
%s诊断
403
EniPerInstanceLimitExceeded
%s诊断
403
InvalidOperation.AvailabilityZoneMismatch
%s诊断
403
InvalidOperation.VpcMismatch
%s诊断
403
SecurityGroupInstanceLimitExceed
%s诊断
403
InvalidSecurityGroupId.NotVpc
%s诊断
403
InvalidOperation.InvalidEniType
%s诊断
403
InvalidVSwitchId.IpNotEnough
%s诊断
403
InvalidVSwitchId.IpInvalid
%s诊断
403
QuotaExceed.Tags
%s诊断
403
InvalidIp.Address
%s诊断
403
InvalidIp.IpRepeated
%s诊断
403
MaxEniPrivateIpsCountExceeded
%s诊断
403
InvalidOperation.ResourceManagedByCloudProduct
%s诊断
403
InvalidOperation.TrunkingIsNotAllowed
%s诊断
403
InvalidParameter.InvalidEniQueueNumber
%s诊断
403
InvalidOperation.MaxEniQueueNumberExceeded
%s诊断
403
InvalidOperation.ExceedInstanceTypeQueueNumber
%s诊断
403
InvalidParameter.EniTrafficMode
%s诊断
403
InvalidOperation.HighPerformanceTrafficModeIsNotAllowed
%s诊断
403
InvalidParameter.QueuePairNumberMustEmpty
%s诊断
403
InvalidParameter.InvalidQueuePairNumber
%s诊断
403
InvalidParams.NetworkInterfaceName
%s诊断
403
InvalidIp.IpPrefixIllegal
The ip prefixes %s is/are illegal.诊断
403
InvalidIp.IpPrefixMustInReserveSegment
The ip prefix must in vswitch reserve segment.诊断
403
InvalidOperation.Ipv4CountExceeded
%s诊断
403
InvalidOperation.Ipv6CountExceeded
%s诊断
403
InvalidOperation.HighPerformanceTrafficModeEniUnsupported
High performance traffic mode does not support the current ENI type. Expected ENI type is "%s" but the current ENI type is "%s".诊断
403
AclLimitExceed
%s诊断
403
InvalidIp.IpPrefixMaskInvalid
The IP prefix mask %s is illegal which must be between %s and %s.诊断
403
InvalidVSwitchId.IpPrefixNotEnough
The specified VSwitch does not have enough IP prefixes.诊断
403
InvalidIp.IpPrefixMaskNotSame
The IP prefixes %s are illegal.The IP prefix mask must be the same.诊断
403
EnterpriseGroupLimited.MutliGroupType
The specified instance can't associate security group of different types.诊断
403
InvalidOperation.BoundingEniSlaveQuotaExceed
The number of Slave ENIs exceeds the limit of Bond ENI.诊断
403
InvalidIp.IpPrefixNotAvailable
The IP prefix is not available.诊断
403
InvalidIp.IpPrefixMaskIllegal
The current IP prefix mask is illegal.诊断
403
InvalidIp.IpPrefixNotStrict
The IP prefix "%s" must be strict CIDR format.诊断
403
InvalidOperation.NotSupport
The specified region does not support allocating IPv6 when creating ENI.诊断
404
InvalidEcsId.NotFound
%s诊断
404
InvalidEniId.NotFound
%s诊断
404
InvalidVSwitchId.NotFound
%s诊断
404
InvalidSecurityGroupId.NotFound
%s诊断
404
InvalidResourceGroup.NotFound
The ResourceGroup provided does not exist in our records.诊断
404
InvalidOperation.MaxEniIpv6IpsCountExceeded
The ipv6 address count exceed limitation.诊断
404
InvalidOperation.VSwitchIpv6Disabled
The specified VSwitch does not support Ipv6 feature.诊断
404
InvalidOperation.EnableIpv6Failed
The specified VSwitch does not support Ipv6 feature.诊断
404
InvalidOperation.AddressAlreadyAllocated
The specified ipv6 has been already allocated.诊断
404
InvalidOperation.AddressNotInVSwitchCidr
The specified ipv6 does not match VSwitch cidr scope.诊断
404
InvalidOperation.SlaveEniMustHaveBondingEni
Ensure you create the corresponding Bond ENI before creating Slave ENI.诊断
404
InvalidOperation.EniTrafficModeNotSupportIpv6
The High Performance(RDMA) traffic mode does not support IPv6.诊断
404
InvalidOperation.VSwitchCidrReservationNotExist
The specified VSwitch does not have CIDR reservation.诊断
500
InternalError
The request processing has failed due to some unknown error, exception or failure.诊断
500
InvalidOperation.RegionNotSupportIpPrefix
The current region does not support IP prefix feature.诊断

变更历史

变更时间变更内容概要操作
2025-03-25
变更错误码400
2025-01-13
变更错误码400
2025-01-09
变更请求参数EnhancedNetwork
2024-12-04
新增错误码401
2024-11-05
新增请求参数SourceDestCheck
变更返回参数
2024-08-19
变更错误码400
变更错误码403
变更错误码404
变更错误码500
2024-07-03
变更错误码403
变更请求参数SecurityGroupIds

相关示例

本文展示了如何通过阿里云ECS SDK调用CreateNetworkInterface创建弹性网卡。
2024-07-26