Sunday, January 8, 2012

OpenDNS, Dyndns, and DNS cache on Windows

I hope this helps someone in the future.

I've been using Dyndns.org for probably more than 10 years in order to be able to access my servers at home while I'm out of the house. Since most home routers have been supporting Dyndns for many years, this is a really simple setup.

In the last year or two, my kids have grown up and are now at the age where they use the internet on a daily basis, and so I've decided to use OpenDNS for my DNS needs, which has the added bonus of having url filters built in, so that I can minimally control what web sites my kids have access to.

I'm also a developer, and I have a machine set up at my buddy's house to host a web site. Since he has a dynamic IP also, I set up his own Dyndns account so that I can access the site from my home.

What I started experimenting was that when my buddy's ISP changed his IP, I couldn't access the site anymore using the Dyndns name.

As it turns out, OpenDNS' DNS tables are not updated right away when an IP address changes. After a bit of research, I found another service, DNS-O-MATIC, which allows you to tell OpenDNS that your IP has changed. So I set up an account there for my buddy, added dns-o-matic to his ddclient, and it worked fine.

Except for my Windows machines.

When my buddy's IP would change, ddclient on his machine would contact DNS-O-MATIC to request the OpenDNS IP change. At that point, if I was at home on a Linux machine and I tried to ping the Dyndns name, it would return the new address. However, on my Windows 7 machine, I'd still get the old address.

More Google.

It turns out that Windows has a DNS cache running by default. This cache, it seems, gets reset every 24 hours. If you disable that cache, then your system will query OpenDNS everytime you request a URL, but at least you'll get the latest one.

To enable/disable the cache, Start, Run..., and type "services.msc" and Enter. Then look for DNS Client, and disable/enable it.

With DNS cache enabled, you can also flush the current cache by typing the following in a command window : ipconfig /flushdns.

Finally, you can see the list of cached URLs by typing ipconfig /displaydns.