Saturday

Hack the Hosts file to block websites

If you work in a kiosk mode PC say a computer cafe or in a school setting, there are restrictions that you want to enforce when it comes to sites that users can browse. This is specially important when you have a family workstation which little kids can use. Filtering is an option but programs Procon and others can definitely affect system and browser performance. You can also use software like AnyWeblock but it is pretty complicated and time-consuming for busy users to configure.
For starters here’s a nifty way to filter those unwanted websites off your computer. For either Vista and Windows XP, go to the directory C:\Windows\System32\drivers\etc (If C is your default Windows directory). Back-up first your Hosts file in another secured directory. Next, open the Hosts file with Notepad (or any other text editor like Vim or Darkroom). Most probably the file is in Read-Only attribute so you cannot edit the Hosts file. First off, right click on Hosts, click Properties and uncheck Read-Only. Now go open and edit it in Notepad and you will see this:
————————————————————-

————————————————————-
Add the following on its own line in the hosts file below 127.0.0.1 localhost:
127.0.0.1 www.google.com (we will use it as an example).
————————————————————-

————————————————————-

Save the file and make sure you don’t save it in txt extension but choose all files, exit notepad and make sure you check read-only attribute again in properties. Make sure you have cleared your browser history or flush the DNS cache, otherwise you will still see the blocked site. If you cleared the history, fire-up your favorite browser and Voila! You cannot access Google but you can still access other sites. Accessing your listed site will return a Server not found error.
Just a note, For Macintosh fans, just go to /etc/ folder and edit Hosts. In Windows 2k the directory should be C:\Winnt\System32\drivers\etc (if c: is the default drive) in Windows 98 and ME it is C:\Winnt if (if c: is the default drive). In Ubuntu and other Linux distros do this in your favorite text editor echo "127.0.0.1 www.google.com” | sudo tee -a /etc/hosts.
There is a downside if you have a very big list of blocked sites in Hosts file. It can slow down your machine. It seems to affect PCs in the 2k kernel and Vista but not the 9x Windows systems. To avoid slowdowns, do this: Type services.msc in Run dialog box. In the new Services window scroll down to DNS Client and double-click it or just right-click and hit Properties. Click the drop-down for Start-up type then either select Manual or Disabled. Hit ok, exit the window and restart your PC.
Of course, anybody with a depth knowledge in Hosts files and ports like myself, even proxy settings can bypass this technique and browse into any intended website. But what we are concerned here is the easiest way to block sites from common users without them even knowing that somebody blocked their ability to browse specific sites. It is better to have a layer of protection, than nothing at all. Now apply it, test it, and have a happy filtered browsing!

No comments:

Post a Comment

Related Posts Plugin for WordPress, Blogger...