All Products
Search
Document Center

HTTPDNS:Configure rule-based custom DNS resolution

Last Updated:Dec 05, 2025

This topic describes how to configure rule-based custom DNS resolution.

Prerequisites

  • You have added the domain name that you want to use for custom DNS resolution. For more information, see Overview.

Procedure

  1. Log on to the EMAS console.

  2. In the navigation pane on the left, choose Resolution Management > Custom Resolution.

  3. Click Add Custom Resolution, and set Policy Type to Rule-based Policy.image

  4. Configure the following parameters:

    • Basic information

      Parameter

      Description

      Domain Name

      The domain name for which you want to configure custom DNS resolution, such as www.aliyun.com.

      Note
      • The domain names in the drop-down list are sourced from the domain names that you have added in Domain Name Management. If the domain name that you want to use is not in the drop-down list, add it in Domain Name Management and then add a custom DNS record for it.

      • To add a custom DNS record for a subdomain of a wildcard domain name, such as a.aliyun.com for *.aliyun.com, you must first add a.aliyun.com to the domain name list, and then add a custom DNS record for it.

      • The domain name you want might not appear in the drop-down list for the following reasons:

        • The domain name is not in the domain name list. Add the domain name in Domain Name Management.

        • The domain name is a subdomain of a wildcard domain name. Add the subdomain to the domain name list.

        • A custom DNS record already exists for the domain name. Manage the domain name in the custom DNS record list.

      Line

      Configure lines based on carrier and region.

      • Carrier: You can specify a carrier, such as China Telecom.

        • If you set Carrier to Default, the line covers all carriers.

      • Geographic Location: You can specify a province, such as Beijing or Hebei. This feature is available only in the Chinese mainland.

        • If you set the province to Default, the line covers all provinces.

      Note

      For users in the same region under the same domain name, the line priority is: Carrier > Geographic Location > Default. For example, the priority order is: China Telecom-Beijing > China Telecom-Default > Default-Beijing > Default-Default.

      For example, if two rule-based policies exist for the same domain name with lines set to China Telecom-Beijing and China Telecom-Default, users of China Telecom in Beijing will use the rule-based policy for the China Telecom-Beijing line.

    • Custom DNS resolution rules

      A rule-based policy can contain up to 10 custom DNS resolution rules.

      Parameter

      Description

      Rule Name

      The name of the rule. The name can describe the purpose of the rule, such as scheduling by SDK version.

      Rule Sorting

      You can adjust the order of the rules. The rules are matched sequentially from top to bottom. The order determines which rule is hit first. After you adjust the order, the rules are matched in the new order.

      SDNS Parameter Settings

      Matches the SDNS parameters carried in the resolution request from the client to determine whether the rule is hit. If a match is found, the DNS record value in the rule is returned. For more information about the matching logic, see Matching logic for rule-based policies.

      • Parameter Name: The name of the SDNS parameter. The name must be 2 to 64 characters in length.

      • Parameter Value: The value of the SDNS parameter. The value must be 1 to 64 characters in length.

      Note

      DNS Record Value

      A collection of return values for custom DNS resolution. Each record value represents a DNS record in the record set. This parameter is required.

      • Record Type: The type of the returned DNS record value. A and AAAA records are supported.

      • Record Value: The returned record value.

      You can add multiple record values. If weighting is disabled, the added record values are merged and returned together.

      You can also schedule based on weight. To do this, enable scheduling by weight. After you enable weighting, you can set a weight for each record value. The weight can range from 1 to 100. A load balancing algorithm returns a suitable record value based on the weights.

      Note

      A rule can contain up to 10 record values.

      TTL

      Required. The validity period of the custom DNS record. A shorter validity period causes the DNS record cache in the HTTPDNS SDK to expire faster. This increases the frequency at which the HTTPDNS SDK requests new DNS records.

  5. Policy validation

    • On the page for adding a rule-based policy, you can validate the rules as shown in the following figure:image

    • In the policy validation window, enter the relevant parameters to verify that the policy works as expected.image

Matching logic for rule-based policies

The following figure shows the resolution flow for a rule-based policy. Parameters in the request are used to match a specific rule. The rules are matched sequentially from top to bottom. If a rule is hit, the matching process stops and the result for that rule is returned. If no rules are hit, the result from the authoritative server is returned.

image

The matching logic for parameters in a single rule is as follows:

  • A match occurs if the request parameters fully match the parameters configured in the rule. A full match means that the request parameters must contain all parameters that are configured for the rule.

  • If no parameters are configured in the rule, the rule is considered a match.

  • Multiple parameters within a rule have a logical AND relationship.

The following examples describe the matching logic:

Assume that the domain name for custom DNS resolution is www.example.com

Example 1

Rule A parameter settings:

Parameter name

Parameter value

osType

Android

Rule B parameter settings:

Parameter name

Parameter value

osType

iOS

Rule C parameter settings:

Parameter name

Parameter value

osType

Android

bizType

car

Request parameters:

Parameter name

Parameter value

osType

iOS

Matching result:

In Example 1, the request parameters fully match Rule B. The HTTPDNS server returns the record value from Rule B.

Example 2

Rule A parameter settings:

Parameter name

Parameter value

osType

iOS

bizType

app

Parameter settings for Rule B:

Parameter name

Parameter value

osType

iOS

Parameter settings for Rule C:

Parameter name

Parameter value

osType

Android

bizType

car

Parameters:

Parameter name

Parameter value

osType

iOS

Matching results:

In Example 2, the request parameters match Rule B because the parameters in a rule are evaluated with a logical AND. The HTTPDNS server returns the record value from Rule B.

Example 3

Rule A parameter settings:

Parameter name

Parameter value

osType

iOS

bizType

car

Rule B parameter settings:

Parameter name

Parameter value

osType

iOS

bizType

car

region

hangzhou

Rule C parameter settings:

Parameter name

Parameter value

osType

Android

bizType

car

region

shanghai

Request parameters:

Parameter name

Parameter value

osType

iOS

bizType

car

region

hangzhou

Matching result:

In Example 3, based on the principles of full match and first match priority, the request parameters match Rule A. The HTTPDNS server returns the record value from Rule A.

Example 4

Rule A parameter settings:

Parameter name

Parameter value

osType

Android

bizType

car

Rule B parameter settings:

Parameter name

Parameter value

osType

iOS

bizType

car

region

hangzhou

Rule C parameter settings:

Parameter name

Parameter value

osType

Android

bizType

car

region

shanghai

Request parameters:

Parameter name

Parameter value

osType

iOS

Matching result:

In Example 4, based on the principles of full match and first match priority, the request parameters do not hit any rule. The HTTPDNS server returns the query result from the authoritative server.

Example 5

Rule A parameter settings:

Parameter name

Parameter value

osType

Android

bizType

car

Rule B has no parameters configured.

Rule C parameter settings:

Parameter name

Parameter value

osType

Android

bizType

car

region

shanghai

Request parameters:

Parameter name

Parameter value

osType

iOS

Matching result:

In Example 5, based on the principles of full match and first match priority, the request parameters match Rule B. The HTTPDNS server returns the record value from Rule B.

What to do next

After you configure rule-based custom DNS resolution, see Overall workflow to complete the subsequent steps.