Register FAQ / Rules Forum Spy Search Today's Posts Mark Forums Read
Go Back   MacRumors Forums > Apple Systems and Services > Mac Basics and Help

Reply
 
Thread Tools Search this Thread Display Modes
Old Aug 20, 2012, 12:24 PM   #1
wluprocks
macrumors newbie
 
Join Date: Mar 2012
Block Facebook using Host file

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
Attached Thumbnails
Click image for larger version

Name:	Screen Shot 2012-08-20 at 12.19.00 PM.png
Views:	371
Size:	37.5 KB
ID:	353797  
wluprocks is offline   0 Reply With Quote
Old Aug 20, 2012, 12:50 PM   #2
ScoobyMcDoo
macrumors 65816
 
Join Date: Nov 2007
Location: Austin, TX
You might consider using a service like opendns to do this.
ScoobyMcDoo is offline   0 Reply With Quote
Old Aug 20, 2012, 12:50 PM   #3
hafr
Banned
 
Join Date: Sep 2011
Quote:
Originally Posted by wluprocks View Post
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?
hafr is offline   0 Reply With Quote
Old Aug 20, 2012, 01:03 PM   #4
d4rkc4sm
macrumors 6502
 
Join Date: Apr 2011
apple is a liberal company, should block apple.com
d4rkc4sm is online now   0 Reply With Quote
Old Aug 20, 2012, 02:15 PM   #5
Stooby Mcdoobie
macrumors 6502a
 
Stooby Mcdoobie's Avatar
 
Join Date: Jun 2012
Location: Dallas, TX
Quote:
Originally Posted by hafr View Post
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.
Stooby Mcdoobie is online now   0 Reply With Quote
Old Aug 20, 2012, 02:18 PM   #6
charlieegan3
macrumors 68020
 
charlieegan3's Avatar
 
Join Date: Feb 2012
Location: U.K
They use websense at guantanamo bay.
charlieegan3 is offline   0 Reply With Quote
Old Aug 20, 2012, 02:59 PM   #7
wluprocks
Thread Starter
macrumors newbie
 
Join Date: Mar 2012
Quote:
Originally Posted by hafr View Post
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 is offline   0 Reply With Quote
Old Aug 20, 2012, 03:10 PM   #8
chown33
macrumors 603
 
Join Date: Aug 2009
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/editi...mac-os-x-lion/

Found by googling mac os hosts file. It's on the first page of results.
chown33 is offline   0 Reply With Quote
Old Aug 20, 2012, 06:00 PM   #9
wluprocks
Thread Starter
macrumors newbie
 
Join Date: Mar 2012
Quote:
Originally Posted by chown33 View Post
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/editi...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...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
Attached Thumbnails
Click image for larger version

Name:	Screen Shot 2012-08-20 at 6.02.03 PM.png
Views:	217
Size:	50.8 KB
ID:	353833  

Last edited by wluprocks; Aug 20, 2012 at 06:28 PM. Reason: Update without bump
wluprocks is offline   0 Reply With Quote
Old Aug 20, 2012, 07:00 PM   #10
Darth.Titan
macrumors 68020
 
Darth.Titan's Avatar
 
Join Date: Oct 2007
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.
Darth.Titan is offline   0 Reply With Quote
Old Aug 20, 2012, 09:37 PM   #11
wluprocks
Thread Starter
macrumors newbie
 
Join Date: Mar 2012
Quote:
Originally Posted by Darth.Titan View Post
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?
wluprocks is offline   0 Reply With Quote
Old Aug 20, 2012, 09:44 PM   #12
Alameda
macrumors 6502
 
Join Date: Jun 2012
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.
Alameda is offline   0 Reply With Quote
Old Aug 20, 2012, 11:05 PM   #13
Darth.Titan
macrumors 68020
 
Darth.Titan's Avatar
 
Join Date: Oct 2007
Quote:
Originally Posted by wluprocks View Post
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.
Darth.Titan is offline   0 Reply With Quote
Old Aug 20, 2012, 11:29 PM   #14
wluprocks
Thread Starter
macrumors newbie
 
Join Date: Mar 2012
Quote:
Originally Posted by Darth.Titan View Post
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
wluprocks is offline   0 Reply With Quote
Old Aug 21, 2012, 12:09 AM   #15
Vizin
macrumors 6502a
 
Join Date: Jul 2007
.

Last edited by Vizin; Feb 28, 2013 at 02:16 AM.
Vizin is offline   0 Reply With Quote
Old Aug 21, 2012, 12:28 AM   #16
chown33
macrumors 603
 
