Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

How can I block complete access of my computer to certain domains but be able to switch it on whenever I want to? That is, I want that by default whenever my browser or any other application hits a page of the form http://something.domain.com, or a page who is somehow connecting me to http://something.domain.com — that it blocks it and don't send anything without my explicit consent.

I know we can block something completely by using hosts, but the trouble is that I may need to check these domains once in a while, so I would have to keep removing and adding it to hosts. Which is ok if I can refresh it somehow, or have a script do it quickly for me.

Is there a simple way to do it?

I have the impression it can be done with iptables, but this is a subject I am not familiar with.

share|improve this question
add comment

1 Answer 1

up vote 2 down vote accepted

There is a Linux version of SelfControl program which essentially does that - blocks a list of domains for a specified number of hours. It does this using iptables, so you may consider it a nice wrapper for shell commands. The difference from your description is that it intentionally makes it difficult to unblock a domain - to make self-control a bit easier :)

Other options, such as editing /etc/hosts or writing a script which adds/removes an iptables rule - are also viable.

At least you can study SelfControl source to see how it manipulates iptables.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.