阿里云如何使用網(wǎng)絡(luò)相關(guān)接口
來源:技術(shù)員聯(lián)盟┆發(fā)布時(shí)間:2017-12-01 00:44┆點(diǎn)擊:
分配公網(wǎng) IP 地址
描述
給一個(gè)特定實(shí)例分配一個(gè)可用公網(wǎng)IP地址。
實(shí)例的狀態(tài)必須為 Running 或 Stopped 狀態(tài),才可以調(diào)用此接口。
分配的 IP 必須在實(shí)例啟動(dòng)或重啟后才能生效。
分配的時(shí)候只能是 IP,不能是 IP 段。
目前,一個(gè)實(shí)例只能分配一個(gè) IP。當(dāng)調(diào)用此接口時(shí),如果實(shí)例已經(jīng)擁有一個(gè)公網(wǎng) IP,將直接返回原 IP 地址。
被安全控制在實(shí)例的 OperationLocks 中標(biāo)記了 "LockReason" : "security" 的鎖定狀態(tài)時(shí),不能分配公網(wǎng) IP。
請(qǐng)求參數(shù)
名稱
類型
是否必須
描述
Action
String
是
系統(tǒng)規(guī)定參數(shù),取值:AllocatePublicIpAddress
InstanceId
String
是
需要分配 IP 地址的實(shí)例 ID
返回參數(shù)
名稱
類型
描述
IpAddress
String
分配的公網(wǎng) IP 地址
錯(cuò)誤碼
錯(cuò)誤代碼
描述
Http 狀態(tài)碼
語義
InvalidInstanceId.NotFound
The InstanceId provided does not exist in our records.
404
指定的 InstanceId 不存在
MissingParameter
The input parameter "InstanceId" that is mandatory for processing this request is not supplied.
400
缺少 InstanceId 值
IncorrectInstanceStatus
The current status of the resource does not support this operation.
403
該資源目前的狀態(tài)不支持此操作
InstanceLockedForSecurity
The specified operation is denied as your instance is locked for security reasons.
403
該資源目前被安全鎖定被拒絕操作
InstanceExpiredOrInArrears
The specified operation is denied as your prepay instance is expired (prepay mode) or in arrears (afterpay mode).
403
實(shí)例到期或者欠費(fèi)(是指該實(shí)例是包年包月或者按量欠費(fèi)的情況)
IpInUse
The specified IP is already in use.
403
用戶使用指定 IP 進(jìn)行綁定時(shí),IP 已經(jīng)被使用在別的機(jī)器上
AllocatedAlready
There is an IpAddress allocated already for the specified instance.
403
用戶使用指定 IP 進(jìn)行綁定時(shí),該實(shí)例已經(jīng)被分配了別的 IP 地址
示例
請(qǐng)求示例
https://ecs.aliyuncs.com/?Action=AllocatePublicIpAddress
&InstanceId=i-instance1
&<公共請(qǐng)求參數(shù)>