Join Date: Aug 2009
Well, if technical means fail, there's always self-restraint. And that's not just the whiskey talking.
chown33 is offline   0 Reply With Quote
Old Aug 21, 2012, 12:33 AM   #17
wluprocks
Thread Starter
macrumors newbie
 
Join Date: Mar 2012
Quote:
Originally Posted by chown33 View Post
Well, if technical means fail, there's always self-restraint. And that's not just the whiskey talking.
If only that wasn't wishful thinking...I'm pretty much addicted to the internet
wluprocks is offline   0 Reply With Quote
Old Aug 21, 2012, 05:20 AM   #18
hallux
macrumors 65816
 
Join Date: Apr 2012
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?
__________________
2012 15" MBP, 2.3 GHz, 16 GB RAM, 750 GB Samsung EVO SSD, Hi-Res glossy
2012 Mac Mini 2.5, 8 GB RAM, 120 GB OCZ Vertex 3 SSD (soon, need the install kit)
hallux is offline   0 Reply With Quote
Old Aug 21, 2012, 10:26 AM   #19
wluprocks
Thread Starter
macrumors newbie
 
Join Date: Mar 2012
Quote:
Originally Posted by hallux View Post
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!
wluprocks is offline   0 Reply With Quote
Old Aug 21, 2012, 11:07 AM   #20
djharris
macrumors member
 
Join Date: Jun 2009
Location: Virginia, USA
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.
__________________
--Dave
13" MBP Mid-2009, Mid 2010 Mac Mini Server, 64GB Wi-fi iPad 3rd Gen., Verizon Wireless, HTC Thunderbolt (Rooted, Skyraider ROM)
djharris is offline   0 Reply With Quote
Old Aug 21, 2012, 11:49 AM   #21
hallux
macrumors 65816
 
Join Date: Apr 2012
Quote:
Originally Posted by wluprocks View Post
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.
__________________
2012 15" MBP, 2.3 GHz, 16 GB RAM, 750 GB Samsung EVO SSD, Hi-Res glossy
2012 Mac Mini 2.5, 8 GB RAM, 120 GB OCZ Vertex 3 SSD (soon, need the install kit)
hallux is offline   0 Reply With Quote
Old Aug 22, 2012, 07:01 PM   #22
wluprocks
Thread Starter
macrumors newbie
 
Join Date: Mar 2012
Quote:
Originally Posted by hallux View Post
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.

----------

Quote:
Originally Posted by djharris View Post
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.
wluprocks is offline   0 Reply With Quote
Old Mar 25, 2013, 08:56 PM   #23
kwikdeth
macrumors 6502
 
Join Date: Feb 2003
Location: Tempe, AZ
Quote:
Originally Posted by wluprocks View Post
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 www.facebook.com
127.0.0.1 facebook.com
127.0.0.1 static.ak.fbcdn.net
127.0.0.1 www.static.ak.fbcdn.net
127.0.0.1 login.facebook.com
127.0.0.1 www.login.facebook.com
127.0.0.1 fbcdn.net
127.0.0.1 www.fbcdn.net
127.0.0.1 fbcdn.com
127.0.0.1 www.fbcdn.com
127.0.0.1 static.ak.connect.facebook.com
127.0.0.1 www.static.ak.connect.facebook.com
kwikdeth is offline   0 Reply With Quote
Old Mar 26, 2013, 09:29 AM   #24
hallux
macrumors 65816
 
Join Date: Apr 2012
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.
__________________
2012 15" MBP, 2.3 GHz, 16 GB RAM, 750 GB Samsung EVO SSD, Hi-Res glossy
2012 Mac Mini 2.5, 8 GB RAM, 120 GB OCZ Vertex 3 SSD (soon, need the install kit)
hallux is offline   0 Reply With Quote

Reply
MacRumors Forums > Apple Systems and Services > Mac Basics and Help

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Similar Threads
thread Thread Starter Forum Replies Last Post
iPhone: Host File HankHowdy Jailbreaks and iOS Hacks 3 Mar 3, 2014 10:39 PM
etc host file problem marceff Mac Basics and Help 5 Dec 4, 2013 05:37 AM
Host file Terminal Password DeafRaiders OS X 1 Nov 29, 2012 06:34 AM
iPhone 4 - any way to block YouTube via Facebook? jaxmac250 iPhone Tips, Help and Troubleshooting 2 Oct 17, 2012 11:15 PM
how associate os x guest file ext to run host application oharamj Mac Basics and Help 0 Aug 5, 2012 07:02 PM

Forum Jump

All times are GMT -5. The time now is 04:56 PM.

Mac Rumors | Mac | iPhone | iPhone Game Reviews | iPhone Apps

Mobile Version | Fixed | Fluid | Fluid HD
Copyright 2002-2013, MacRumors.com, LLC