Hi petterg,
I am not sure if my issue is related to the same problem, but I had also problem with marking IPsec packets
and I have found reason/solution/bug ??.
I do not want to paste here all my config, so I will try explain just the problem the best way I can.
I have dual WAN config (no BGP) (with additional scripts for WAN fail-over switching, but it does not matter).
I have mangle rules, based on this site:
https://aacable.wordpress.com/2011/07/2 ... t-by-zaib/
just short of few ones:
/ip firewall mangle
add chain=input in-interface=WAN1 action=mark-connection new-connection-mark=WAN1_conn
add chain=input in-interface=WAN2 action=mark-connection new-connection-mark=WAN2_conn
In my case I have chain=prerouting here, so all incomming connections to the router (both router itself and destined for my local subnets) are connection-marked.
I have VPNs connections with remote locations,
(GRE tunnels working over IPsec).
The GRE tunnels work on local IP's (10.255.255.10/32 - central office, 10.255.255.20/32 - remote office).
The IPsec policies are set up only for those IP's so they are encapsulated and encrypted with IPsec.
I have two GRE tunnels to every remote location (one working on our WAN1 and second working on our WAN2).
What I have discovered, that outgoing IPsec packets that are marked to WAN2 are not really outgoing with correct interface.
(they were outgoing throught WAN1 (default)).
As both our ISP's does not filter our source addresses, we can use IP address assigned by ISP1 and packet can succesfully go out using ISP2 interface and vice-versa. So I was not even conscious, that bad thing is happening..
After 2 day hard investigation, log analisys, I have found the reason !!
All decrypted packets that comes from IPsec tunnel (those one 10.255... on which GRE tunnels are working) in firewall acts with incomming interface = physical interface that IPsec packet was received.
That is actually nothing new for me, I knewed it before and this is probably OK.
This way, according to mangle rules from above, the GRE connections (with local/private IPs) are also connection-marked,
and causes that outgoing GRE packet is correctly marked for correct outgoing WAN interface.
But it completely does not matter, as the outgoing GRE packet is catched by IPsec polisy, encrypted, encapsulated, and whole process starts again.
http://wiki.mikrotik.com/images/thumb/2 ... _final.png
and.. here the problem beggins.. !
Now, the outgoing IPsec packet should be also marked and routed via the correct wan interface, but this is not working.
Either route-marking rule is not working or the routing mark is ignored during the routing.
and.. now the solution/reason ! This problem with marking/routing of IPsec packets is casued by previously route-marking of packet that was encapsulated into IPsec !!!!!! (GRE packets in my case)
I have completely no idea.. what is the relation/reason of route-marking packets that comes into IPsec tunnel, with marking IPsec packets itself ???
Solution was very simple, I have updated the above rules with destination IP subnets of WAN links,
so now only real packets coming into WAN interfaces destinet to public IP's are connection marked.
(GRE packets are not marked now).
I have made several tests, not only with GRE but with simple ICMP ping over those private IP's used by GRE.
And I can confirm:
every packet that is marked for routing but finally encapsulated into IPsec packet, cause that route-marking for this IPsec packet is not working.
Please somebody guys from MikroTik, confirm if this is a bug or I do not know something ?
(checked on ROS 6.18 and 6.20)