What is a DNS CNAME record?

The DNS CNAME records create aliases for one hostname ("Alias Name") to another hostname ("Canonical Name"). In simple terms, DNS CNAME record maps one hostname (say www.example.com) to another hostname (example.net), instead of mapping them to IP addresses of hosts as compared to DNS A and AAAA records.

Input required to set DNS CNAME records

DNS CNAME record requires three inputs:

  1. Name: This is the DNS name of a hostname. For example, the DNS name will be "www" for the hostname "www.example.com". DNS Name must follow the limits defined in RFC1035,
    i. DNS name can have up to 250 characters, and must start with a letter (a-z), end with a letter or a digit (0-9), and can have only letters, digits, and hyphens (-) as characters.
    ii. DNS name can be split into labels using the dot (.) character, to a maximum of 8 labels. Each label can have 63 characters or less.
  2. Data: For the DNS CNAME record, data (target) is the hostname destination of the resource. This target hostname can resolve a host using a DNS A or AAAA record, or a DNS CNAME alias itself.
  3. TTL: TTL or Time To Live is the time-span limit (in seconds) for the DNS data on the Internet. DNS caching servers use this limit while saving the record temporarily for faster DNS resolution.

Usage scope for DNS CNAME records

DNS CNAME records can create aliases of one hostname to another. Different hostnames (e.g. www.example.com, blog.example.com,..) can have the same DNS data (e.g. example.com) for hostname, however, DNS name of each CNAME record for a domain should be unique among its CNAME, A and AAAA records. For example, if the domain name "example.com" has a DNS CNAME record "www.example.com" pointing to a hostname "example.net", it cannot have another CNAME, A or AAAA record for the same hostname "www.example.com". Also, the DNS name field cannot be empty, since CNAME records cannot be set for root domains (like "example.com").

How to host a DNS CNAME record

DNS records are hosted on the Internet through DNS hosting services. If you are using Slickalpha DNS, check this related guide to learn how to add a DNS record on your Slickalpha account.

How to check DNS CNAME records

DNS records can be queried directly on your system terminal using the dig command. To check your DNS CNAME records on the browser, try our free DNS Lookup tool.

Uses of DNS CNAME records

DNS CNAME records are useful in creating aliases for sub-domains instead of pointing them directly to host IPs using DNS A or AAAA records. When the hostname is entered on a web browser, the DNS servers resolve recursively and return the destination IP address to the client, instead of returning the hostname mapped in the CNAME record.

Managed DNS