Lately, I've been having quite a bit of problems at home with DNS and my Internet connection. The problem started manifesting by pages simply refusing to open in Firefox, constantly getting the "this page cannot be displayed" dialog as soon as I tried to open the page.

Hitting F5 to refresh usually didn't work, and closing and reopening Firefox didn't work either. Sometimes (but not always), if I switched to IE7 and tried the exact same URL, it would open, and if I switched right away to Firefox, it would load there as well. Annoying, but most importantly, it didn't work always either. Sometimes the site refused to load in IE7 as well.

I was really stumped about this issue, but it was starting to be obvious by now that this was some sort of DNS problem. I have my router configured to use the OpenDNS servers instead of my ISP ones (as those are pretty flaky), so I would switched them temporarily to pick the servers from DHCP instead. It worked, but only for a little while; soon the error would start manifesting itself again.

What was even more puzzling was that my other laptop, running Ubuntu doesn't seem to be much affected by the problem, and my sister's WinXP machine hasn't had much trouble, either.

I still don't know exactly what the problem is, but it appears the problem is that my old Microsoft MN-700 wireless router is starting to get flaky and rejects a lot of DNS requests, but only momentarily. For example, if a page refused to open, sometimes I could go into the console and try to do a TRACERT command on the server and get a DNS error back, but if I ran it right away through NSLOOKUP, it would correctly resolve the host name.

So, if the DNS errors are only short-lived flukes, why is it giving me so much trouble and seems so persisting (even surviving process restarts)? It would appear that the problem is Windows Vista itself.

As far as I can see, it appears that the DNS Client Cache on Vista is way too aggressive, and tends to cache the "results" of failed DNS queries a bit too much (or at least more than previous windows versions). So what would happen is that when I tried to open a web page, and the DNS query failed, it would get inserted into the DNS cache and keep failing until the entry expired and was removed from the cache.

This became pretty obvious when I started dumping the contents of the DNS Client Cache using the "ipconfig /displaydns" command and could see entries like this on the cache:

www.winterdom.com
----------------------------------------
Server failure of type A

Running the "ipconfig /flushdns" command would remove the entry from the cache and let Vista retry it, so that was one possible option to deal with the issue until I get a new router (pretty soon, hopefully). However, that's too annoying, so for now I've simply disabled the DNS cache in vista by shutting down the "DNS Client" (aka "dnscache") service. The problem still happens, but now pressing hitting refresh (F5) usually manages to open the page successfully. You can find more information about the DNS Cache on this KB entry (though it talks about WinXP and WinServer2K3).

Why DNS server failures are cached by Vista makes absolutely no sense to me. I can understand caching negative DNS responses, but not server failures! On the other hand, I haven't sat down with a protocol analyzer to see what exactly DNS response the router is sending out.

Technorati tags: ,


Tomas Restrepo

Software developer located in Colombia. Sr. PFE at Microsoft.