Sunday, 5 May 2013

Windows DNS client cache timeout

I've had problems especially during testing of systems where if the DNS name isnt resolved then a machine will cache that the "Name does not exist" for 300 seconds, this is the default for a Windows computer.  It's a little annoying when at first you don't realise this but fix any DNS issue and find your computer still won't resolve!  To reduce this negative cache behaviour you can update the following key:

HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Dnscache\Parameters

MaxNegativeCacheTtl

Data type: REG_DWORD
Value data: Set the value to 0 if you do not want negative responses to be cached.  Otherwise set to a value in seconds.  

I think a configured a value of 5 to 10 seconds is useful to stop computers constantly querying a DNS server if you want to stop the negative cache from causing problems.  This could be useful particularly if you have any kind of DNS based geo load balancing such as the Kemp Loadmaster DR which can give negative results in certain circumstances where the device sees all services are down.

Having done a little googling to figure this out I think the key for Windows 2000 is NegativeCacheTime.