All Products
Search
Document Center

HTTPDNS:Add custom DNS records

Last Updated:Feb 17, 2025

This topic explains how to add custom DNS records.

On the Custom DNS page, click Add DNS to add a custom DNS record for your domain name.

Add Policy Type

In the pop-up form, select Rule Strategy as the policy type to add a custom DNS rule policy.

image

You can configure the following settings:

Basic information

Parameter

Remarks

Domain name

The domain name for which you want to customize the DNS, such as: www.aliyun.com.

Note
  • The data source for the domain name selection dropdown comes from the domain name list of already added domain names. If the domain name you want to customize is not in the dropdown list, you can add it to the domain name list and then add a custom DNS record for it.

  • If you want to add a custom DNS record for a subdomain of a wildcard domain name, such as: *.aliyun.com, but you want the custom domain name to be a.aliyun.com, you need to add a.aliyun.com to the domain name list and then add a custom DNS record for it.

  • There are several situations where the domain name selection dropdown does not show the corresponding domain name:

    • The domain name you want to add is not in the domain name list. You can add the corresponding domain name to the domain name list.

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

    • The domain name you want to add already has a custom DNS record. You need to manage the corresponding domain name in the custom DNS record list.

Line

You can configure lines for carriers and regions.

  • Carrier: You can customize the carrier, such as Telecom

    • If the carrier is set toDefault, it means the current line covers all carriers.

  • Geographic location: You can customize the province, such as: Beijing, Hebei. Currently, only the Chinese mainland is supported.

    • If the province is set toDefault, it means the current line covers all provinces.

Note

Under the same domain name, for users in the same region, the priority of line effectiveness is: Carrier > Geographic location > Default. For example, Telecom-Beijing > Telecom-Default > Default-Beijing > Default-Default.

For example: If there are two rule policies under the same domain name, with lines of Telecom-Beijing and Telecom-Default, the Telecom-Beijing line rule policy will be used for Telecom users in Beijing.

Custom DNS rules

A rule policy supports up to 10 custom DNS rules.

Parameter

Remarks

Rule name

Indicates the name of the current rule, which can be used to express the purpose of the rule, such as scheduling by SDK version.

Rule order

The order of multiple rules can be adjusted. The matching logic is serial matching from top to bottom. The order determines which rule will be hit first. After adjusting the order, the new order will be used for matching.

SDNS parameter configuration

Used to match the SDNS parameters carried by the client request parsing interface to determine whether the rule is hit. If the match is successful, the DNS record value in the rule is returned. For detailed matching logic, see Rule policy matching logic description .

  • Parameter name: SDNSparameter name, with a length limit of 2 to 64 characters.

  • Parameter value: SDNS parameter value, with a length limit of 1 to 64 characters.

Note
  • A rule can add up to 10 SDNS parameters.

  • The parsing interface can add SDNS parameters. For details, see How to add SDNS parameters .

DNS record value

The return value collection of custom DNS. Each record value represents a DNS record in the record set, required.

  • Record type: The type of the returned DNS record value, supporting A and AAAA records.

  • Record value: The returned record value

You can add multiple record values. When weight scheduling is not enabled, the added multiple record values will be merged and returned together.

You can also schedule by weight. Just turn on the weight scheduling switch. After enabling weight, you can set the weight for each record value. The weight value range is 1-100. According to the weight of the record value, a suitable record value is returned through the load balancing algorithm.

Note

A rule can add up to 10 record values.

TTL

Required. The validity period of the custom DNS record. The shorter the validity period, the faster the DNS record cache in the HTTPDNS SDK expires. At the same time, the frequency of HTTPDNS SDK requests for new DNS records is higher.

Verify whether the current policy meets expectations

The rule policy addition page allows you to verify rules, as illustrated below:

image

In the policy verification window, enter the relevant parameters to check if the current policy meets your requirements.

image

Add function compute policy

Prerequisites

In the custom DNS addition drawer, selectFunction Compute Policy as the policy type to add a custom DNS Function Compute policy.

image

You can configure the following settings:

Parameter

Remarks

Region

Select the region where the Function Compute service is located. For instance, if your Function Compute service is in the Singapore region, select Singapore.

Service

Select the Function Compute service corresponding to the region.

Service Version/Alias

Select the version or alias of the corresponding service. Using the LATEST version of Function Compute is not recommended.

Note

Using the LATEST version of Function Compute is not recommended.

The Custom DNS Feature during the BEFORE_READ_CACHE Phase

Configure the Function Compute function for the pre-hook phase before reading the HTTPDNS server cache. Activation is optional.

For a detailed explanation of the Function Compute policy hook, see the policy hook documentation.

The Custom DNS Feature During the BEFORE_WRITE_CACHE Phase

Configure the Function Compute function for the pre-hook phase before writing to the cache after recursive resolution by the HTTPDNS server. Activation is optional.

For more information, see the Function Compute policy hook description.

Custom DNS Functionality During the BEFORE_WRITE_RESPONSE Phase

Configure the Function Compute function for the pre-hook phase before constructing the return content after writing to the cache by the HTTPDNS server. Activation is optional.

For details on the Function Compute policy hook, see the policy hook documentation.

Unit Testing for Hook Functions

Test the connectivity between the HTTPDNS service and the Function Compute service:

  • Test successful: The HTTPDNS service can connect to the Function Compute service normally.

  • Test failed: The HTTPDNS service cannot connect to the Function Compute service yet.

After configuring the settings above, click Confirm to return to the policy list.

For operations such as enabling, shutting down, or deleting policies, see Manage Custom DNS Policies and .