A Canonical Name (CNAME) record is a type of resource record in the Domain Name System (DNS) that maps one domain name to another.
What is a DNS CNAME record?
There are various types of DNS records. In most cases, a CNAME record works with an A record. The following section describes A records.
A record
An address record (A record) is a mapping record that maps a domain name to an IP address.
When you access a domain name, the DNS server uses the A record to resolve the domain name to the mapped IP address. Then, you can access the domain name by using the IP address.
Example:
Record type Domain name Record value
A www.example.com 10.10.10.10
CNAME record
Compared with an A record, a CNAME record maps a domain name to another domain name, which can be considered an alias. A CNAME record value can be mapped to a specific server through an A record.
Example:
Record type Domain name Record value
CNAME cname1.example.com www.example.com.w.kunlunsl.com
A www.example.com.w.kunlunsl.com 10.10.10.10
When you access the domain name cname1.example.com, the DNS server obtains the CNAME record value www.example.com.w.kunlunsl.com. Based on the A record of www.example.com.w.kunlunsl.com, the domain name cname1.example.com is resolved to the IP address 10.10.10.10.
You cannot have an A record and CNAME record for the same hostname.
Benefits of DNS CNAME records
Quickly update server IP addresses
When the IP address of a server changes, such as from 10.10.10.10 to 10.10.10.1, you only need to change the value of the A record to the new IP address 10.10.10.1. This way, you can point three domain names to the new IP address without the need to modify the CNAME records of the domain names.
Before the server IP address changes:
Record type Domain name Record value
CNAME cname1.example.com www.example.com
CNAME cname2.example.com www.example.com
CNAME cname3.example.com www.example.com
A www.example.com 10.10.10.10
After the server IP address changes:
Record type Domain name Record value
CNAME cname1.example.com www.example.com
CNAME cname2.example.com www.example.com
CNAME cname3.example.com www.example.com
A www.example.com 10.10.10.1
Work with Alibaba Cloud CDN to accelerate the delivery of static resources
Alibaba Cloud CDN is a global network of points of presence (POPs) that are distributed across the globe. Alibaba Cloud CDN serves to reduce origin traffic. This in turn prevents network congestion and ensures that content is delivered with minimal latency across regions in various use cases. For more information, see What is Alibaba Cloud CDN?
The CNAME record value returned by Alibaba Cloud DNS in Step 3 is the CNAME assigned by Alibaba Cloud CDN to the domain name. You can reach the routing system of Alibaba Cloud CDN by accessing www.example.com.cname.com. Then, the routing system assigns an optimal POP based on the information of the user. This way, the user can obtain the resource from the POP so that the delivery of the resource is accelerated.