All Products
Search
Document Center

Elastic Compute Service:AssignIpv6Addresses

Last Updated:Jun 25, 2026

Assigns one or more IPv6 addresses to an Elastic Network Interface (ENI).

Operation description

Operation description

You can specify IPv6 addresses from the CIDR block of the vSwitch to which the Elastic Network Interface (ENI) belongs, or specify the number of IPv6 addresses for automatic creation. Note the following items:

  • The vSwitch to which the ENI belongs must have IPv6 enabled. For more information, see Enable an IPv6 CIDR block for an existing vSwitch.

  • The ENI must be in the Active (Available) or InUse state.

  • When you operate a primary ENI, the instance to which the network interface controller (NIC) is attached must be in the Running or Stopped state.

  • The number of IPv6 addresses that can be allocated to a single network interface controller (NIC) depends on the instance type of the instance to which the ENI is attached.

    • If the ENI is in the Active (Available) state, you can allocate up to 10 IPv6 addresses to it.

    • If the ENI is attached to an instance, the number of IPv6 addresses that can be allocated is limited by the instance type. For more information, see Instance family.

  • After you successfully invoke this operation, you can obtain the allocated IPv6 address information from the response.

Try it now

Try this API in OpenAPI Explorer, no manual signing needed. Successful calls auto-generate SDK code matching your parameters. Download it with built-in credential security for local usage.

Test

RAM authorization

The table below describes the authorization required to call this API. You can define it in a Resource Access Management (RAM) policy. The table's columns are detailed below:

  • Action: The actions can be used in the Action element of RAM permission policy statements to grant permissions to perform the operation.

  • API: The API that you can call to perform the action.

  • Access level: The predefined level of access granted for each API. Valid values: create, list, get, update, and delete.

  • Resource type: The type of the resource that supports authorization to perform the action. It indicates if the action supports resource-level permission. The specified resource must be compatible with the action. Otherwise, the policy will be ineffective.

    • For APIs with resource-level permissions, required resource types are marked with an asterisk (*). Specify the corresponding Alibaba Cloud Resource Name (ARN) in the Resource element of the policy.

    • For APIs without resource-level permissions, it is shown as All Resources. Use an asterisk (*) in the Resource element of the policy.

  • Condition key: The condition keys defined by the service. The key allows for granular control, applying to either actions alone or actions associated with specific resources. In addition to service-specific condition keys, Alibaba Cloud provides a set of common condition keys applicable across all RAM-supported services.

  • Dependent action: The dependent actions required to run the action. To complete the action, the RAM user or the RAM role must have the permissions to perform all dependent actions.

Action

Access level

Resource type

Condition key

Dependent action

ecs:AssignIpv6Addresses

create

*NetworkInterface

