These days I’m trying to cut down my Facebook addiction, and let’s be honest: everybody has it. Visiting it only on week-ends, i.e. only on Saturday and Sunday, would already be a great achievement.

On my Mac, the geekiest way to prevent access to it is by blocking the URL inside the /etc/hosts file, adding a line like this one:

127.0.0.1     facebook.com

Unfortunately, the file doesn’t support wild cards so a new line must be added for every subdomain, and Facebook has a lot of them, not to mention that the number of line doubles because of the encrypted connection. So basically the lines to effectively block Facebook are at least the following:

127.0.0.1     facebook.com
127.0.0.1     www.facebook.com
127.0.0.1     https://facebook.com
127.0.0.1     https://www.facebook.com

The site still remains accessible if another subdomain is included in the URL, like “m.facebook.com” or “apps.facebook.com”, so one may consider to add them as well. I know, maybe there are better way like using a web filter, but I don’t like them so much.

Once having blocked Facebook on Mac OS X, I still needed to do the same on my Android phone. It is well known that being based on Linux, Android has the same /etc/hosts file working the exact same way that on a desktop system. Apparently, it resides on a read-only partition and it’s quite a pain to quickly add and remove a site, this time a web filter would do the job. So I spent almost an hour looking for a way to block Facebook on Android, but the informations online are really poor.

In the end, I stumbled across an app called Webnanny in the market, and it works pretty well. It’s a full-featured web filter and has an option to block various site categories like adult material, gambling sites, security threats and even social networks, so I didn’t even need to manually blacklist facebook, it was included in the settings and sure enough, it works for every subdomain so I saved a lot of time.