How to Block Websites Using Host File

On occasion you will need to edit the hosts file on your machine. Sometimes because of an attack or prank, and others so that you can simply and freely control access to websites and network traffic.
hosts files have been in use since ARPANET. They were used to resolve hosts names before DNS. hosts files

would be massive documents used to aide the network name resolution.
Microsoft kept the hosts file alive in Windows networking which is why it varies very little whether used in Windows, OS X or Linux. The syntax stays mostly the same across all platforms. Most hosts files will have several entries for loopback. We can use that for the basic example for the typical syntax.
The first part will be the location to redirect the address to, the second part will be the address that you will want to redirect, and the third part is the comment. They can be separated by a space, but for ease of reading are typically separated by one or two tabs.

Before Reading this Article you must read
How To Access Host File

Once notepad is open you can edit the file. In this example we will block Facebook. To do this just enter in the following after the # mark.


0.0.0.0    www.facebook.com



Now that you have edited your Hosts file make sure to save it.




Now notice if we try to access Facebook in IE we can’t get to the page.



We also were not able to get to it in Google Chrome… (check notes at the end). Also for more info on editing your Hosts file.



Snow Leopard (OS X 10.6)

In Snow Leopard, accessing the hosts file is very similar to Ubuntu. Begin in terminal and use your favorite editor, even is you wish to call a GUI text editor, it is easier to do so from terminal.

The file will look a bit more like Windows, only with a little less explanation. Again we are going to redirect Facebook.


This time it seems that 0.0.0.0 is a loopback and will direct you to the computers Apache test page.



Notes:

There are some things to note from this walkthrough that we did notice. When tested it, Chrome did not use the hosts file in any operating system but we were able to block Facebook in Chrome by adding www.facebook.com. Also, make sure to place and extra line after the last entry for the section.
This should get you started in understanding the Hosts file and how it can help protect your computer. You can use it to block sites that you don’t want a PC to be able to access. If you have more suggestions for any of the operating systems we coved, then leave a comment and let us know!

1 comment:

  1. efore Reading this Article you must read How To Access Host File

    Once notepad is open you can edit the file. In this example we will block Facebook. To do this just enter in the following after the # mark.
    how-to access host file

    ReplyDelete