acs:ecs:{#regionId}:{#accountId}:eni/{#eniId}

None None

Request parameters

Parameter

Type

Required

Description

Example

RegionId

string

Yes

The region ID of the network interface controller (NIC). You can invoke DescribeRegions to query the most recent region list.

cn-hangzhou

RegionId

string

Yes

The ID of the network interface controller (NIC).

cn-hangzhou

NetworkInterfaceId

string

Yes

The number of IPv6 addresses to randomly generate for the network interface controller (NIC). Valid values: 1 to 10.

Note

When you invoke this operation, you must set either the Ipv6Addresses.N parameter or the Ipv6AddressCount parameter, but not both.

eni-bp1iqejowblx6h8j****

Ipv6AddressCount

integer

No

One or more IPv6 addresses to assign to the network interface controller (NIC). You can set up to 10 IPv6 addresses. Valid values of N: 1 to 10.

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

Note

When you invoke this operation, you must set either the Ipv6Addresses.N parameter or the Ipv6AddressCount parameter, but not both.

1

Ipv6Address

array

No

One or more IPv6 prefixes to assign to the network interface controller (NIC). Valid values of N: 1 to 10.

Note

To set IPv6 prefixes for the ENI, you must set either the Ipv6Prefix.N parameter or the Ipv6PrefixCount parameter, but not both.

2001:db8:1234:1a00::****

string

No

One or more IPv6 prefixes to assign to the network interface controller (NIC). Valid values of N: 1 to 10.

Note

To set IPv6 prefixes for the ENI, you must set either the Ipv6Prefix.N parameter or the Ipv6PrefixCount parameter, but not both.

2001:db8:1234:1a00::****

Ipv6Prefix

array

No

The number of IPv6 prefixes to assign to the network interface controller (NIC). Valid values: 1 to 10.

Note

To set IPv6 prefixes for the ENI, you must set either the Ipv6Prefix.N parameter or the Ipv6PrefixCount parameter, but not both.

string

No

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

Note

To set IPv6 prefixes for the ENI, you must set either the Ipv6Prefix.N parameter or the Ipv6PrefixCount parameter, but not both.

2001:db8:1234:1a00:****::/80

Ipv6PrefixCount

integer

No

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

1

ClientToken

string

No

The client token that is used to ensure the idempotence of the request. You can use the client to generate the token, but make sure that the token is unique among different requests. The ClientToken value 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

Response elements

Element

Type

Description

Example

object

RequestId

string

The request ID.

473469C7-AA6F-4DC5-B3DB-A3DC0DE3C83E

NetworkInterfaceId

string

The network interface controller (NIC) ID.

eni-bp1iqejowblx6h8j****

Ipv6Sets

object

Ipv6Address

array

The IPv6 addresses allocated to the network interface controller (NIC).

string

The IPv6 addresses allocated to the network interface controller (NIC).

2001:db8:1234:1a00::****

Ipv6PrefixSets

object

Ipv6Prefix

array

The IPv6 prefixes allocated to the network interface controller (NIC).

string

The IPv6 prefix allocated to the network interface controller (NIC).

2001:db8:1234:1a00:****::/80

Examples

Success response

JSON format

{
  "RequestId": "473469C7-AA6F-4DC5-B3DB-A3DC0DE3C83E",
  "NetworkInterfaceId": "eni-bp1iqejowblx6h8j****",
  "Ipv6Sets": {
    "Ipv6Address": [
      "2001:db8:1234:1a00::****"
    ]
  },
  "Ipv6PrefixSets": {
    "Ipv6Prefix": [
      "2001:db8:1234:1a00:****::/80"
    ]
  }
}

Error codes

HTTP status code

Error code

Error message

Description

400 UnsupportedParameter %s The parameter is not supported.
400 InvalidParameter %s The specified parameter is invalid.
400 InvalidInstanceID.Malformed %s The specified InstanceId parameter is invalid.
400 MissingParameter %s A parameter is not specified.
400 InValidParameter %s
400 InvalidParams.EniId %s The specified EniId parameter is invalid.
400 InvalidOperation.InvalidEcsState %s
400 InvalidOperation.InvalidEniState %s
400 InvalidPrivateIpAddress.Duplicated Specified private IP address is duplicated.
400 IncorrectVSwitchStatus The current status of vSwitch does not support this operation.
400 InvalidParameter.Conflict %s The specified parameter is invalid. Check whether parameter conflicts exist. %s is a variable. An error message is dynamically returned based on call conditions.
400 InvalidOperation.EniOperationConflict The previous ENI operation is still in progress. Please try again later. Current operation conflict, please wait for a moment and try again
500 InvalidOperation.RegionNotSupportIpPrefix The current region does not support ip prefix. You cannot assign IP address prefixes in this region.
403 InvalidUserType.NotSupported %s Your account does not support this operation.
403 Abs.InvalidAccount.NotFound %s Your Alibaba Cloud account does not exist or your AccessKey pair has expired.
403 MissingParameter %s
403 Forbedden.NotSupportRAM %s RAM users are not authorized to perform this operation.
403 Forbbiden.SubUser %s You are not authorized to manage this resource. Contact the owner of the Alibaba Cloud account for authorization.
403 InvalidOperation.InvalidEniType %s
403 MaxEniIpv6IpsCountExceeded %s The maximum number of IPv6 addresses that can be assigned to the ENI has been reached.
403 InvalidIp.IpUnassigned %s The specified IP address is not assigned.
403 InvalidIp.IpRepeated %s The specified IP address already exists.
403 InvalidIp.IpAssigned %s The specified IP address is already assigned.
403 InvalidIp.Address %s The IP entered is not in the correct format or is not in the optional CIDR range.
403 InvalidOperation.EniCountExceeded %s
403 InvalidOperation.Ipv4CountExceeded %s The operation is valid because the maximum number of IPv4 addresses has been reached.
403 InvalidOperation.Ipv6CountExceeded %s The operation is valid because the maximum number of IPv6 addresses has been reached.
403 InvalidOperation.Ipv6NotSupport %s
403 InvalidOperation.Ipv4NotSupport %s
403 InvalidVSwitch.Ipv6NotTurnOn %s The IPv6 feature is not enabled for your current vSwitch. Enable the feature and try again.
403 InvalidParam.IpAssign %s
403 InvalidVSwitchId.IpInvalid %s The specified private IP address is invalid.
403 Forbidden.RegionId %s
403 InvalidOperation.EniServiceManaged %s The operation is invalid.
403 SecurityGroupInstanceLimitExceed %s
403 InvalidOperation.HighPerformanceTrafficModeEniNotSupport %s
403 InvalidOperation.EniTypeNotSupport The member eni does not support ipv6.
403 InvalidIp.IpPrefixIllegal The ip prefixes %s is/are illegal. The IP address prefix is invalid and is not in the CIDR format.
403 InvalidIp.IpPrefixMaskIllegal The ip prefix mask is illegal. The IP address prefix mask is invalid.
403 InvalidIp.IpPrefixMaskInvalid The 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.
403 InvalidIp.IpPrefixMaskNotSame The ip prefixes %s are illegal which mask must be same. The IP address prefix masks are not the same.
403 InvalidIp.IpPrefixMustInReserveSegment The ip prefix must in vswitch reserve segment. The IP address prefix is invalid and is not in the reserved CIDR block of the vSwitch.
403 InvalidIp.IpPrefixNotAvailable The ip prefix is/are not available. The IP address prefix is not available.
403 InvalidIp.IpPrefixNotStrict The ip prefix must be strict cidr format. The IP address prefix is invalid and is not in the CIDR format.
403 InvalidVSwitchId.IpPrefixNotEnough The specified vSwitch has not enough ip prefix. The number of IP address prefixes in the specified vSwitch is insufficient.
404 InvalidEniId.NotFound %s
404 MaxEniIpv6IpsCountExceeded The ipv6 address count exceed limitation.
404 InvalidOperation.VSwitchIpv6Disabled The specified VSwitch does not support Ipv6 feature. The specified VSwitch does not support IPv6.
404 InvalidOperation.EnableIpv6Failed The specified VSwitch does not support Ipv6 feature.
404 InvalidIp.IpAssigned The specified ipv6 has already been allocated.
404 InvalidVSwitchId.IpInvalid The specified ipv6 does not match VSwitch cidr scope.
404 InvalidOperation.HasIpv6RouteEntry The specified eni has been pointed to the next hop of the route.
404 InvalidOperation.VSwitchCidrReservationNotExist The specified vSwitch has no cidr reservation.

See Error Codes for a complete list.

Release notes

See Release Notes for a complete list.