The abbreviation CNAME stands for Canonical Name.
In the context of DNS (Domain Name System), a CNAME record is a type of resource record that maps an alias name to a true or canonical domain name. This is commonly used to link multiple domain names to a single host.
A CNAME (Canonical Name) record is a type of DNS (Domain Name System) record that links an alias domain name to a canonical (main) domain name. Instead of pointing directly to an IP address, a CNAME record points one domain to another domain, which can then resolve to an IP address. This helps streamline domain management, particularly for subdomains or multiple domains pointing to the same website.
Key Functions of CNAME Records
Domain Aliasing: CNAMEs allow you to alias one domain to another. For example, if you have multiple versions of your website (e.g., www.example.com
and example.com
), you can create a CNAME record to make one version an alias of the other, ensuring both direct to the same server.
Load Balancing and Redundancy: In some cases, CNAMEs are used in load balancing setups, where they point to a service that distributes requests across multiple IPs for redundancy and performance.
Simplified Domain Management: If the IP address of the server changes, only the primary domain's A record (the record that maps a domain to an IP address) needs updating, as all CNAMEs point to that domain.
External Services Integration: CNAMEs are often used when integrating third-party services like content delivery networks (CDNs), email services, or web hosting services. For example, to point blog.example.com
to a blog hosted by a third-party provider, a CNAME record can be created to map blog.example.com
to the third-party's domain.
How a CNAME Record Works
When a user types an alias domain (e.g., blog.example.com
), the DNS server follows the CNAME record and maps that domain to the canonical domain (e.g., example.com
). The DNS then looks up the A record of example.com
to find its IP address and direct the user to the appropriate server.
Example
Suppose you want store.example.com
to point to the same content as example.com
. You could set a CNAME record like this:
store.example.com
→ CNAME → example.com
Then, if example.com
has an A record pointing to 192.0.2.1
, any request for store.example.com
will also resolve to 192.0.2.1
.
Limitations
- CNAMEs cannot coexist with other records of the same name, such as A or MX records.
- Root (or apex) domain names (like
example.com
) usually cannot have CNAME records because DNS specifications restrict this usage.