in

WindowsWindows Loving ItLoving It

Windows Host File can be used for tricking friends by using local DNS resolution

Windows Host File can be used for editing DNS resolution. In this post we will show you how to do that in Windows 10/8.1/8/7 Ubuntu and Mac OS

windows host file edit

The host file is one of the system facilities that assists in addressing several network nodes.  It serves the functionality of translating the human-friendly domain names to a numeric IP address.  On some OSes, the content of the host file is used preferentially over other name resolution methods as this is quicker.  And many OSes implements name service switches with nsswitch.conf.  Generally, the host file is a text file that contains the IP address of the Domain name against the Domain name.

Instructions on how to use the windows host file:

  • This file contains the mappings of IP addresses to hostnames.
  • Each entry should be kept on an individual line.
  • The IP address should be placed in the first column followed by the corresponding hostname.
  • The IP address and the hostname should be separated by at least one space.
  • Additionally, comments may be inserted on individual line using #

Now that we have understood what is the purpose the windows host file and how it works, let us see how to use it in Windows 10/8.1/8, Linux, Mac, and other operating systems.

Windows Host file in Windows 10:

In this example, we will show you how to use the Windows Host File in Windows 10.  For editing the windows host file, the user must launch notepad in administrator privileges.  The following instructions will guide you with all the necessary steps.

  • Press the start button.
start button
start button
  • Type Notepad
type notepad
type notepad
  • Right-click on the result that is shown in the image and select, run as administrator.
run as administrator
run as administrator
  • Click on file.
click on file
click on file
  • Click on open.
click on open
Click on open
  • Now enter the following address.
c:\windows\system32\drivers\etc\
path for host file
path for host file
  • Now change the file type to all files.
all files
all files
  • Select the host file as shown in the image.
select hosts file
select hosts file
  • This will open the windows host file.
  • Enter the following line at the end of the file.
0.0.0.0 www.facebook.com
  • Save the file and close it.
  • Launch Internet Explorer and enter www.facebook.com in the address bar.
  • You will get the following error.
browser error message
browser error message
  • Close chrome and enter www.facebook.com and you will see the same error.
  • Now remove the entry in the same file and save it.
  • You will see that Facebook is working fine.

Here we learned how to edit and change the host file in order to manipulate the DNS resolution in the uses computer.  Please read on to see how to do it in other operating systems also.

Windows Host file edit in Windows 8.1/8:

  • Press the start button.
  • Start typing notepad.
  • Right-click the result and run as administrator.
  • Now click on the file.
  • Click on Open.
  • Enter the following path in the address bar.
c:\windows\system32\drivers\etc\
  • Now enter the following line at the end of the file.
0.0.0.0 www.facebook.com
  • Save the file and close it.
  • If you go to Internet Explorer and enter www.facebook.com you will receive the following error.

Windows Host file edit in Windows 7:

  • Open notepad with administrative privileges.
  • Press Ctrl+o
  • In the address bar, enter the following path.
c:\windows\system32\drivers\etc\
  • Now select the file type as all files.
  • Now open the host
  • Enter the following line in the end.
0.0.0.0 www.facebook.com
enter 0.0.0.0
enter 0.0.0.0
  • Save the file.
save and close the file
save and close the file
  • Close the file.

This will prevent loading facebook with the following error.

IE error message
IE error message

Host file editing in Ubuntu:

In Ubuntu and most Linux distributions, the host file is located in the root directory.  The root directory requires users to use root privileges.  That is why the command is preponed with sudo.  The host file is located in the /etc/ directory.  Use the following instructions to edit the host file in Linux and Ubuntu.

  • Launch the terminal in Ubuntu.
  • Enter the following command and press enter.
sudo vim /etc/hosts
Ubuntu command
Ubuntu command
  • This will open the file.
  • Please note that there is a section for IPv6 and we are not going to use it.
  • Add the following line under the last line for the section in IPv4 as shown in the figure.
0.0.0.0 www.facebook.com
enter 0.0.0.0
enter 0.0.0.0
  • Press Ctrl+x it will ask you to save the file or not.
  • Choose to save the file and exit.
  • Launch the browser and check www.facebook.com
host error
host error

Edit Host file in Mac OS:

In Mac OS, editing the host file is similar to editing the host file in Ubuntu.  The contents look more like windows host file.  Just like our previous steps, we will resolve the Domain Name www.facebook.com to 0.0.0.0.  In Mac OS the IP 0.0.0.0 is a loopback address.  It is pointing to the local apache server.  Use the following instructions to see this happen.

  • Launch the terminal.
  • Enter the following command in the terminal.
sudo vim /etc/hosts
mac os command
mac os command
  • Enter the following line at the end of the file and press enter.
0.0.0.0 www.facebook.com
enter 0.0.0.0
enter 0.0.0.0

  • Save the file and close it.

Conclusion:

The Windows host file is used for DNS resolution in the user’s computer.  This file can be used to give predefined IP address for a Domain name.  But be careful as it will prevent the access of the website by any means from the computer.

In this post, we learned to edit the file in Windows, Linux, Mac OS.  These methods are generally applicable to most of the OSes.  If you want more such awesome posts, please stay tuned to TecKangaroo.

Windows Host File Edit
  • Author Rating
  • Content Quality
  • Content Accuracy
4.5

Leave a Reply

Your email address will not be published. Required fields are marked *

Loading…

0

Comments

0 comments