counting marked connections per IP

I don’t know if this is scripting connection or it can be done with nth for example.

What I would like to do is to limit how many highpri marked connections one IP can have.

For example there mased on certain rules I mark one type of traffic as lowpri and another as highpri. Now I want to make it so no particular IP can have more than 10 highpri connections. If connection qualifies as highpri but IP has 10 highpri connections already I want to mark the connection lowpri (or something else like forced_lowpri). Any ideas?

thanks!

I think that should be possible by first configuring passthrough=yes on your initial highpri marking rules, and then further down use connection-limit to re-mark if necessary:

add chain=whatever connection-mark=highpri connection-limit=10,32 action=mark-connection new-connection-mark=lowpri

I may be mistaken on how connection-limit counts the connections and if the other filters (connection-mark=highpri) limit what connections are counted.

I tested it on live system and it does seem that connection-mark has effect on what gets counted. I’ll email support to confirm. Thank you fewi.