Load Balancing Multiple Same Subnet Links

You might also like

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 1

1 Load Balancing Multiple Same Subnet Links

This example demonstrates how to set up load balancing if the provider is giving IP addresses from the same
subnet for all links.

2 Detailed Section Overview


3 IP address
In this example, our provider assigned two upstream links, one connected to ether1 and the other to ether2. Both
links have IP addresses from the same subnet. Our local network has two subnets 192.168.1.0/24 and 192.168.2.0/2:
/ip address
add address=10.1.101.18/24 interface=ether1
add address=10.1.200.10/24 interface=ether2
add address=192.168.1.1/24 interface=ether3
add address=192.168.2.1/24 interface=ether4

After the IP address is set up, the connected route will be installed as an ECMP route:
[admin@MikroTik] > /ip route print detail
0 ADC dst-address=10.1.101.0/24 pref-src=10.1.101.18 gateway=ether1,ether2
gateway-status=ether1 reachable,ether2 reachable distance=0 scope=10

4 Mangle
In our example, very simple policy routing is used. Let`s start with adding routing tables for each mangle mark:
/routing table
add fib name=first
add fib name=other

Clients from the 192.168.1.0/24 subnet are marked to use the "first" routing table and 192.168.2.0/24 to use
the "other" subnet:
/ip firewall mangle
add action=mark-routing chain=prerouting src-address=192.168.1.0/24 new-routing-mark=first
add action=mark-routing chain=prerouting src-address=192.168.2.0/24 new-routing-mark=other

5 NAT
And masquerade our local network:
/ip firewall nat
add action=masquerade chain=srcnat out-interface=ether1
add action=masquerade chain=srcnat out-interface=ether2
The same can be achieved by setting up route rules instead of mangle.

6 Routes
We are adding two gateways, one to resolve in the "first" routing table and another to the "other" routing table:
/ip route
add gateway=10.1.101.1@main routing-table=first
add gateway=10.1.101.1@main routing-table=other

You might also like