Blocking websites using /etc/hosts
September 12, 2007 5:48 PM
Why won't OSX let me block MeFi via the /etc/hosts file?
I'm trying to make one computer "work only" and eliminate web sites on which I waste a lot of time (MeFi being one of them). I have successfully blocked all the websites that I care to EXCEPT MetaFilter. I am running OSX 10.4.10 on a MacBook Core 2 Duo. The following is my /etc/hosts file:
I have tried it with JUST metafilter.com, just www.metafilter.com, etc. with no luck. Rebooting, refreshing, clearing cache, etc. MeFi continues to load normally. Safari, Opera, Firefox have all produced the same results. This is driving me crazy!
I'm trying to make one computer "work only" and eliminate web sites on which I waste a lot of time (MeFi being one of them). I have successfully blocked all the websites that I care to EXCEPT MetaFilter. I am running OSX 10.4.10 on a MacBook Core 2 Duo. The following is my /etc/hosts file:
127.0.0.1 localhost metafilter.com www.metafilter.com metatalk.metafilter.com
255.255.255.255 broadcasthost
::1 localhost
I have tried it with JUST metafilter.com, just www.metafilter.com, etc. with no luck. Rebooting, refreshing, clearing cache, etc. MeFi continues to load normally. Safari, Opera, Firefox have all produced the same results. This is driving me crazy!
The other websites in the file (which I omitted) are all on the same line as well. I tried with separate lines and it still didn't work.
posted by proj at 5:57 PM on September 12, 2007
posted by proj at 5:57 PM on September 12, 2007
What application or tool are you using to edit the /etc/hosts file? Perhaps you're using something that's messing up the line ending characters?
Also: To get the changes to be noticed by the system, without rebooting, do this in Terminal:
posted by xil at 6:00 PM on September 12, 2007
Also: To get the changes to be noticed by the system, without rebooting, do this in Terminal:
sudo lookupd -flushcache(If even a reboot doesn't make it work, I doubt this will help, but it's worth knowing...)
posted by xil at 6:00 PM on September 12, 2007
I'm guessing this is because the resolver is looking at dns first, rather than files. I actually don't know how to change that behavior, but google does.
posted by cactus at 6:04 PM on September 12, 2007
posted by cactus at 6:04 PM on September 12, 2007
No, by default lookupd looks in its cache first, then /etc/hosts, then DNS. I didn't think the cache persisted across reboots, but anything's possible.
You can see this yourself:
posted by xil at 6:10 PM on September 12, 2007
You can see this yourself:
lookupd -configurationreports that "Host Configuration" has a LookupOrder of "Cache FF DNS NI DS". FF == "Flat file" == /etc/hosts.
posted by xil at 6:10 PM on September 12, 2007
This thread is closed to new comments.
posted by xil at 5:55 PM on September 12, 2007