I am trying to understand fully packet, connection and route marking. Can anyone confirm any of the following?
Can a packet have a connection mark, a packet mark and a route mark at the same time?
Can a packet have multiple packet marks?
Is a connection mark associated with all packets related to the connection?
Some explanation of why I am looking at this may clarify things. I have routers (RB150 and Dell 1950 with RoS) located in a data centre that has multiple networks connected.
The routers I have used (Linux and Cisco) have traditionally ensured the reply packets leave on the interface they entered on if the packets target the router itself. Packets forwarding through the router follow traditional route tables.
The issue I have with RoS is that if I try to connect via ssh or winbox to any interface the replies try to leave by the default gateway and not the gateway associated with the entry interface. This then means the packets are incorrectly addressed for the upstream connection.
My plan to address this had been as follows:
1. Mark the connection to the router to identify the entry network e.g. wan2-in, wan2-in
2. Route mark packets if a connection mark exists e.g. if connection mark = wan1-in apply a route mark wan2-out
3. Setup policy route to route according to the route mark to the correct gateway
The effect I see at the moment is as follows:
1. If I apply a packet mark for packets from a selected network the packets are marked
2. If I apply a connection mark the connections get marked
3. If I apply a route mark selecting packets with connection mark they do not appear to mark.
To confirm mark I look at the count in the magle rule and also apply a filter rule in input or output to simply log packets that have the relevant mark in place
WIth this in place the policy route does not apply. I can ping the router gateway but when I try to connect via ssh or winbox the connection fails unless I connect to the interface that contains the default gateway. This suggests the policy route is not being applied and packets are leaving via the default gateway.
I have searched the forums and find this has come up quite a few times. It is clearly a FAQ and common config. If I can get some information and conclusively establish a procedure for this I think it would be excellent to document this and submit to the wiki. I am prepared to do this if it helps others.
If anyone can offer any help I would be very grateful. It is one small quirk in what is otherwise an excellent router product. Thanks in advance for your time and attention - all help much appreciated!