CNAME is short for canonical name, also referred to as a CNAME record, a record in a DNS database that indicates the true, or canonical, host name of a computer that its aliases are associated with.
CNAME-records can be used when a computer or service needs to be renamed, to temporarily allow access through both the old and new name.
1. A CNAME-record should always point to an A-record and never to itself or another CNAME-record to avoid circular references:
In the following example, an A record binds a hostname to an IP address, while a CNAME record points the commonly used www hostname to it:
server1 IN A 10.0.1.5
www IN CNAME server1
2. Often a CNAME is used to point a subdomain to another domain. Here is an example of a CNAME:
www.toolbaz.com. IN CNAME eric.toolbaz.com.
Example: to point www1.mydomain.com to point to
Subdomain to enter: www1
CNAME to enter: www
Result: Browsing to www1.mydomain.com would render the same page as www.mydomain.com
3. One of the times where CNAME records can be useful is when you want a subdomain to point to a computer outside of your domain. For example, you might want “news.example.com” to go to your ISP’s newsserver. Instead of putting in the IP address, you could put configure the following:
Subdomain to enter: news.example.com
CNAME to enter: news.myisp.com
That way if the IP address of the newsserver changed, you wouldn’t have to make any changes.
4. Another simple example of CNAME is when you wish to mask your domain:
Example: To point www.yourdomain.com to another website while maintaining www.yourdomain.com in the address bar of the browser:
Subdomain: to enter: www
CNAME to enter: www.anotherdomain.com