Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Configuring Windows DNS resolver cache

Tags:

c#

.net

dns

Note that I'm talking about the client DNS resolver cache. This message is not concerned with the Windows DNS Server.

I have a C# program that does a lot of DNS resolutions. Because the HTTPWebRequest component won't let me change the Host header, I can't create my own internal DNS cache. So I have to depend on the Windows DNS cache, which doesn't appear amenable to change.

There's a reasonably good TechNet article about the DNS cache Registry settings in Windows Server 2003, but I haven't been able to prove that setting them does anything. All the other pages I found through a Google search either reference that page, or paraphrase it, sometimes incorrectly.

Windows' ipconfig command has a /displaydns switch that will output the contents of the cache. To my knowledge, that's the only way to determine the size of the DNS cache. In my experiments on a 32 bit Windows XP box with 2 GB of memory, no matter what I set the DNS cache registry values to, I always end up with between 30 and 40 items in the cache--even after doing thousands of DNS resolutions. On my 64-bit Windows 2008 machine with 16 GB of memory, I always get between 270 and 300 items in the cache.

I'm stumped. I don't know what the answer is, but I figure one of the following is the case:

  1. It's not possible to change the size of the DNS resolver cache.
  2. It is possible, but the documentation is wrong.
  3. The documentation is correct as far as it goes, but it’s incomplete.
  4. The documentation is correct and complete, but I’m too dumb to make sense of it.
  5. The documented registry entries actually changed the size of the cache, but ipconfig isn’t showing me all the entries that are in the cache.

Can anybody tell me if it's possible to configure the size of the DNS resolver cache in Windows XP, Vista, or Server 2008?

like image 386
Jim Mischel Avatar asked Mar 10 '09 15:03

Jim Mischel


People also ask

What is the DNS resolver cache?

The DNS cache (also known as DNS resolver cache) is a temporary DNS storage on a device (your computer, smartphone, server, etc.) that contains DNS records of already visited domain names (A records for IPv4 addresses, AAAA records for IPv6, etc.). It keeps those records, depending on their time-to-live (TTL).

What happens when you flush DNS resolver cache?

What does flush DNS do? Flushing DNS will clear any IP addresses or other DNS records from your cache. This can help resolve security, internet connectivity, and other issues. It's important to understand that your DNS cache will clear itself out from time to time without your intervention.

Does Windows have a DNS cache?

Windows contains a client-side DNS cache. Microsoft doesn't recommend disabling DNS client-side caching on DNS clients. A configuration in which DNS client-side caching is disabled isn't supported.


1 Answers

With these settings, after just a few minutes on the web, I am seeing 1517 cached entries:

REGEDIT4

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Dnscache\Parameters]
"QueryIpMatching"=dword:00000001
"NegativeCacheTime"=dword:00000000
"NegativeSOACacheTime"=dword:00000000
"CacheHashTableBucketSize"=dword:00000001
"CacheHashTableSize"=dword:00000180
"MaxCacheEntryTtlLimit"=dword:00000e10
"MaxSOACacheEntryTtlLimit"=dword:0000012c

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters]
"QueryIpMatching"=dword:00000001

like image 162
Darek Avatar answered Sep 28 '22 16:09

Darek