L2TP With FastTrack in MikroTik
L2TP With FastTrack in MikroTik
Share
The story is that I need to use a VPN to access another network where I have an
L2TP/IPsec server ready. So I created an L2TP client interface on the MikroTik hAP
ac using the command
/interface l2tp-client
add name="myL2TP" disabled=no connect-to=.......... \
use-ipsec=yes ipsec-secret=......... user=. ...... password=.......
Now that the hAP ac has started contacting the prepared L2TP server, I created a
mangle rule (firewall) to make a routing mark that must be routed through the
VPN, then force all user traffic on the network to go. Stay on VPN with src-nat rule
using the following command:
The problem is that FastTrack doesn't support IPsec... If I disable FastTrack, that
means that when I'm not using the VPN, I'll have to turn FastTrack back on.
Conversely, when I'm using the VPN, I'll have to turn FastTrack off. And in the
worst case scenario, FastTrack doesn't support IPsec. If the VPN server goes down,
the router is smart enough to cut NAT rules so you can continue using the internet,
but it's not smart enough to automatically turn on FastTrack.
I started looking for a solution in various forums/blogs [3, 4]. I tried many
methods, including making connection marks, which was unsuccessful in case 3
from the previously mentioned problem, and filtering with IPsec was unsuccessful
because of L2TP. will encapsulate IPsec another layer
In the end, I chose to create a simple firewall rule to solve this problem by adding a
forward rule that would pass the L2TP interface both in and out to accept
immediately before reaching the FastTrack forward rule.
Case 1 : Open VPN as usual. The packet will have a routing mark for VPN to be
issued, and the L2TP forward rule will work normally without going directly to
FastTrack.
Case 2 : Disable the use of VPN. Disabling the use of VPN in this way will not
disable the L2TP client interface, but will disable the routing mark instead. When
there is no routing mark, the NAT rule will not work, so the packet will not be
masquerade towards the L2TP interface, for example: This will cause the L2TP
forward rule to not work and will go directly to FastTrack... Hurry!
Case 3 VPN server down / connection lost In this case, both NAT rule and L2TP
forward rule will be disabled by default due to L2TP interface down. As a result, all
packets will pass through FastTrack… fast.
Summary
FastTrack is a very good thing because it makes forwarding packets about 5 times
faster because it doesn't have to go through the kernel and also reduces the CPU
load. But it is not compatible with L2TP/IPsec, so it must be fixed by using 2 L2TP
forward filters. rules with an example config as follows:
/interface l2tp-client
add name="myL2TP" disabled=no connect-to=.......... \
use-ipsec=yes ipsec-secret=......... user=. ...... password=.......
/ip firewall mangle
add action=mark-routing chain=prerouting \
comment="L2TP Routing Mark" new-routing-mark=myL2TP \
passthrough=yes src-address=192.168.88.2-192.168.88.254
** NOTE: The L2TP forward filter must always be placed before the FastTrack rule.