One of the most powerful tools available to anyone working on their site during a migration is their computer’s “hosts” file. The hosts file is used to map domain names to IP addresses, and can be used as an alternative to DNS. It also allows you to specify the IP address to which a website resolves on your computer, regardless of what may be published in the site’s DNS zone file.

Why Edit Your Hosts File?

Modifying your hosts file lets you view and test a site on one server while the rest of the world continues to see the site on another. That makes it an essential tool when migrating your website. With this method, you’re able to ensure that:

  • Everything on the site works as expected on the new server before you update the DNS records
  • The visitors to your existing website will not be affected by any potential issues related to different server environments before you’ve had a chance to resolve them

Example

It’s actually a very simple process. Let’s take a look at an example hosts file:

127.0.0.1       localhost
 255.255.255.255    broadcasthost
 ::1             localhost
 123.123.123.123       liquidweb.com www.liquidweb.com

In this case, the first three entries are defaults used to configure the local network interface. You may have more or less local entries in your hosts file. You do not need to worry about them other than to note their presence. Any custom entries will go at the bottom of the file, and in this case, you can see that we have added a custom entry to the end of the file already:

123.123.123.123       liquidweb.com www.liquidweb.com

My custom entry specifies that any request made from my computer (via a web browser or SSH, email, or FTP client) for liquidweb.com or www.liquidweb.com will be directed to the IP address I’ve specified: 123.123.123.123. To redirect your specific request, you must add your own custom entry to the end of your file using the same format.

The line for your custom entry will consist of three elements.

  • The IP address of the server to which you want the domain name to resolve on your computer
  • A tab or space
  • The domain name(s) meant to resolve to the specified IP address

If you’re migrating to a Liquid Web server, your migration technician will supply you with the information to add. Simply copy and paste the line into your hosts file. If your migration involves multiple IP addresses, you will have one line for each IP address, regardless of how many domain names share it.

#getting started #tutorials #apple #dig #dns #hosts #hosts file #linux

How to Edit Your DNS Hosts File
1.85 GEEK