load balance l2tp ExpressVPN

can anyone please help me ?

i have three FTTH 16MB bandwidth i have successfully made a PCC Load Balancer using this scrip

/interface ethernet
set [ find default-name=ether5 ] name=LAN
set [ find default-name=ether1 ] name=WAN1
set [ find default-name=ether2 ] name=WAN2
set [ find default-name=ether3 ] name=WAN3
set [ find default-name=ether4 ] disabled=yes

/ip address
add address=192.168.0.1/24 interface=LAN network=192.168.0.0
add address=192.168.1.4/24 interface=WAN1 network=192.168.1.0
add address=192.168.2.4/24 interface=WAN2 network=192.168.2.0
add address=192.168.3.4/24 interface=WAN3 network=192.168.3.0

/ip dns
set allow-remote-requests=yes servers=8.8.8.8,8.8.4.4

/ip firewall mangle
add action=mark-connection chain=input in-interface=WAN1 new-connection-mark=\
    WAN1_conn passthrough=yes
add action=mark-connection chain=input in-interface=WAN2 new-connection-mark=\
    WAN2_conn passthrough=yes
add action=mark-connection chain=input in-interface=WAN3 new-connection-mark=\
    WAN3_conn passthrough=yes
add action=mark-routing chain=output connection-mark=WAN1_conn \
    new-routing-mark=to_WAN1 passthrough=yes
add action=mark-routing chain=output connection-mark=WAN2_conn \
    new-routing-mark=to_WAN2 passthrough=yes
add action=mark-routing chain=output connection-mark=WAN3_conn \
    new-routing-mark=to_WAN3 passthrough=yes
add action=accept chain=prerouting dst-address=192.168.1.0/24 in-interface=\
    LAN
add action=accept chain=prerouting dst-address=192.168.2.0/24 in-interface=\
    LAN
add action=accept chain=prerouting dst-address=192.168.3.0/24 in-interface=\
    LAN
add action=mark-connection chain=prerouting dst-address-type=!local \
    in-interface=LAN new-connection-mark=WAN1_conn passthrough=yes \
    per-connection-classifier=both-addresses-and-ports:3/0
add action=mark-connection chain=prerouting dst-address-type=!local \
    in-interface=LAN new-connection-mark=WAN2_conn passthrough=yes \
    per-connection-classifier=both-addresses-and-ports:3/1
add action=mark-connection chain=prerouting dst-address-type=!local \
    in-interface=LAN new-connection-mark=WAN3_conn passthrough=yes \
    per-connection-classifier=both-addresses-and-ports:3/2
add action=mark-routing chain=prerouting connection-mark=WAN1_conn \
    in-interface=LAN new-routing-mark=to_WAN1 passthrough=yes
add action=mark-routing chain=prerouting connection-mark=WAN2_conn \
    in-interface=LAN new-routing-mark=to_WAN2 passthrough=yes
add action=mark-routing chain=prerouting connection-mark=WAN3_conn \
    in-interface=LAN new-routing-mark=to_WAN3 passthrough=yes

/ip firewall nat
add action=masquerade chain=srcnat out-interface=WAN1
add action=masquerade chain=srcnat out-interface=WAN2
add action=masquerade chain=srcnat out-interface=WAN3

/ip route
add check-gateway=ping distance=1 gateway=192.168.1.1 routing-mark=to_WAN1 \
    scope=255
add check-gateway=ping distance=1 gateway=192.168.2.1 routing-mark=to_WAN2 \
    scope=255
add check-gateway=ping distance=1 gateway=192.168.3.1 routing-mark=to_WAN3 \
    scope=255
add check-gateway=ping distance=1 gateway=192.168.1.1 scope=255
add check-gateway=ping distance=2 gateway=192.168.2.1 scope=255
add check-gateway=ping distance=3 gateway=192.168.3.1 scope=255

and on speedtest.com my speed is balanced 48mb
i added a l2tp ExpressVPN in PPP and create NAT to masquerade out-interface=l2tp-out
and create a mangle rule

add action=mark-routing chain=prerouting new-routing-mark=vpn-now passthrough=no src-address=192.168.0.100-192.168.0.150

and create router for the routing mark vpn-now

add distance=1 gateway=l2tp-out routing-mark=vpn-now

when i assign 192.168.0.110 ip for my laptop the VPN works fine put it is only using 1 of the WAN interfaces and it look like i cant control witch WAN that i can make the VPN connects to
i need you to help me to make a Load Balancer that the VPN connect to all my WAN’s
i can make a 3 l2tp-out connections with my ExpressVPN account but how can i make every l2tp connect throw 1 of the WAN’s and balance the hole thing

First - a single connection will always use just one of the uplinks. speedtest.net uses multiple connections to test the bandwidth; for real traffic, it depends on the application.

Second - yes, to load-balance the traffic via VPN, you need three separate VPN connections. And if ExpresVPN only supports a single connection per account, you need three accounts. A single VPN connection cannot be load-balanced among three WANs.

