There are lot of softwares available in the market – just to make some websites inaccessible from a computer, possibly for productivity reasons e.g blocking facebook, (facebook is killing productivity ? but I don’t think it’s good way, as I promote free speech, free information and of course,freedom!) or to filter out the sites having contents, which may not be suitable for some users (e.g if you want to block porn sites, to make it inaccessible for kids) or simply to block useless spam sites. Anyway, in this post, you will learn – how to block websites or domains in just a couple of click, without any third party softwares – in an efficient way.
Blocking a website or domain name on Ubuntu
Although, I’m using Ubuntu 11.10, but it should work fine with older (11.04/10.10/10.04..) or newer versions(12.04/12.10..) of Ubuntu, not only on Ubuntu but also on other Linux distributions such as Linux Mint, Fedora, OpenSuse, PCLinuxOS, etc. Just follow the simple steps -
step #1 : Open a terminal (Ctrl+Alt+t) and execute the following command -
sudo gedit /etc/hosts
OR
sudo nano /etc/hosts
if you prefer command line text editor and it’s more convenient to use in this case.
step #2 : Then add the following line to the file and click on Save (or Ctrl+s) orCtrl+x, followed by ‘y‘ if you’re using nano text editor (one of the most popular command line text editor, like vim)
127.0.0.1 domaintoblock.com
where domaintoblock.com is a sample domain name which you want to block.
step #3 : That’s all, you’re done! Now open a browser and type the domain name (website address) you specified in above step -
domaintoblock.com => Then you will get an error page such as the it couldn’t be connected to the server or the default server page of your local server (if you’ve installed apache2).
If the domain name is still not blocked then try to flush DNS cache using the nscd (Name Service Cache Daemon).
sudo apt-get install nscd
sudo /etc/init.d/nscd restart
That’s All
NOTE : The file system directories shouldn’t be writable for the users for which you have blocked the sites, because in that case they can easily revert the changes, so they shouldn’t be in sudoers or super user groups (add those users in somewhat less powerful group).
source : http://blog.sudobits.com/2012/01/13/how-to-block-a-website-domain-in-ubuntu/
No comments:
Post a Comment