路由规则

响应对象为路由规则对象:

  {
        "Id": "5feae645-0285-4263-873c-9cc24f76d0ff", # 路由规则id
        "DestinationCidrBlock": "1.1.1.3/32", # 目标网段
        "RouteTableId": "5feae645-0285-4263-873c-9cc24f76d0ff", # 路由表id
        "InstanceType": "NWS", # 目标实例类型,目前有:snat(到网关的路由)/local(本地)/NWS(到云主机的路由),
        "InstanceId": "17c4caeb-c683-4b90-814d-aa316e23778b", # 目标实例id
        "NetworkInterfaceId": null, # 【当前无效】目标网卡id(port_id)用于以后支持多网卡作保留参数使用,目前暂时不使用。
        "Description":"hahahahahaha", # 规则描述
        "RouteType": "User", # 路由规则类型,目前有User用户路由/System系统路由
        "CreateAt": "2017-12-11T09:22:01Z", #创建时间,UTC时间
        "UpdateAt": "2017-12-11T09:22:01Z"  #更新时间,UTC时间
    }

1. CreateRoute

请求格式:

POST /vpc?Version=2017-11-30&Action=CreateRoute

请求体:

{ "DestinationCidrBlock":"1.1.1.6/32", 
  "RouteTableId":"5feae645-0285-4263-873c-9cc24f76d0ff", 
  "InstanceType":"NWS", 
  "InstanceId":"17c4caeb-c683-4b90-814d-aa316e23778b", 
  "NetworkInterfaceId":"",  
  "Description":"hahahahaha" 
}

请求参数:

参数是否必填说明
DestinationCidrBlock必选目标地址段
RouteTableId必选路由表id
InstanceType必选服务名,云主机为NWS
InstanceId必选实例Id
NetworkInterfaceId当前无效网卡id 用于以后支持多网卡作保留参数使用,目前暂时不使用
Description可选路由规则描述

响应体:

{
    "RequestId": "4569c5bc-8976-47c6-ac6b-0c6c8be08c34",
    "Route": {
        "Id": "5feae645-0285-4263-873c-9cc24f76d0ff",
        "DestinationCidrBlock": "1.1.1.10/32",
        "RouteTableId": "5feae645-0285-4263-873c-9cc24f76d0ff",
        "InstanceType": "NWS",
        "InstanceId": "17c4caeb-c683-4b90-814d-aa316e23778b",
        "NetworkInterfaceId": null,
        "Description": "hahahahaha",
        "RouteType": "User",
        "CreateAt": "2017-08-03T09:31:43Z",
        "UpdateAt": "2017-08-03T09:31:43Z"
    }
}

常见错误

1 当请求的DestinationCidrBlock和公共服务地址段地址相等,或者公共服务地址段包含了DestinationCidrBlock时,会返回“路由网段目标与公共服务网段冲突”

但是请求的DestinationCidrBlock包含了公共服务地址段没关系,因为有最长匹配原则,还会走到公共服务段的路由

{
    "Code": "InvalidParameterValue",
    "Message": "路由网段目标与公共服务网段冲突",
    "RequestId": "65ff41d0-a759-434e-b1f1-87426ba0632f",
    "Result": ""
}
对应英文message: DestinationCidrBlock conflicts with public service
2 当请求的DestinationCidrBlock和用户vpc内的local路由相等,或者用户vpc的local路由的cidr包含了请求的DestinationCidrBlock时:
{
    "Code": "InvalidParameterValue",
    "Message": "路由网段目标与已存在路由目标地址段冲突",
    "RequestId": "43347377-ee2d-4309-86eb-6781d4853dc2",
    "Result": ""
}
对应英文Message:DestinationCidrBlock conflicts with existed route
3 当请求的DestinationCidrBlock和用户自建其他路由的目标cidr相等时:
{
    "Code": "InvalidParameterValue",
    "Message": "路由网段目标与已存在路由目标地址段冲突",
    "RequestId": "ea13bf41-5849-4ce5-8b9a-6d173b3a3b01",
    "Result": ""
}
对应英文Message:DestinationCidrBlock conflicts with existed route
举例如:

假设某用户的路由表中已经拥有路由如下:

目标地址段类型下一跳
192.168.0.0/16local系统-
1.1.1.4/32NVM用户自建17c4caeb-c683-4b90-814d-aa316e23778b

