Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.
Hello

I need help with blocking a few specific sites on my mac

I know you've got to play around with the host files to block a site and know how to do that and I am able to block almost all the sites I want blocked.
I follow these instructions and i get sites blocked.

=======================================
Use Finder to search for the application Terminal.
In there type: sudo pico /etc/hosts
Enter your root password.
Use the arrow keys to move down to the bottom line and then type:

127.0.0.1 www .thesiteyouwanttoblock.com

There is a space between 127.0.0.1 and www.

User Ctrl+X to exit and Y to Save.

Then type lookupd -flushcache
Quit the Terminal and restart Safari
============================

But there are a few sites that seem to not get blocked.

for example, if I attempt to block Yahoo.com and gawker.com, yahoo will get blocked and gawker.com wont.

I have noticed that the sites that refuse to get blocked start out with 'http://' and do not have the 'www' on their URL. for example, http://gawker.com is how the URL appears on my address bar.

any help/suggestion will be greatly appreciated.

What you are doing is a brute force approach to blocking sites. You are editing your "/etc/hosts" file to add blacklisted sites to it.

The syntax for the hosts file is as follows:
ip_address hostname

If you want to block www .gawker.com and gawker.com, you will need 2 entries on the same line:
127.0.0.1 gawker.com www .gawker.com
127.0.0.1 yahoo.com www .yahoo.com


Note: I had to insert blanks between www and .whatever.com to prevent vbulletin from turning everything into links. :rolleyes:

This isn't foolproof because somebody could always simply enter www2 .yahoo.com and get around your blacklist.

Be very careful when editing /etc/hosts! Do not simply delete /etc/hosts to undo all your changes. You can render your machine incapable of connecting to the local network or the internet! I suggest you look for another approach to blacklisting web sites.

For your reference, here is the default /etc/hosts in case you want to get back to the way it should be...

Code:
##
# Host Database
#
# localhost is used to configure the loopback interface
# when the system is booting.  Do not change this entry.
##
127.0.0.1	localhost

A better blacklist method might be to use a dns based filtering service like opendns. Read everything carefully and be sure to follow all their directions. Also make a note of your current dns settings before chaning over to theirs in case you break something and need to go back. If you break something, you will need access to the net to get help fixing it so proceed methodically and slowly and write everything down so you can go back to where you were before you started. Opendns allows you to block sites by category, ie violence or adult content. You can also whitelist sites that you don't want blocked and blacklist sites you do want blocked.
 
Most routers today have a built-in site blocking mechanism.

Then you can control which computers can access what (based on IP).
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.