調用CreateVpnPbrRouteEntry介面建立VPN策略路由。
介面說明
前提條件
建立策略路由前,請確保您已經建立了 IPsec 串連。具體操作,請參見 CreateVpnConnection 。
建立策略路由前,建議您先瞭解策略路由的使用限制、匹配規則等資訊。更多資訊,請參見使用原則路由。
使用限制
不支援添加目標網段為 0.0.0.0/0 的策略路由。
請勿添加目標網段為 100.64.0.0/10、100.64.0.0/10 下的子網段或者包含 100.64.0.0/10 網段的策略路由,該類策略路由會導致控制台無法顯示 IPsec 串連的狀態或者導致 IPsec 串連協商失敗。
- CreateVpnPbrRouteEntry 介面屬於非同步介面,即系統先返回策略路由的資訊,但該策略路由尚未建立成功,系統背景建立任務仍在進行。您可以調用 DescribeVpnGateway 介面查詢 VPN 閘道執行個體狀態,來確定策略路由的建立狀態:
當 VPN 閘道執行個體處於 updating 狀態時,表示策略路由正在建立中。
當 VPN 閘道執行個體處於 active 狀態時,表示策略路由建立成功。
CreateVpnPbrRouteEntry 介面不支援在同一個 VPN 閘道執行個體下並發建立策略路由。
調試
您可以在OpenAPI Explorer中直接運行該介面,免去您計算簽名的困擾。運行成功後,OpenAPI Explorer可以自動產生SDK程式碼範例。
調試
授權資訊
請求參數
|
名稱 |
類型 |
必填 |
描述 |
樣本值 |
| RegionId |
string |
是 |
VPN 閘道執行個體所在的地區 ID。您可以通過調用 DescribeRegions 介面擷取地區 ID。 |
cn-hangzhou |
| ClientToken |
string |
否 |
用戶端 Token,用於保證請求的等冪性。 從您的用戶端產生一個參數值,確保不同請求間該參數值唯一。ClientToken 只支援 ASCII 字元。 說明
若您未指定,則系統自動使用 API 請求的 RequestId 作為 ClientToken 標識。每次 API 請求的 RequestId 不一樣。 |
d7d24a21-f4ba-4454-9173-b3**** |
| VpnGatewayId |
string |
是 |
VPN 閘道執行個體的 ID。 |
vpn-bp1a3kqjiiq9legfx**** |
| RouteSource |
string |
是 |
策略路由的源網段。 |
192.168.1.0/24 |
| RouteDest |
string |
是 |
策略路由的目標網段。 |
10.0.0.0/24 |
| NextHop |
string |
是 |
策略路由的下一跳。 |
vco-bp15oes1py4i66rmd**** |
| Weight |
integer |
是 |
策略路由的權重值。 在您使用同一個 VPN 閘道執行個體搭建主備 IPsec-VPN 串連的情境中,您可以通過配置策略路由的權重值來指定主鏈路和備鏈路,權重值為 100 的策略路由預設為主鏈路,權重值為 0 的策略路由預設為備鏈路。 您可以通過為 IPsec 串連配置健全狀態檢查來自動探測鏈路的連通性,在主鏈路不通的情況下,系統自動將流量切換至備鏈路進行傳輸,實現上雲鏈路的高可用。具體操作,請參見 CreateVpnConnection 。
說明
|
0 |
| PublishVpc |
boolean |
是 |
是否發布策略路由到 VPC 中。取值:
|
true |
| Description |
string |
否 |
策略路由的描述資訊。 描述資訊長度為 1~100 個字元。 |
desctest |
| OverlayMode |
string |
否 |
隧道協議。僅取值:Ipsec(IPsec 隧道協議)。 |
Ipsec |
| Priority |
integer |
否 |
策略路由的策略優先順序。取值範圍:1~100。預設值:10。 策略優先順序數字越小,策略路由的優先順序越高。 |
10 |
| DryRun |
boolean |
否 |
是否只預檢此次請求。取值:
|
false |
返回參數
|
名稱 |
類型 |
描述 |
樣本值 |
|
object |
返回結果。 |
||
| NextHop |
string |
策略路由的下一跳。 |
vco-bp15oes1py4i66rmd**** |
| Weight |
integer |
策略路由的權重值。
|
0 |
| RouteDest |
string |
策略路由的目標網段。 |
10.0.0.0/24 |
| RequestId |
string |
請求 ID。 |
5BE01CD7-5A50-472D-AC14-CA181C5C03BE |
| Description |
string |
策略路由的描述資訊。 |
desctest |
| State |
string |
策略路由的發布狀態。
|
normal |
| CreateTime |
integer |
建立策略路由的時間戳記。單位:毫秒。 時間戳記的格式採用 Unix 時間戳記,表示從格林威治時間 1970 年 01 月 01 日 00 時 00 分 00 秒至建立策略路由時的總時間長度。 |
1492747187000 |
| OverlayMode |
string |
隧道協議。僅取值:Ipsec(IPsec 隧道協議)。 |
Ipsec |
| RouteSource |
string |
策略路由的源網段。 |
192.168.1.0/24 |
| VpnInstanceId |
string |
VPN 閘道執行個體 ID。 |
vpn-bp1cmw7jh1nfe43m9**** |
| Priority |
integer |
策略路由的策略優先順序。 |
10 |
樣本
正常返回樣本
JSON格式
{
"NextHop": "vco-bp15oes1py4i66rmd****",
"Weight": 0,
"RouteDest": "10.0.0.0/24",
"RequestId": "5BE01CD7-5A50-472D-AC14-CA181C5C03BE",
"Description": "desctest",
"State": "normal",
"CreateTime": 1492747187000,
"OverlayMode": "Ipsec",
"RouteSource": "192.168.1.0/24",
"VpnInstanceId": "vpn-bp1cmw7jh1nfe43m9****",
"Priority": 10
}
錯誤碼
|
HTTP status code |
錯誤碼 |
錯誤資訊 |
描述 |
|---|---|---|---|
| 400 | Resource.QuotaFull | The quota of resource is full | |
| 400 | VpnGateway.FinancialLocked | The specified service is financial locked. | |
| 400 | VpnRouteEntry.AlreadyExists | The specified route entry is already exist. | 該路由已存在。 |
| 400 | VpnRouteEntry.Conflict | The specified route entry has conflict. | 路由條目存在衝突。 |
| 400 | VpnRouteEntry.ConflictSSL | The specified route entry has conflict with SSL client. | 路由條目與SSL用戶端衝突。 |
| 400 | VpnRouteEntry.BackupRoute | Validate backup route entry failed. | 主備路由條目校正失敗。 |
| 400 | VpnRouteEntry.InvalidWeight | Invalid route entry weight value. | 路由權重值不合法 |
| 400 | InvalidNextHop.NotFound | The specified NextHop does not exist. | 路由指定的下一跳不存在 |
| 400 | IllegalParam.RouteDest | The specified RouteDest is invalid | 目的地址不合法。 |
| 400 | OperationFailed.RouteConflict | Operation failed because there is already a route in VPC route table to another VPN on the same network block. | 在VPC路由表中同一網段上已經存在一條指向另一個VPN網關的路由。 |
| 400 | OperationFailed.InvalidCidrBlock | Operation failed because the specified network block is invalid. | 網段不合法。 |
| 400 | QuotaExceeded.VpnRouteEntry | The number of route entries to the VPN gateway in the VPC routing table has reached the quota limit. | VPC路由表中指向VPN網關的路由條目已經達到配額限制。 |
| 400 | VpnPbrRouteEntryPriority.NotSupport | Current version of the VPN does not support setting custom pbr route entry priority. | 目前的版本的VPN不支援設定策略路由條目優先順序 |
| 400 | TaskConflict | The operation is too frequent, please wait a moment and try again. | 操作過於頻繁,請稍等一會再重試 |
| 400 | VpnTask.CONFLICT | Vpn task has conflict. | Vpn操作存在衝突,請稍後重試。 |
| 400 | VpnGateway.Configuring | The specified service is configuring. | |
| 400 | InternalError | The request processing has failed due to some unknown error, exception or failure. | |
| 400 | VpnRouteEntry.SrcDestWeightConflict | The VPN gateway does not support Policy-based routing with the same source CIDR, destination CIDR and weight. | VPN網關不支援配置源網段、目標網段與權重同時相同的策略路由。 |
| 400 | VpnRouteEntry.SamePriorityPbrRoutePrefixOverlap | The source CIDR and destination CIDR of Policy-based routes with the same priority cannot overlap. | VPN網關不支援相同優先順序下的多個策略路由源和目標網段同時重合。 |
| 400 | VpnRouteEntry.SrcDestConflict | The VPN gateway does not support Policy-based routing with the same source CIDR and destination CIDR. | 雙隧道類型的VPN網關不支援配置源網段與目標網段同時相同的策略路由。 |
| 400 | CreatePbrRoutesQuotaFull.QuotaFull | The number of policy routes exceeds the quota limit. | 策略路由數量超過配額限制。 |
| 400 | InvalidCidrBlock.Malformed | Specified CIDR block is not valid. | |
| 400 | DryRunOperation | Request validation has been passed with DryRun flag set. | DryRun校正通過。 |
| 400 | VpnPbrRouteEntry.NotSupport | Current version of the VPN does not support pbr route entry. | 當前VPN執行個體不支援策略路由。 |
| 403 | Forbbiden.SubUser | User not authorized to operate on the specified resource as your account is created by another user. | |
| 403 | Forbidden | User not authorized to operate on the specified resource. | 您沒有許可權操作指定資源,請申請許可權後再操作。 |
| 404 | InvalidVpnGatewayInstanceId.NotFound | The specified vpn gateway instance id does not exist. |
訪問錯誤中心查看更多錯誤碼。
變更歷史
更多資訊,參考變更詳情。