Active/Active Load Balancing with Mikrotik RouterOS
If you have multiple internet connections or site to site tunnels, like VPN or IPIP, with multiple links, you may want to load balance between the links. With Mikrotik this is achieved very easily.
Lets take for example the below scenario:
ISP Link 1 Gateway IP : 1.1.1.1
ISP Link 2 Gateway IP : 2.2.2.1
If you want to give equal priority to both links, you can set the below route:
1 | /ip route add dst-address=0.0.0.0 gateway=1.1.1.1,2.2.2.1 distance=1 check-gateway=ping |
The above route will, for example, route the first packet to the internet on ISP link 1, the second on ISP link 2, the 3rd on ISP link 1 and so on.
If you would like to give higher priority to one of the links, for example if ISP link 1 has a bandwidth of 10M down/2M up and ISP Link 2 has a bandwidth of 2M down / 500K up you would want to prioritise the use of ISP link 1.
Taking the example above we will assign a ratio of 4:1 (ISP1:ISP2). We can acheive this with the route below:
1 | /ip route add dst-address=0.0.0.0 gateway=1.1.1.1,1.1.1.1,1.1.1.1,1.1.1.1,2.2.2.1 distance=1 check-gateway=ping |
In the above route will route the first four connections through ISP link 1, the fifth connection through ISP link 2 and so on.
The check-gateway=ping property will check if the route is still available by pinging the gateway ip. If it is not reachable, the route will not be used.
The above methods are very basic examples of load balancing but it gets the job done.