ACanonical Name (CNAME)record is a type ofresource record in theDomain Name System (DNS) that maps one domain name (an alias) to another (thecanonical name).[1]
This can prove convenient when running multiple services (like anFTP serverand aweb server, each running on different ports) from a singleIP address. One can, for example, use CNAME records to pointftp.example.com andwww.example.com to the DNS entry forexample.com, which in turn has anA record which points to the IP address. Then, if the IP address ever changes, one only has to record the change in one place within the network: in the DNS A record forexample.com.
CNAME records must always point to another domain name, never directly to an IP address.
DNS CNAME records are specified inRFC 1034 and clarified in Section 10 ofRFC 2181.
CNAME records are handled specially in the domain name system and have several restrictions on their use. When aDNS resolver encounters a CNAME record while looking for a regular resource record, it will restart the query using the canonical name instead of the original name. However, if the resolver is specifically told to look for CNAME records, the canonical name (right-hand side) is returned, rather than restarting the query. The canonical name that a CNAME record points to can be anywhere in the DNS, whether local or on a remote server in a differentDNS zone.
For example, consider a DNS zone as follows:
NAMETYPEVALUE--------------------------------------------------bar.example.com.CNAMEfoo.example.com.foo.example.com.A192.0.2.23
When anA record lookup forbar.example.com is carried out, the resolver will see a CNAME record and restart the lookup forfoo.example.com and will then return 192.0.2.23.
With a CNAME record, one can point a name such as "bar.example.com" to "foo.example.com". Because of this, during casual discussion, the "bar.example.com." (left-hand) side of a DNS entry can be incorrectly identified as "the CNAME" or "a CNAME". However, this is inaccurate. The canonical (true) name of "bar.example.com" is "foo.example.com". Because CNAME stands for Canonical Name, the right-hand side is theactual "CNAME"; on the same side as the address "A".
This confusion is specifically mentioned in RFC 2181, "Clarifications to the DNS Specification". The left-hand label is an alias for the right-hand side (the RDATA portion), whichis (or should be) a canonical name.[2] In other words, consider the following CNAME record:
bar.example.com.CNAMEfoo.example.com.
This may be read as saying that "bar.example.com" is an alias for the canonical name (CNAME) "foo.example.com". A client will request "bar.example.com" and the answer will be "foo.example.com".
foo.example.com.CNAMEbar.example.com.bar.example.com.CNAMEfoo.example.com.
example.com.MX0foo.example.com.foo.example.com.CNAMEhost.example.com.host.example.com.A192.0.2.1
ADNAME record orDelegation Name record is defined byRFC 6672 (original RFC 2672 is now obsolete). The DNAME record provides redirection (alias) for a subtree of the domain name tree in the DNS. That is, all names that end with a particular suffix are redirected to another part of the DNS. In contrast, the CNAME record creates an alias for a single name and not its subdomains. Like the CNAME record, the DNS lookup will continue by retrying the lookup with the new name. The name server synthesizes a CNAME record to actually apply the DNAME record to the requested name—CNAMEs for every node on a subtree have the same effect as a DNAME for the entire subtree.
For example, if there is a DNS zone as follows:
foo.example.com.DNAMEbar.example.com.bar.example.com.A192.0.2.23xyzzy.bar.example.com.A192.0.2.24*.bar.example.com.A192.0.2.25
AnA record lookup forfoo.example.com will return no data because a DNAME is not a CNAME and there is no A record directly atfoo.
However, a lookup forxyzzy.foo.example.com will be DNAME mapped and return theA record forxyzzy.bar.example.com, which is 192.0.2.24; if the DNAME record had been a CNAME record, this request would have returned name not found.
Lastly, a request forfoobar.foo.example.com would be DNAME mapped and return 192.0.2.25.
Several managed DNS platforms implement a non-standard ALIAS[8] or ANAME[9] record type. These pseudo records are managed by DNS administrators like CNAME records, but are published and resolved by (some) DNS clients like A records. ANAME records are typically configured to point to another domain, but when queried by a client, answer with an IP address. While ANAME record types were submitted for standardization,[10] there are other non-conforming implementations, so they can do whatever the owner of the DNS platform chooses, including existing at the apex of a zone and existing for domains that receive mail.
The main advantage of ANAME records over CNAME records is that they can be used on azone apex, while a standards-following resolver will not treat domain names with CNAME records as a zone apex.[11]Also, while a DNS client requires at least two queries to resolve a CNAME to an A record to an IP address, an ANAME will shift the second and subsequent query to the server. If the DNS server can resolve the A record and cache the requested IP address more efficiently and with less latency than its DNS clients can, then the DNS client can resolve the query faster.
The ANAME record type was submitted as a draft standard to IETF. However, the latest draft document expired in January 2020[10] and has been superseded by a series of proposals, the most recent of which is the one for the SVCB and HTTPS record types.[12]