Blocking Facebook with DNS

Facebook has repeatedly shown to be untrustworthy in their handling of privacy, their IPO was an over-inflated/over-hyped scam, and their business model is shady at best. I block all Facebook domains at the DNS level so they can’t get their grubby hands on any of my data, browsing habits, etc.

To block all Facebook domains, “Like” buttons, cookies, etc on the web, add the following to /etc/hosts:

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

Google’s probably the next-worst offender of “get/sell ALL the user data!”, but at least they’re providing services I use (search, mail, Android, docs, etc). Nothing in life is free, eh?

Update: Commenter Stephen Jakubiec points out that redirecting to 0.0.0.0 is a more robust way of achieving the desired effect, as it doesn’t have the unwanted side effect of redirecting Facebook requests to your local webserver (if you have one running). In case you’re daft, here’s what you need to change:

# Block Facebook
0.0.0.0 www.facebook.com
0.0.0.0 facebook.com
0.0.0.0 static.ak.fbcdn.net
0.0.0.0 www.static.ak.fbcdn.net
0.0.0.0 login.facebook.com
0.0.0.0 www.login.facebook.com
0.0.0.0 fbcdn.net
0.0.0.0 www.fbcdn.net
0.0.0.0 fbcdn.com
0.0.0.0 www.fbcdn.com
0.0.0.0 static.ak.connect.facebook.com
0.0.0.0 www.static.ak.connect.facebook.com

Update: Also see this curated list which seems to be updated frequently: http://someonewhocares.org/hosts/zero/

11 thoughts on “Blocking Facebook with DNS

  1. Done, do I need to restart network services or anything? Added them and still saw sites showing me the ‘Like’ button… Its not supposed even to be there, yeah?

    1. You shouldn’t need to restart, but the DNS might be cached. I just had a look around on a few blogs and I didn’t see any “Like” buttons, so I think mine’s working.

    1. Yeah, it should be, but I haven’t tried blocking just Facebook on Android. I use the AdAway application from the Google Play Store to block all ad servers.

  2. I generally block with 0.0.0.0 as it will give an immediate failure to load.
    Whereas 127.0.0.1 will fill your error logs with 404s (among others) if you’re running LAMP (MAMP, etc).

    Just my two cents there Alan.

        1. 0.0.0.0 redirects to localhost, someone tried to fb with my machine and was redirected to localhost, Funny, 0.0.0.1 works just fine

Comments are closed.