Hello! I’m curious, is it possible to check just specified subnet instead of whole IP address? For example, i have few incoming connections from various IPs, let’s say
192.168.1.23
192.168.2.24
192.168.5.1
192.168.7.2
I want to count how many new connections came from subnet 192.168 and if it reaches limit then trigger some action.
Yes i tried connection limit already but not sure how it works. I put limit to 10 and netmask to 16, as i thought it means 10 connections for x.x.0.0 subnet per second, but it blocks everything, whatever if i put 1 or even 100000 to limit.
That’s why there is a manual…
connection-limit: Matches connections per address or address block after given value is reached. Should be used together with connection-state=new and/or with tcp-flags=syn because matcher is very resource intensive.
Source: https://wiki.mikrotik.com/wiki/Manual:IP/Firewall/Filter
I saw that piece in manual already and i have such rule for ‘new’ connections and with ‘syn’ flag already. To give better description - i have rule ‘accept’ new TCP connections on 80 port, and in such rule i put that Connection Limit. So i guess it accepts few connections and if limit is reached, then goes to next rule/action which is ‘add src to address list’. But still, even few connections trigger adding IP to list, considering that limit is high.
Thank you very much, I was asking myself for ages why does it not work for me. I had to turn my impression 180 degrees and now it working as I thought it would.
I guess it was designed to be used mainly with a “drop” rule: “passthrough all connections until they reach the limit, then drop”.
Opposed to logic you needed: “accept all connections until they reach the limit, then passthrough”.