Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

wluprocks

macrumors newbie
Original poster
Mar 8, 2012
14
0
I've had success blocking every other website that I am trying to block using my host file, but it does not seem to work for facebook. I have attached an image of my host file so you can see what I do. While attempting to block Facebook I have also searched for every url that facebook might use and put those in and after that did not work I only put in one line for facebook which was just 'facebook.com'. Every time I do this I also flush the cache through Terminal. In case it matters I have Lion.

Also, interestingly as part of my test I attempted to block apple.com, but that did not work. Though I don't care to block apple.com, just facebook
 

Attachments

  • Screen Shot 2012-08-20 at 12.19.00 PM.png
    Screen Shot 2012-08-20 at 12.19.00 PM.png
    37.5 KB · Views: 751

hafr

macrumors 68030
Sep 21, 2011
2,743
9
I've had success blocking every other website that I am trying to block using my host file, but it does not seem to work for facebook. I have attached an image of my host file so you can see what I do. While attempting to block Facebook I have also searched for every url that facebook might use and put those in and after that did not work I only put in one line for facebook which was just 'facebook.com'. Every time I do this I also flush the cache through Terminal. In case it matters I have Lion.

Also, interestingly as part of my test I attempted to block apple.com, but that did not work. Though I don't care to block apple.com, just facebook

I can't offer any answer to your question, but I have one of my own: what's the gain in blocking sites that way?
 

Stooby Mcdoobie

macrumors 6502a
Jun 26, 2012
834
45
I can't offer any answer to your question, but I have one of my own: what's the gain in blocking sites that way?
My only guess would be that he/she does not want his/her kids accessing the sites, but I am curious as well.
 

wluprocks

macrumors newbie
Original poster
Mar 8, 2012
14
0
I can't offer any answer to your question, but I have one of my own: what's the gain in blocking sites that way?

I'm a freelancer and I work out of my house and this helps me be more productive and not waste time online, blocking through Apple's controls really sucks because you have to approve EVERY website and cookie that comes through(you can't ONLY block a few sites) and other services like Selfcontrol you have to reimplement every day. This is an easy, free, and thoughtless way to get me to not waste time once I have it in place. Yes I know how to go through Terminal now, but its enough of a deter for me to be more productive and not easily escape to websites that are easy to waste time on.

ScoobyMcDoo and charlieegan3 I will look into those.
 

wluprocks

macrumors newbie
Original poster
Mar 8, 2012
14
0
Some of the lines in your "hosts" file look wrong. All the ones where you have "http://blah.blah" should be simple hostnames, not URLs. A URL contains a hostname component, but a URL is not a hostname.


Also see this article:
http://thecoredump.org/2011/09/editing-the-hosts-file-in-mac-os-x-lion/

Found by googling mac os hosts file. It's on the first page of results.

Tried that guys technique and it didn't work at first, then I added 'www.' in front of every hostname and it worked for everything except for facebook...this article surfaced yesterday, but its about Windows: http://www.ghacks.net/2012/08/19/you-cant-block-facebook-using-windows-8s-hosts-file/

Could mac be doing the same thing?



I've also attached the new code, much less lines of code so thats nice, but still facebook works even with their fbcdn.net host attached

Edit: Actually strangely the new technique works for mail.yahoo.com but not yahoo.com
 

Attachments

  • Screen Shot 2012-08-20 at 6.02.03 PM.png
    Screen Shot 2012-08-20 at 6.02.03 PM.png
    50.8 KB · Views: 380
Last edited:

Darth.Titan

macrumors 68030
Oct 31, 2007
2,905
753
Austin, TX
Well you're doing something wrong, because the hosts file shouldn't have any http:// or www in it. If you block facebook.com, it will block all subdomains of Facebook including the www subdomain. I know you said in some cases that the blocks didn't work without www, but my point is that they should. All of the addresses you're blocking in your hosts file are blocked just fine without www on my machine.

Perhaps it's an issue with ownership/permissions on your hosts file. What do you get when you ls -la /etc/hosts? Mine shows
Code:
-rw-r--r--  1 root  wheel  949 Aug 20 18:52 /etc/hosts
BTW, the article stating that custom host entries have to be entered at the beginning of the file in Lion is just false. All my custom rules have been added at the end on my machines and work just fine.
 

wluprocks

macrumors newbie
Original poster
Mar 8, 2012
14
0
Well you're doing something wrong, because the hosts file shouldn't have any http:// or www in it. If you block facebook.com, it will block all subdomains of Facebook including the www subdomain. I know you said in some cases that the blocks didn't work without www, but my point is that they should. All of the addresses you're blocking in your hosts file are blocked just fine without www on my machine.

Perhaps it's an issue with ownership/permissions on your hosts file. What do you get when you ls -la /etc/hosts? Mine shows
Code:
-rw-r--r--  1 root  wheel  949 Aug 20 18:52 /etc/hosts
BTW, the article stating that custom host entries have to be entered at the beginning of the file in Lion is just false. All my custom rules have been added at the end on my machines and work just fine.

When I first tried to do this whole thing I had permissions problems and had to repair them. I entered in the code you gave me and it says -rw-r--r--@ 1 root wheel 661 Aug 20 18:27 /etc/hosts

Also, in case anyone is wondering the only experience I have with any form of coding is HTML/CSS and thats just enough to design/maintain my own website...

Do you think this could be a Lion thing?
 

Alameda

macrumors 6502a
Jun 22, 2012
921
543
Seriously, you want to block access to National Public Radio and The Daily Show? Well, there's still the New York Times and ten million more sources of liberal thought.
 

Darth.Titan

macrumors 68030
Oct 31, 2007
2,905
753
Austin, TX
When I first tried to do this whole thing I had permissions problems and had to repair them. I entered in the code you gave me and it says -rw-r--r--@ 1 root wheel 661 Aug 20 18:27 /etc/hosts

Also, in case anyone is wondering the only experience I have with any form of coding is HTML/CSS and thats just enough to design/maintain my own website...

Do you think this could be a Lion thing?

No I don't think it has anything to do with Lion. I run Lion and have not experienced your issues. I hope someone else may have a suggestion.
 

wluprocks

macrumors newbie
Original poster
Mar 8, 2012
14
0
No I don't think it has anything to do with Lion. I run Lion and have not experienced your issues. I hope someone else may have a suggestion.

Thanks for trying to help.

As for users commenting on/noticing my website preferences these are ones that I tend to waste the most time on and I would think anyone who is not a liberal should be happy to help me block those sites ;)
 

