Is there a way to rate limit connections on MySQL 3306 by using IPTABLES? I'm thinking to allow 2 connection attemps to port 3306 every 5 minutes. Thanks
Would it not be better to keep these restrictions within MySQL itself, rather than on the network level? According to the MySQL documentation you can limit the following server resources for individual accounts:
* The number of queries that an account can issue per hour * The number of updates that an account can issue per hour * The number of times an account can connect to the server per hour * The number of simultaneous connections to the server an account can have
An example MySQL query to do this:
mysql> CREATE USER 'francis'@'localhost' IDENTIFIED BY 'frank'; mysql> GRANT ALL ON customer.* TO 'francis'@'localhost' -> WITH MAX_QUERIES_PER_HOUR 20 -> MAX_UPDATES_PER_HOUR 10 -> MAX_CONNECTIONS_PER_HOUR 5 -> MAX_USER_CONNECTIONS 2;
I'd personally prefer to keep this type of setting within the application itself, rather than trying to manipulate it without the applications knowledge. But from what I understand the other examples of using iptables should technically work too.
I was interested enough to do a search, found this article amongst others. Looks like you can do it.