All Products
Search
Document Center

Virtual Private Cloud:CreateDhcpOptionsSet

Last Updated:Sep 07, 2026

Creates a DHCP options set.

Operation description

  • CreateDhcpOptionsSet is an asynchronous operation. After you invoke this operation, the system returns an instance ID but the DHCP options set is not yet created. The background node is still in progress. You can invoke GetDhcpOptionsSet to query the creation status of the DHCP options set:
    • If the vSwitch is in the Pending state, the DHCP options set is being configured.

    • If the vSwitch is in the Available state, the DHCP options set is active.

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:CreateDhcpOptionsSet

create

*DhcpOptionsSet

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

None None

Request parameters

Parameter

Type

Required

Description

Example

RegionId

string

Yes

The region where the DHCP options set resides.

You can call DescribeRegions to query the region ID.

cn-hangzhou

DomainNameServers

string

No

The IP addresses of DNS servers. You can specify up to four DNS server IP addresses. Separate multiple IP addresses with commas (,).

Note

If you do not specify DNS server IP addresses, ECS instances use the DNS server IP addresses provided by Alibaba Cloud by default (100.100.2.136 and 100.100.2.138).

192.XX.XX.123

DhcpOptionsSetName

string

No

The name of the DHCP options set.

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 (-).

name

DhcpOptionsSetDescription

string

No

The description of the DHCP options set.

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

description

DomainName

string

No

The hostname suffix. Example: example.com.

After the DHCP options set is associated with a VPC, the hostname suffix is automatically synchronized to the ECS instances in the associate VPC.

example.com

ResourceGroupId

string

No

The ID of the resource group to which the DHCP options set belongs.

rg-acfmxazb4ph****

Tag

array<object>

No

The tags of the resource.

object

No

The tag.

Key

string

No

The tag key of the resource. You can specify up to 20 tag keys. The tag key cannot be an empty string.

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

FinanceDept

Value

string

No

The tag value of the resource. You can specify up to 20 tag values. The tag value can be an empty string.

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

FinanceJoshua

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 ClientToken value 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.

0c593ea1-3bea-11e9-b96b-88e9fe637760

DryRun

boolean

No

Specifies whether to perform a dry run. Valid values:

true: performs a dry run. The system checks the required parameters, request syntax, and limits. If the request fails the dry run, an error message is returned. If the request passes the dry run, the DryRunOperation error code is returned.

false (default): performs a dry run and sends the request. If the request passes the dry run, an HTTP 2xx status code is returned and the DHCP options set is created.

false

LeaseTime

string

No

The lease time of the IPv4 DHCP options set.

  • If the lease time is in hours, the unit is h. Valid values: 24h to 1176h and 87600h to 175200h. Default value: 87600h.

  • If the lease time is in days, the unit is d. Valid values: 1d to 49d and 3650d to 7300d. Default value: 3650d.

Note

You must include the unit when specifying the value.

3650d

Ipv6LeaseTime

string

No

The lease time of the IPv6 DHCP options set.

  • If the lease time is in hours, the unit is h. Valid values: 24h to 1176h and 87600h to 175200h. Default value: 24h.

  • If the lease time is in days, the unit is d. Valid values: 1d to 49d and 3650d to 7300d. Default value: 1d.

Note

You must include the unit when specifying the value.

3650d

Response elements

Element

Type

Description

Example

object

The ID of the DHCP options set that is created.

DhcpOptionsSetId

string

The ID of the DHCP options set that is created.

dopt-o6w0df4epg9zo8isy****

RequestId

string

The request ID.

0ED8D006-F706-4D23-88ED-E11ED28DCAC0

ResourceGroupId

string

The ID of the resource group to which the DHCP options set belongs.

rg-acfmxazb4ph****

Examples

Success response

JSON format

{
  "DhcpOptionsSetId": "dopt-o6w0df4epg9zo8isy****",
  "RequestId": "0ED8D006-F706-4D23-88ED-E11ED28DCAC0",
  "ResourceGroupId": "rg-acfmxazb4ph****"
}

Error codes

HTTP status code

Error code

Error message

Description

400 OperationUnsupported.DhcpOptionsSet The DHCP options set feature in this region is not supported. The current region does not support the DHCP options sets feature.
400 InvalidDomainNameServers.Malformed The specified format of DomainNameServers is invalid. The format of the value of DomainNameServers is invalid. Check whether the parameter is set to a valid value.
400 QuotaExceeded.DomainNameServers The maximum number of domain name servers cannot exceed 4. DomainNameServers is set to a value greater than four.
400 IllegalParam.DomainNameServers The specified DomainNameServers is invalid. DomainNameServers is set to an invalid value.
400 IllegalParam.DomainName The specified DomainName is invalid. The error message returned because DomainName is set to an invalid value.
400 IllegalParam.DhcpOptionsSetName The specified DhcpOptionsSetName is invalid. DhcpOptionsSetName is set to an invalid value.
400 IllegalParam.DhcpOptionsSetDescription The specified DhcpOptionsSetDescription is invalid. DhcpOptionsSetDescription is set to an invalid value.
400 QuotaExceeded.RegionDhcpOptionsSet The quota of dhcpOptionsSet in the region is exceeded. The number of DHCP options sets reaches the upper limit.
400 OperationUnsupported.DhcpLeaseTime The DhcpOptionsSet of this region does not support custom LeaseTime. DHCP options sets in the region do not support a custom lease time.
400 IllegalParam.LeaseTime LeaseTime [%s] is illegal. The specified LeaseTime parameter is illegal
400 InvalidRegionId.NotFound The specified RegionId does not exist. The specified region does not exist.
400 IllegalParam.Ipv6LeaseTime Ipv6LeaseTime [%s] is illegal. The specified Ipv6LeaseTime parameter is illegal

See Error Codes for a complete list.

Release notes

See Release Notes for a complete list.