2
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.
Try
echo "" >> /etc/hosts_BLOCKED_sites.txt
. Also what doesif grep -E -rl '\r' /etc/hosts_BLOCKED_sites.txt ; then echo windows; else echo unix; fi
print? – Camden Narzt – 2017-01-06T21:53:19.1271Why would I want to pass an empty string to /etc/hosts_BLOCKED_sites.txt ? – BryanWheelock – 2017-01-06T22:58:16.887
unix was returned from the conditional statement. – BryanWheelock – 2017-01-06T22:58:54.977
1The empty string gets appended to the end (thus the double angle brackets) to ensure the last line is a newline. – Camden Narzt – 2017-01-06T23:01:35.213
It might be helpful if you could check with a packet analyzer (tcpdump), for instance) whether DNS queries for the supposedly blocked sites leave your pc or not. Also, it might be helpful to see exactly the DNQ query for any of the blocked site, say reddit.com. – MariusMatutiae – 2017-01-10T08:02:15.567