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.)
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.
DNS lookups are sequential, starting at the end. Assuming empty caches, the lookup for MISSING.DOMAIN.COM would go something like this ...
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.
It looks like you have a DNS Wildcard record for your domain.
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.)
Yes
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.
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!