Saturday, July 21, 2007

How to block sites

In this blog I will describe how you can prevent all the browsers in your system from opening certain sites.

Requirements:
  1. You should be logged in as the administrator.
  2. You should know the exact URL address of the websites you want to block.
How To:
  1. Open notepad or your favorite editor(Vim/Emacs/etc)
  2. Open the file C:\WINDOWS\system32\drivers\etc\hosts
  • Look for the line containing " 127.0.0.1 localhost "
  • Add another line below it :
127.0.0.1 www.sitename.com


Please note that you need not add http:// before the sitename.

For the more inquisitive ones :)

Basically the hosts file specifies the IP address for the hostname/address.
So when you actually type 127.0.0.1 in front of the websites name , you are indirectly telling the machine to look into the IP address 127.0.0.1 whenever the web page URL is typed in a browser.But 127.0.0.1 is the address of your own machine so the browsers fail to load the actual page.So in other words you are not blocking but just misleading ;)

Difference of opinion:

In case you feel that I have mentioned anything which is TECHNICALLY wrong then please do revert back to me, I would be glad to correct my/your mistakes/doubts.