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, 126.96.36.199.
Can anyone tell me how I can do this in ubuntu?
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 188.8.131.52 --dport 7632 -j ACCEPT iptables -A INPUT -p tcp --dport 7632 -j DROP
That should do the trick.