Usha Guduri

CNAME Vs. A Record

This is one of a nuances of the Domain Name System (read nuisances as well, if you dont quite understand it and end up mixing the two, running with pants on fire that the website is not working!)

Called the Canonical Name, it is similar to saying Jane Smith and Mrs.Smith are the same person. Almost all the websites have a single default CNAME for www. If you see sites where example.com works but www.example.com fails, it most likely is because of this missing CNAME which looks as simple as:

1
www.example.com. CNAME example.com.

And all it is saying is that www.example.com is just another name for example.com, so serve the request as if it went directly to example.com. A-record on the other hand is telling you where to find Jane Smith and Mrs.Smith. In cyberspace, its the address of the machine capable of servicing the requests to example.com and looks equally simple as:

1
example.com. A 123.45.67.8

In essence, the minimum DNS entry when you set up a new site should look like:

1
2
www.example.com. CNAME example.com.
example.com. A 123.45.67.8

The order does not matter as much, but note that each CNAME needs a minimum of 2 lookups to get to the machine to talk to.

So choose wisely, depending on how many hoops are required to finally get to the machine!

For the geek in you, the trailing . in the domain names is for the imaginary root server in the internet hierarchy and is called a FQDN notation (Fully Qualified Domain Name)

Comments