Compute
Elastic Cloud Server
Huawei Cloud Flexus
Bare Metal Server
Auto Scaling
Image Management Service
Dedicated Host
FunctionGraph
Cloud Phone Host
Huawei Cloud EulerOS
Networking
Virtual Private Cloud
Elastic IP
Elastic Load Balance
NAT Gateway
Direct Connect
Virtual Private Network
VPC Endpoint
Cloud Connect
Enterprise Router
Enterprise Switch
Global Accelerator
Management & Governance
Cloud Eye
Identity and Access Management
Cloud Trace Service
Resource Formation Service
Tag Management Service
Log Tank Service
Config
OneAccess
Resource Access Manager
Simple Message Notification
Application Performance Management
Application Operations Management
Organizations
Optimization Advisor
IAM Identity Center
Cloud Operations Center
Resource Governance Center
Migration
Server Migration Service
Object Storage Migration Service
Cloud Data Migration
Migration Center
Cloud Ecosystem
KooGallery
Partner Center
User Support
My Account
Billing Center
Cost Center
Resource Center
Enterprise Management
Service Tickets
HUAWEI CLOUD (International) FAQs
ICP Filing
Support Plans
My Credentials
Customer Operation Capabilities
Partner Support Plans
Professional Services
Analytics
MapReduce Service
Data Lake Insight
CloudTable Service
Cloud Search Service
Data Lake Visualization
Data Ingestion Service
GaussDB(DWS)
DataArts Studio
Data Lake Factory
DataArts Lake Formation
IoT
IoT Device Access
Others
Product Pricing Details
System Permissions
Console Quick Start
Common FAQs
Instructions for Associating with a HUAWEI CLOUD Partner
Message Center
Security & Compliance
Security Technologies and Applications
Web Application Firewall
Host Security Service
Cloud Firewall
SecMaster
Anti-DDoS Service
Data Encryption Workshop
Database Security Service
Cloud Bastion Host
Data Security Center
Cloud Certificate Manager
Edge Security
Situation Awareness
Managed Threat Detection
Blockchain
Blockchain Service
Web3 Node Engine Service
Media Services
Media Processing Center
Video On Demand
Live
SparkRTC
MetaStudio
Storage
Object Storage Service
Elastic Volume Service
Cloud Backup and Recovery
Storage Disaster Recovery Service
Scalable File Service Turbo
Scalable File Service
Volume Backup Service
Cloud Server Backup Service
Data Express Service
Dedicated Distributed Storage Service
Containers
Cloud Container Engine
SoftWare Repository for Container
Application Service Mesh
Ubiquitous Cloud Native Service
Cloud Container Instance
Databases
Relational Database Service
Document Database Service
Data Admin Service
Data Replication Service
GeminiDB
GaussDB
Distributed Database Middleware
Database and Application Migration UGO
TaurusDB
Middleware
Distributed Cache Service
API Gateway
Distributed Message Service for Kafka
Distributed Message Service for RabbitMQ
Distributed Message Service for RocketMQ
Cloud Service Engine
Multi-Site High Availability Service
EventGrid
Dedicated Cloud
Dedicated Computing Cluster
Business Applications
Workspace
ROMA Connect
Message & SMS
Domain Name Service
Edge Data Center Management
Meeting
AI
Face Recognition Service
Graph Engine Service
Content Moderation
Image Recognition
Optical Character Recognition
ModelArts
ImageSearch
Conversational Bot Service
Speech Interaction Service
Huawei HiLens
Video Intelligent Analysis Service
Developer Tools
SDK Developer Guide
API Request Signing Guide
Terraform
Koo Command Line Interface
Content Delivery & Edge Computing
Content Delivery Network
Intelligent EdgeFabric
CloudPond
Intelligent EdgeCloud
Solutions
SAP Cloud
High Performance Computing
Developer Services
ServiceStage
CodeArts
CodeArts PerfTest
CodeArts Req
CodeArts Pipeline
CodeArts Build
CodeArts Deploy
CodeArts Artifact
CodeArts TestPlan
CodeArts Check
CodeArts Repo
Cloud Application Engine
MacroVerse aPaaS
KooMessage
KooPhone
KooDrive

Querying Subnets

Updated on 2024-03-05 GMT+08:00

Function

This API is used to query all subnets accessible to the tenant submitting the request.

URI

