in

WindowsWindows Loving ItLoving It

Windows Host file is used to Resolve Domain Names in the System

Windows Host file is used to Resolve Domain Names in the System. It can be used by network nodes to identify another node. It can be modified by our needs.

Windows Host file

What is Windows Host File and what are its purposes?

The windows host file is an Operating System file that is used to map the hostname to the IP address.  The host file is one of the several system files that assist in network node addressing.  Some OSes take the contents of the host file preferentially because it helps the Domain Name resolution faster.

Every time the user makes a request to a website, the URL using which the request is made contains the domain name of the website.  This domain name is first, resolved for the physical address of the computer where the domain name is hosted and second, redirected to the computer pointed by the physical address.  The second time the user makes the request, the domain name has already been resolved to the physical address and the physical address is used henceforth to make any more request.

Here we can see that there is an overhead of resolving the domain name.  This resolution of the domain name to the actual physical computer that it is hosted on happens at the system level.  That when you make a request to a website using a browser, the host of the website identifies your request at the system level and not as high as the browser level and similarly the system identifies the host at the physical computer level.  From this, it is clear that both the host and the local system identifies each other using the IP address.

As explained earlier, the host and the computer needs to identify each other using an IP address for successful communication and it is an inevitable process for each and every communication.

Now that we have understood the importance of the host resolution, let us see how to use it for our benefits.

Modifying the Host file in Windows:

Modifying the host file in Windows is easy.  The user has to only launch notepad with administrator privileges and add the necessary information in the notepad and save it.  Please note that there are certain rules that the user needs to follow while entering the contents of the host file.  Please follow the given instructions to edit the host file in windows.

  • Press the start button.
press the start button and enter notepad
press the start button and enter notepad
  • Type Notepad.
  • Right-click on the result and select Run as Administrator.
choose run as administrator
choose run as administrator
  • Click on File.
click on file
click on file
  • Click on Open.
select open
select open
  • Enter the following address in the address bar.
C:\Windows\System32\drivers\etc
enter address
enter address
  • Change the file types to all file types.
choose all files
choose all files
  • Now you can see the host file.
open host
open host
  • Select the host file and open it.
  • Enter the following line at the end of the file.
0.0.0.0 www.facebook.com
  • Now save the file and close it.

Following the above steps will help the user edit the Windows host file.  This will now make the browser point to 0.0.0.0 which is a connection timed out error address.  The address is being resolved to the IP address 0.0.0.0 instead of the real IP address tWehat needs to be obtained from the DNS and therefore when we enter www.facebook.com we are seeing the same error that we will see when we enter 0.0.0.0.

These can be used to play tricks on friends but it is recommended to undo the changes to ensure the proper functioning of the systems.

Edit the Host file in Ubuntu:

Here we will show you how to edit the host file in Ubuntu.  As we learned earlier, an IP is pointing to an actual computer.  We can edit the destination IP address of a website using a host file in Linux.  For this tutorial, we are using Ubuntu.

  • Launch the terminal.
launch terminal
launch terminal
  • Enter the following command.

sudo vim /etc/hosts

enter VIM command
enter VIM command
  • This will open the host file in the VIM editor in the terminal.
  • Enter the following line at the end of the file as shown in the image.

test.demo

test demo
test demo

  • Now save the file and quit the editor.

There you go, you have opened a host file, edited it and save it in Linux.

Edit the host file in Mac OS:

The above features of Host file apply to the Mac OS as well.  Use the following instructions on how to edit the host file in Mac OS.

  • Click on Go and click on Go to folder.
select go and go to folder
select go and go to folder
  • In the dialog box, enter /private and press enter.
enter /private
enter /private
  • Right click on etc and select get info.
etc folder
etc folder
select get info
select get info
  • Click on the lock icon.
click on the lock icon
click on the lock icon
  • Enter the user name and password.
enter username and password
enter username and password
  • Click on the plus button shown in the image to add a user.
adding users
adding users
  • Click on the user that needs to be added.
select the users
select the users
  • Click on the select button.
click the select button
click the select button
  • Choose the type of permission as read and write.
add read and write permission
add read and write permission
add read and write permission
add read and write permission
  • Click on the lock icon to lock the changes.
lock the changes
lock the changes
  • Double click on the etc folder.
etc folder
etc folder
  • Right-click the host file and select get info.
get info
get info
  • Click on the lock icon.
click on the lock icon
click on the lock icon
  • Enter the user name and password.
enter credentials
enter credentials
  • Click on the plus icon to add a user.
click on the plus icon
click on the plus icon
  • Select the users and click on the select button.
select user
select user
  • Provide read and write permission for all the necessary users.
read and write permission
read and write permission
  • Double click on the host file to open it for editing.
edit file
edit file
  • Enter the line at the end of the file.

0.0.0.0 www.facebook.com

  • Save the file.
  • Close the file.

If you navigate to facebook.com in your Mac OS it will show an error message until the last line is removed.

Conclusion:

In this post, we learned what is windows host file.  How to edit the Windows host file.  How to use it for our purpose and various other matter.  We also learned how to edit and change the windows host file in other operating systems.  We edited the host file in Ubuntu, Mac also.

For more awesome posts on Host file tips and tricks, please stay tuned to TecKangaroo.com.

windows host file
  • Author Rating
  • Content Quality
  • Content Length
4.5

Leave a Reply

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

Loading…

0

Comments

0 comments