4

I'm trying to learn the different types in DNS (A, CNAME, NS etc).

I do understand what they is used for, but the way I see it, CNAME could be used whenever NS is used, or am I wrong?

For instance:

(dns.mysite.example, 192.0.2.4, A)
(mysite.example, dns.mysite.example, CNAME)

Would it matter if I used CNAME of NS here?

Also, a second question, am I right in assuming that top level domain (TLD) DNS servers don't have any CNAME records?

1 Answer 1

11

No, CNAME and NS are quite different.

CNAME associates an alias with a canonical ("true") name. So in your example, dns.mysite.example would be an alias for canonical/true name mysite.example, and all DNS queries for dns.mysite.example would be referred to (ie, retried with) mysite.example.

NS records identify an authoritative name server for a domain (more correctly, a DNS zone). They tell a DNS query where to look for authoritative detail about a domain (zone). Typically, unless you are setting up name server infrastructure, your domain registrar will provide correct NS details for your domain (typically, a few name servers for redundancy, each controlled by your registrar, such as ns1.registrar.example, ns2.registrar.example).

For subdomains which will resolve to the same address, you do have a choice between A and CNAME records. The practical difference between A and CNAME records is that CNAME will cause an additional lookup (to resolve the alias to the canonical name) which is not incurred with a direct A record. So there is a slight performance penalty on lookups if you use CNAME records rather than individual A records for your subdomains.

The root zone file does not contain any CNAME records, but that's not because it can't, but that it doesn't need to. It mainly contains NS and address (A & AAAA) records for top level domains, for country-code top level domains (and, more recently, for all those new/extended TLDs like .auction).

3
  • Thanks! But if I made a DNS request for mysite.com, I would wind up at 1.2.3.4, right? Isn't that what my example table does? Which would mean it would have the same effect as putting NS?
    – lawls
    Mar 16, 2015 at 13:29
  • 1
    How do you define "effect"? An NS would mean that mysite.com is hosted on the dns.mysite.com infrastructure, and that when you you hit mysite.com, the visitor should check for a response for mysite.com with dns.mysite.com infrastructure. A CNAME simply says, mysite.com points to dns.mysite.com. Typically, you would not create a CNAME or A Record to dns.mysite.com because that's not an actual website. You would mysite.com, who's Nameservers are dns.mysite.com, and CNAMES would be a.mysite.com and b.mysite.com. If you hosted yousite.com on the same infrastrucutre, you'd use an A Record. Mar 16, 2015 at 14:26
  • " your domain registrar will provide correct NS details for your domain" Only if it provides DNS service for its customer. A domain name registrar and a DNS hosting provider are two completely separate jobs. One company can do both, but they are technically unrelated. Jul 3, 2020 at 22:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.