We operate a private VPN service which has been recently abused by spammers and we would like to be able to limit the number of SMTP connections per minute/hour to make it ineffective for spammers whilst still functional for normal use. I did my homework and came up with the following, but we are still receiving spam reports. Any better ideas or is this approach flawed in some way?
# if it has more than 60 connections in a 120 seconds interval: DROP
iptables -A Limit_SMTP -m recent -p tcp --update --name ovpn_smtp --seconds 120 \
--hitcount 30 -j REJECT --reject-with tcp-reset
# otherwise: allow
iptables -A Limit_SMTP -m recent --set --name ovpn_smtp -j ACCEPT