使用IPTABLES限制MySQL 3306端口 [英] Restricting MySQL 3306 port with IPTABLES

查看:714
本文介绍了使用IPTABLES限制MySQL 3306端口的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何为所有人阻止mysql端口3306,但允许其用于特定IP?这是我目前正在做的事情:

How to block mysql port 3306 for everybody, but allow it for a specific IP? This is what I currently do:

iptables -I INPUT 1 -p tcp --dport 3306 -j ACCEPT

推荐答案

您需要多个规则. 在大多数情况下,连接会发生什么情况取决于连接所匹配的第一个规则.因此,首先,我们接受我们的朋友关系,其次,我们放弃其他任何人.瞧!

You need multiple rules to do that. In most cases, what will happen with a connection depends on the first rule, which it matches. So, first we accept our friends connection, second, we drop anybody other. Voila!

iptables -I INPUT 1 -p tcp -s 1.2.3.4 --dport 3306 -j ACCEPT
iptables -I INPUT 2 -p tcp --dport 3306 -j DROP

这篇关于使用IPTABLES限制MySQL 3306端口的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