Server Fault is a question and answer site for system and network administrators. 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

I have 1 server that runs Redis on port 7632. I want to block all incoming traffic to that server, for this port, except from my web server and from localhost.

My web server ip is, for this example,

Can anyone tell me how I can do this in ubuntu?


share|improve this question

closed as not a real question by Michael Hampton, mdpc, Jeff Ferland, TheCleaner, Ward Feb 8 '13 at 5:49

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.If this question can be reworded to fit the rules in the help center, please edit the question.

possible duplicate of Iptables: How to allow only one ip through specific port? – Jeff Ferland Feb 7 '13 at 21:50

Add the following three firewall rules in this order:

iptables -A INPUT -p tcp -s --dport 7632 -j ACCEPT
iptables -A INPUT -p tcp -s --dport 7632 -j ACCEPT
iptables -A INPUT -p tcp --dport 7632 -j DROP

That should do the trick.

share|improve this answer
And also apply those during machine boot. – Matt Feb 7 '13 at 20:00
Where should I put these firewall rules? In which file? Sorry, I am a web developer, not a sys-admin. – user158052 Feb 7 '13 at 20:15

Use a couple of iptables commands... For example Try this or this...

share|improve this answer
An answer should provide an answer within itself and use links as supporting references. Your answer post doesn't provide any information without following links and one of the links is a Google search. In this particular case, a concrete answer to the question should have been posted. – Jeff Ferland Feb 7 '13 at 21:52

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