GET /v2.0/subnets

Example:

GET https://{Endpoint}/v2.0/subnets?name={subnet_name}&ip_version={ip_version}&network_id={network_id}&cidr={subnet_cidr_address}&gateway_ip={subnet_gateway}&tenant_id={tenant_id}&enable_dhcp={is_enable_dhcp}

Example of querying networks by page

GET https://{Endpoint}/v2.0/subnets?limit=2&marker=011fc878-5521-4654-a1ad-f5b0b5820302&page_reverse=False

Table 1 describes the parameters.

Table 1 Parameter description

Name

Mandatory

Type

Description

id

No

String

Specifies that the ID is used as the filtering condition.

name

No

String

Specifies that the subnet name is used as the filtering condition.

enable_dhcp

No

Boolean

Specifies whether DHCP is enabled for the subnet is used as the filtering condition.

The value can be true or false.

cidr

No

String

Specifies that the CIDR block is used as the filtering condition.

network_id

No

String

Specifies that the network ID is used as the filtering condition.

ip_version

No

String

Specifies that the IP address version is used as the filtering condition.

gateway_ip

No

String

Specifies that the gateway IP address is used as the filtering condition.

tenant_id

No

String

Specifies that the project ID is used as the filtering condition.

marker

No

String

Specifies a resource ID for pagination query, indicating that the query starts from the next record of the specified resource ID.

This parameter can work together with the parameter limit.

  • If parameters marker and limit are not passed, resource records on the first page will be returned.
  • If the parameter marker is not passed and the value of parameter limit is set to 10, the first 10 resource records will be returned.
  • If the value of the parameter marker is set to the resource ID of the 10th record and the value of parameter limit is set to 10, the 11th to 20th resource records will be returned.
  • If the value of the parameter marker is set to the resource ID of the 10th record and the parameter limit is not passed, resource records starting from the 11th records (including 11th) will be returned.

limit

No

Integer

Specifies the number of records that will be returned on each page. The value is from 0 to intmax (2^31-1). The default value is 2000.

limit can be used together with marker. For details, see the parameter description of marker.

Request Parameters

None

Example Request

Example 1

GET https://{Endpoint}/v2.0/subnets?limit=1

Example 2

GET https://{Endpoint}/v2.0/subnets?id=011fc878-5521-4654-a1ad-f5b0b5820322

Response Parameters

Table 2 Response parameter

Parameter

Type

Description

subnets

Array of subnet objects

Specifies the subnet list. For details, see Table 3.

subnets_links

Array of subnets_link objects

Specifies the pagination information. For details, see Table 6.

Only when limit is used for filtering and the number of resources exceeds the value of limit or 2000 (default value of limit), value next will be returned for rel and a link for href.

Table 3 subnet objects

Attribute

Type

Description

id

String

Specifies the subnet ID.

This parameter is not mandatory when you query subnets.

name

String

Specifies the subnet name.

ip_version

Integer

Specifies the IP address version.

The value can be 4 (IPv4) or 6 (IPv6).

ipv6_address_mode

String

Specifies the IPv6 addressing mode.

Only dhcpv6-stateful is supported.

ipv6_ra_mode

String

Specifies the IPv6 route broadcast mode.

Only dhcpv6-stateful is supported.

network_id

String

Specifies the ID of the network to which the subnet belongs.

cidr

String

Specifies the CIDR format.

Only the IPv4 addresses in the 10.0.0.0/8, 172.16.0.0/12, and 192.168.0.0/16 ranges are supported. The subnet mask cannot be greater than 28.

This parameter cannot be set if the value of ip_version is 6.

gateway_ip

String

The gateway IP address cannot conflict with IP addresses configured for allocation_pools.

This attribute cannot be modified.

allocation_pools

Array of allocation_pool objects

Specifies available IP address pools. For details, see Table 4.

Example: [ { "start": "10.0.0.2", "end": "10.0.0.251"} ]

The last three and the first IP addresses in each subnet are the ones reserved by the system. For example, in IPv4 subnet 192.168.1.0/24, IP addresses 192.168.1.0, 192.168.1.253, 192.168.1.254, and 192.168.1.255 are reserved by the system.

[{"start": "2001:db8:a583:9::2", "end": "2001:db8:a583:9:ffff:ffff:ffff:fffc"}]

