Browse All Articles > How to simulate a DNS change
One of the typical problems I have experienced is when you have to move a web server from one hosting site to another. You normally prepare all on the new host, transfer the site, change DNS and cross your fingers hoping all will be ok on new server when DNS changes has been propagate (which can take hours).
One of the tricks I do to simulate that DNS has already propagated, even if you haven't still changed your DNS server to point to your new web server, is to edit the file c:\Windows\system32\drivers\etc\hosts.
This file is a text file that acts as a local DNS, where you can see some names and IPs such as:
127.0.0.1 localhost
You can add your new server's IP and your domain to simulate the new configuration on the DNS. After all tests run ok, you can make the changes on your DNS server and then remove the line you added on hosts file. Then wait for the DNS to propagate, but you don't need to cross your fingers as you have already tested your new server with your domain.
This is also userful for new sites too (not only for moving sites from server). You normally buy a domain, and then develop the site, but this is not correct as any development errors will be online for some periods of time.
You can develop your site without buying a domain (but use the domain from your computer where you added the IP of your server and the domain on hosts file) and when development is finish, you can buy the domain so your private domain on hosts files gets public. Also you save to spend to the domain until your site is completed.
Finally, linux and mac has also this file. normally at /etc/hosts on linux, and on /private/etc/hosts on mac.
Hope it helps.
Comments (3)
Commented:
1. On Windows when you edit the text file you must do so with elevated privileges (administrator). Right click on notepad and click Run as Administrator.
2. On a Mac you can only edit the file in a sudo environment. IE: from ssh sudo vi /etc/hosts
Then you would enter in your mac password.
Author
Commented:Commented: