I run into this question every now and again and have recently run into this while helping my soon to be brother-in-law transfer his hosting of GarnerBrewing.com. Most people rarely adjust their hosting provider after its paid for, and even if they do, it’s rare that they change it more than once. So, its not uncommon that most people ask the questions What are my name servers?, What is the difference between an A record and a CNAME?, and How do these things relate to each other?.
With the ability to buy a domain from one place, manage the DNS from another, and have hosting somewhere completely different its no wonder this is a topic that gets people scratching their heads. I had to recently double check on this to make sure I was helping to correctly make the DNS changes via email. After a little searching I was able to jog my memory, but it was almost impossible for anyone to explain in easily, so here I go.
What is a Name Server
Every web site out on the world wide web resolves to what is known as an Internet Protocol address (better known as IP address). The IP for issueblogit.com is 50.63.72.1. However, the IP is not necessarily unique for each web site. Take for example, my personal website johnzeren.com. This site also shares the IP 50.63.72.1.
This is where setting the Name Servers comes into play. A Domain Name Server (DNS), or name server as it will be called by your DNS manager, can be thought of as a look up for the IP address of the host computer where the web site is located. This can be tricky because the name servers themselves are simply domains that resolve to IP addresses. The key thing to remember is that the name server contains the mapping (or lookup) of which server (by IP address) hosts the website.
For Example: I am currently getting my hosting through GoDaddy So currently (at the time of the writing of this post) the name servers for issueblogit.com are:
ns35.domaincontrol.com
AND
ns36.domaincontrol.com
Don’t let this confuse you. There are typically at least 2 name servers for each domain. This just means that there is more than one place that knows where to find the website (think of it as a fail safe mechanism. If one of the name servers is down, people will still be able to reach your site because the other one knows where to find it).
What is an A record
If the name server is looked at as who has the map of your domain name to it’s IP address, the A record is the actual mapping. In the name server example above, the two name servers (ns35.domaincontrol.com and ns36.domaincontrol.com) contain the knowledge of how to find the mapping of the IP address to the domain name. To continue the example, say someone (you reading this example) goes to a page on issueblogit.com. Because the name servers are set to a location(s) that knows the mapping, they are “asked” for that mapping. Those name servers than look at the A record to see what the IP is set to.
The A record is commonly known as the “host” record. I would like to say that this being set is the most important part of configuring your DNS, but I would then have to argue with myself that setting the name servers is the most important part, because if those were not set than the A record (host) could never actually be found (mapped or “looked up”).
So, again keeping with the example of this site, the A record for issueblogit.com is set to 50.63.72.1.
What is a CNAME
Now that we have the “easy” questions out of the way, lets get to the CNAME. CNAME stands for Canonical Name, which is to really say that when you set the CNAME of a site you are setting the alias for another actual (unique) domain name. That sounds confusing, but basically what it boils down to is that CNAMEs are used to set aliases. Lets move to a different example using my johnzeren.com. Let’s say I wanted to have a personal blog site to compliment my main website and I want it to reside on blog.johnzeren.com. However, the actual blog is hosted on a different domain, lets say somewhere.else.com. This is where you would want to create a CNAME record “blog” and have it pointed somewhere.else.com. This way when site visitors type in the URL http://blog.johnzeren.com they are actually seeing the contents for http://shomewhere.else.com.
Again, CNAMEs are used as aliases to sites hosted at other locations. Typically your CNAME is a subdomain (like the blog. in blog.john.zeren.com) that points to a different server.
Conclusion
I know this topic can be confusing, that is why I wrote the post. The exact working behind all of this a a bit more technical, but at a high level the explanation should give a clearer picture as to the difference between setting name servers, A records, and CNAMEs.
Please feel free to leave any questions or comments on this subject as I would be happy to help provide further clarification.
Good write up, but my question is: If I have a domain name purchased at a registra and they also offer the email. So should I use NS1 … and NS2 … or a cname to connect a website hosted on a different server?
I tried this with cname, my website resolved correctly, but emails sopped working. Would this be resolved if I used nameservers of the web host server instead of cname?