In IPv6 subnet 2001:db8:a583:9::/64, IP addresses 2001:db8:a583:9::1, 2001:db8:a583:9:ffff:ffff:ffff:fffd, 2001:db8:a583:9:ffff:ffff:ffff:fffe, and 2001:db8:a583:9:ffff:ffff:ffff:ffff are reserved by the system.

By default, the IP addresses reserved by the system are not in the IP address pool specified by allocation_pool.

When updating an IP address pool, the allocation_pool value can contain neither gateway nor broadcast IP addresses.

dns_nameservers

Array of strings

Specifies the DNS server address.

Example: "dns_nameservers": ["8.xx.xx.8","8.xx.xx.4"]

host_routes

Array of host_route objects

Specifies the static VM routes. For details, see Table 5.

Static routes are not supported, and entered information will be ignored.

tenant_id

String

Specifies the project ID.

enable_dhcp

Boolean

Specifies whether to enable the DHCP function. Value false indicates that the DHCP function is not enabled.

The value can only be true.

subnetpool_id

String

Specifies the subnet pool ID.

Currently, only IPv6 is supported.

project_id

String

Specifies the project ID. For details about how to obtain a project ID, see Obtaining a Project ID.

created_at

String

Specifies the time (UTC) when the subnet is created.

Format: yyyy-MM-ddTHH:mm:ss

updated_at

String

Specifies the time (UTC) when the subnet is updated.

Format: yyyy-MM-ddTHH:mm:ss

Table 4 allocation_pool objects

Parameter

Type

Description

start

String

Specifies the start IP address of a network pool.

end

String

Specifies the end IP address of a network pool.

Table 5 host_route objects

Parameter

Type

Description

destination

String

Specifies the destination subnet of a route.

nexthop

String

Specifies the next-hop IP address of a route.

Table 6 subnets_link object

Parameter

Type

Description

href

String

Specifies the API link.

rel

String

Specifies the relationship between the API link and the API version.

Example Response

Example 1

{
    "subnets": [
        {
            "name": "kesmdemeet",
            "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"
        }
    ],
    "subnets_links": [
       {
            "rel": "next", 
            "href": "https://{Endpoint}/v2.0/subnets?limit=1&marker=011fc878-5521-4654-a1ad-f5b0b5820302"
        }, 
       {    "rel": "previous", 
            "href": "https://{Endpoint}/v2.0/subnets?limit=1&marker=011fc878-5521-4654-a1ad-f5b0b5820302&page_reverse=True"
        }
    ]
}

Example 2
{
    "subnets": [
        {
	    "id": "011fc878-5521-4654-a1ad-f5b0b5820322",
	    "name": "elb_alpha_vpc0_subnet0_172_16_0_0_24",
	    "tenant_id": "0c55e5b2b100d5202ff6c01a2fac4580",
	    "network_id": "3053b502-11b2-4599-bcf4-d9d06b6118b2",
            "ip_version": 6,
	    "cidr": "2001:db8:a583:a0::/64",
            "subnetpool_id": "cb03d100-8687-4c0a-9441-ea568dcae47d",
	    "allocation_pools": [{
	        "start": "2001:db8:a583:a0::2",
		"end": "2001:db8:a583:a0:ffff:ffff:ffff:fffc"
	    }],
	    "gateway_ip": "2001:db8:a583:a0::1",
	    "enable_dhcp": true,
	    "ipv6_ra_mode": "dhcpv6-stateful",
	    "ipv6_address_mode": "dhcpv6-stateful",
	    "description": "",
	    "dns_nameservers": [],
	    "host_routes": [],
	    "project_id": "0c55e5b2b100d5202ff6c01a2fac4580",
	    "created_at": "2021-07-01T07:59:28",
	    "updated_at": "2021-07-01T07:59:28"
        }
    ],
    "subnets_links": [
       {    "rel": "previous", 
            "href": "https://{Endpoint}/v2.0/subnets?limit=1&id=011fc878-5521-4654-a1ad-f5b0b5820322&marker=011fc878-5521-4654-a1ad-f5b0b5820302&page_reverse=True"
        }
    ]
}

Status Code

See Status Codes.

Error Code

See Error Codes.

We use cookies to improve our site and your experience. By continuing to browse our site you accept our cookie policy. Find out more

Feedback

Feedback

Feedback

0/500

Selected Content

Submit selected content with the feedback