-2

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, 123.43.45.6.

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

Thanks!

  • possible duplicate of [Iptables: How to allow only one ip through specific port?](http://serverfault.com/questions/146569/iptables-how-to-allow-only-one-ip-through-specific-port) – Jeff Ferland Feb 07 '13 at 21:50

2 Answers2

1

Add the following three firewall rules in this order:

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

That should do the trick.

Dennis Kaarsemaker
  • 18,793
  • 2
  • 43
  • 69
-1

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

  • 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 07 '13 at 21:52