<

Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x

How to simulate a DNS change

Published on
8,690 Points
2,590 Views
1 Endorsement
Last Modified:
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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

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

We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…
In a question here at Experts Exchange (https://www.experts-exchange.com/questions/29062564/Adobe-acrobat-reader-DC.html), a member asked how to create a signature in Adobe Acrobat Reader DC (the free Reader product, not the paid, full Acrobat produ…

Keep in touch with Experts Exchange

Tech news and trends delivered to your inbox every month