Flush the DNS cache on Windows workstations
In one of my previous post (“Moving your website to another server? Tune your DNS for minimum downtime”) I have showed how we can tune DNS servers to minimize the downtime during a server migration. One additional concern that we might face on this issue is with client side DNS caching… Some operating system (MS Windows for example) will not follow DNS standards and will just cache the DNS records and will not query for them even if we have setup everything properly on the server side. This will happen even if the resolver for the Win workstation is a Linux server (or something else) that will correctly see the change.
This is my first (and hopefully the last) post that contains information about ms windows, but you might find it useful if you are doing a migration for someone else that uses windows on his workstation or even if you are working yourself from a windows system. There is a high chance that this will happen if you will check the site prior to making the DNS change and then it will be cached by windows. Since I have heard peoples recommending restarting the computer to clean up the local DNS cache, I have decided to write this little post…
Windows workstations
As I explained previously windows will cache the DNS hostnames and if you don’t want to reboot the workstation you will have to clear its internal cache so it will query again the DNS resolver that will hopefully follow the standards and get the correct IP. In order to do this open a command prompt (Start/Run then type cmd) and type:
ipconfig /flushdns
The output of this command will look like:
C:\\Documents and Settings\\user><strong>ipconfig /flushdns</strong>
Windows IP Configuration
Successfully flushed the DNS Resolver Cache.
Just as a note this will obviously clear the entire local dns cache.
Linux workstations
Normally this will not happen on Linux workstations as the linux resolver will follow the standards and query for the new IP once the TTL will expire. Anyway if you want to clear the DNS cache even in this case (maybe for a case where the TTL was not expired yet for ex.) you have to restart the DNS service. If you are using bind you only have to run:
/etc/init.d/bind9 restart
on Debian based systems, or:
/etc/init.d/named restart
on RedHat based systems.
I guess that this was just a silly reason to insert some Linux related information in this post as probably everyone knows how to do that… :-)…