文档

CreateVpnPbrRouteEntry - 创建VPN策略路由

更新时间:

调用CreateVpnPbrRouteEntry接口创建VPN策略路由。

接口说明

  • 创建策略路由前,建议您先了解策略路由的使用限制、匹配规则等信息。更多信息,请参见使用策略路由
  • 创建策略路由前,请确保您已经创建了 IPsec 连接。具体操作,请参见 CreateVpnConnection
  • CreateVpnPbrRouteEntry 接口属于异步接口,即系统先返回策略路由的信息,但该策略路由尚未创建成功,系统后台的创建任务仍在进行。您可以调用 DescribeVpnGateway 接口查询 VPN 网关实例状态,来确定策略路由的创建状态:
    • 当 VPN 网关实例处于 updating 状态时,表示策略路由正在创建中。
    • 当 VPN 网关实例处于 active 状态时,表示策略路由创建成功。
  • CreateVpnPbrRouteEntry 接口不支持在同一个 VPN 网关实例下并发创建策略路由。

调试

您可以在OpenAPI Explorer中直接运行该接口,免去您计算签名的困扰。运行成功后,OpenAPI Explorer可以自动生成SDK代码示例。

授权信息

下表是API对应的授权信息,可以在RAM权限策略语句的Action元素中使用,用来给RAM用户或RAM角色授予调用此API的权限。具体说明如下:

  • 操作:是指具体的权限点。
  • 访问级别:是指每个操作的访问级别,取值为写入(Write)、读取(Read)或列出(List)。
  • 资源类型:是指操作中支持授权的资源类型。具体说明如下:
    • 对于必选的资源类型,用背景高亮的方式表示。
    • 对于不支持资源级授权的操作,用全部资源表示。
  • 条件关键字:是指云产品自身定义的条件关键字。
  • 关联操作:是指成功执行操作所需要的其他权限。操作者必须同时具备关联操作的权限,操作才能成功。