该环境配置的公共服务地址段为:

10.185.3.0/24
10.185.0.0/24
10.182.0.0/22
10.182.8.0/22

那么请求中的DestinationCidrBlock不同提交会获得的响应如下:

请求目标地址段响应原因
192.168.0.0/16InvalidParameterValue和用户的local路由cidr相等
192.168.0.0/20InvalidParameterValue用户的local路由cidr包含该请求地址段
192.168.0.0/15通过该请求地址段包含用户的local路由cidr
1.1.1.4/32InvalidParameterValue和用户已有之间路由的cidr相同
1.1.1.0/24通过和用户已有之间路由的cidr没有相同
10.185.0.0/20通过请求的DestinationCidrBlock包含了公共服务地址段

2. DeleteRoute

请求格式:

GET /vpc?Version=2017-11-30&Action=DeleteRoute
&Id=e3b8d61c-dd7b-4675-86c7-004e698ee257 

请求参数:

参数是否必填说明
Id必选路由规则的id

响应示例:

{
    "RequestId": "78b67a32-2807-4345-8fc5-6f1e99a8eb68",
    "Route": {
        "Id": "5feae645-0285-4263-873c-9cc24f76d0ff",
        "DestinationCidrBlock": "1.1.1.9/32",
        "RouteTableId": "5feae645-0285-4263-873c-9cc24f76d0ff",
        "InstanceType": "NWS",
        "InstanceId": "17c4caeb-c683-4b90-814d-aa316e23778b",
        "NetworkInterfaceId": null,
        "Description": "hahahahaha",
        "RouteType": "User",
        "CreateAt": "2017-08-03T09:31:43Z",
        "UpdateAt": "2017-08-03T09:31:43Z"
    }
}

3. ListRoute

请求格式:

GET /vpc?Version=2017-11-30&Action=ListRoute
&RouteTableId=5feae645-0285-4263-873c-9cc24f76d0ff
&KeyWord=c
&Limit=2
&Offset=1

请求参数:

参数是否必填备注
RouteTableId必选路由表id
Limit可选返回个数,不填默认20
Offset可选总偏移量,不填默认0
KeyWord可选搜索参数,可选,匹配范围为:destinationSegment目标网段, routeId 路由Id,serviceName 服务名,description 描述

响应格式:

{
    "RequestId": "e5ece85d-fa4d-43e3-ae2e-ae6cfdbf91ad",
    "Limit": 2,
    "Count": 8,
    "Routes": [
        {
            "Id": "5feae645-0285-4263-873c-9cc24f76d0ff",
            "DestinationCidrBlock": "1.1.1.6/32",
            "RouteTableId": "5feae645-0285-4263-873c-9cc24f76d0ff",
            "InstanceType": "NWS",
            "InstanceId": "17c4caeb-c683-4b90-814d-aa316e23778b",
            "NetworkInterfaceId": null,
            "Description": "hahahahaha",
            "RouteType": "User",
            "CreateAt": "2017-12-18T03:43:14Z",
            "UpdateAt": "2017-12-18T03:43:14Z"
        },
        {
            "Id": "5feae645-0285-4263-873c-9cc24f76d0ff",
            "DestinationCidrBlock": "1.1.1.4/32",
            "RouteTableId": "5feae645-0285-4263-873c-9cc24f76d0ff",
            "InstanceType": "NWS",
            "InstanceId": "17c4caeb-c683-4b90-814d-aa316e23778b",
            "NetworkInterfaceId": null,
            "Description": null,
            "RouteType": "User",
            "CreateAt": "2017-12-18T02:22:05Z",
            "UpdateAt": "2017-12-18T02:22:05Z"
        }
    ],
    "Offset": 1
}

常见错误:

缺乏必要参数
{
    "Code": "MissingParameter",
    "Message": "Empty necessary param",
    "RequestId": "c74f5d58-7cb7-4362-bb00-43561b7581fd",
    "Result": "Required String parameter 'RouteTableId' is not present"
}
路由表未找到
{
    "Code": "InvalidParameterValue",
    "Message": "RouteTable is not found",
    "RequestId": "669c3ac5-a12b-43d5-9067-b4f62cad121a",
    "Result": ""
}