Routing traffic to the correct interface

I could not find a relative thread although it must have been asked before. Anyway. I would like to mark traffic coming from a wan interface and reroute it back using the same one. I am using masqurade for the wan interfaces. will this work?

/ip firewall mangle
add action=mark-connection chain=input comment=“” disabled=no in-interface=
ether5 new-connection-mark=“New Incoming Eth5” passthrough=yes
add action=mark-connection chain=input comment=“” disabled=no in-interface=
ether6 new-connection-mark=“New Incoming Eth6” passthrough=yes
add action=mark-connection chain=input comment=“” disabled=no in-interface=
ether7 new-connection-mark=“New Incoming Eth7” passthrough=yes
add action=mark-routing chain=output comment=“” connection-mark=
“New Incoming Eth5” disabled=no new-routing-mark=“New Outgoing Eth5”
passthrough=no
add action=mark-routing chain=output comment=“” connection-mark=
“New Incoming Eth6” disabled=no new-routing-mark=“New Outgoing Eth6”
passthrough=no
add action=mark-routing chain=output comment=“” connection-mark=
“New Incoming Eth7” disabled=no new-routing-mark=“New Outgoing Eth7”
passthrough=no


/ip route
add check-gateway=ping comment=“” disabled=no distance=1 dst-address=
0.0.0.0/0 gateway=192.168.4.254 routing-mark=“New Outgoing Eth5” scope=30
target-scope=10
add check-gateway=ping comment=“” disabled=no distance=1 dst-address=
0.0.0.0/0 gateway=192.168.5.254 routing-mark=“New Outgoing Eth6” scope=30
target-scope=10
add check-gateway=ping comment=“” disabled=no distance=1 dst-address=
0.0.0.0/0 gateway=192.168.6.254 routing-mark=“New Outgoing Eth7” scope=30
target-scope=10

Of course I also have a default route

Any help would be greatly appriciated.

yes, this should work, if you need to do it for router’s traffic, not for customers’ traffic

No, I would like to use it for marking customer’s traffic. What should I do in this case? Mark packets and not connections?

For customer traffic you need to use different chains. Read the packet flow diagram on the wiki, and the entry for firewall filters as they explain chains and what traffic ends up where.