block access to facebook.comIn this config you can find an easy and cheap solution on how to block Facebook.com on any Linux desktop using /etc/hosts file. This is not a bulletproof solution but should help as a first level privacy protection for your kids, yourself or should aid if your students do not pay enough attention in the class.

Below you can find a list of facebook.com subdomains:
  • m.facebook.com
  • upload.facebook.com
  • apps.facebook.com
  • newsroom.fb.com
  • developers.facebook.com
  • touch.facebook.com
  • pixel.facebook.com
  • static.facebook.com
  • beta.facebook.com
  • graph.facebook.com
  • login.facebook.com
  • inyour.facebook.com
  • secure.facebook.com
  • latest.facebook.com
Once we have the above list we amend /etc/hosts to make sure that the above Facebook.com subdomains as well as domain facebook.com will resolve to loopback IP address 127.0.0.1. To do that, as a root user open a local /etc/hosts on any Linux machine you wich to block the Facebook on and add the following single line:
127.0.0.1 facebook.com login.facebook.com secure.facebook.com latest.facebook.com inyour.facebook.com beta.facebook.com static.facebook.com touch.facebook.com developers.facebook.com newsroom.fb.com pixel.facebook.com apps.facebook.com graph.facebook.com m.facebook.com upload.facebook.com
Once you save the hosts file your browser will no longer be able to resolve the facebook.com properly and return similar error like the one below:
Blocked facebook access on linux desktop
.

If you own a DNS server and you force DNS settings on your clients by DHCP server you can enable similar solution by creating a facebook.com zone file and pointing it either to 127.0.0.1 or some virtual host on your webserver with multiple ServerAlias names.
FIND LATEST LINUX JOBS on LinuxCareers.com
Submit your RESUME, create a JOB ALERT or subscribe to RSS feed.
LINUX CAREER NEWSLETTER
Subscribe to NEWSLETTER and receive latest news, jobs, career advice and tutorials.
DO YOU NEED ADDITIONAL HELP?
Get extra help by visiting our LINUX FORUM or simply use comments below.

You may also be interested in: