
# 查询VPN网关路由表 - QueryGatewayRouteTable
#### 功能介绍
根据VPN网关ID，查询指定VPN网关的路由表。
#### 调用方法
请参见[如何调用API](https://support.huaweicloud.com/api-vpn/vpn_api_0008.html)。
#### 授权信息
账号具备所有API的调用权限，如果使用账号下的IAM用户调用当前API，该IAM用户需具备调用API所需的权限。
- 如果使用角色与策略授权，具体权限要求请参见[权限和授权项](https://support.huaweicloud.com/api-vpn/vpn_api_0044.html)。
- 如果使用身份策略授权，需具备如下身份策略权限。
| 授权项                             | 访问级别 | 资源类型（\*为必须） | 条件键                                                                                                                                                                                                                                                                                                                                                                                                                                                       | 别名 | 依赖的授权项 |
|:---|:---|:---|:---|:---|:---|
| vpn:vpnGateways:getRoutingTable | read | vpnGateways | - [g:EnterpriseProjectId](https://support.huaweicloud.com/usermanual-iam5/iam_01_0934.html#section2)  - [g:ResourceTag/\<tag-key\>](https://support.huaweicloud.com/usermanual-iam5/iam_01_0934.html#section2)   | -  | -      |
   
#### URI
GET /v5/{project_id}/vpn-gateways/{vgw_id}/routing-table
表1参数说明 
| 名称         | 类型     | 是否必选 | 说明                                                                                  |
|:---|:---|:---|:---|
| project_id | String | 是    | 项目ID，可以通过[获取项目ID](https://support.huaweicloud.com/api-vpn/vpn_api_0051.html)获取项目ID。 |
| vgw_id     | String | 是    | VPN网关ID。                                                                            |
   
#### 请求消息
- 请求参数 无。
  
- 请求样例
  ```
  GET https://{Endpoint}/v5/{project_id}/vpn-gateways/{vgw_id}/routing-table
  ```
  
 
#### 响应消息
- 响应参数 返回状态码为 200: 查询成功。
  表2响应Body参数列表 
  | 名称            | 类型                                                                           | 描述           |
  |:---|:---|:---|
  | routing_table | Array of [Route] objects | 指定VPN网关的路由表。 |
  | total_count   | Long                                                                         | 该网关下的路由总条数。  |
  | page_info     | [ResponsePageInfoV3] object   | 分页信息。        |
     
   表3Route 
  | 名称                    | 类型                                                                          | 描述                                                                                                                                                                                                                                                                                           |
  |:---|:---|:---|
  | destination           | String                                                                      | 路由目的地址。                                                                                                                                                                                                                                                                                      |
  | nexthop               | String                                                                      | 下一跳IP地址。                                                                                                                                                                                                                                                                                     |
  | outbound_interface_ip | String                                                                      | 出接口IP地址。                                                                                                                                                                                                                                                                                     |
  | origin                | String                                                                      | - 功能说明：BGP路由的路由来源。  - 取值范围：igp，egp，incomplete。   |
  | as_path               | String                                                                      | BGP路由的AS路径。                                                                                                                                                                                                                                                                                  |
  | med                   | Integer                                                                     | BGP路由的MED值。                                                                                                                                                                                                                                                                                  |
  | nexthop_resource      | [NexthopResource] object | 该路由对应的下一跳资源。                                                                                                                                                                                                                                                                                 |
     
   表4NexthopResource 
  | 名称   | 类型     | 描述                                                                                                                                                                                                                                                                                                             |
  |:---|:---|:---|
  | id   | String | 下一跳资源的ID，UUID格式。                                                                                                                                                                                                                                                                                               |
  | type | String | - 功能说明：下一跳资源的资源类型。  - 取值范围：vpn_gateway，vpn_connection，er。   |
     
   表5ResponsePageInfoV3 
  | 名称            | 类型      | 描述          |
  |:---|:---|:---|
  | current_count | Integer | 当前列表中资源数量。  |
  | next_marker   | String  | 下一页的marker。 |
     
  
- 响应样例
  1. 查询公网类型关联ER的VPN网关。
     ```
     {
         "routing_table": [
             {
                 "destination": "192.168.0.0/24",
                 "nexthop": "192.168.0.240",
                 "outbound_interface_ip": "192.168.0.240",
                 "origin": "igp",
                 "as_path": "64513",
                 "med": 0,
                 "nexthop_resource": {
                     "id": "fd8e4220-cdcd-4c84-809e-09fd3148b24b",
                     "type": "vpn_connection"
                 }
             },
             {
                 "destination": "222.69.222.1/32",
                 "nexthop": "169.254.1.2",
                 "outbound_interface_ip": "169.254.1.1",
                 "origin": "igp",
                 "as_path": "64513",
                 "med": 0,
                 "nexthop_resource": {
                     "id": "e3c28cc1-fb34-4acd-97f9-29d8e42efe0f",
                     "type": "vpn_gateway"
                 }
             },
             {
                 "destination": "222.69.222.2/32",
                 "nexthop": "169.254.2.2",
                 "outbound_interface_ip": "169.254.2.1",
                 "origin": "igp",
                 "as_path": "64513",
                 "med": 0,
                 "nexthop_resource": {
                     "id": "85d31993-f519-49ea-8d2e-7afeffb8ef5e",
                     "type": "vpn_connection"
                 }
             }
         ],
         "total_count": 3,
         "page_info": {
             "current_count": 3
         }
     }
     ```
     
   
 
#### 状态码
请参见[状态码](https://support.huaweicloud.com/api-vpn/vpn_api_0052.html)。
