Change DNS cache expire time in Windows

Windows XP and Vista (and maybe 2000 too) by default have a DNS cache set with a 15 minutes expire time. That is, if you have made changes in your DNS server, a WinXP box will get this changes only after 15 minutes. If you want to change this, you have to add a key to the Windows Registry. Rant: add? ADD?!? why defaults have to be hardcoded and why a key doesn’t already exists with the default value in it? Rationals? Anyway, the path to the registry is:

HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Dnscache\Parameters

and you have to create a dword key here called NegativeCacheTime, and set its value to whateveer you want. 0 in case you want to disable this feature. Remember that the values is in second.
If you want to deploy this change, the quickest (and easiest) method I found was to create a registry file delete_dnscache.reg like this:


Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Dnscache\Parameters]
"NegativeCacheTime"=dword:0

(remember to change the final :0 with the seconds of cache you want.

and then create a simple batch (.bat) file to put in the Group Policy machine’s startup scripts with something like this:

regedit /s \\YOURSERVER\netlogon\delete_dnscache.reg

Then, give a gpupdate /force on your DC, reboot a WinXP machine and check its registry for the new parameter.

Advertisements

4 thoughts on “Change DNS cache expire time in Windows

  1. @MV: when you have to deploy a DNS change quickly (a service migration, for example) to thousands of workstations, ipconfig /flushdns could be a little problematic :)
    IMO it’s better to not have DNS cache at all, and better dimension your local DNS server to handle more DNS queries. The tradeoff is worth (at least in my environment).

  2. This is a VERY old reply to an old post but a google search provided this page. The reg entry of NegativeCacheTime is for failed lookups, not successful lookups. For Windows 2000 it is MaxCacheEntryTtlLimit and for XP and later it is MaxCacheTtl.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s