Is it possible to create more than one connection-mark for a specific connection? For example, one for doing traffic shaping and another for routing policy?
Thanks.
/ip firewall mangle
### chain=prerouting:
# skip to routing and packet mark assignment if packet belongs to an already marked connection:
add chain=prerouting action=jump jump-target=assign-r-q-marks connection-mark=!no-mark
# only packets belonging to not-yet-marked connections, i.e. initial packets of each connection, get here
# because chain=assign-r-q-marks always provides a final verdict so nothing ever returns from there
add chain=prerouting action=jump jump-target=r1-conns ...criteria for selection of routing policy #1 here...
# only initial packets matching routing policy #2 criteria should get here
add chain=prerouting action=mark-connection new-connection-mark=cm_r2_q1 passthrough=yes ...criteria for selection of QoS policy #1 here...
add chain=prerouting action=mark-connection new-connection-mark=cm_r2_q2 passthrough=yes connection-mark=no-mark ...criteria for selection of QoS policy #2 here...
#only initial packets matching routing policy #2 criteria and QoS policy #3 criteria should get here
add chain=prerouting action=mark-connection new-connection-mark=cm_r2_q3 passthrough=yes connection-mark=no-mark
add chain=prerouting action=jump jump-target=assign-r-q-marks
### chain=r1_conns:
add chain=r1_conns action=mark-connection new-connection-mark=cm_r1_q1 passthrough=yes ...criteria for selection of QoS policy #1 here...
add chain=r1_conns action=mark-connection new-connection-mark=cm_r1_q2 passthrough=yes connection-mark=no-mark ...criteria for selection of QoS policy #2 here...
#only initial packets matching routing policy #1 criteria and QoS policy #3 criteria should get here
add chain=r1_conns action=mark-connection new-connection-mark=cm_r1_q3 passthrough=yes connection-mark=no-mark
add chain=r1_conns action=jump jump-target=assign-r-q-marks
### chain=assign-r-q-marks:
### first, assign routing marks:
add chain=assign-r-q-marks action=mark-routing new-routing-mark=r1 connection-mark=cm_r1_q1,cm_r1_q2,cm_r1_q3 passthrough=yes
add chain=assign-r-q-marks action=mark-routing new-routing-mark=r2 passthrough=yes
### then, assign packet (QoS) marks:
add chain=assign-r-q-marks action=mark-packet new-packet-mark=q1 connection-mark=cm_r1_q1,cm_r2_q1 passthrough=no
add chain=assign-r-q-marks action=mark-packet new-packet-mark=q2 connection-mark=cm_r1_q2,cm_r2_q2 passthrough=no
add chain=assign-r-q-marks action=mark-packet new-packet-mark=q3 passthrough=no
I mean that for example for following rules:What kind of input to the generating script would you expect? It is a matter of two hours to write such script, but you'd spend the remaining 46 hours debugging it
What do you mean by doing the same for QoS queues - to create an own copy of the queue tree for each WAN? What if the WANs have different bandwidth?
The 2k mangle rules are not that bad as each packet would pass just a small subset of them.
chain=prerouting action=jump jump-target=routemark connection-mark=no-mark
chain=routemark action=mark-connection new-connection-mark=mgmt in-interface=br-mgmt
chain=routemark action=mark-connection new-connection-mark=srv dst-address-list=networkSERVICE
...
chain=prerouting action=jump jump-target=qosmark connection-mark=no-mark
chain=qosmark action=mark-connection new-connection-mark=www protocol=tcp dst-port=80,443
chain=qosmark action=mark-connection new-connection-mark=ssh protocol=tcp dst-port=22
...
chain=prerouting action=jump jump-target=qosmark-mgmt connection-mark=mgmt
chain=qosmark-mgmt action=mark-connection new-connection-mark=mgmt-www protocol=tcp dst-port=80,443
chain=qosmark-mgmt action=mark-connection new-connection-mark=mgmt-ssh protocol=tcp dst-port=22
...
chain=prerouting action=jump jump-target=qosmark-srv connection-mark=srv
chain=qosmark-srv action=mark-connection new-connection-mark=srv-www protocol=tcp dst-port=80,443
chain=qosmark-srv action=mark-connection new-connection-mark=srv-ssh protocol=tcp dst-port=22
...
and so on, one copy for each routing mark given as parameter