# 限制redis端口只能被制定ip访问
vim /etc/sysconfig/iptables
*filter
:INPUT ACCEPT [0:0]
:FORWARD ACCEPT [0:0]
:OUTPUT ACCEPT [0:0]
#-A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
#-A INPUT -p icmp -j ACCEPT
#-A INPUT -i lo -j ACCEPT
#-A INPUT -m state --state NEW -m tcp -p tcp --dport 22 -j ACCEPT
#-A INPUT -j REJECT --reject-with icmp-host-prohibited
#-A FORWARD -j REJECT --reject-with icmp-host-prohibited
# 除127.0.0.1、10.10.67.77这两台机器外禁止链接本机redis 6379端口
-A INPUT -s 127.0.0.1 -p tcp --dport 6379 -j ACCEPT
-A INPUT -s 10.10.67.77 -p tcp --dport 6379 -j ACCEPT
-A INPUT -p TCP --dport 6379 -j REJECT
COMMIT
service iptables restart
service iptables status