> For the complete documentation index, see [llms.txt](https://docs.console.zenlayer.com/api-reference/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.console.zenlayer.com/api-reference/cn/compute/zec/vpc-network/describesubnets.md).

# DescribeSubnets

## 1. 接口描述

本接口(DescribeSubnets)用于查询子网列表信息。可以根据子网ID, 名称等信息筛选查询子网。

## 2. 请求参数

以下请求参数列表仅列出了接口中需要的请求参数

| 参数名称             | 必选 | 类型              | 描述                                             |
| ---------------- | -- | --------------- | ---------------------------------------------- |
| subnetIds        | 否  | Array of String | 根据子网的ID进行筛选。                                   |
| name             | 否  | String          | <p>根据子网的名称进行筛选。</p><p>该字段支持模糊搜索。</p>           |
| cidrBlock        | 否  | String          | 根据子网的CIDR进行筛选。                                 |
| regionId         | 否  | String          | 根据子网所在的节点进行筛选。                                 |
| pageSize         | 否  | Integer         | <p>返回的分页大小。</p><p>可选值范围：\[1, 1000]</p>         |
| pageNum          | 否  | Integer         | <p>返回的分页数。</p><p>可选值范围：\[1, +)</p><p>默认值：1</p> |
| vpcIds           | 否  | Array of String | 根据所属VPC的ID进行筛选。最多支持100个VPC ID。                 |
| dhcpOptionsSetId | 否  | String          | 子网绑定的DHCP 选项集ID。                               |

## 3. 响应结果

| 参数名称       | 类型                                                                               | 描述                                                       |
| ---------- | -------------------------------------------------------------------------------- | -------------------------------------------------------- |
| requestId  | String                                                                           | <p>唯一请求 ID。</p><p>每次请求都会返回。定位问题时需要提供该次请求的 requestId。</p> |
| totalCount | Integer                                                                          | 符合条件的数据总数。                                               |
| dataSet    | Array of [SubnetInfo](/api-reference/cn/compute/zec/datastructure.md#subnetinfo) | 子网的结果集。                                                  |

## 4. 代码示例

{% tabs %}
{% tab title="示例" %}
**1.查询CidrBlock为`10.0.0.0/24`的Subnet列表。**

```json
POST /api/v2/zec HTTP/1.1
Host: console.zenlayer.com
Content-Type: application/json
X-ZC-Action: DescribeSubnets
<Common Request Params>

Request:
{
  "cidrBlock": "10.0.0.0/24",
  "pageSize": 10,
  "pageNum": 1
}

Response:
{
  "requestId": "TBFC01FCF-6439-4530-ADBC-16809F0C3E8F",
  "response": {
    "requestId": "TBFC01FCF-6439-4530-ADBC-16809F0C3E8F",
    "dataSet": [
      {
        "subnetId": "<subnetId>",
        "regionid": "asia-east-1",
        "name": "Test",
        "cidrBlock": "10.0.0.0/24",
        "gatewayIpAddress": "10.0.0.1",
        "ipv6GatewayIpAddress": "2001:2:0:xx::1",
        "ipv6CidrBlock": "2001:2:0:xx::/64",
        "stackType": "IPv4_IPv6",
        "ipv6Type": "Public",
        "vpcId": "<vpcId>",
        "vpcName": "Test",
        "usageIpv4Count": 253,
        "usageIpv6Count": 1,
        "createTime": "2022-01-01T01:00:00Z",
        "isDefault": true,
        "dhcpOptionsSetId": null
      }
    ],
    "totalCount": 1
  }
}
```

{% endtab %}
{% endtabs %}

## 5. 开发者工具

Zenlayer Cloud API 2.0 提供了配套的[开发工具集（SDK）](/api-reference/cn/api-introduction/toolkit.md)，未来会陆续支持更多开发语言，方便快速接入和使用Zenlayer的产品和服务。

## 6. 错误码

下面包含业务逻辑中遇到的错误码，其他错误码见[公共错误码](/api-reference/cn/api-introduction/instruction/commonerrorcode.md)

| HTTP状态码 | 错误码 | 说明 |
| ------- | --- | -- |
