How exactly do name servers handle unknown subdomains?

Solution 1:

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.

Solution 2:

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.

Solution 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!