34. Mikrotik Load Sharing (LAN1 to WAN1 and LAN2 to WAN2)




Here is a script:

/interface ethernet
set [ find default-name=ether1 ] name=ether1-WAN1
set [ find default-name=ether2 ] name=ether2-WAN2
set [ find default-name=ether3 ] name=ether3-LAN1
set [ find default-name=ether4 ] name=ether4-LAN2

/ip address
add address=192.168.96.2/24 interface=ether4-LAN2 network=192.168.96.0
add address=192.168.95.2/24 interface=ether3-LAN1 network=192.168.95.0
add address=192.168.92.3/24 interface=ether1-WAN1 network=192.168.92.0
add address=192.168.93.3/24 interface=ether2-WAN2 network=192.168.93.0
/ip dns
set servers=8.8.8.8,8.8.4.4

/ip firewall mangle
add chain=prerouting comment="allow to ping gateway" dst-address=192.168.96.2 \
    src-address=192.168.96.0/24
add chain=prerouting comment="Allow ping gateway" dst-address=192.168.95.2 \
    src-address=192.168.95.0/24
add action=mark-routing chain=prerouting comment="LAN1 go through WAN1" \
    new-routing-mark=LAN1ToWAN1 src-address=192.168.95.0/24
add action=mark-routing chain=prerouting comment="LAN2 Go through WAN2" \
    new-routing-mark=LAN2ToWAN2 src-address=192.168.96.0/24

/ip firewall nat
add action=masquerade chain=srcnat comment=WAN1 out-interface=ether1-WAN1
add action=masquerade chain=srcnat comment=WAN2 out-interface=ether2-WAN2

/ip route
add distance=1 gateway=192.168.92.2 routing-mark=LAN1ToWAN1
add distance=1 gateway=192.168.93.2 routing-mark=LAN2ToWAN2
add distance=1 gateway=192.168.93.2
add distance=1 gateway=192.168.92.2

Previous
Next Post »

2 comments

Write comments
محمد
AUTHOR
February 20, 2019 at 5:23 AM delete

only work when add
ip route
dst address for lan2 with getway wan1 and dst addres for lan2 with getway wan 2 !!!!

Reply
avatar