Moving web servers and hosts file

For whatever reason there may come a time when you need to change web hosts for a site. Its not a good look for the world see a broken site due to differences between the old and new. So how do you test everything is set up correctly at the new host before updating nameservers?
When you type a site into the browser location bar, a DNS lookup goes on and the typed in domain name is resolved to an IP address and a known location. the requested site is returned to you. So how do you test a domain that is to be hosted at a new location? In the scenario where you do not have a dedicated IP address, the answer is the hosts file on your local PC.
Your local hosts file is checked before any DNS lookup, so adding a domain and the new IP will cause your browser to go to the new location not the old.
So what does a hosts file look like? In the case of Windows XP, something like below, ignoring the comment lines which start with a #. In this case localhost will resolve to the IP address of 127.0.1 which is your local machine.       localhost

Hosts files for other OS are much the same. Ubuntu has entries for the local machine name and IPv6 setup in its default hosts file. localhost mymachine.local mymachine

# The following lines are desirable for IPv6 capable hosts'
::1 ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
ff02::3 ip6-allhosts

Now if you wished to have www.mysite.com resolve to IP address you would add the following line into the hosts file. As simple as that. It’s always a good idea to back up the existing hosts file.     mysite.com

So where is your hosts file? Obviously this varies by operating system. The table below will cover the standard location for common operating systems.

OS Location
Win XP, Vista, 7 & 2003 (32 bit) C:WINDOWSsystem32driversetchosts
Windows 64 bit C:WINDOWSSysWOW64driversetchosts
Mac OS X /private/etc/hosts
Linux distributions /etc/hosts

These lookup entries are often cached, so you will need to either restart networking or even reboot your machine for the new IP address to be used.
Once you have finished your move & testing, and updated the real nameservers for your new location, its always best to remove these temporary lines from the hosts file. That way you find the site, the same way everybody else does, and you may find out early if there are any problems.


Domain name madness

A client came to us for a web site, and they also needed a domain name. Even though the business is based out of Australia the preference was for a .com address. Their name was relatively generic so I knew it was unlikely to be available, and asked them to think about alternatives they would be happy with.

Now of the 10 domain possibilities all 10 are taken. But what was most frustrating about this is, that of the 10, only 4 had actual web sites, with 1 more redirecting to an alternative but similar name. Of the other 5, all had ‘affiliate’ type sites filled with advertising, and three being up for sale. None had a connection with the name of the current owner, and seemed to be purchased for speculative purposes.

My ‘free market’ friends would say this is an optimal solution coming from a very lightly regulated market. To me it is market failure. The likes of goDaddy have helped created such a situation with low cost domain names, that groups and companies can sit on large numbers of domain names in the hope of selling them to a legitimate user down the line.

I know this situation is not going to improve, (unless there is some kind of from left field dot-com bust number 2). But I do have 2 suggestions that will be disliked and ignored.

  • A flat rate charge (tax) per domain name with all proceeds to a charity/worthwhile cause.
  • The use it or lose it principle. Pick a random 13 year old of mySpace, and get him or her to judge if the site is real. If negative you lose the domain name.

Just my 2 frustrated cents.