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

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

link|improve this question

60% accept rate
feedback

3 Answers

Options. Options.

  1. just ifdown the eth0 interface.
  2. iptables as suggested above. better to use:
 iptables -A output -p tcp --dport 80 ! --destination 127.0.0.1 -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...

link|improve this answer
feedback

Use IPTables to block all outgoing traffic. https://help.ubuntu.com/community/IptablesHowTo

edit:

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

should block all outgoing web traffic (http requests).

link|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 example.com pointed to 127.1.1.0, 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
1  
@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 127.0.0.1 -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
feedback

Another possibility... Configure a static IP, and set the gateway to 127.0.0.1

link|improve this answer
Do you know how I can do that in Ubuntu? – emurad Dec 19 '10 at 6:40
feedback

Your Answer

 
or
required, but never shown

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