操作访问级别资源类型条件关键字关联操作
vpc:CreateVpnPbrRouteEntryWrite
  • VpnGateway
    acs:vpc:{#regionId}:{#accountId}:vpngateway/{#VpnGatewayId}

请求参数

名称类型必填描述示例值
RegionIdstring

VPN 网关实例所在的地域 ID。您可以通过调用 DescribeRegions 接口获取地域 ID。

cn-hangzhou
ClientTokenstring

客户端 Token,用于保证请求的幂等性。

从您的客户端生成一个参数值,确保不同请求间该参数值唯一。ClientToken 只支持 ASCII 字符。

说明 若您未指定,则系统自动使用 API 请求的 RequestId 作为 ClientToken 标识。每次 API 请求的 RequestId 不一样。
d7d24a21-f4ba-4454-9173-b3****
VpnGatewayIdstring

VPN 网关实例的 ID。

vpn-bp1a3kqjiiq9legfx****
RouteSourcestring

策略路由的源网段。

192.168.1.0/24
RouteDeststring

策略路由的目标网段。

10.0.0.0/24
NextHopstring

策略路由的下一跳。

vco-bp15oes1py4i66rmd****
Weightinteger

策略路由的权重值。

在您使用同一个 VPN 网关实例搭建主备 IPsec-VPN 连接的场景中,您可以通过配置策略路由的权重值来指定主链路和备链路,权重值为 100 的策略路由默认为主链路,权重值为 0 的策略路由默认为备链路。

您可以通过为 IPsec 连接配置健康检查来自动探测链路的连通性,在主链路不通的情况下,系统自动将流量切换至备链路进行传输,实现上云链路的高可用。具体操作,请参见 CreateVpnConnection

  • 100:表示当前策略路由关联的 IPsec 连接为主链路。
  • 0:表示当前策略路由关联的 IPsec 连接为备链路。
说明
  • 在您指定主备链路时,主策略路由和备策略路由的源网段和目标网段需相同。
  • 对于支持双隧道模式 IPsec-VPN 连接的 VPN 网关实例,无需配置该参数。一个双隧道模式 IPsec-VPN 连接包含两条隧道,两条隧道自动形成主备链路,无需再通过配置该参数指定主备链路。如果您配置了该参数,则该参数配置后不生效。
  • 0
    PublishVpcboolean

    是否发布策略路由到 VPC 的路由表中。取值:

    • true:发布策略路由到 VPC 的路由表。

    • false:不发布策略路由到 VPC 的路由表。

    true
    Descriptionstring

    策略路由的描述信息。

    描述信息长度为 1~100 个字符。

    desctest
    OverlayModestring

    隧道协议。仅取值:Ipsec(IPsec 隧道协议)。

    Ipsec
    Priorityinteger

    策略路由的策略优先级。取值范围:1~100。默认值:10

    策略优先级数字越小,策略路由的优先级越高。

    10

    返回参数

    名称类型描述示例值
    object

    返回结果。

    NextHopstring

    策略路由的下一跳。

    vco-bp15oes1py4i66rmd****
    Weightinteger

    策略路由的权重值。

    • 100:表示当前策略路由关联的 IPsec 连接为主链路。
    • 0:表示当前策略路由关联的 IPsec 连接为备链路。
    0
    RouteDeststring

    策略路由的目标网段。

    10.0.0.0/24
    RequestIdstring

    请求 ID。

    5BE01CD7-5A50-472D-AC14-CA181C5C03BE
    Descriptionstring

    策略路由的描述信息。

    desctest
    Statestring

    策略路由的发布状态。

    • published:已发布策略路由到 VPC 的路由表。

    • normal:未发布策略路由到 VPC 的路由表。

    normal
    CreateTimelong

    创建策略路由的时间戳。单位:毫秒。

    时间戳的格式采用 Unix 时间戳,表示从格林威治时间 1970 年 01 月 01 日 00 时 00 分 00 秒至创建策略路由时的总时长。

    1492747187000
    OverlayModestring

    隧道协议。仅取值:Ipsec(IPsec 隧道协议)。

    Ipsec
    RouteSourcestring

    策略路由的源网段。

    192.168.1.0/24
    VpnInstanceIdstring

    VPN 网关实例 ID。

    vpn-bp1cmw7jh1nfe43m9****
    Priorityinteger

    策略路由的策略优先级。

    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错误码错误信息描述
    400Resource.QuotaFullThe quota of resource is full资源配额已达上限。
    400VpnGateway.FinancialLockedThe specified service is financial locked.该服务已欠费,请您先充值再操作。
    400VpnRouteEntry.AlreadyExistsThe specified route entry is already exist.该路由已存在。
    400VpnRouteEntry.ConflictThe specified route entry has conflict.路由条目存在冲突。
    400VpnRouteEntry.ConflictSSLThe specified route entry has conflict with SSL client.路由条目与SSL客户端冲突。
    400VpnRouteEntry.BackupRouteValidate backup route entry failed.主备路由条目校验失败。
    400VpnRouteEntry.InvalidWeightInvalid route entry weight value.路由权重值不合法
    400InvalidNextHop.NotFoundThe specified NextHop does not exist.路由指定的下一跳不存在
    400IllegalParam.RouteDestThe specified RouteDest is invalid目的地址不合法。
    400OperationFailed.RouteConflictOperation failed because there is already a route in VPC route table to another VPN on the same network block.在VPC路由表中同一网段上已经存在一条指向另一个VPN网关的路由。
    400OperationFailed.InvalidCidrBlockOperation failed because the specified network block is invalid.网段不合法。
    400OperationFailed.RouteConflictOperation failed because there is already a route in VPC route table to a non-RI and non-VPN next hop on the same network block.在VPC路由表中同一网段上已经存在一条指向RI、VPN网关之外其他资源的路由。
    400QuotaExceeded.VpnRouteEntryThe number of route entries to the VPN gateway in the VPC routing table has reached the quota limit.VPC路由表中指向VPN网关的路由条目已经达到配额限制。
    400VpnPbrRouteEntryPriority.NotSupportCurrent version of the VPN does not support setting custom pbr route entry priority.当前版本的VPN不支持设置策略路由条目优先级
    400TaskConflictThe operation is too frequent, please wait a moment and try again.操作过于频繁,请稍等一会再重试
    400VpnTask.CONFLICTVpn task has conflict.Vpn操作存在冲突,请稍后重试。
    400VpnGateway.ConfiguringThe specified service is configuring.服务正在配置中,请您稍后再试。
    400InternalErrorThe request processing has failed due to some unknown error, exception or failure.内部错误
    400VpnRouteEntry.SrcDestWeightConflictThe VPN gateway does not support Policy-based routing with the same source CIDR, destination CIDR and weight.VPN网关不支持配置源网段、目标网段与权重同时相同的策略路由。
    400VpnRouteEntry.SamePriorityPbrRoutePrefixOverlapThe source CIDR and destination CIDR of Policy-based routes with the same priority cannot overlap.VPN网关不支持相同优先级下的多个策略路由源和目标网段同时重合。
    400VpnRouteEntry.SrcDestConflictThe VPN gateway does not support Policy-based routing with the same source CIDR and destination CIDR.双隧道类型的VPN网关不支持配置源网段与目标网段同时相同的策略路由。
    400Resource.QuotaFullThe resources you are operating have reached the upper limit of the quota. Please increase the quota or use other solutions to avoid it according to the VPN operation document.您现在所操作的资源目前已经达到了配额的上限,请参考VPN操作文档,进行配额提升或者使用其他方案进行规避。
    400CreatePbrRoutesQuotaFull.QuotaFullThe number of policy routes exceeds the quota limit.策略路由数量超过配额限制。
    403Forbbiden.SubUserUser not authorized to operate on the specified resource as your account is created by another user.您没有权限操作该资源,请您申请操作权限后再试。
    403ForbiddenUser not authorized to operate on the specified resource.您没有权限操作指定资源,请申请权限后再操作。
    404InvalidVpnGatewayInstanceId.NotFoundThe specified vpn gateway instance id does not exist.指定的 VPN 网关不存在,请您检查 VPN 网关是否正确。

    访问错误中心查看更多错误码。

    变更历史

    变更时间变更内容概要操作
    2024-01-04OpenAPI 描述信息更新、OpenAPI 去除了 deprecated 标记、OpenAPI 错误码发生变更看变更集
    变更项变更内容
    API 描述OpenAPI 描述信息更新
    API 弃用说明(deprecated)OpenAPI 去除了 deprecated 标记
    错误码OpenAPI 错误码发生变更
      错误码 400 变更
      删除错误码:403
      删除错误码:404
    2023-08-02OpenAPI 错误码发生变更看变更集
    变更项变更内容
    错误码OpenAPI 错误码发生变更
      错误码 400 变更
      删除错误码:403
      删除错误码:404
    • 本页导读 (1)
    文档反馈