I’m often using Remote Desktop Gateways to connect to various environments, including our Private Cloud. One challenge arises when I change IP-address or network settings on a computer through SCVMM. As the RDGW has cached the DNS entry and IP Address, it takes a while until that information is cleared and I’m able to eastablish a connection. Or to be fair, what I usually do is RDP into the RDGW and does a “ipconfig /flushdns” and then reconnect the first server.
It does work, but wouldn’t it be better if that was kind of done automatically. Well, I guess you could schedule a “ipconfig /flushdns” every X minutes and get the desired result.
A better solution is to reduce the DNS Cache timeout on the RDGW server! I’ve modified mine to cache entries for just 10 seconds, and then do a new DNS query. 10 Seconds might be a bit too aggressive though it works fine for me.
Use this registry key to set the DNS Client Cache timeout;
Value: 10 (Decimal, in Seconds)
Default: 0x15180 (86,400 seconds = 1 day)
Restart the “DNS Client” service to take effect. (net stop dnscache & net start dnscache).
I’ve only tried this on Windows Server 2012 R2, but I guess it should also work on Windows Server 2008, Windows Server 2008 R2 and Windows Server 2012.
Personally, I’ve set this key through Group Policy Preferences to make sure it’s always done, even if the RDGW Server is reinstalled.
The other two values; MaxCacheEntryTtlLimit and MaxNegativeCacheTtl are leftovers from my testing, it seems those values worked for “Windows 2000” and are not used anymore.
2 thoughts on “Reduce DNS Client Cache in Windows Server 2012 R2”
The default value is that it uses the TTL of the DNS Record, or a maximum of 24hours in seconds, 86400 (1 day) depending on which is the shortest.
So by default; a DNS Record with a TTL of 1 hour will be cached 1 hour. A DNS Record with a TTL of 2 days, will be cached 1 day.
Most DNS values in a default Windows AD DNS has a TTL of 1 hour, so that what will be used for those entries if you don’t change the Value as described in this post.
Great info, what is the default value?