<

Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x

How to simulate a DNS change

Published on
8,785 Points
2,685 Views
1 Endorsement
Last Modified:
Approved
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.
1
Comment
Author:gplana
  • 2
3 Comments
 
LVL 7

Expert Comment

by:Robert Saylor
A few notes:

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.
0
 
LVL 15

Author Comment

by:gplana
You are right. On Mac (and Linux) you should use sudo. On Windows 7 and above you should execute with elevated privileges or otherwise you can't save the file. Thanks for your comment! :)
0
 
LVL 7

Expert Comment

by:Robert Saylor
No problem. Well mostly Mac is sudo. RedHat based including centOS is not sudo by default where Ubunto is sudo by default.
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Join & Write a Comment

This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …
Enter Foreign and Special Characters Enter characters you can't find on a keyboard using its ASCII code ... and learn how to make a handy reference for yourself using Excel ~ Use these codes in any Windows application! ... whether it is a Micr…
Suggested Courses
Course of the Month14 days, 13 hours left to enroll

Keep in touch with Experts Exchange

Tech news and trends delivered to your inbox every month