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 1: Switch from an A record to a CNAME record for CDN 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. To further reduce risk:
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.
Enterprise 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. This ensures that DNS caches worldwide 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).
Keep the default value.
Use case 2: A root domain was used 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
This is a requirement for services hosted in the Chinese mainland. Ensure that both the root domain (the source domain) and the
wwwsubdomain (the destination domain) have a valid Internet Content Provider (ICP) filing.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 CDN to a domain that already uses 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 while domestic users connect directly to the origin server
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 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 China 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
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 request source and resolve to your origin server's IP address. Requests from users outside the Chinese mainland match the 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. 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.