Wednesday, February 17, 2010

Dev Tool Of The Day: DNS Flusher

One of my clients was migrating servers this morning, and naturally we wanted to thoroughly test it before making it live. In this case, all we had was the hosting company's server domain name to access the site with. Something like:

 http://129-398-29-29-ip.hostingcompany.com

The site, however, is only accessible under its domain name - something like: http://www.clientsite.com.

A common solution to dealing with this temporary name mismatch is to add an entry to your computer's host file that overrides what's normally in DNS. For example, I edited: C:\Windows\system32\drivers\etc\hosts to read:

# Temporarily override clientsite.com
129.398.29.29       www.clientsite.com

Now, when I enter www.clientsite.com in my web browser, I'm directed to the new server with the correct hostname.

All of this works great. The tricky part comes into play when you want to switch between the old and new servers. Yes, you can easily comment out the entry in the hosts file, but you need to be sure to restart your web browser, otherwise its own DNS cache will come into play and you'll be sent to the wrong location.

Enter the slick little Firefox plugin: DNS Flusher. It does exactly two things:

  • It shows you the current IP address in the bottom right hand corner for the page you're looking at
  • If you click the IP, it will dump the cache, allowing you to get the latest address from your hosts file or DNS

It's simple, but made the sort of testing I describe above a real breeze. If you find yourself hacking your hosts file, you should definitely grab it.

No comments:

Post a Comment