What is a CNAME record? We show examples & explain
It is not uncommon for a website to be accessible from multiple addresses. For this purpose, the Domain Name System (DNS) includes the CNAME Record, which is specialised in redirects, alongside the dominant and widely used TXT Record. With the CNAME Record, requests to a subdomain can be redirected to a root or another subdomain, provided that it has been defined elsewhere by the A Record. This allows the CNAME Record to be used in various ways, such as distributing requests within one's own IT infrastructure or capturing erroneous inputs and redirecting them to the responsible virtual or dedicated server.
What is the CNAME Record?
The CNAME Record defines an alias for a subdomain, automatically redirecting to another domain when a defined address is accessed, and directing the request to its A Record and AAAA Record. Like all other DNS entries, CNAMES Records consist of an entry in a nameserver and, alongside other details such as A Record for IPv4 addresses, AAAA Record for IPv6, MX Record for mail traffic, and TXT Record for additional information like SPAM protection through DMARC, DKIM, or SPF, it is one of the most crucial parameters for name resolution. Similar to these, the CNAME Record is structured according to a fixed syntax, following the standards for DNS entries.
What characteristics does the CNAME entry possess?
Several aspects distinguish the CNAME Record from other entries such as the freely definable TXT Record or the A Record and AAAA Record directly responsible for routing - it is subject to strict requirements on one hand, and on the other hand, it is not mandatory but can be used as needed. There are strict rules specific to its purpose that define its capabilities and limitations:
- The entry must always be for a subdomain.
- A record must only point to a domain, never to an IP address.
- No other entry like MX Record or A Record may point to a CNAME.
- The target can be subdomains or external domains.
- The entry should never be used for email.
- A combination of multiple records is possible but considered inefficient.
- A CNAME should not be used in any other entry like an A Record.
In its function, the CNAME Record resembles an ALIAS entry on a nameserver but fundamentally differs in two points. The ALIAS allows redirecting from a root domain to another - for example, from example.com to example.net - and does not categorically exclude other DNS Records. In contrast, this record is exclusively permissible for referencing a subdomain to another address - such as my.example.com to example.net - and must never appear a second time in another A Record or MX Record.
How is the CNAME Record structured?
In its syntax, this entry resembles those of all other entries in the DNS and consists of several pieces of information, some of which are optional, following the structure of other information on the nameserver. The structure is kept simple and consists of five different fields:
- Name: Subdomain that the client accesses
- Time To Live (TTL, optional): Maximum duration in the cache before a new access
- Class (optional): Type of network, usually always IN for Internet
- Type: Type of DNS entry
- Data: Destination of the reference from the name
Exemplary entries for an entry look as follows:
www.example.com. 9600 IN CNAME example.com.
ftp.example.com. CNAME example.com.
site.example.de. CNAME example.com.
The entry is usually made either manually or through a corresponding form on the website of the responsible domain provider, who also operate their own nameservers. If you are looking for a new domain provider, you are in the right place in our Domain Comparison.
Image: Manfred Steger on Pixabay
Write a comment
More web hosts
More interesting articles
Changing Domain Names - How to Do It?
How can the selected domain name be changed later?