Do you want to keep yourself or your employees from wasting time on certain websites? Maybe you don’t want your child to see some of the virtual trashbins of the internet? By editing the /etc/hosts systems file, you can block any website, and here’s how to do it.

Easily block websites from being accessed in Safari, Firefox, or the Chrome browser

* Launch the Terminal and type the following command, you will need to enter a root password:
sudo pico /etc/hosts
* Using your arrow keys navigate down and create a new line in the file
* You can block any website by following the format of:
127.0.0.1 facebook.com
127.0.0.1 myspace.com
127.0.0.1 twitter.com
* Exit and save /etc/hosts by hitting Control+O and then the Return key

Next you will need to flush your DNS cache for the changes to take effect, this is done through the Terminal as well with the following command in 10.6:

sudo dscacheutil -flushcache

block websites mac safari firefox chrome Unblocking the sites is simply a matter of removing them from the /etc/hosts file and flushing your DNS cache again. This whole thing works by pointing the domains you want blocked to your machines localhost (127.0.0.1). If you wanted to be tricky you could point the blocked domain to a different IP address entirely, like 74.125.19.103 (Google.com in English). For this purpose, you can get any websites IP address by typing nslookup domain.com into the Terminal.

If you want a network wide solution to blocking websites or any other network services, you’d need to modify your routers settings.

Note: This tip was covered a few years back with instructions to block websites on a Mac. I’ve gotten enough messages about the topic that I felt it was worth repeating, even though the methodology is the same.


Via http://feedproxy.google.com/~r/osxdaily/~3/RmGNsecVhXk/

Related Posts with Thumbnails
Tagged with:  

Comments are closed.

WordPress主题