1. Home
  2. /
  3. Web
  4. /
  5. How to make Host file DNS entry on Windows or Linux?

How to make Host file DNS entry on Windows or Linux?

Introduction

This example illustrates how to make entries into your host file on windows or linux based systems and thus allowing you to access hosting servers with any xyz domain name of your imagination or real without acutally having a real domain.

This is very useful when you want to test your website before going live.

Some interesting facts of this example:

  • Test website with actual links without going live.
  • To verify the working of an alias site prior to any DNS changes.
  • Modifying the host file allows the local machine to perform look up at only specified ip location

Add the following two Lines at the end of the host file

0.0.0.1 www.xyz.com
0.0.0.1 xyz.com

Steps for Windows

  • Press the Windows key.
  • Type Notepad in the search field.
  • In the search results, right-click Notepad and select Run as administrator.
  • In Notepad, open the following file: c:\Windows\System32\Drivers\etc\hosts
  • Make the necessary changes to the file.
  • Click File > Save to save your changes.

Steps For Windows 7 and Windows Vista

  • Click Start > All Programs > Accessories.
  • Right-click Notepad and select Run as administrator.
  • Click Continue on the Windows needs your permission UAC window.
  • When Notepad opens, click File > Open.
  • In the File name field, type C:\Windows\System32\Drivers\etc\hosts.
  • Click Open.
  • Make the necessary changes to the file.
  • Click File > Save to save your changes.

Steps for Linux

  • Open a terminal window.
  • Open the hosts file in a text editor (you can use any text editor) by typing the following line:
    sudo nano /etc/hosts
  • Enter your domain user password.
  • Make the necessary changes to the file.
  • Press Control-x.
  • When asked if you want to save your changes, answer y.

Now, you can access your website on your computer with xyz.com in the browser. Remember to replace or use any domain name in place of xyz.

Reviews & Ratings Get your stoe online with Shopify in 60 minutes Shop Now