hallux

macrumors 68040
Apr 25, 2012
3,437
1,005
Do you have a router for your internet access? How about implementing the controls on that to block the sites you don't want to be able to browse?
 

wluprocks

macrumors newbie
Original poster
Mar 8, 2012
14
0
Do you have a router for your internet access? How about implementing the controls on that to block the sites you don't want to be able to browse?

Thats a good idea except that I work out of my home (I still allow myself to browse those sites during my leisure time) and have a roommate. Thanks for the suggestion though!
 

hallux

macrumors 68040
Apr 25, 2012
3,437
1,005
Thats a good idea except that I work out of my home (I still allow myself to browse those sites during my leisure time) and have a roommate. Thanks for the suggestion though!

Some of the more advanced routers may allow for granular application of the block rule, based on either MAC address or IP address (set your work machine as static if this is the case). Mine might, it's a Netgear WNDR3700 (I think). You should then also be able to set the policy to only apply during certain hours of the day. It'd be in the "Parental Controls" section of most routers, by which logic (if the firmware is any good), it should be able to block on a system-by-system basis rather than on a network-wide basis.

DD-WRT may also be available for your router and might allow this level of blocking (but research before jumping into that route).

Part of what I'm getting at is this; if you're researching (and struggling) the way to do it using the hosts file, look into other means. There's more than one way to solve this problem.
 

wluprocks

macrumors newbie
Original poster
Mar 8, 2012
14
0
Some of the more advanced routers may allow for granular application of the block rule, based on either MAC address or IP address (set your work machine as static if this is the case). Mine might, it's a Netgear WNDR3700 (I think). You should then also be able to set the policy to only apply during certain hours of the day. It'd be in the "Parental Controls" section of most routers, by which logic (if the firmware is any good), it should be able to block on a system-by-system basis rather than on a network-wide basis.

DD-WRT may also be available for your router and might allow this level of blocking (but research before jumping into that route).

Part of what I'm getting at is this; if you're researching (and struggling) the way to do it using the hosts file, look into other means. There's more than one way to solve this problem.

Thanks for the advice. I will talk to my roommate who has access to the router through his computer about that. I think what made me keep trying with this was the fact that facebook was the ONLY site that did not work for me. If half of them worked or it only blocked one I would have searched for a different method right away.

----------

Check out OpenDNS

http://en.wikipedia.org/wiki/Opendns

You could use their domain blocking feature (requires registration and log-in) on your "work" computer by setting their DNS servers to OpenDNS, and using your ISP's DNS servers on the other computers in the house like always.

Thanks, I will look into that.
 

kwikdeth

macrumors 65816
Feb 25, 2003
1,140
1,709
Tempe, AZ
Thanks for the advice. I will talk to my roommate who has access to the router through his computer about that. I think what made me keep trying with this was the fact that facebook was the ONLY site that did not work for me. If half of them worked or it only blocked one I would have searched for a different method right away.

----------



Thanks, I will look into that.


hey i dont know if you're still having this issue but I am trying to accomplish the exact goal (being that, im trying to block time-wasting websites in my home office)... obviously there are always around this stuff but usually my brain kicks in when i start to go to /etc/hosts and i keep myself from removing the listings.

ANYWAY, i too had the same problem with facebook still being accessible despite entries being in the hosts file. after doing some research online, i found that you have to block a whole bunch of related sites, as I believe there is some kind of redirect going on through their login server which is bypassing the hosts block.

Try putting ALL of these entries in your hosts file, reboot and see if you still can access facebook:


127.0.0.1 http://www.facebook.com
127.0.0.1 facebook.com
127.0.0.1 static.ak.fbcdn.net
127.0.0.1 http://www.static.ak.fbcdn.net
127.0.0.1 login.facebook.com
127.0.0.1 http://www.login.facebook.com
127.0.0.1 fbcdn.net
127.0.0.1 http://www.fbcdn.net
127.0.0.1 fbcdn.com
127.0.0.1 http://www.fbcdn.com
127.0.0.1 static.ak.connect.facebook.com
127.0.0.1 http://www.static.ak.connect.facebook.com
 

hallux

macrumors 68040
Apr 25, 2012
3,437
1,005
As an addendum to my previous suggestion.

In playing with my router settings, I found that it will block sites based on keywords in the address. So, on my router if I just enter 'facebook' in the block list it will block ALL links with 'Facebook' in them. Now, this is a Netgear WNDR3700 with the Netgear firmware, others will differ.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.