1

I am trying to use /etc/hosts on my mac to block infamous scumbag sites like mackeeper.com and com-cleaner.systems from ever loading again in popups.

While doing that I've found these entries on my hosts file:

##
# 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

so I have added these...

127.0.0.1  mackeeper.com
127.0.0.1  www.mackeeper.com
127.0.0.1  mackeeperapp.zeobit.com
127.0.0.1  mackeeperapp2.mackeeper.com
127.0.0.1  *.mackeeper.com
127.0.0.1  activate.adobe.com
127.0.0.1  practivate.adobe.com
127.0.0.1  *.com-cleaner.systems
127.0.0.1  *.bet.pt

and all these sites continue to load fine even after a restart.

I have tried also adding the same lines with fe80::1%lo0 and ::1 without success.

Any ideas?

  • 1
    Though this will not answer your question, you could install some pop-up blocker extension plus an ad-blocker. – LinuxSecurityFreak Dec 10 '17 at 19:22
  • Please edit question with contents of /etc/nsswitch.conf. – dirkt Dec 10 '17 at 20:40
  • 4
    Wildcards like *.bet.pt will not work in /etc/hosts. – Ulrich Schwarz Dec 10 '17 at 20:45
  • @UlrichSchwarz - brilliant. The problems were the wildcards. Please convert your comment to an answer so I can accept. – SpaceDog Dec 10 '17 at 21:55
5

macOS has a DNS cache, and if the IP addresses of the problem sites are already in your DNS cache, editing /etc/hosts won't have an immediate effect.

The procedure for flushing the DNS cache is annoyingly version-dependent:

https://help.dreamhost.com/hc/en-us/articles/214981288-Flushing-your-DNS-cache-in-Mac-OS-X-and-Linux

  • 10.4: lookupd -flushcache
  • 10.5, 10.6: dscacheutil -flushcache
  • 10.7, 10.8: sudo killall -HUP mDNSResponder
  • 10.9: dscacheutil -flushcache; sudo killall -HUP mDNSResponder
  • 10.10.1 .. 10.10.3: sudo discoveryutil udnsflushcaches
  • 10.10.4+: sudo dscacheutil -flushcache; sudo killall -HUP mDNSResponder
  • 11: sudo killall -HUP mDNSResponder
  • 12+: sudo killall -HUP mDNSResponder; sudo killall mDNSResponderHelper; sudo dscacheutil -flushcache
|improve this answer|||||
  • Thank you for actually including the solution for people who (like me) haven't upgraded past 10.4! – Fox Dec 13 '17 at 20:21
  • I've learned that it's useful to quote the essential parts of a linked solution, in case the linked article goes away someday. This way the answer will also work stand-alone even if the link becomes outdated. – telcoM Dec 13 '17 at 23:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.