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?

credit stephen phillips host file dns entry

The Hosts file is a text file that allows you to map hostnames to IP addresses. By making changes to the Hosts file, you can effectively override DNS settings on your computer, making it possible to redirect traffic to a specific IP address. 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. Let’s explore how to make host file DNS entry on Windows or Linux.

In this blog, we will discuss how to make Host file DNS entries on Windows and Linux operating systems.

What is Host File DNS Entry?

A Hosts file DNS entry is a line of code in a text file that maps a hostname to an IP address. The Hosts file is a local file on a computer that is used to resolve domain names to IP addresses without consulting a DNS server. When a user types a URL into a web browser, the browser looks up the IP address associated with the hostname by consulting the Hosts file on the user’s computer.

A Hosts file DNS entry typically consists of an IP address followed by a hostname, separated by a space or a tab. For example, if a user wants to map the hostname “example.com” to the IP address “192.0.2.1”, they would add the following line to the Hosts file:

192.0.2.1 example.com

When a user types “example.com” into a web browser, the browser looks up the IP address associated with the hostname in the Hosts file on the user’s computer. If the entry exists in the file, the browser uses the IP address specified in the Hosts file to connect to the server hosting the website. If the entry does not exist in the file, the browser consults a DNS server to resolve the hostname.

Related: How to Choose the Right Content Management System (CMS) for Your Website?

Windows

To make Host file DNS entries on a Windows operating system, you will need to follow these steps:

Step 1: Open Notepad as Administrator

To edit the Hosts file, you must have administrative privileges on your computer. To open Notepad as Administrator, click on the Start menu and type “Notepad” into the search bar. Then, right-click on the Notepad icon and select “Run as Administrator”.

Step 2: Open the Hosts File

In Notepad, click on “File” and then select “Open”. And, in the file browser, navigate to the following directory: “C:\Windows\System32\drivers\etc”. In this folder, you will find the Hosts file. Select the Hosts file and click “Open”.

Step 3: Add DNS Entries

Once the Hosts file is open in Notepad, you can add DNS entries by typing the IP address followed by the hostname. For example, if you want to redirect traffic from google.com to a local server with the IP address 192.168.0.10, you would add the following line to the Hosts file:

192.168.0.10 google.com

You can add as many DNS entries as you need, each on a separate line.

Step 4: Save Changes

After you have added the necessary DNS entries, click on “File” and select “Save” to save the changes to the Hosts file.

Also read: How to Implement Auto Suggestion in WordPress Search?

Linux

To make Host file DNS entries on a Linux operating system, you will need to follow these steps:

Step 1: Open Terminal

To edit the Hosts file, you must have root access on your Linux system. Open a terminal window and type “sudo” before any commands that require root access.

Step 2: Open the Hosts File

In the terminal window, type the following command to open the Hosts file:

sudo nano /etc/hosts

This will open the Hosts file in the Nano text editor.

Step 3: Add DNS Entries

Once the Hosts file is open in Nano, you can add DNS entries by typing the IP address followed by the hostname. For example, if you want to redirect traffic from google.com to a local server with the IP address 192.168.0.10, you would add the following line to the Hosts file:

192.168.0.10 google.com

You can add as many DNS entries as you need, each on a separate line.

Step 4: Save Changes

After you have added the necessary DNS entries, press Ctrl+X to exit Nano. When prompted to save changes, type “Y” and press Enter to save the changes to the Hosts file.

Related: How to Use Custom Social Icons in a HubSpot Email Template?

Testing Host File DNS Entries

After making changes to the Hosts file, it’s important to test whether the DNS entries are working as expected. To do this, you can open a web browser and navigate to the hostname that you have redirected. If the Hosts file DNS entry is working, the browser will display the website hosted on the redirected IP address.

It’s important to note that changes made to the Hosts file will only affect the computer on which the changes were made. Other computers on the same network will not be affected by these changes.

Related: How to Implement Infinite Pagination in WordPress?

Steps to Make Host File DNS Entry 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.

Related: How to Get Products from Shopify Store to Display on Other Non-Shopify Stores?

Steps to Make Host File DNS Entry 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.

Related: How to Enable Shopify Buy Now Payment Buttons?

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.

Also read: How to Implement Next and Previous Article Navigation Link With Title?

Conclusion

Making Host file DNS entries is a simple and effective way to override DNS settings on your computer. By redirecting traffic to a specific IP address, you can ensure that your computer is accessing the correct website or server. While it’s not recommended to make frequent changes to the Hosts file, it can be a useful tool for troubleshooting and testing website or server configurations.

It’s also important to remember that the Hosts file is just one of many ways to manage DNS settings on your computer. If you are experiencing DNS-related issues or need to make more extensive changes to your DNS settings, it’s recommended to consult with a network administrator or IT professional.

In conclusion, making Host file DNS entries on Windows or Linux is a simple and effective way to override DNS settings on your computer. By following the steps outlined in this article, you can easily add DNS entries to the Hosts file and ensure that your computer is accessing the correct website or server. Just remember to test your changes and use caution when making modifications to the Hosts file, as it can affect the functionality of your computer and other network devices.

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