All Products
Search
Document Center

Virtual Private Cloud:CreateVSwitchCidrReservation

Last Updated:Aug 14, 2026

Creates a reserved CIDR block for a vSwitch.

Operation description

When you invoke this operation to create a reserved CIDR block for a vSwitch, take note of the following items:

  • The maximum number of reserved IPv4 and IPv6 CIDR blocks in a VPC is 100 each.

  • A reserved CIDR block cannot contain the system reserved IP addresses of the vSwitch to which it belongs.
    • IPv4 CIDR block: The first and last three IP addresses of the vSwitch are system reserved IP addresses.

    • IPv6 CIDR block: The first and last nine IP addresses of the vSwitch are system reserved IP addresses.

  • The CreateVSwitchCidrReservation operation is asynchronous. After you send a request, the system returns an instance ID, but the reserved CIDR block for a vSwitch has not been created. The system continues to run the background node. You can invoke ListVSwitchCidrReservations to query the creation status of the reserved CIDR block for a vSwitch:
    • If the reserved CIDR block for a vSwitch is in the Assigning state, the reserved CIDR block for a vSwitch is being allocated.

    • If the reserved CIDR block for a vSwitch is in the Assigned state, the reserved CIDR block for a vSwitch has been allocated.

Try it now

Try this API in OpenAPI Explorer, no manual signing needed. Successful calls auto-generate SDK code matching your parameters. Download it with built-in credential security for local usage.

Test

RAM authorization

The table below describes the authorization required to call this API. You can define it in a Resource Access Management (RAM) policy. The table's columns are detailed below:

  • Action: The actions can be used in the Action element of RAM permission policy statements to grant permissions to perform the operation.

  • API: The API that you can call to perform the action.

  • Access level: The predefined level of access granted for each API. Valid values: create, list, get, update, and delete.

  • Resource type: The type of the resource that supports authorization to perform the action. It indicates if the action supports resource-level permission. The specified resource must be compatible with the action. Otherwise, the policy will be ineffective.

    • For APIs with resource-level permissions, required resource types are marked with an asterisk (*). Specify the corresponding Alibaba Cloud Resource Name (ARN) in the Resource element of the policy.

    • For APIs without resource-level permissions, it is shown as All Resources. Use an asterisk (*) in the Resource element of the policy.

  • Condition key: The condition keys defined by the service. The key allows for granular control, applying to either actions alone or actions associated with specific resources. In addition to service-specific condition keys, Alibaba Cloud provides a set of common condition keys applicable across all RAM-supported services.

  • Dependent action: The dependent actions required to run the action. To complete the action, the RAM user or the RAM role must have the permissions to perform all dependent actions.

Action

Access level

Resource type

Condition key

Dependent action

vpc:CreateVSwitchCidrReservation

create

*VSwitchCidrReservation

