I've been trying to setup Launchd to block several websites on osX 10.12.2 from 9AM – 3PM Monday-Friday
I set up launchd
to cp /etc/hosts_BLOCKED_sites.txt /etc/hosts
Launchd seems to be copying the file correctly.
$ ls -la /etc/hosts
-rw-r--r-- 1 root wheel 715 Jan 10 15:01 /etc/hosts
$ sudo cat /etc/hosts
##
# 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
255.255.255.255 broadcasthost
::1 localhost
# Blocked sites redirected to 0.0.0.0
0.0.0.0 reddit.com
0.0.0.0 www.reddit.com
0.0.0.0 facebook.com
0.0.0.0 www.facebook.com
However, I can still open the blocked sites after the /etc/hosts
are set to block access.
Any suggestions about why /etc/hosts
isn't blocking access to the sites?
Things I have attempted but have failed to block sites on Chrome:
sudo killall -HUP mDNSResponder
from the command line- I attempted to flush the Chrome DNS cache via
chrome://net-internals/#dns
- I attempted to flush the Chrome Sockets
chrome://netinternals/#sockets
- I switched the hosts file to redirect sites to 127.0.0.1 , it did not block the site and I was told it's faster to redirect to 0.0.0.0
This did not make a difference. All the blocked sites are still accessible via Chrome v55.0.2883.95.
Best Answer
I noticed that your /etc/hosts file has permission 600. The permissions on that file should generally be 644. If your application can't read /etc/hosts then it will just use DNS.