7

I own a domain econemon.com. Below is an excerpt from the DNS entry (some records omitted for brevity):

econemon.com.       1800    IN  NS  ns.stratoserver.net.
econemon.com.       1800    IN  NS  ns2.stratoserver.net.
econemon.com.       1800    IN  A   85.214.92.48

These nameservers there are those from my provider, and as far as I understood it, they are the authorative ones for my domain.

Now, when I go ask one of them for the address record of a nonexistent subdomain, it responds with the address for my server, like so:

$ host -t A nosuchdomain.econemon.com ns.stratoserver.net
Using domain server:
Name: ns.stratoserver.net
Address: 81.169.163.40#53
Aliases: 

nosuchdomain.econemon.com has address 85.214.92.48

Which is, of course, exactly what I want in order to have virtual hosts etc. Now, say I added an entry

econemon.com.    IN  NS  ns.econemon.com

and the proper A record for ns.econemon.com to the list, and that nameserver actually had different A records for some subdomains, what would happen?

  • would a request for subdomain.econemon.com yield a different address depending on which name server you asked? (I guess it would.)
  • if so, this might actually be useful to fall back to a "main server" if my DNS was down, but how do I make the client to use my name server when it's up?
  • would this mess up caching on the clients? (Probably.)

(Note: This is related to my other two questions)

1
  • "nosuchdomain.econemon.com has address 85.214.92.48". As there is no such domain, I would instead expect "Host nosuchdomain.econemon.com not found: 3(NXDOMAIN)".
    – Abdull
    Nov 23, 2015 at 16:17

3 Answers 3

4

DNS lookups are sequential, starting at the end. Assuming empty caches, the lookup for MISSING.DOMAIN.COM would go something like this ...

  • the DNS client would request MISSING.DOMAIN.COM from a DNS server.
  • the DNS server asks the "root" DNS for MISSING.DOMAIN.COM domain, and gets back a name server for the COM domain.
  • the DNS server asks the COM name server for MISSING.DOMAIN.COM, and gets back a name server for the DOMAIN.COM domain.
  • the DNS server asks the DOMAIN.COM name server for MISSING.DOMAIN.COM. The DOMAIN.COM name server has no answer, so it reports back an address for DOMAIN.COM, depending on it's configuration.
  • If there were an NS record for MISSING.DOMAIN.COM, it would be returned, and the original DNS server would query it next. If there was an A record for MISSING, the IP on it would be reported back.

That is the gist of it. In reality it is far more complicated due to caching, load balancing, and the fact that Name Servers can be specified by name and so must be looked up as well.

To summarize your question .. you can specify several name servers for a domain and have them setup with different information. The answer is yes, but you must be careful and know what you are doing. You can use DNS to support load balancing and can use it to support failover lite. But you need to be careful!

EDIT: in a comment, bortzmeyer pointed out a couple of simplifications which in his opinion cross the line to error. I made adjustments that I hope address the concerns.

2
  • 1
    Wrong explanation. In the second step, the server does NOT "asks the root DNS for the COM domain", it just transmits the same question, verbatim (here, MISSING.DOMAIN.COM). Same thing for the steps after. That's why managing a root or TLD name server is a great way to spy the users :-) Also, when the DNS server authoritative for DOMAIN.COM replies, it does not always send "it's default host address", it depends if there are wildcards or not.
    – bortzmeyer
    Jun 19, 2009 at 11:56
  • Thanks for this explanation. Would it be possible to add a bit more info on what the request looks like; i.e. is it requesting the requested record type each time (e.g. A/Cname), or does it first look for NS/SOA records, then once it's drilled down to the lowest of those, requests the A/CName record from the given name server?
    – JohnLBevan
    Aug 25, 2020 at 11:04
4

This is one of those "I don't think that word means what you think it means" situations. You're calling host records within a given domain "subdomains". They're not.

To answer your bullet-point questions all together:

A request to a given name server will return what it thinks the appropriate answer is. It sounds like you're suggesting that you could add another DNS server as authoritative for your "econemon.com" domain that would have some "A" records in it that the others would not. That is not a common or recommended configuration of DNS. You generally want all the DNS servers authoritative for a given domain to have the same records (unless you know why you're doing that... aka "split-horizon" DNS.)

There's no generally useful reason for doing what you describe. You cannot influence the client computer resolver's choice of DNS server. It wouldn't "mess up" caching-- the caching would work like it's supposed to. It would create inconsistent results depending on which DNS server a client talked to, and that's generally bad.

A subdomain would be something like a "subdomain.example.com" domain that contained host records like "www.subdomain.example.com". What you're talking about are just hosts in a domain.

3
  • OK, thanks for clarifying that. So I'd put several host records, i. e. A records for the names example.com, www.example.com, ftp.example.com in a zone file that can then live on either my server or the provider's, or both? And what happens then with doesntexist.example.com, how's that resolved? Jun 17, 2009 at 16:25
  • +1 for Princess Bride reference ;) Jun 17, 2009 at 16:27
  • Host records are subdomains. Every domain name but "." (the root) is a subdomain.
    – bortzmeyer
    Jun 19, 2009 at 11:56
3

It looks like you have a DNS Wildcard record for your domain.

*.econemon.com.  IN A 81.169.163.40

This means that if a query results in no records, you'll get an A record for 81.169.163.40. Actually it is more complicated than that. If there is ANY record for a "label" (a fully qualified domain name, or FQDN) then that disables the wildcard record for that label. So, if you have an MX record for foo.econemon.com., a query for foo.econemon.com's A record will turn up nothing.

Wildcard records are somewhat rare and can confuse certain software systems. I don't recommend using them. However, your ISP is using them so that you don't have to bother them to update DNS records every time you add a subdomain. That makes sense.

Now on to your question...

What it seems like you are asking is, "If I have one nameserver with different data than the others, what will happen?"

Well, if you have 2 that your ISP runs with certain data, and 1 that you run with different data, then there is a 2:1 chance of getting data from your ISPs server. The DNS system doesn't keep looking to other nameservers if it doesn't find the data it wants in the first one. In other words, you can't ask Daddy if Mommy said "no".

This is an important concept in DNS. DNS needs to be FAST. Therefore, never do 2 queries when 1 will do.

That's why you should have the same exact zone data for a domain in each of the domain's nameservers. (Unless you have some funny load balancing scheme.)

  • would a request for subdomain.econemon.com yield a different address depending on which name server you asked? (I guess it would.)

Yes

  • if so, this might actually be useful to fall back to a "main server" if my DNS was down, but how do I make the client to use my name server when it's up?

The nameservers are tried in random order. If the first one doesn't respond, the DNS client will try the next one. When all have been tried the client gets a DNS error. Since each DNS server it sent 1 query, but generally we wait 30 seconds (I think) for a reply, if you have 100 nameservers, you'll be waiting 50 minutes before the client errors out. That's why I don't usually have more than 3 nameservers for a domain. More isn't better.

  • would this mess up caching on the clients? (Probably.)

Not really. The software is very robust. Postel's robustness principle ("be conservative in what you send, liberal in what you accept") comes into play here. It has benefits. Do queries for www.yahoo.com, www.microsoft.com and www.google.com. You'll see that each nameserver gives different IP addresses depending on where you are in the world (and other factors). If that were to confuse clients, those sites wouldn't survive!

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .