When you add a DNS record, a "record conflict" error may prevent you from saving it. This typically happens because the CNAME record conflicts with an existing record for the same host, such as an A or MX record.
Use case: switch from an A record to a CNAME record for acceleration
To minimize the impact on your services during the switch, perform this operation during off-peak hours.
Procedure
-
In the Alibaba Cloud CDN console, add your domain name and configure its CNAME record. Ensure that the CNAME address is active.
-
Lower the TTL of the existing A record.
-
Log on to the Alibaba Cloud DNS console, navigate to Public Zone, and click the target domain name.
-
Find the A record for the host, such as
www. Change its TTL to the minimum value that your edition supports:-
Personal Edition: 10 minutes.
-
Ultimate Edition: 60 seconds or less. For example, you can set the TTL to 10 seconds.
-
-
Wait for a period equal to the original TTL value. For example, if the original TTL was 10 minutes, wait for at least 10 minutes. This ensures that DNS caches across the globe are updated with the new TTL.
-
-
Switch to the CNAME record. Perform the following steps to minimize downtime.
-
Delete the original A record.
-
Add the CNAME record.
Parameter
Example value
Description
Record type
CNAMERequired
Host
wwwSame as the original record
Record value
example.cdn.aliyun.com.Copy this from the Alibaba Cloud CDN console. Do not omit the trailing dot (
.).TTL
Set to the value recommended by Alibaba Cloud CDN (usually 10 minutes).
You can keep the default value.
-
Use case: use a root domain for both a website and an email service
To avoid a conflict between CNAME and MX records, use URL forwarding to redirect HTTP and HTTPS requests from the root domain to a CNAME-configured subdomain such as www.
Procedure
-
Ensure that both the root domain (the source domain) and the
wwwsubdomain (the destination domain) have a valid Internet Content Provider (ICP) filing. This is a requirement for services hosted in mainland China. -
Add a CNAME record for the
wwwsubdomain. Set the value of the record to the address provided by Alibaba Cloud CDN, such asexample.cdn.aliyun.com.. -
Add an explicit URL forwarding record for the root domain (
@). Set the destination tohttps://www.example.com. -
Retain the MX record for the root domain (
@) to handle your email service.
This solution applies only to web access. Other protocols, such as API calls or email client connections, cannot use URL forwarding to access the root domain.
Use case 3: Connect a CDN with GTM
If your domain is already managed by Global Traffic Manager (GTM), GTM creates a CNAME record for it. Adding another CNAME record for Alibaba Cloud CDN causes a conflict that prevents the CDN from connecting properly.
Solution
Choose one of the following methods based on your business needs:
-
If you no longer need the GTM service, log on to the Alibaba Cloud DNS console, delete the corresponding GTM instance and its CNAME record, and then add the Alibaba Cloud CDN CNAME record for your domain.
-
If you need to use both GTM and Alibaba Cloud CDN for access acceleration and high availability, see Use GTM with CDN for access acceleration and service high availability. Configure the CDN CNAME address as an address pool in GTM. This allows GTM to centrally manage traffic and direct it to CDN nodes.
Use case 4: Accelerate traffic outside the Chinese mainland
When the CDN acceleration region is set to Global (Excluding the Chinese Mainland), you can use DNS resolution lines to split traffic by geographic location. Users in the Chinese mainland connect directly to the origin server, while users outside the Chinese mainland are routed through the CDN. This avoids record conflicts without deleting existing records.
Procedure
-
Log on to the Alibaba Cloud DNS console, navigate to Public Zone, and click the target domain name.
-
Find the existing A record for the domain (where the Hostname is
wwwor@and the Request Source is set to Default). Change the Request Source to Chinese Mainland, and keep the Record Value as the IP address of your origin server. -
Add a new CNAME record to route users from regions outside the Chinese mainland to the CDN.
Parameter
Example value
Description
Record Type
CNAMERequired.
Hostname
wwwMust be the same as the host for the A record.
Request source
Regions outside the Chinese mainland
Select this option to route requests from users outside the Chinese mainland to the CDN.
Record Value
example.cdn.aliyun.com.Copy the CNAME address from the Alibaba Cloud CDN console. The trailing dot (
.) is required. -
After the configuration is complete, DNS requests from users in the Chinese mainland match the Chinese Mainland request source and resolve to your origin server's IP address. Requests from users outside the Chinese mainland match the Regions outside the Chinese mainland request source and resolve to the CDN's CNAME address for acceleration.
Verify the configuration
After you change the DNS records, wait for the changes to propagate worldwide. You can then run the following commands to verify your configuration:
# Verify the CNAME record
dig www.example.com CNAME +short
# Expected output: example.cdn.aliyun.com.
# Verify the MX record
dig example.com MX +short
# Expected output: 10 your-mail-server.com.