Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

How can I prevent Desktop Users from accessing any online website in Ubuntu? I tried * in /etc/hosts but it didn't do the trick.

Please note that I need to keep http://localhost fully functional.

share|improve this question

Options. Options.

  1. just ifdown the eth0 interface.
  2. iptables as suggested above. better to use:
 iptables -A output -p tcp --dport 80 ! --destination -j DROP 

as suggested by @hlovdal.

Actually i think both options are very crippling to the system... Is there a reason that we can know why you need the proposed changes? Maybe we can have some easier changes if we know more about your need...

share|improve this answer

Use IPTables to block all outgoing traffic.


sudo iptables -A OUTPUT -p tcp --dport www -j DROP

should block all outgoing web traffic (http requests).

share|improve this answer
It seems to be working but... 1. How can I reverse the line of code when needed to have the internet working again? 2. In my host file, I have pointed to, how can I access it while having the sites blocked? 3. I see www mentioned, does that mean that sites without www may work?! Thanks. – emurad Dec 18 '10 at 1:46
@emurad: In the command shown, "www" is the port (80). In a URL "www" is simply a hostname. (Almost) no relation. – Dennis Williamson Dec 18 '10 at 2:09
Probably better to use iptables -A OUTPUT -p tcp --dport www ! --destination -j DROP – hlovdal Dec 18 '10 at 2:27
The "standard" name for 80 is http, not www - would cause less confusion. – grawity Dec 18 '10 at 14:28

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .