Two years ago, I switched hosting companies from QualityHostOnline to WebHostingBuzz. It's not that I didn't like my previous host. In fact, I thought that my old host was outstanding and I was very happy with them. It was just that (1) I needed more up-to-date IMAP mail servers and (2), with my numerous websites, I needed more bandwidth and space.
I've switched hosts three times already ... which would probably make me a pro! After performing three migrations, on thing is for sure: switching hosts is not a walk in the park. It's actually more like a nightmare. I can't even fathom how full-fledged website administrators handle these migrations!
I dreaded the move last year. For one, I couldn't tell if web site visitors would see old or new server data until Internet propagation (of about three days) took effect on the world. Play, I would have to move my numerous files, settings, email accounts, etc. Worst of all, I would not be able to fully see, configure, and touch up my websites on the new hosting company until the Time-To-Live on my ISP's name servers expired. Most of the time, getting situated in a new host takes longer than Internet propagation itself!
DNS Server IP Address Lookup Requests
While I was switching my name servers and moping over my ordeal, I thought of way to relieve some of the headache of host migration. I remembered that every computer connected online has it's own local "DNS server." It is called the "host file." Nearly every operating system - Windows, Unix, Linux, and Macintosh - uses this file. It is a simple text document that computers refer to before sending out DNS lookup requests. Every time somebody types a domain name in their browser, DNS performs a slew of activities to translate that domain name into an IP address so that it can request a transfer of the actual web page. Imagine this process:
- The user types "hackernotcracker.com" into the browser URL bar.
- The computer first checks it's local DNS cache. It checks the host file and then the browser history to see if there are any IP address records for "hackernotcracker.com".
- If there are no results, it asks the DNS server of the ISP (Internet Service Provder) if it knows what IP address belongs to "hackernotcracker.com."
- If those servers still do not know, they refer the client computer to the main DSN servers of the Internet.
- Those main servers will then point the client to the name servers of the "hackernotcracker.com" domain name. In this case, it is "ns10.ultrawhb.com" or "ns9.ultrawhb.com."
- Finally, one of those name servers will relay the actual IP address of "hackernotcracker.com."
- The client with cache that IP address in the browser history and the ISP will cache that information in the DNS servers so that the process will not have to be so long the next time the IP address of "hackernotcracker.com" is requested.
- Finally, armed with the IP address of the host, the browser can actually fetch data from "hackernotcracker.com."
As you can see in step two, the host file is the first thing referred in a DNS lookup request. While waiting for Internet propagation, you can modify the host file so that your domain points to the correct IP address. This will save you time for making last-minute changes before the web site on the new host goes public.
Host File Locations
The following is a list of host file locations from Wikipedia:
- Linux and other Unix related operating systems - /etc
- Windows 95/Windows 98/Windows Me - C:\windows\
- Windows 2000/Windows XP - %SystemRoot%\system32\drivers\etc\
- Windows NT - C:\winnt\system32\drivers\etc\
- Mac OS - System Folder:Preferences or System folder (format of the file may vary from Windows and Linux counterparts)
- Mac OS X - /etc (uses BSD-style hosts file)
Host File Usage
It is really simple to add entries to the host file. This is the one that I used when I switched hosts:
#THIS IS A COMMENT. ANYTHING AFTER A "#" IS NOT PROCESSED IN A HOST FILE
Each entry starts with the IP address of the host followed by the actual host name. A tab or a space separates the host name and the IP address. As you can see above, I also had to add an entry for each subdomain in order to access the new server.
Propagation of the host file in the operating system is almost instantaneous (at least compared to that of the Internet). Usually, just closing and reopening the browser window does the trick. To make sure the operating system recognizes the change, it is best to either restart the computer.
Word of Caution
Note that this hack only affects your computer. It will not speed up actual propagation time on the Internet. Also remember that after Internet propagation is completed (about 3 days), the host file should be restored to its previous state. This is important because some hosts periodically change IP addresses without client notification. If you forget to update the host file, you will be unable to access your website (with a new IP address) until the host file is restored.