开发者

Iptables: Two IP-Adresses, allow Port 3306 just for one

my server has two ip's:

# IP one: 192.168.45.1 (allow MYSQL on Port 3306)
# IP 开发者_运维百科two: 192.168.45.2 (disallow MYSQL on Port 3306)

.

how can i configure iptables, to drop incoming connections for a specific IP and allow it to the other?

.

#
# Allow MYSQL-Port only for 192.168.45.1!
#

 /sbin/iptables -A INPUT -p tcp 192.168.45.1 --dport 3306 -j ACCEPT
 /sbin/iptables -A INPUT -p tcp 192.168.45.2 --dport 3306 -j DROP

# END SCRIPT

this seems not to work.. :-(


Rather than enforcing this at the firewall level, have MySQL bind to 192.168.45.1 with the bind-address option. Add this to /etc/my.cnf:

bind-address=192.168.45.1


I think you want:

/sbin/iptables -A INPUT -p tcp -d 192.168.45.1 --dport 3306 -j ACCEPT
/sbin/iptables -A INPUT -p tcp -d 192.168.45.2 --dport 3306 -j DROP
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