I'm attempting to block myself from time-wasting websites but changes I make to /etc/hosts. For example:
127.0.0.1 localhost
127.0.1.1 ross-laptop
127.0.0.1 bing.com
# The following lines are desirable for IPv6 capable hosts
::1 localhost ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
ff02::3 ip6-allhosts
I can access bing.com in a freshly opened Chrome or Firefox - why is this not working?
You'll find the browsers and the system will cache things for you. In order to get this to apply right off the bat you should make sure to clear caches and restart your browser. In order to test this out, try performing a dns check from a terminal such as
You should get it replying back from 127.0.0.1. If this works then your hosts file change is good, but it's just cached in your browser.
Have you tried putting the
127.0.0.1
entries on the same line?120.0.0.1 abc bing.com foo
That should work.
Open Terminal (ALT+F2).
Type
sudo -i
in the input field. Check the Run in terminal option. Finally click Run button.Type your password if necessary and press enter. Then enter the following commands.
You will get Gedit Text Editor window.
For Example, if we need to block Facebook add the following lines just after
127.0.0.1 localhost
.By doing this, it will block the site in all browsers including Google Chrome, Chromium, Mozilla.
That's it. When you now open www.facebook.com or facebook.com, you cannot access it. To enable back Facebook, remove the lines we added from the file
/etc/hosts
.Source - Subin's Blog
Besides CragM's solution, remember you can use all 127.x.x.x address for this purpose, don't repeat the same address.
Modifying /etc/hosts looks like a global hack. I'd suggest setting up a local http proxy instead (squid, privoxy etc) and point your browser to use it. This way you would get a more flexible way of managing blacklists at proxy level.