Tutorial

How To Emulate Your Hosts File (DNS Trick)

The hosts file is used by your local computer’s operating system to resolve hosts names to IP addresses. It is a plain text file and is usually named hosts.

This file is really useful when you have just moved a website to a new hosts as you may want to know how your site works on the new server at the first time so you can troubleshoot any problem or error on your website before going live and update the DNS name servers or a records for your domain.

How to use the hosts file is pretty simple, let’s say we have the DNS named clickittech.com and you want it to point to the IP address 10.10.10.1, you have to look for the hosts file on you operating system (see instructions below) and add a line with the next format:

10.10.10.1 clickittech.com www.clickittech.com

And then just save the configuration on the file, once this is done, now we have to open a browser and type the domain in it, and you will be pointed to the IP specified on the hosts file, to see how the site is behaving in this new server, if you want to stop resolving to the new IP you only have to erase or comment the line added.

Windows XP/7/8/

  • Go to “My Computer” or “Computer” and go to your local disk of Windows.
  • Go to Windows and Scroll down until you locate your System32 Folder.
  • Open the Drivers folder and go to the “etc” folder.
  • There you will see your “hosts” file.
  • Double Click on it and select Notepad to run it.
  • Go to the ips which are not 127.0.0.1. There you can add any ip which you want to emulate the DNS change.
  • Add a new line in the hosts file with the format of“ip-address domain.com www.domain.com”
  • Save your hosts file in Desktop
  • Remove the “.txt” extension from the hosts Desktop file
  • Go to your etc folder and replace the hosts file
  • (if you don’t remember how to go “etc” folder Follow steps 1-4)

Linux and MAC OS:

  • Sudo nano /etc/hosts
  • Type your password
  • You will see your host file
  • Use arrow keys or mouse to move thru text
  • Add a new line in the hosts file with the format of “ip-address domain.com www.domain.com”
  • Ctrl+X to exit from nano
  • Press Y = Yes

Or You can use this MAC tool: Gas Mask It allows you to easily edit the hosts file.

Restart Browser

In order for the hosts file settings to take effect, please restart the browser. You can now access your website hosted using the domain name.

As we can see in this blog, using the hosts file is a secure and easy way to test our migrations and troubleshoot any possible problem, here at ClickIT we implement this practices to migrate our sites in the cloud, combining high security, scalability, and redundancy. ClickiT aims to provide secure and high-quality service for the satisfaction and comfort of our clients. Our Agile Team also includes leading IT experts in application migration in the cloud, web security, web development, IT automation, clustering, scalability and near-shore support. Contact Us Now!

Disqus Comments Loading...
Published by
DevOps Guy

Recent Posts

Web Application Architecture: The Latest Guide 2024

When a user logs on to this desktop/laptop or mobile, opens a browser and types…

1 day ago

Low-Code Development for Business Success

Low-code development is great news for businesses, reducing time-to-market for apps, and allocating costs more…

4 days ago

PHP Latest Versions Guide | Video

So, have you caught wind of the latest PHP update? If you not, this PHP…

2 weeks ago

ECS vs EC2: Choosing the Right AWS Service for Your Workloads

When it comes to AWS ECS vs EC2, the choice boils down to your specific…

3 weeks ago

Netflix Architecture | A Look Into Its System Architecture

Ever wondered how Netflix keeps you glued to your screen with uninterrupted streaming bliss? Netflix…

3 weeks ago

Snowflake vs Redshift: Key Differences

In today's busy world, where information is important, handling data well is crucial for success.…

1 month ago