acs:vpc:{#regionId}:{#accountId}:vswitchcidrreservation/*

None None

Request parameters

Parameter

Type

Required

Description

Example

Tag

array<object>

No

The resource tags.

object

No

The tag information.

Key

string

No

The tag key of the resource. You can specify up to 20 tag keys. If you specify this parameter, the value cannot be an empty string.

A tag key can be up to 128 characters in length and cannot start with aliyun or acs:. It cannot contain http:// or https://.

FinanceDept

Value

string

No

The tag value of the resource. You can specify up to 20 tag values. If you specify this parameter, the value can be an empty string.

The tag value can be up to 128 characters in length and cannot start with aliyun or acs:. It cannot contain http:// or https://.

FinanceJoshua

VSwitchId

string

Yes

The ID of the vSwitch to which the reserved CIDR block for a vSwitch belongs.

vsw-25navfgbue4g****

VSwitchCidrReservationName

string

No

The name of the reserved CIDR block for a vSwitch.

The name must be 1 to 128 characters in length and must start with a letter or Chinese character. It can contain digits, underscores (_), and hyphens (-). It cannot start with http:// or https://.

ReservationName

VSwitchCidrReservationDescription

string

No

The description of the reserved CIDR block for a vSwitch. If you do not specify this parameter, the description is empty. The default value is empty.

The description must be 1 to 256 characters in length and must start with a letter or Chinese character. It cannot start with http:// or https://.

ReservationDescription

IpVersion

string

No

The IP version of the reserved CIDR block for a vSwitch. Valid values:

  • IPv4 (default)

  • IPv6

Note

You do not need to specify this parameter when you create an IPv4 reserved CIDR block for a vSwitch. This parameter is required when you create an IPv6 reserved CIDR block for a vSwitch.

IPv4

VSwitchCidrReservationMask

string

No

The mask of the reserved CIDR block for a vSwitch.

  • If IpVersion is set to IPv4, the mask length of the reserved CIDR block must be at least 2 bits longer than the IPv4 CIDR block mask of the vSwitch and cannot exceed 28.

  • If IpVersion is set to IPv6, the mask length of the reserved CIDR block must be longer than the IPv6 CIDR block mask of the vSwitch and cannot exceed 80.

Note
  • You must specify either the VSwitchCidrReservationMask or VSwitchCidrReservationCidr parameter.

  • The reserved CIDR block cannot contain the system reserved IP addresses of the vSwitch to which it belongs.

28

VSwitchCidrReservationCidr

string

No

The reserved CIDR block for a vSwitch.

  • If IpVersion is set to IPv4, the reserved CIDR block for a vSwitch must be a proper subset of the IPv4 CIDR block of the vSwitch and the mask length cannot exceed 28.

  • If IpVersion is set to IPv6, the reserved CIDR block for a vSwitch must be a proper subset of the IPv6 CIDR block of the vSwitch and the mask length cannot exceed 80.

Note
  • You must specify either the VSwitchCidrReservationMask or VSwitchCidrReservationCidr parameter.

  • The reserved CIDR block cannot contain the system reserved IP addresses of the vSwitch to which it belongs.

192.168.1.64/28

VSwitchCidrReservationType

string

No

The type of the reserved CIDR block for a vSwitch. Valid values: prefix, which indicates that IP addresses are allocated by CIDR block.

Note

When users or cloud services automatically assign CIDR blocks to elastic network interfaces (ENIs), the CIDR blocks must be allocated from the reserved CIDR block for a vSwitch. If the IP addresses in the reserved CIDR block for a vSwitch are exhausted, the system returns an error.

prefix

IpPrefixNumber

integer

No

The expected number of IP prefixes to reserve. Valid values: 1 to 32.

1

ClientToken

string

No

The client token that is used to ensure the idempotence of the request.

You can use the client to generate the token, but you must make sure that the token is unique among different requests. The token can contain only ASCII characters.

Note

If you do not specify this parameter, the system automatically uses the RequestId of the API request as the ClientToken. The RequestId may be different for each API request.

123e4567-e89b-12d3-a456-426655440000

DryRun

boolean

No

Specifies whether to perform only a dry run, without performing the actual request. Valid values:

  • true: sends a check request without creating the reserved CIDR block for a vSwitch. The system checks whether the required parameters are specified, the request format is valid, and the service limits are not exceeded. If the check fails, the corresponding error is returned. If the check passes, the DryRunOperation error code is returned.

  • false (default): sends a Normal request. After the check passes, an HTTP 2xx status code is returned and the vSwitch reserved CIDR block is created.

false

RegionId

string

Yes

The region ID of the vSwitch.

You can call the DescribeRegions operation to query the most recent region list.

cn-hangzhou

Response elements

Element

Type

Description

Example

object

The instance ID of the reserved CIDR block for a vSwitch.

VSwitchCidrReservationId

string

The instance ID of the reserved CIDR block for a vSwitch.

vcr-bp1m12saqteraw3rp****

RequestId

string

The request ID.

54B48E3D-DF70-471B-AA93-08E683A1B45

Examples

Success response

JSON format

{
  "VSwitchCidrReservationId": "vcr-bp1m12saqteraw3rp****",
  "RequestId": "54B48E3D-DF70-471B-AA93-08E683A1B45"
}

Error codes

HTTP status code

Error code

Error message

Description

400 IllegalParamFormat IllegalParamFormat The parameter format is invalid.
400 IllegalParamFormat.VSwitchCidrReservationCidr The param format of VSwitchCidrReservationCidr is illegal. The VSwitchCidrReservationCidr value is invalid.
400 ResourceNotFound.VSwitch The specified resource of VSwitch is not found. The specified vSwitch does not exist.
400 UnsupportedFeature.ReservedType The specified ReservedType is not supported. The ReservedType value is invalid.
400 UnsupportedFeature.VSwitchIpv6 The ipv6 feature of switch is not supported. IPv6 is not enabled for the specified vSwitch.
400 OperationFailed.VSwitchCidrReservationCidr The specified VSwitchCidrReservationCidr conflicts with existed cidr reservation or vswitch cidr. The VSwitchCidrReservationCidr value conflicts with an existing VSwitchCidrReservation value.
400 MissingParam.CidrReservationMaskOrCidrReservationCidr Either VSwitchCidrReservationMask or VSwitchCidrReservationCidr should be specified. You cannot leave both the VSwitchCidrReservationMask and VSwitchCidrReservationCidr parameters empty. Set a value and try again.
400 UnsupportedRegion UnsupportedRegion The error message returned because the current region does not support this feature.
400 UnsupportedFeature.VpcAdvancedFeature UnsupportedFeature.VpcAdvancedFeature The error message returned because the VPC where the specified vSwitch is deployed does not support advanced VPC features. Specify another vSwitch and try again.
400 QuotaExceeded.CidrReservationCount The quota of VSwitchCidrReservation is exceeded. The VSwitchCidrReservation value exceeds the upper limit.
400 Conflict.CidrReservationMaskAndCidrReservationCidr The specified VSwitchCidrReservationMask and VSwitchCidrReservationCidr is conflict. The VSwitchCidrReservationMask value conflicts with the VSwitchCidrReservationCidr value. Adjust the values and try again.
400 OperationFailed.CidrNotEnoughInVSwitch No enough cidr to allocate in this vswitch. The specified vSwitch does not have sufficient CIDR blocks.
400 OperationFailed.SystemReservedIpContained The specified VSwitchCidrReservationCidr cannot contain system reserved IP addresses. VSwitchCidrReservationCidr cannot contain a reserved IP address.
400 OperationFailed.AlreadyUsedIpContained The specified VSwitchCidrReservationCidr cannot contain already used IP addresses. The reserved CIDR block cannot contain used IP addresses.
400 IncorrectStatus.VSWITCH The status of the specified VSwitch is invalid. The status of the specified VSwitch is invalid.
400 IllegalParam.VSwitchCidrReservationMask The specified VSwitchCidrReservationMask must be at least 2 bits greater than the vSwitch mask. The specified VSwitchCidrReservationMask must be at least 2 bits greater than the vSwitch mask.
400 QuotaExceeded.VSwitchCidrReservationMask The operation is failed because of %s. The mask of the reserved subnet cidr exceeds the current default mask of IP Prefix, %s/%s. The operation failed because of the quota %s. The mask of the reserved CIDR block exceeds the default mask of the current IP Prefix, %s/%s.
400 IllegalParam.ReservedType IpPrefixNumber is only supported with Prefix reserved type. IpPrefixNumber is only supported with Prefix reserved type.
400 MissingParam.VSwitchCidrReservationParam One of IpPrefixNumber, VSwitchCidrReservationMask, or VSwitchCidrReservationCidr must be specified. One of IpPrefixNumber, VSwitchCidrReservationMask, or VSwitchCidrReservationCidr must be specified.
400 Conflict.VSwitchCidrReservationParam IpPrefixNumber cannot be used together with VSwitchCidrReservationCidr or VSwitchCidrReservationMask. IpPrefixNumber cannot be used together with VSwitchCidrReservationCidr or VSwitchCidrReservationMask.

See Error Codes for a complete list.

Release notes

See Release Notes for a complete list.