The only scenario would be an established (I refer to TCP state) connection where the client sends an ACK,FIN or an ACK which is later not replied by the server, or (most probably) a hiccup in conntrack leaving these orphan connections as-is with a 24Hour timeout…
I don’t think it is a bug, but rather the nature of how router deals with the connections.
This needs a very thorough analyze of the whole connection from the begin to the end of it, in both sites, client and server from someone who has time and good knowledge of how ip tables works > > .
I don’t know what is it, but… why doesn’t these connections get marked properly?
90% connections get marked properly and behave as expected, w/o these “stalled” connections. Then, amongst the “stalled” ones, only a 5% of these Unreplied, TCP state established “orphan” connections are marked properly, the rest seem to “jump” to the latest marking mangle rule…
That, again, would depend on how the router considers these connection. As we know, the mangle will apply mark according to the chain. In which chain they will belong is kind of mystery to me, or if they do even skip the chain process at all, because the router itself does not know where to put them (maybe?).
Public IP -----> Router ------> Internet
a.b.c.d:54321 -------------------> f.g.h.i:443
All connections traversing the router go through the forward chain.
I’m marking on the forward chain based on that criteria (destination port tcp 443).
Say in connections, there are 1000 connections from a.b.c.d to f.g.h.i; what I am seeing is:
About 9500 of these connections will have consistent TCP states, and would have been marked correctly.
50 of these connections will have unconsistent TCP state, BUT still are marked correctly.
450 of these connections will have an unconsistent tcp state (established while being unreplied), AND won’t be correctly marked.
This drops all connections that had not received a reply for 30 seconds. Values are based on the default timeout settings.
I have scheduled this to run every minute and it works without problems so far.