Ask Ubuntu is a question and answer site for Ubuntu users and developers. 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 setup Ubuntu box so logged user can access only to several IP addresses, on all protocols?

Additional problem is that Ubuntu uses proxy to acceess to internet.

Tried with UFW, but did not manage with it (probably because pf proxy?)

share|improve this question
up vote 0 down vote accepted


You can edit your host file:

sudo gedit /etc/hosts

add the websites you want to block:

It works with all browsers I guess.


and to only allow access to one ip adress try:

iptables -A INPUT -p tcp -d {type here the ip} --dport 80 -j ACCEPT
iptables -A INPUT -p tcp --dport 80 -j REJECT

See! it's easy ;)

share|improve this answer
tnx :-) will it work if my ubuntu uses proxy? – user198003 Dec 25 '12 at 7:47
try it and leave us a response to know please :) – Hakeem Wahab Dec 25 '12 at 12:34

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.