All Products
Search
Document Center

Cloud Firewall:AddDnsFirewallPolicy

Last Updated:Aug 01, 2026

Adds a DNS firewall access control list (ACL).

Operation description

Creates a DNS firewall access control policy to allow, deny, or monitor traffic that passes through the DNS firewall.

Quota description

DNS firewall policies are counted independently in the DNS policy table (counted separately by IP version), but they share the same quota upper limit with Internet access control policies (determined by the Cloud Firewall edition). If the number of address combinations after a single policy is expanded exceeds the limit, or the total number of user policies exceeds the limit, the error ErrorAclExtendedCountExceed (-200139) is returned.

Note

The value returned by DescribeAclCheckQuota is the quota for ACL policy check (inspection) times, which is unrelated to firewall policy count quota and cannot be used to predict whether the quota for this operation is sufficient. Confirm firewall policy count quota in the Cloud Firewall console.

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

yundun-cloudfirewall:AddDnsFirewallPolicy

get

*DnsFirewallPolicy

acs:yundun-cloudfirewall::{#accountId}:dnsfirewallpolicy/*

None None

Request parameters

Parameter

Type

Required

Description

Example

SourceIp

string

No

The source IP address of the request.

140.205.118.97

Lang

string

No

The language of the request and response. Valid values:

  • zh: Chinese

  • en: English

zh

AclAction

string

Yes

The action that Cloud Firewall performs on the traffic in the access control policy. Valid values:

  • accept: Allow.

  • drop: Deny.

  • log: Monitor.

log

Description

string

Yes

The description of the access control policy.

Allow specified domain names

Destination

string

Yes

The destination address in the access control policy.

  • If DestinationType is set to net, Destination is a destination CIDR block. Example: 1.2.3.4/24.

  • If DestinationType is set to group, Destination is a destination address book name. Example: db_group.

  • If DestinationType is set to domain, Destination is a destination domain name. Example: *.aliyuncs.com.

  • If DestinationType is set to location, Destination is a destination area (see the area positional encoding below). Example: ["BJ11", "ZB"].

db_group

DestinationType

string

Yes

The type of the destination address in the DNS firewall access control policy. Only group (destination address book) and domain (destination domain name) are supported. net and CIDR addresses are not applicable to this operation.

domain

Direction

string

No

The traffic direction of the DNS firewall access control policy.

Note

This parameter is not validated on the backend. When you create or modify a DNS firewall policy, the direction is always stored as out (outbound). Passing in does not cause an error or take effect. The DNS firewall supports only outbound policies.

out

Source

string

Yes

The source address in the access control policy. Valid values:

  • If SourceType is set to net, Source is a source CIDR block. Example: 10.2.XX.XX/24.

  • If SourceType is set to group, Source is a source address book name. Example: db_group.

192.168.0.223/32

SourceType

string

Yes

The type of the source address in the access control policy. Valid values:

  • net: source CIDR block

  • group: source address book

net

Priority

string

Yes

The policy priority of the DNS firewall policy. Valid values: 1 to 20000. A smaller value indicates a higher policy priority.

1

Release

string

Yes

The enabled status of the access control policy. The policy is enabled by default after creation. Valid values:

  • true: Enable the access control policy.

  • false: Disable the access control policy.

true

IpVersion

string

Yes

The IP address version. Valid values:

  • 4: IPv4

  • 6: IPv6

Valid values:

  • 4 :

    IPv4

  • 6 :

    IPv6

4

Response elements

Element

Type

Description

Example

object

AclUuid

string

The unique ID of the access control policy.

f88dae6f-XXX-XXX-613de9ab2be8

RequestId

string

The request ID.

71209DFE-XXX-XXX-52B4A4E9DA3B

Examples

Success response

JSON format

{
  "AclUuid": "f88dae6f-XXX-XXX-613de9ab2be8",
  "RequestId": "71209DFE-XXX-XXX-52B4A4E9DA3B"
}

Error codes

HTTP status code

Error code

Error message

Description

400 ErrorParametersUid The aliUid parameter is invalid. The aliUid parameter is invalid.
400 ErrorDBSelect An error occurred while querying database. An error occurred while querying database.
400 ErrorParameterIpVersion The IP version is invalid. The IP version is invalid.
400 ErrorParametersSource The source is invalid. The source is invalid.
400 ErrorParametersDestination The Destination parameter is invalid. The Destination parameter is invalid.
400 ErrorParametersAction The action is invalid. The action is invalid.
400 ErrorParametersNewOrder The newOrder is invalid. The newOrder is invalid.
400 ErrorParameters Parameters error. Parameter error.
400 ErrorAddressCountExceed The maximum number of addresses is exceeded. The maximum number of address is exceeded.
400 ErrorDBInsert An error occurred while performing an insert operation in the database. An error occurred while performing an insert operation in the database.
400 ErrorRecordLog An error occurred while updating the operation log. An error occurred while updating the operation log.
400 ErrorMarshalJSON An error occurred while encoding JSON. An error occurred while encoding JSON.
400 ErrorAclExtendedCountExceed ACL or extended ACL rules are not matched. The quota for access control policies or extra access control policies is exhausted.
400 ErrorAclRuleDuplicate acl rule duplicate. The same strategy exists.
400 ErrorUUIDNew The UUID is invalid. The UUID is invalid.

See Error Codes for a complete list.

Release notes

See Release Notes for a complete list.