Friday, February 24, 2006

Windows XP DNS Cache problem

I never thought that famous Windows XP DNS Cache problem comes in my way. Someone told me about this problem couple of years back, but I just ignored it with the feeling that I would ever have to encounter it personally.

The problem is about DNS cache. When ever you visit a site from a browser or try to ping a hostname from command line, XP looks for “A (Host) Record” of that hostname in its DNS Cache.

DNS Cache can be accessed from command prompt using following command

C:\>ipconfig /displaydns

Here I listed typical entries. One of type CNAME and another of type A (Host) Record
www.math.harvard.edu
----------------------------------------
Record Name . . . . . : www.math.harvard.edu
Record Type . . . . . : 5
Time To Live . . . . : 9015
Data Length . . . . . : 4
Section . . . . . . . : Answer
CNAME Record . . . . : math.harvard.edu

stuff.techwhack.com
----------------------------------------
Record Name . . . . . : stuff.techwhack.com
Record Type . . . . . : 1
Time To Live . . . . : 4399
Data Length . . . . . : 4
Section . . . . . . . : Answer
A (Host) Record . . . : 70.87.95.34

XP has its own algorithm to add items into cache. It normally adds records based on “Time To Live” parameter or based on frequency of access. If TTL is very small it doesn’t make any sense to add it to cache even though it is frequently accessed.

The problem I faced is with expired A (Host) Record entry in DNS cache. I have a domain account with Yahoo and hosting account with znetindia. I changed nameserver settings in my yahoo domain account to point to my new name server provided by znet. I left “A (Host) Records”, CNAME Records and MX Records as they were in Yahoo. I have new entries for them at my new nameserver with znet.

When I try to access my page say with the request http://sriharsha.net/ or http://www.sriharsha.net/ sometimes it takes me to my old starter webpage with Yahoo.

I got following of solutions to get around with this problem.

check for entries in DNS cache, if there are expired entries then consider flushing DNS cache by following command

"C:\ipconfig /flushdns"

If there are no entries in DNS cache try adding an entries at the end of

“c:\WINDOWS\system32\drivers\etc\hosts” file

70.85.149.228 sriharsha.net

70.85.17.215 mail.sriharsha.net


Try to ping your domain and check IP address. Based on that change your “A (Host) Records” and CNAME records in domain control panel

Also consider adding following two entries to registry key
HKEY_LOCAL_MACHINE\SYSTEM\

CurrentControlSet\Services\Dnscache\Parameters

Block XP from adding unresolved or failed (Negative) entries to cache

DWORD: MaxNegativeCacheTtl

Value: 0

Force XP to keep valid (Positive) entries only for specified time. This will be useful if your ISP/Domain registrar updates DNS entries more frequently than your XP DWORD:

MaxCacheTtl

Value: 14400

No comments: