
# 查询子网
#### 功能介绍
查询子网详情
#### 调试
您可以在[API Explorer](https://apiexplorer.developer.huaweicloud.com/apiexplorer/doc?product=VPC&version=v2&api=NeutronShowSubnet)中调试该接口。
#### URI
GET /v2.0/subnets/{subnet_id}
#### 请求参数
无。
#### 请求示例
```
GET https://{Endpoint}/v2.0/subnets/011fc878-5521-4654-a1ad-f5b0b5820302
```
#### 响应参数
表1响应参数 
| 参数名称   | 类型                                                                         | 说明                                                                          |
|:---|:---|:---|
| subnet | [subnet] object | subnet对象，参见[表2]。 |
   
 表2subnet对象 
| 参数名称              | 类型                                                                                                                                                           | 说明                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 |
|:---|:---|:---|
| id                | String                                                                                                                                                       | 子网的id 【使用说明】在查询子网列表时非必选                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   |
| name              | String                                                                                                                                                       | 子网的名称                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              |
| ip_version        | Integer                                                                                                                                                      | IP版本 【使用说明】支持4（IPv4）、6（IPv6）                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                |
| ipv6_address_mode | String                                                                                                                                                       | IPv6寻址模式 【使用说明】仅支持dhcpv6-stateful                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          |
| ipv6_ra_mode      | String                                                                                                                                                       | IPv6路由广播模式 【使用说明】仅支持dhcpv6-stateful                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       |
| network_id        | String                                                                                                                                                       | 所属网络的id                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            |
| cidr              | String                                                                                                                                                       | CIDR格式 【使用说明】IPV4只支持10.0.0.0/8,172.16.0.0/12,192.168.0.0/16三个网段内的地址，掩码长度不能大于28。 约束:当ip_version=6时,该字段不支持设置                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             |
| gateway_ip        | String                                                                                                                                                       | 网关IP不允许和allocation_pools地址块冲突。 【使用说明】不支持修改。                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 |
| allocation_pools  | Array of [allocation_pool] objects  | 可用的IP池，allocation_pool对象参见[表3] 例如：\[ { "start": "10.0.0.2", "end": "10.0.0.251"} \] 每个子网的第1个和最后3个IP地址为系统保留地址。以192.168.1.0/24为例，192.168.1.0、 192.168.1.253、192.168.1.254和192.168.1.255这些地址是系统保留地址。 \[{"start": "2001:db8:a583:9::2", "end": "2001:db8:a583:9:ffff:ffff:ffff:fffc"}\] ipv6子网以2001:db8:a583:9::/64为例，2001:db8:a583:9::1和2001:db8:a583:9:ffff:ffff:ffff:fffd、2001:db8:a583:9:ffff:ffff:ffff:fffe、2001:db8:a583:9:ffff:ffff:ffff:ffff这些地址是系统保留地址。系统预留地址默认不在allocation_pool范围内。 约束：更新时allocation_pool范围不能包含网关和广播地址的所有IP。  |
| dns_nameservers   | Array of strings                                                                                                                                             | dns服务器 例如："dns_nameservers": \["8.xx.xx.8","8.xx.xx.4"\]                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     |
| host_routes       | Array of [host_route] objects                                                                     | 虚拟机静态路由，参见["host_route对象"表] 【使用说明】不支持，忽略输入信息                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    |
| tenant_id         | String                                                                                                                                                       | 项目ID                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               |
| enable_dhcp       | Boolean                                                                                                                                                      | 是否启动dhcp，false表示不提供dhcp服务的能力 【使用说明】只支持true                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   |
| subnetpool_id     | String                                                                                                                                                       | 子网池id 【使用说明】目前IPv4不支持，IPv6支持                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                |
| project_id        | String                                                                                                                                                       | 项目ID，请参见[获取项目ID](https://support.huaweicloud.com/api-vpc/vpc_api_0011.html)。                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       |
| created_at        | String                                                                                                                                                       | 资源创建时间，UTC时间 格式：yyyy-MM-ddTHH:mm:ss                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        |
| updated_at        | String                                                                                                                                                       | 资源更新时间，UTC时间 格式：yyyy-MM-ddTHH:mm:ss                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        |
   
 表3allocation_pool对象 
| 参数名   | 参数类型   | 备注      |
|:---|:---|:---|
| start | String | 网络池起始IP |
| end   | String | 网络池结束IP |
   
 表4host_route对象 
| 参数名         | 参数类型   | 备注      |
|:---|:---|:---|
| destination | String | 路由目的子网  |
| nexthop     | String | 路由下一跳IP |
   
#### 响应示例
```
{
    "subnet": {
        "name": "subnet-test",
        "cidr": "172.16.236.0/24",
        "id": "011fc878-5521-4654-a1ad-f5b0b5820302",
        "enable_dhcp": true,
        "network_id": "48efad0c-079d-4cc8-ace0-dce35d584124",
        "tenant_id": "bbfe8c41dd034a07bebd592bf03b4b0c",
        "project_id": "bbfe8c41dd034a07bebd592bf03b4b0c",
        "dns_nameservers": [],
        "allocation_pools": [
            {
                "start": "172.16.236.2",
                "end": "172.16.236.251"
            }
        ],
        "host_routes": [],
        "ip_version": 4,
        "gateway_ip": "172.16.236.1",
        "created_at": "2018-03-26T08:23:43",
        "updated_at": "2018-03-26T08:23:44"
    }
}
```
#### 状态码
请参见[状态码](https://support.huaweicloud.com/api-vpc/vpc_api_0002.html)。
#### 错误码
请参见[错误码](https://support.huaweicloud.com/api-vpc/vpc_api_0003.html)。
