:global i;
:global u;
:global l;
:set i 4;
:set u 0;
:for a from=1 to="$i" do={
/ip route
add dst-address=0.0.0.0/0 gateway=("pppoe-out"."$a") routing-mark=$a check-gateway=ping
add dst-address=0.0.0.0/0 gateway=("pppoe-out"."$a") distance=$a check-gateway=ping
/ ip firewall nat
add chain=srcnat out-interface=("pppoe-out"."$a") action=masquerade
/ip fi man
add chain=input in-interface=("pppoe-out"."$a") action=mark-connection new-connection-mark=("wlan"."$a")
}
:for a from=1 to="$i" do={
add chain=output connection-mark=("wlan"."$a") action=mark-routing new-routing-mark=$a
}
:for a from=1 to="$i" do={
add action=mark-connection chain=prerouting dst-address-type=!local comment=("C"."$a") new-connection-mark=("wlan"."$a") passthrough=yes per-connection-classifier=("both-addresses-and-port:"."$i"."/"."$u") src-address-list="\BE\D6\D3\F2\CD\F8"
:set u ($u + 1)
}
:for a from=1 to="$i" do={
add action=mark-routing chain=prerouting comment=("R"."$a") connection-mark=("wlan"."$a") new-routing-mark=$a passthrough=no
}