How to Edit Your DNS Hosts File

How to Edit Your DNS Hosts File

The hosts file is used to map domain names to IP addresses, and can be used as an alternative to DNS. Learn how to modify your host file on Mac, Windows, and Linux.

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

Bootstrap 5 Complete Course with Examples

Bootstrap 5 Tutorial - Bootstrap 5 Crash Course for Beginners

Nest.JS Tutorial for Beginners

Hello Vue 3: A First Look at Vue 3 and the Composition API

Building a simple Applications with Vue 3

Deno Crash Course: Explore Deno and Create a full REST API with Deno

How to Build a Real-time Chat App with Deno and WebSockets

Convert HTML to Markdown Online

HTML entity encoder decoder Online

Tutorial: Getting Started with R and RStudio

Get your R programming journey off on the right foot with this RStudio tutorial that walks through everything from installation to best practices.

Configure DNS over TLS on Linux Mint to Protect DNS Privacy

Configure DNS over TLS on Linux Mint to Protect DNS Privacy - This tutorial will be showing you how to protect your DNS privacy on Linux Mint with DNS over TLS. We will use a tool called stubby, but first, let me tell you why DNS is not secure.

User Administration in Linux - Linux Tutorial - Linux Training

User Administration in Linux - Linux Tutorial - Linux Training

Package Management in Linux - Linux Tutorial - Linux Training

Package Management in Linux - Linux Tutorial - Linux Training

Bootstrap Tutorial 2020 - Getting Started

In this video, I'll be showing you how to quickly get started with Bootstrap. 🔴 Subscribe for more https://www.youtube.com/channel/UCMA8gVyu_IkVIixXd2p18NQ?s...