Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

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

Can somebody come up with (an) Ubuntu command line(s) that will allow me to deal with a specific site and block all other IP’s, preferably using ufw, but if not, iptables?

share|improve this question
Sorry, but could could you clarify what you mean by "deal with" and "site" ? Perhaps a short story of the problem you are trying to solve will help. – adric Oct 4 '09 at 17:43
Assume I’m engaged in Internet banking. – Anonymous Oct 4 '09 at 18:01

As I write this it's not clear what you're looking for (and commenting that you're engaged in internet banking doesn't help one bit), but here's my guess: are you looking for a way to configure your firewall so that it allows traffic to and from only one particular IP address and blocks everything else? If so, here are the IPtables commands to do that:

iptables -I INPUT 0 --src ! -j DROP
iptables -I OUTPUT 0 --dst ! -j DROP

and then to reset it afterwards (assuming you haven't made any other changes to the firewall in the interim):

iptables -D INPUT 0
iptables -D OUTPUT 0
share|improve this answer
it'll be DROP rather then DENY – pQd Oct 4 '09 at 19:55
arrrgh silly me. Thanks, I'll edit that. – David Z Oct 4 '09 at 20:10
Nevertheless, I’m getting an error message about the ‘0’ in the string (Ubuntu 9.04). – Anonymous Oct 4 '09 at 22:53

Your Answer


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