Circumventing DNS Caching
During my recent host switch I ran into a bit of a problem. After I had moved my database and content to the new server and changed the name servers, requests were still be directed toward my old server. The reason for this is that my ISP had not yet updated their DNS record cache thereby causing requests to be directed to the old server. It typically takes several days for a domain to fully propagate; the amount of time it takes for changes to take effect for an individual depends on how often their ISP updates the DNS records. There is, however, a simple way to avoid having to wait for DNS propagation.
(Note that it may be sufficient just to clear your local DNS cache using the command ipconfig /flushdns)
When resolving a domain a host will usually check for an IP address in its local DNS record first. If it cannot find an address it will pass the request on to the DNS server. The problem occurs when neither the local dns record nor the DNS servers’ records are up-to-date. In most cases the DNS servers’ records are out of our hands so the solution is to manually tell the local machine the IP address for a given domain. You can do this by editing the hosts file located in C:\Windows\System32\drivers\etc (the location should be the same for Windows XP/Vista/7). You should edit the file using notepad with administrative privileges. You can do so by selecting your Start Menu -> Accessories and then right clicking Notepad and selecting Run as administrator (This is how I did it using Windows 7).
You can now add the entries for your domain. Each entry should be on its own line and specify an IP address followed by a domain name:
123.45.67.89 mydomain.com
123.45.67.89 www.mydomain.com
You domain should now resolve to the correct host. Note that this does not in any way effect DNS propagation; users who’s DNS servers have not updated their records will still be directed to the old server. You should also note that this method assumes a static IP address; if at some point the IP address of your web server changes the domain will not resolve correctly and the entries will have to be updated or changed. This shouldn’t be much of a problem considering that the entries can (and probably should) be removed once your ISP has updated their DNS records.