Disable Caching of DNS Records

Send Us a Sign! (Contact Us!)

This article explains how you can disable caching of DNS Resource Records for a DNS Server.

Have you ever had bogus name resolution data in your DNS cache? This happens when you’re pointed to a DNS server with outdated records, or perhaps a misconfigured server. You might see symptoms like all fully-qualified domain names (FQDNs) resolving to the same IP address, or even all FQDNs resolving to 127.0.0.1 (localhost).

Even when you configure clients and servers to use a properly configured DNS server they will retain previously resolved DNS addresses. The DNS resolution data is usually cached on both the client computer and the DNS server. So until the cache expiration time expires you will continue to see bogus name resolution results.

If you’re using Windows there are quick ways to purge the DNS cache on the client and on the server. We suggest you start with the server.

Purging the DNS Server Cache on a Windows DNS Server

If you’re using Windows Server 2003, Windows Server 2008, or Windows Server 2012 as your DNS server you can easily purge the server-side DNS cache using either a command-line tool or Windows PowerShell.

Purging the DNS Server Cache From the Command Prompt

At the command prompt, run the following command:

Dnscmd /ClearCache

Purging the DNS Server Cache With Windows PowerShell

To clear the DNS server cache using Windows PowerShell, use the following cmdlet from the dnsserver module:

Clear-DnsServerCache

This command purges the DNS client (or resolver) cache on Windows XP, Windows 7, and Windows 8, as well as Windows 2000, Windows Server 2003, Windows Server 2008, and Windows Server 2012.

At a command prompt, run the following command:

ipconfig /FlushDNS

By default Microsoft DNS Servers cache a record for 1 day. In some cases, you might need to disable this functionality for a DNS Server. To disable this behaviour, you can modify the below mentioned registry entry:

KEY Name: HKLM\System\CurrentControlSet\Services\DNS\Parameters
Entry Name: MaxCacheTtl
Type: REG_DWORD
Value: 0x15180 (this is the default value)

To disable the caching completely on DNS Server, set the value of MaxCacheTtl to 0x0. The DNS Server saves the records in memory area so that it can respond quickly to the Client DNS Queries for the same name. Records are deleted from the cache as per the value defined in the MaxCacheTtl registry entry. The value of this entry overrides the TTL Value set on the Resource Record.