This topic describes the principles and usage of the HTTPDNS custom resolution feature.
Introduction to custom resolution
In certain business scenarios, you may want to return specific resolution results for a domain name. The HTTPDNS custom resolution feature lets you do this by configuring rules or using Function Compute to customize the resolution for specific domain names.
When you use DNS over HTTPS (DoH), custom resolution is not supported for the resolved domain names.
Scenarios
Grayscale testing: Assume your domain name is
www.example.com. To support business growth, you have released a new service with the IP address1.1.X.X. Before a full release, you want to perform grayscale testing on traffic fromChina Telecom_Shanghaifor a specific app version number. For this traffic, domain name resolution requests forwww.example.commust return1.1.X.X.Traffic rerouting: Assume an automotive company's service domain name is
www.example.com. The company wants the DNS resolution process to return the IP addresses of servers in different regions based on specific business logic. For example, different service IP addresses can be returned based on a car's home region. If a car's home region is Guangzhou, DNS query requests forwww.example.comfrom that car must return the IP address of a server in Guangzhou.
Workflow
1. Add a domain name
Log on to the EMAS console.
Choose HTTPDNS > Resolution Management > Domain Names, and add a domain name to resolve.

2. Add a custom resolution policy
Choose Resolution Management > Custom Resolution, and click the Add Custom Resolution button.

Select the domain name, and then select and configure a policy type as needed:
3. (Optional) Pass custom parameters from the client
When you send a request using the HTTPDNS software development kit (SDK) or HTTP API, include custom resolution parameters to execute more granular routing logic. For more information, see Pass custom resolution parameters from the client.
4. Enable the policy
After you add a policy, it does not take effect immediately. In the policy list, turn on the switch in the Status column to enable the policy.
Enabling a policy is a critical operation. A confirmation dialog box is displayed. Risk control verification may also be triggered, which requires you to enter a CAPTCHA.

5. Verify the resolution result
After the configuration is complete, you can use the online test tool to verify the resolution result. For more information, see Test a custom resolution function online.
6. (Optional) Manage custom resolution policies
After you add a custom resolution policy, you can perform operations such as disabling or deleting the policy. For more information, see Manage custom resolution policies.
Policy details
Recommended scenarios
When to use a rule-based policy: Use this policy type for scenarios with clear requirements and simple logic, such as routing by carrier, region, or device type. This policy is ideal when real-time dynamic calculations are not required.
When to use a Function Compute-based policy: Use this policy type for complex logic, such as load balancing, real-time data-driven decisions, or multi-condition judgments.
Rule-based policy
A rule-based policy lets you customize resolution based on specific rules. You can configure network lines with greater precision. By configuring different resolution parameters, you can accurately route user traffic from different carriers and regions to specific endpoints.
The procedure is as follows:
In the HTTPDNS console, create a custom rule-based resolution policy for a specific domain name.
When the client sends a DNS query request through the SDK or HTTP API, include the corresponding custom resolution parameters.
When the HTTPDNS server receives the request, it returns a resolution result based on the preset matching rules.
For detailed configuration steps, see Configure rule-based custom resolution
The following figure shows the resolution flow for a rule-based policy.
Function Compute-based policy
A Function Compute-based policy uses Alibaba Cloud Function Compute to schedule domain name access traffic based on a policy. This method is more flexible than a rule-based policy. You can implement your business logic as a function in Function Compute and then configure that function as a resolution hook. This lets you meet more complex business requirements. For detailed configuration steps, see Configure Function Compute-based custom resolution
The following figure shows how Function Compute works.

