转发路由器支持连接VPN网关的IPsec连接。本地数据中心可以通过IPsec连接直接连接至转发路由器,然后通过转发路由器实现与其他网络的互通,调用CreateTransitRouterVpnAttachment接口创建VPN连接。
接口说明
创建 VPN 连接后,VPN 连接默认不与任何转发路由器路由表建立路由学习关系和关联转发关系。
在调用
CreateTransitRouterVpnAttachment
接口的过程中,如果您指定了 CenId、RegionId 参数的值,则无需指定 TransitRouterId 参数的值;如果您指定了 TransitRouterId、RegionId 参数的值,则无需指定 CenId 参数的值。
前提条件
在创建 VPN 连接前,请确保您已经在转发路由器实例所在的地域创建了一个 IPsec 连接,且 IPsec 连接未绑定任何资源。具体操作,请参见 CreateVpnAttachment 。
如果转发路由器实例需要连接跨账号的 IPsec 连接,则需确保 IPsec 连接已对转发路由器实例授权。具体操作,请参见 GrantInstanceToTransitRouter 。
在创建 VPN 连接之前,请确保您已设置转发路由器的 TR 地址段。具体操作,请参见 CreateTransitRouterCidr 。
调试
您可以在OpenAPI Explorer中直接运行该接口,免去您计算签名的困扰。运行成功后,OpenAPI Explorer可以自动生成SDK代码示例。

