Subnet Related Operations
Updated at:2025-10-16
Create subnet
Description:
Create a subnet in your VPC.
Command format:
Plain Text
1$ bce vpc create-subnet <vpc_id> <subnet_name> <zone_name> <cidr> [-st SUBNET_TYPE] [-des DESCRIPTION]
Description:
- subnet_name: The name for the subnet, which cannot be set as "default," must be under 65 characters in length, and can include numbers, letters, and underscores.
- zone_name: The name of the availability zone.
- cidr: The CIDR associated with the subnet.
- vpc_id: The ID of the VPC to which the subnet belongs.
- \-des DESCRIPTION, --description DESCRIPTION: The description of the subnet, which should not exceed 200 characters.
- \-st SUBNET_TYPE, --subnet_type SUBNET_TYPE: The type of subnet, such as "BCC" or "BBC.\
Operation example:
Plain Text
1$ bce vpc create-subnet vpc-2mdntsz0jbki test-name cn-bj-a 192.168.0.0/24
Response example:
Plain Text
1{
2 “subnet_id”: “sbn-fxgs4vq0g3np”
3}
| Parameter name | Types | Description |
|---|---|---|
| subnet_id | String | ID of subnet created |
Query subnet list
Description:
Query information about all subnet lists.
Command format:
Plain Text
1$ bce vpc list-subnet [-a] [-vi VPC_ID] [-mkr MARKER] [-mky MAX_KEYS] [-zn ZONE_NAME] [-st {BCC,BBC}]
Description:
- -a, --all list all subnets.
- \-vi VPC_ID, --vpc_id VPC_ID: The ID of the VPC to which the subnet is linked.
- \-mkr MARKER, --marker MARKER: The starting point for batch query retrievals, provided as a system-generated string.
- \-mky MAX_KEYS, --max_keys MAX_KEYS: The maximum number of VPCs per page, with an upper limit typically set to 1000. The default value is 1000.
- \-zn ZONE_NAME, --zone_name ZONE_NAME: The name of the availability zone linked to the subnet.
- \-st {BCC,BBC}, --subnet_type {BCC,BBC}: The type of subnet, either "BCC" or "BBC.\
Operation example:
Plain Text
1$ bce vpc list-subnet
Response example:
Plain Text
1{
2 “marker”: null,
3 “max_keys”: 1000,
4 “subnets”: [
5 {
6 “subnet_type”: “BCC”,
7 "name": "System predefined subnet",
8 “vpc_id”: “vpc-suzek0b5vi4r”,
9 “subnet_id”: “sbn-yf43kw8wj3ss”,
10 “zone_name”: “cn-bj-a”,
11 “cidr”: “192.168.0.0/20”,
12 “description”: “”
13 },
14 {
15 “subnet_type”: “BCC”,
16 “name”: “test-name”,
17 “vpc_id”: “vpc-2mdntsz0jbki”,
18 “subnet_id”: “sbn-fxgs4vq0g3np”,
19 “zone_name”: “cn-bj-a”,
20 “cidr”: “192.168.0.0/24”,
21 “description”: “”
22 }
23 ],
24 “is_truncated”: false
25}
| Parameter name | Types | Description |
|---|---|---|
| marker | String | Mark the starting position of the query. |
| is_truncated | boolean | true indicates there is more data later, false indicates it is the last page |
| nextMarker | String | The marker value needed to fetch the next page. This field is absent when isTruncated is false. |
| max_keys | Integer | Maximum number of items included per page |
| subnets | List\<[Subnet](VPC/API Reference/Appendix.md#Subnet)> | Instance information, which is a collection composed of subnets |
Query specified subnet
Description:
Query detailed information about the specified subnet.
Command format:
Plain Text
1$ bce vpc show-subnet <subnet_id>
Operation example:
Plain Text
1$ bce vpc show-subnet sbn-fxgs4vq0g3np
Response example:
Plain Text
1{
2 “subnet”: {
3 “subnet_type”: “BCC”,
4 “name”: “test-name”,
5 “vpc_id”: “vpc-2mdntsz0jbki”,
6 “subnet_id”: “sbn-fxgs4vq0g3np”,
7 “zone_name”: “cn-bj-a”,
8 “cidr”: “192.168.0.0/24”,
9 “description”: “”
10 }
11}
| Parameter name | Types | Description |
|---|---|---|
| subnet | [Subnet](VPC/API Reference/Appendix.md#Subnet) | Returned instance details |
Delete subnet
Description:
Delete the subnet.
Command format:
Plain Text
1$ bce vpc delete-subnet <subnet_id>
Operation example:
Plain Text
1$ bce vpc delete-subnet sbn-fxgs4vq0g3np
Response example:
Plain Text
1{}
No special response parameters are available.
Update subnet
Description:
Update the subnet details.
Command format:
Plain Text
1$ bce vpc update-subnet <subnet_id> <name>[-des DESCRIPTION]
Description:
- subnet_id: The ID of the subnet instance that requires an update.
- \-des, --description: The description of the VPC, which should not exceed 200 characters.
- name: The subnet name, which cannot be set as "default," must be under 65 characters, and can include numbers, letters, and underscores.
Operation example:
Plain Text
1$ bce vpc update-subnet sbn-fxgs4vq0g3np update-name -des update-description
Response example:
Plain Text
1{}
No special response parameters are available.
