I am trying to figure out a few things about DNS Client caching. Specifically, I'd like to know how many name servers for a particular domain are cached when the client resolves a record for the first time, and what happens if the cached name server becomes unavailable when future requests are made. Also, is there a way to display the NameServers in a client cache on a windows servers. ipconfig/displaydns only seems to display the cached A and CNames, not the NameServers.
Name servers are not cached. The records they provide are.
Name servers are assigned on a per-connection basis. In Windows, here are typically two name servers assigned to each network connection, though the upper bound for how many can be assigned is much larger. The configured DNS servers are tried in order - the first one is queried first, if it is unavailable, the second one will be queried, and so on.
ipconfig /all will display a connection's currently configured nameservers, as will going into the connection properties through the GUI, but you will not be able to find a "nameserver cache" because one doesn't exist.
Servers are not cached. Each DNS record (DNS-to-IP assignment) has a TTL (Time-To-Live) attribute (in seconds). So when you first connect server by name, you ask DNS server to provide IP address for DNS name, you get this DNS-to-IP assignment record cached by OS for some time (depends on this record's TTL). Also the time when you got this record from DNS stored in cache and this record's TTL.
If you connect again, OS checks if previous request was more than TTL seconds ago.
- If TTL passed, OS clears cache record for this DNS-to-IP assignment and requests DNS server again
- If TTL is not passed yet, OS returns DNS-to-IP assigned from cache.
You can force OS to forget all cached DNS-to-IP assignments using