Sign up ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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

2 Answers 2

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

Your Answer


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.