MySQL 3306 port limitation using IPTABLES

How to block mysql port 3306 for everyone, but allow it for a specific IP address? This is what I am doing now:

iptables -I INPUT 1 -p tcp --dport 3306 -j ACCEPT 
+7
security mysql firewall centos iptables
source share
1 answer

For this you need a few rules. In most cases, what happens to the join depends on the first rule that it matches. So, first we accept the connection of our friends, and secondly, we drop someone else. 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 
+13
source share

All Articles