Third - when creating an /interface l2tp-client, you can specify a src-address, which supersedes the choice of source address done by routing. However, it does not supersede the routing itself. So in addition to specifying a distinct WAN IPs as a src-address for each /interface l2tp-client, you need to use rules in chain output of /ip firewall mangle to add a routing-mark value depending on the source address:

/ip firewall mangle
add chain=output src-address=192.168.1.0/24 action=mark-routing new-routing-mark=to_WAN1
add chain=output src-address=192.168.2.0/24 action=mark-routing new-routing-mark=to_WAN2
add chain=output src-address=192.168.3.0/24 action=mark-routing new-routing-mark=to_WAN3

Thank you sindy for the quick reply
I’ll try it now i can create 3 L2TP interfaces with the same account and each one of them is getting a deferent ip seems good so far
What is the scr-address is the L2TP out refer to i don’t now which source thay mean :confused: (new to all this)
I want to ladbalance the vpn interfaces
Please help me how to

The src-address parameter tells the /interface l2tp-client row which one of the own IPs of the router to use. So it must be set to one of the addresses you’ve got on your WAN interfaces. If this parameter is not specified, the route to the server is found in the routing table called main, i.e. the one used if no routing-mark value is assigned to the packet. This determines the WAN to be used, and the IP address assigned to this WAN is then used to establish the VPN transport connection.

In any case, some route (the default one is sufficient) must exist for the destination IP in routing table main, otherwise the packet to that destination doesn’t make it to mangle/output.

The load balancing setup will be the same you currently use with the real WANs, except that you’ll use the VPN tunnels instead of the real WANs.

So you’ll keep the three existing routes with routing-mark values to_WAN1, to_WAN2, to_WAN3 for the real WANs and use the rules in chain output of mangle I gave in my previous post, these will be used to push the VPN transport traffic via the individual WANs.

And you’ll add three more routes via the three L2TP tunnels (using the interface names as gateway parameters of these routers), with another set of routing-mark values (to_VPN1, to_VPN2, to_VPN3), and use your load distribution rules to assign these values to the traffic that should be routed via VPN.

ill try it tomorrow and thank you very much
and one last thing
do i need to copy my current mangle rules and make them for l2tp
like this

/ip firewall mangle
add action=mark-connection chain=input in-interface=l2tp-out1 new-connection-mark=\
    VPN1_conn passthrough=yes
add action=mark-connection chain=input in-interface=2tp-out2 new-connection-mark=\
    VPN2_conn passthrough=yes
add action=mark-connection chain=input in-interface=2tp-out3 new-connection-mark=\
    VPN3_conn passthrough=yes
add action=mark-routing chain=output connection-mark=VPN1_conn \
    new-routing-mark=to_VPN1 passthrough=yes
add action=mark-routing chain=output connection-mark=VPN2_conn \
    new-routing-mark=to_VPN2 passthrough=yes
add action=mark-routing chain=output connection-mark=VPN3_conn \
    new-routing-mark=to_VPN3 passthrough=yes
    
add action=mark-connection chain=prerouting dst-address-type=!local \
    in-interface=LAN new-connection-mark=VPN1_conn passthrough=yes \
    per-connection-classifier=both-addresses-and-ports:3/0
add action=mark-connection chain=prerouting dst-address-type=!local \
    in-interface=LAN new-connection-mark=VPN2_conn passthrough=yes \
    per-connection-classifier=both-addresses-and-ports:3/1
add action=mark-connection chain=prerouting dst-address-type=!local \
    in-interface=LAN new-connection-mark=VPN3_conn passthrough=yes \
    per-connection-classifier=both-addresses-and-ports:3/2
add action=mark-routing chain=prerouting connection-mark=VPN1_conn \
    in-interface=LAN new-routing-mark=to_VPN1 passthrough=yes
add action=mark-routing chain=prerouting connection-mark=WAN2_conn \
    in-interface=LAN new-routing-mark=to_VPN2 passthrough=yes
add action=mark-routing chain=prerouting connection-mark=WAN3_conn \
    in-interface=LAN new-routing-mark=to_VPN3 passthrough=yes

i am very sorry to trouble you many time :frowning:

The rules above in chain input, and those translating the connection-mark to a routing-mark in chain output, are only necessary if your router acts as a server and some clients connect to it from remote (incoming VPN connections, some https server at home, etc.). If this is the case, these rules ensure that the response of the router will be sent via the same WAN through which the request has arrived. If this is not the case, there is no need for these rules.

sindy can you please help me when i put a scr-address in the l2tp the l2tp interface get disconnect
if you can anydesk me i would be pleased

You use those IP as source-address for L2TP tunnels?

/ip address
add address=> 192.168.1.4> /24 interface=WAN1 network=192.168.1.0
add address=> 192.168.2.4> /24 interface=WAN2 network=192.168.2.0
add address=> 192.168.3.4> /24 interface=WAN3 network=192.168.3.0

It is normal that it gets disconnected, but it should re-connect again.

The source address you set must be up on the router, is it?

The action=src-nat (or action=masquerade) rules in nat and action=mark-routing rules in mangle, or instead rules in /ip route rule, must exist in order that it worked.

If all the above is met, and it doesn’t work, post an anonymized export of the configuration in the non-working state, see my automatic signature below for a hint.