授权信息
操作 |
访问级别 |
资源类型 |
条件关键字 |
关联操作 |
cen:CreateTransitRouterVpnAttachment |
create |
CenInstance
TransitRouter
|
无 | 无 |
请求参数
名称 |
类型 |
必填 |
描述 |
示例值 |
ClientToken |
string |
否 |
客户端 Token,用于保证请求的幂等性。 从您的客户端生成一个参数值,确保不同请求间该参数值唯一。ClientToken 只支持 ASCII 字符。 说明
若您未指定,则系统自动使用 API 请求的 RequestId 作为 ClientToken 标识。每次 API 请求的 RequestId 不一样。 |
123e4567-e89b-12d3-a456-42665544**** |
DryRun |
boolean |
否 |
是否只预检此次请求。取值:
|
false |
CenId |
string |
否 |
云企业网实例 ID。 |
cen-rsgxs8ng2awen2**** |
TransitRouterId |
string |
否 |
转发路由器实例 ID。 |
tr-p0wm740vjnbaprv0m**** |
RegionId |
string |
否 |
转发路由器实例所属的地域 ID。 您可以通过调用 DescribeChildInstanceRegions 接口获取地域 ID。 |
cn-hangzhou |
TransitRouterAttachmentName |
string |
否 |
VPN 连接的名称。 名称可以为空或长度为 1~128 个字符,不能以 http://或 https://开头。 |
nametest |
TransitRouterAttachmentDescription |
string |
否 |
VPN 连接的描述信息。 描述可以为空或长度为 1~256 个字符,不能以 http://或 https://开头。 |
desctest |
VpnId |
string |
是 |
IPsec 连接 ID。 |
vco-p0w042cqwvlhl4zyw**** |
VpnOwnerId |
integer |
否 |
IPsec 连接所属的阿里云账号(主账号)ID。
|
1210123456123456 |
AutoPublishRouteEnabled |
boolean |
否 |
是否允许转发路由器实例自动向 IPsec 连接发布路由条目。取值:
|
true |
ChargeType |
string |
否 |
计费方式。 仅取值:POSTPAY(默认值),表示按使用量付费。 |
POSTPAY |
Zone |
array |
否 |
当前地域下的可用区 ID。 系统将在您指定的可用区下创建资源。 说明
如果绑定的 IPsec 连接是双隧道模式,此字段不填值。 |
|
object |
否 |
可用区 ID。 |
||
ZoneId |
string |
否 |
可用区 ID。 您可以通过调用 ListTransitRouterAvailableResource 接口获取地域 ID。 |
cn-hangzhou-h |
Tag |
array |
否 |
标签信息列表。 一次最多支持输入 20 个标签信息。 |
|
object |
否 |
标签信息。 |
||
Key |
string |
否 |
资源的标签键。 一旦传入该值,则不允许为空字符串。最多支持 64 个字符,不能以 一次最多支持输入 20 个标签的标签键。 |
TagKey |
Value |
string |
否 |
资源的标签值。 标签值可以为空或输入不超过 128 个字符的字符串,不能以 每一个标签键对应一个标签值,一次最多支持输入 20 个标签键对应的标签值。 |
TagValue |
返回参数
名称 |
类型 |
描述 |
示例值 |
object |
返回结果。 |
||
TransitRouterAttachmentId |
string |
VPN 连接 ID。 |
tr-attach-y5dup2qwfyh9lu**** |
RequestId |
string |
请求 ID。 |
8B5DD40A-3A29-5AC0-B8DA-05FD10D5C893 |
示例
正常返回示例
JSON
格式
{
"TransitRouterAttachmentId": "tr-attach-y5dup2qwfyh9lu****",
"RequestId": "8B5DD40A-3A29-5AC0-B8DA-05FD10D5C893"
}
错误码
HTTP status code |
错误码 |
错误信息 |
描述 |
---|---|---|---|
400 | NoPermission.AliyunServiceRolePolicyForCEN | You are not authorized to create the service linked role. Role Name: AliyunServiceRolePolicyForCEN. Service Name: cen.aliyuncs.com. Make sure that the user has been granted the ram:CreateServiceLinkedRole permission. | 您没有权限创建服务关联角色,角色名:AliyunServiceRolePolicyForCEN,服务名:cen.aliyuncs.com。请确保已授予当前用户ram:CreateServiceLinkedRole权限。 |
400 | OperationUnsupported.TransitRouterRegionId | The specified TransitRouterRegion does not support the operation. | |
400 | InvalidCenId.NotFound | CenId is not found. | CEN实例不存在。 |
400 | InvalidStatus.ResourceStatus | The resource is not in a valid state for the attachment operation. | 当前资源状态不支持该操作,请稍后重试。 |
400 | InvalidTransitRouterId.NotFound | TransitRouterId is not found. | 转发路由实例ID不存在。 |
400 | Forbbiden.TransitRouterServiceNotOpen | The user has not open transit router service. | 转发路由器服务未打开,请打开后重试。 |
400 | InvalidTransitRouterMode.NeedUpgrade | TransitRouter need to upgrade. | 当前转发路由器模式不支持。 |
400 | InvalidAvailable.NoResource | No resource in the available zone. | 当前可用区资源不足。 |
400 | OperationUnsupported.VpnAttachment | The specified region does not support the operation. | 当前地域不支持该操作。 |
400 | OperationUnsupported.TransitRouterType | The specified TransitRouterType does not support the operation. | 当前TransitRouter类型不支持该操作。 |
400 | OperationFailed.AllocateCidrFailed | Operation failed because vpn allocate cidr failed. | vpn申请cidr失败。 |
400 | OperationUnsupported.ZoneId | The specified ZoneId does not support the operation. | |
400 | MissingParam.CenIdOrRegionId | Either CenId or RegionId must be specified. | CenId或者RegionId是必选参数。 |
400 | IllegalParam.RegionId | RegionId is illegal. | 参数中指定的Region不合法。 |
400 | OperationUnsupported.CenFullLevel | CEN full level does not support TransitRouter | Full类型CEN不支持创建企业版转发路由器。 |
400 | InvalidOperation.CenInstanceStatus | The CEN instance is not in a valid state for the operation. | |
400 | IllegalParam.ZoneMappings | The Specified Parameter ZoneMappings is illegal | 参数中指定的ZoneMappings不合法。 |
400 | IncorrectStatus.TransitRouter | The status of TransitRouter is incorrect. | 当前TransitRouter的状态不支持该操作,请稍后重试。 |
400 | InvalidOperation.VpnNetworkTypeInvalid | The network type of child-instance is invalid. | 该实例的network type不合法。 |
400 | QuotaExceeded.CenQuotaVpnAttachPerTransitRouter | The maximum number of VPN attachment per Transit Router is exceeded. | 每个转发路由器支持创建的VPN连接个数超限,可提交工单提升额度。 |
400 | QuotaFull.ChildInstanceRelatedCen | The childinstance has exceed the quota of the times that a childinstance can be attached as an attachment. | 该实例绑定CEN数量已达到上限,无法加载。 |
400 | Forbidden.ResourceOwnerTransitRouterServiceNotOpen | The resource owner user has not opened transit router service. | 资源所属账号转发路由器服务未开通,请通知对方开通后重试。 |
400 | OperationUnsupported.VcoTunnelNotMatchZoneParam | The tunnel type of the entered Vco does not match the Zone parameter. | 输入的Vco的隧道类型和Zone参数不匹配。 |
400 | Forbidden.ResourceOwnerTransitRouterServiceExpired | The transit router service of the account to which the resource belongs has been suspended due to arrears. Please notify the other party to renew the service and try again. | 资源所属账号的转发路由器服务已欠费停服,请通知对方续费后重试。 |
400 | Forbidden.TransitRouterServiceExpired | The transit router service is out of service. | 转发路由器服务已欠费停服,请续费后重试。 |
400 | InvalidParameter | Invalid parameter. | 参数不合法。 |
400 | Unauthorized | The AccessKeyId is unauthorized. | 账号无权限操作。 |
400 | IllegalParam.TransitRouterRegionId | TransitRouterRegionId is illegal. | TransitRouterRegionId不合法。 |
400 | InvalidVpnId.NotFound | The specified vpn connection instance id does not exist. | 指定的VPN连接不存在,请您检查该VPN连接ID是否正确。 |
400 | InvalidParameter.ResourceType | The specified parameter ResourceType is invalid. | |
400 | InvalidParameter.VpnId | The specified parameter VpnId is invalid. |
访问错误中心查看更多错误码。
变更历史
更多信息,参考变更详情。