MİKROTİK LOAD BALANCİNG 2 WAN 2 LAN
Mikrotik Load Balancing 2 WAN 2 LAN with Failover – Load balance 2 WAN on Mikrotik Router is a technique to distribute the traffic load on the two-paths connection in a balanced manner so that traffic can run optimally, maximize throughput, minimize response time and avoid overload on one connection path. This experiment, I have 2 internet connections different IP WAN and 2 LAN. I‘ve tried it, load balancing and failover can run normally. You can see the Mikrotik script below.
Network Topology
IP WAN 1 = 10.10.10.2/29
IP WAN 2 = 10.10.11.2/29
Block IP LAN 1 = 192.168.1.0/24 Gatheway 192.168.1.1 Mask 255.255.255.0
Block IP LAN 2 = 192.168.100.0/24 Gatheway 192.168.100.254 Mask 255.255.255.0
1. Add Ip address to interfaces Mikrotik router
Mikrotik Script :
/ip address
add address=10.10.11.2/29 interface=ether2 network=10.10.11.1
add address=10.10.10.2/29 interface=ether1 network=10.10.10.1
add address=192.168.1.1/24 interface=ether3 network=192.168.1.0
2. Setting IP Pool to restrict the range of IP that will be distributed automatically by DHCP system that we enable.
Mikrotik Script :
/ip pool
add name=”LAN 1″ ranges=192.168.1.10-192.168.1.254
add name=”LAN 2″ ranges=192.168.100.20-192.168.100.30
3. Setting DHCP Server on Mikrotik router
Mikrotik Script :
/ip dhcp-server
add address-pool=”LAN 1″ disabled=no interface=ether3 name=”staff”
add address-pool=”LAN 2″ disabled=no interface=ether6 name= manager
/ip dhcp-server network
add address=192.168.1.0/24 dns-server=8.8.8.8,8.8.4.4 gateway=192.168.1.1
add address=192.168.100.0/24 dns-server=8.8.8.8,8.8.4.4 gateway=192.168.100.254
4. Add both private addresses ( IP LAN ) to the firewall address list
Mikrotik Script :
/ip firewall address-list
add address=192.168.1.0/24 list=”block lan”
add address=192.168.100.0/24 list=”block lan”
5. Setting Firewall NAT
Mikrotik Script :
add action=masquerade chain=srcnat out-interface=ether1 src-address-list=
“block lan” to-addresses=10.10.10.2
add action=masquerade chain=srcnat out-interface=ether2 src-address-list=\
“block lan” to-addresses=10.10.11.2
6. Setting Mangle
Mikrotik Script :
/ip firewall mangle
add action=mark-connection chain=input in-interface=ether1 \
new-connection-mark=ip10con passthrough=no
add action=mark-connection chain=input in-interface=ether2 \
new-connection-mark=ip11con passthrough=no
add action=mark-routing chain=output connection-mark=ip10con new-routing-mark=\
to-ip10 passthrough=no
add action=mark-routing chain=output connection-mark=ip11con \
new-routing-mark=to-ip11 passthrough=no
7. Setting IP Route
Mikrotik Script :
/ip route
add distance=1 gateway=10.10.10.1 routing-mark=to-ip10
add distance=1 gateway=10.10.11.1 routing-mark=to-ip11
add check-gateway=ping distance=1 gateway=10.10.10.1,10.10.10.1
Test Result
This is winbox capture of the test result
| Mikrotik Load Balance running normally with 2 WAN 2 LAN |
| Mikrotik load balance and Fail Over running normally when WAN 1 down |
| Mikrotik load balance and Fail Over running normally when WAN 2 down |
I hope it has been a useful article.
