Assigns one or more secondary private IP addresses to an elastic network interface (ENI). You can specify available private IP addresses within the CIDR block of the vSwitch that is connected to the ENI. Alternatively, you can specify a number of private IP addresses to automatically assign from the CIDR block of the vSwitch to the ENI.
Usage notes
The ENI to which you want to assign secondary private IP addresses must be in the Available (Available) or InUse (InUse) state.
When you assign secondary private IP addresses to a primary ENI, the Elastic Compute Service (ECS) instance to which the ENI is attached must be in the Running (Running) or Stopped (Stopped) state.
When an ENI is in the Available (Available) state, you can assign up to 49 secondary private IP addresses to it. When an ENI is attached to an instance, the number of secondary private IP addresses that can be assigned to the ENI is subject to the instance type. For more information, see Overview of instance families.
After you call this operation for an ENI, you can obtain the secondary private IP addresses that are assigned to the ENI from the response.
Debugging
Request parameters
Parameter | Type | Required | Example | Description |
Action | String | Yes | AssignPrivateIpAddresses | The operation that you want to perform. Set the value to AssignPrivateIpAddresses. |
RegionId | String | Yes | cn-hangzhou | The region ID of the ENI. You can call the DescribeRegions operation to query the most recent region list. |
NetworkInterfaceId | String | Yes | eni-bp67acfmxazb4p**** | The ID of the ENI. |
SecondaryPrivateIpAddressCount | Integer | No | 1 | The number of private IP addresses to be automatically assigned from the CIDR block of the vSwitch that is connected to the ENI. To assign secondary private IP addresses to the ENI, you cannot specify both |
ClientToken | String | No | 123e4567-e89b-12d3-a456-426655440000 | 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. |
PrivateIpAddress.N | String | No | 10.1.**.** | Secondary private IP address N, which is selected from within the CIDR block of the vSwitch that is connected to the ENI. Valid values of N:
Note To assign secondary private IP addresses to the ENI, you cannot specify both |
Ipv4Prefix.N | String | No | 192.168.**.**/28 | IPv4 prefix N. Valid values of N: 1 to 10. Note To assign IPv4 prefixes to the ENI, you must specify Ipv4Prefix.N or Ipv4PrefixCount but not both. |
Ipv4PrefixCount | Integer | No | 1 | The number of IPv4 prefixes to be randomly generated for the ENI. Valid values: 1 to 10. Note To assign IPv4 prefixes to the ENI, you must specify Ipv4Prefix.N or Ipv4PrefixCount but not both. |
Response parameters
Parameter | Type | Example | Description |
RequestId | String | 473469C7-AA6F-4DC5-B3DB-A3DC0DE3C83E | The request ID. |
AssignedPrivateIpAddressesSet | Object | The secondary private IP addresses that are assigned to the ENI. | |
NetworkInterfaceId | String | eni-bp125p95hhdhn3ot**** | The ENI ID. |
PrivateIpSet | Array of String | 192.168.**.** | The secondary private IP addresses. |
Ipv4PrefixSet | Array of String | 192.168.**.**/28 | The IPv4 prefixes. |
Examples
Sample requests
https://ecs.aliyuncs.com/?Action=AssignPrivateIpAddresses
&NetworkInterfaceId=eni-bp67acfmxazb4p****
&RegionId=cn-hangzhou
&PrivateIpAddress.1=10.1.**.**
&PrivateIpAddress.2=10.1.**.**
&<Common request parameters>Sample success responses
XML format
HTTP/1.1 200 OK
Content-Type:application/xml
<AssignPrivateIpAddressesResponse>
<RequestId>473469C7-AA6F-4DC5-B3DB-A3DC0DE3C83E</RequestId>
<AssignedPrivateIpAddressesSet>
<PrivateIpSet>
<PrivateIpAddress>192.168.**.**</PrivateIpAddress>
</PrivateIpSet>
<NetworkInterfaceId>eni-bp125p95hhdhn3ot****</NetworkInterfaceId>
</AssignedPrivateIpAddressesSet>
</AssignPrivateIpAddressesResponse>JSON format
HTTP/1.1 200 OK
Content-Type:application/json
{
"RequestId" : "473469C7-AA6F-4DC5-B3DB-A3DC0DE3C83E",
"AssignedPrivateIpAddressesSet" : {
"PrivateIpSet" : {
"PrivateIpAddress" : [ "192.168.**.**" ]
},
"NetworkInterfaceId" : "eni-bp125p95hhdhn3ot****"
}
}Error codes
HTTP status code | Error code | Error message | Description |
400 | Throttling | Request was denied due to request throttling. | The request is throttled. |
400 | UnsupportedParameter | %s | A specified parameter is not supported. |
400 | InvalidParameter | %s | An invalid parameter. |
400 | InvalidInstanceID.Malformed | %s | Invalid InstanceId value. |
400 | InvalidOperation.InvalidEcsState | %s | This operation cannot be performed on the instance in the current state. |
400 | InvalidOperation.InvalidEniState | %s | This operation cannot be performed on the ENI in the current state. |
400 | InvalidOperation.DetachPrimaryEniNotAllowed | %s | The ENI cannot be detached from the instance. |
400 | MissingParameter | %s | A required parameter is not specified. |
400 | Forbidden.RegionId | %s | The service is unavailable in the region for the moment. |
400 | InvalidAction | %s | The operation is invalid. |
400 | IncorrectVSwitchStatus | The current status of vSwitch does not support this operation. | The operation cannot be performed on the vSwitch in the current state. |
400 | InvalidPrivateIpAddress.Duplicated | Specified private IP address is duplicated. | The specified private IP address is already in use. Try a different IP address. |
400 | InvalidParameter.Conflict | %s | A specified parameter is invalid. Check whether parameter conflicts exist. %s is a variable. An error message is dynamically returned based on call conditions. |
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 | Forbidden.NotSupportRAM | %s | Resource Access Management (RAM) users have no access to this operation. |
403 | Forbidden.SubUser | %s | You have no access to the resource. Contact the owner of the Alibaba Cloud account. |
403 | MaxEniCountExceeded | %s | The maximum number of ENIs that can be managed is exceeded. |
403 | EniPerInstanceLimitExceeded | %s | The maximum number of ENIs that can be attached to the instance is reached. |
403 | InvalidOperation.AvailabilityZoneMismatch | %s | The operation is invalid. |
403 | InvalidOperation.VpcMismatch | %s | The operation is invalid. Check whether the virtual private cloud (VPC) in the operation corresponds to other parameters. |
403 | SecurityGroupInstanceLimitExceed | %s | The maximum number of instances in the specified security group is reached. |
403 | InvalidSecurityGroupId.NotVpc | %s | Invalid SecurityGroupId value. The network type of the specified security group is not VPC. |
403 | InvalidOperation.InvalidEniType | %s | This operation cannot be performed on this type of ENI. |
403 | InvalidVSwitchId.IpNotEnough | %s | Available IP addresses within the CIDR block of the specified VSwitch are insufficient. |
403 | InvalidVSwitchId.IpInvalid | %s | Invalid private IP address. |
403 | InvalidIp.IpAssigned | %s | The specified IP address is already assigned. |
403 | MaxEniPrivateIpsCountExceeded | %s | The maximum number of secondary private IP addresses that can be assigned to the ENI is exceeded. For more information, see the return value of the %s placeholder in the error message. |
403 | Operation.Conflict | %s | This operation conflicts with another operation in progress. Try again later. |
403 | InvalidOperation.Ipv4CountExceeded | %s | The maximum number of IPv4 addresses is reached. |
403 | InvalidOperation.EniServiceManaged | %s | The operation is invalid. |
403 | InvalidIp.IpRepeated | %s | The IP address already exists. |
403 | InvalidIp.IpPrefixIllegal | The ip prefixes %s is/are illegal. | The IP prefixes are invalid and not in CIDR notation. |
403 | InvalidIp.IpPrefixMaskIllegal | The ip prefix mask is illegal. | The IP prefix mask is invalid. |
403 | InvalidIp.IpPrefixMaskInvalid | The ip prefixes mask %s is illegal which must be between %s and %s. | The IP prefix masks are invalid. |
403 | InvalidIp.IpPrefixMaskNotSame | The ip prefixes %s are illegal which mask must be same. | The IP prefix masks are not the same. |
403 | InvalidIp.IpPrefixMustInReserveSegment | The ip prefix must in vswitch reserve segment. | The IP 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 prefix is not available. |
403 | InvalidIp.IpPrefixNotStrict | The ip prefix must be strict cidr format. | The IP prefix is invalid and not in CIDR notation. |
403 | InvalidVSwitchId.IpPrefixNotEnough | The specified vSwitch has not enough ip prefix. | Available IP prefixes within the CIDR block of the specified vSwitch are insufficient. |
403 | MissingParameter | These parameters %s cannot be both empty. | A required parameter is not specified. |
404 | InvalidEcsId.NotFound | %s | The instance ID is not found. |
404 | InvalidEniId.NotFound | %s | The ENI ID is not found. |
404 | InvalidVSwitchId.NotFound | %s | The vSwitch is not found. |
404 | InvalidSecurityGroupId.NotFound | %s | The security group ID is not found. |
404 | InvalidInstanceId.NotFound | %s | The InstanceId value is not found. |
500 | InvalidOperation.RegionNotSupportIpPrefix | The current region does not support ip prefix. | IP prefixes cannot be assigned in the region. |
For a list of error codes, see Service error codes.