A CNAME record (for Canonical NAME) is a type of resource record in the Domain Name System (DNS) that maps one domain name (the alias) to another (the canonical name).
This can prove convenient when running multiple services (like an FTP server and a web server, each running on different ports) from a single IP address. One can, for example, use records to point and to the DNS entry for , which in turn has an A 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 record for .
records must always point to another domain name, never directly to an IP address.
Details DNS records are specified in RFC 1034 and clarified in Section 10 of RFC 2181.
CNAME records are handled specially in the domain name system and have several restrictions on their use. When a DNS resolver encounters a 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 records, the canonical name (righthand side) is returned, rather than restarting the query. The canonical name that a record points to can be anywhere in the DNS, whether local or on a remote server in a different DNS zone.
$ORIGIN example.com. […] bar.example.com. 3600 IN CNAME foo.example.com. foo.example.com. 3600 IN A 192.0.2.23 Consider the DNS zone shown at right: when an record lookup for is carried out, the resolver will see a record and restart the lookup for , eventually returning .
Possible confusion With a CNAME record, one can point a name such as to . Because of this, during casual discussion, the lefthand () side of a DNS entry can be incorrectly identified as the , however, this is inaccurate. The record stores the canonical (true) name of a host, making the righthand side the actual .
bar.example.com. 3600 IN CNAME foo.example.com. 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), which is (or should be) a canonical name. In other words, consider the record shown at right. This may be read as saying that is an alias for the canonical name . A client will request and the answer will be .
Constraints records must always be pointed to another domain name, never to an IP address. If a record is present at a node, no other data should be present; this ensures that the data for a canonical name and its aliases cannot be different. The exception is when DNSSEC is in use, in which case there can be DNSSEC-related records such as , , etc. records that point to other records should be avoided due to their lack of efficiency, but are not an error. It is possible, then, to create unresolvable loops with records, as in:$ORIGIN example.com. […] foo.example.com. 3600 IN CNAME bar.example.com. bar.example.com. 3600 IN CNAME foo.example.com. RFC 1034 also makes the presence of an record at the zone apex an additional requirement, presenting yet another barrier to placing a record appearing at the zone apex.
and records must never point to a alias. So, for example, a zone must not contain constructs such as:$ORIGIN example.com. @ 3600 IN SOA ns1.example.com. [email protected] ( zone-admin.example.com. […] ) @ 2400 IN MX 0 foo.example.com. foo.example.com. 3600 IN CNAME host.example.com. host.example.com. 3600 IN A 192.0.2.1 Domains that are used in the Simple Mail Transfer Protocol and commands may not have a record. In practice this may work, but can have different behavior with different mail servers, and can have undesired effects.
DNAME record A record (for Delegation NAME) is defined by RFC 6672 (the earlier RFC 2672 now being obsolete). The 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 record creates an alias for a single name and not its subdomains. Like the record, the DNS lookup will continue by retrying the lookup with the new name. The name server synthesizes a record to actually apply the record to the requested name—s for every node on a subtree have the same effect as a for the entire subtree. $ORIGIN example.com. […] foo.example.com. 1200 IN DNAME bar.example.com. bar.example.com. 3600 IN A 192.0.2.23 xyzzy.bar.example.com. 3600 IN A 192.0.2.24 *.bar.example.com. 3600 IN A 192.0.2.25
For example, if there is a DNS zone as seen at right, an record lookup for will return no data because a is not a , and there is no record defined for the host.
However, a lookup for will be mapped and return the record for , which is ; if the record had been a record, this request would have returned name not found.
Lastly, a request for would be mapped and return .
ANAME record Several managed DNS platforms implement a non-standard or record type. These pseudo records are managed by DNS administrators like records, but are published and resolved by (some) DNS clients like records. records are typically configured to point to another domain, but when queried by a client, answer with an IP address. While record types were submitted for standardization, 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 records over records is that they can be used on a zone apex, while a standards-following resolver will not treat domain names with records as a zone apex. Also, while a DNS client requires at least two queries to resolve a to an record to an IP address, an will shift the second and subsequent query to the server. If the DNS server can resolve the 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 record type was submitted as a draft standard to the IETF Domain Name System Operations (DNSOP) working group, however its most recent revision expired in January 2020, having not found the consensus needed for a proposal. It has since been superseded by a series of drafts for two other new record types that resulted in RFC 9460, titled "Service Binding and Parameter Specification via the DNS ( and Resource Records)," being approved as a Proposed Standard in November 2023.
See also ICANN Internet Assigned Numbers Authority List of DNS record types
References
Further reading – Use of DNS aliases for network services – Mirroring a DNS zone subtree onto a second hostname – Increasing network connection efficiency by publishing server configuration details in the DNS