Site icon System Zone

MikroTik Unequal Dual WAN Load Balancing with Failover using ECMP

MikroTik Router is capable of doing Load Balancing with Failover over multiple gateways. Policy Based Routing, ECMP, PCC and NTH Load Balancing are the popular load balancing methods in MikroTik Router. Among these methods, ECMP is so easy to configure and provides almost 100% load balancing and link redundancy solution. In my previous article, I discussed how to configure Load Balancing and Link Redundancy using ECMP over two equal bandwidth gateways. ECMP method is also capable of doing load balancing over unequal bandwidth gateway. In this article, I will discuss how to configure load balancing with failover over two unequal bandwidth gateways using ECMP method.

ECMP (Equal Cost Multi Path) Routing

ECMP stands for Equal-Cost Multi-Path routing. ECMP is persistent per-connection load balancing or per-src-dst-address combination load balancing where a new gateway is chosen for each source and destination IP pair. It means that, for example, one FTP connection will use only one link, but new connection to a different server will use another link.

Network Diagram

We will configure Dual WAN load balancing over two unequal gateways using ECMP method according to the following diagram.

ECMP Load Balancing and Link Redundancy

In this network, MikroTik Router’s ether1 port is connected to ISP1 with IP block 192.168.30.0/30 and ether2 port is connected to ISP2 with IP block 172.30.30./30 and ether3 port is connected to LAN network and its IP block is 10.10.10.0/24. PC-1 and PC-2 are two LAN workstations which are connected to LAN interface through a LAN switch.

We will configure ECMP Load Balancing in this MikroTik Router so that LAN traffics can pass though the both WAN connections. As ECMP is a per connection load balancing method and WAN connection has different bandwidth (WAN1: 20Mbps and WAN2: 10Mbps) with bandwidth ratio 2:1, we will pass two connections among three connections to WAN1 link and one connection to WAN2 link.

This ECMP configuration will also ensure Link Redundancy. So, if any WAN connection gets disconnected, LAN traffic will pass through the available WAN connection until the lost WAN connection gets available.

Load Balancing Configuration using ECMP over Unequal DUAL WAN Connections

We will now start Load Balancing and Link Redundancy configuration in MikroTik Router according to the above network diagram. Complete configuration can be divided into the following five steps.

Step 1: Renaming MikroTik Interface Name

We will first rename interface name so that we can easily understand and remember configuration. The following steps will show how to rename MikroTik interface name.

Renamed Interfaces

Step 2: Assigning WAN and LAN IP

We will now assign WAN and LAN IP addresses on our respected interface. The following steps will show how to assign IP address on MikroTik interfaces.

WAN and LAN IP

Step 3: Assigning DNS IP

DNS is required to resolve domain name to IP address. Without DNS server MikroTik Router cannot resolve domain name to IP address and fail to communicate with the public domain server. The following steps will show how to assign DNS IP in MikroTik Router.

Step 4: NATing Configuration

We will now create two masquerade NAT rules so that LAN users can access internet through the both WAN connections. That means, if any packet leaves via WAN1, it will be NATed to WAN1 gateway IP address and if any packet leaves via WAN2, it will be NATed to WAN2 gateway IP address. The following steps will show how to create masquerade NAT rule in MikroTik Router.

NATing Configuration

Step 5: Routing Configuration

We will now configure ECMP (Equal Cost Multi-Path) gateway over two WAN links. As we have unequal bandwidth link (WAN1:WAN2=2:1), we will put WAN1 gateway twice time and WAN2 gateway one time. The following steps will show how to assign ECMP gateway in MikroTik Router.

ECMP Gateway Configuration

So, two connections among three connections will pass through WAN1 connection and one connection will pass through WAN2 connection. WAN connections will be checked by ping and if any connection gets disconnected, traffic will pass through the available WAN connection until the lost WAN connection gets connected. So, load balancing with failover will be established with ECMP load balancing method.

Connections to the Router Itself

With all multi-gateway situations there is a usual problem to reach router from public network via one, other or both gateways. Because outgoing packets use same routing decision as packets those are going through the router. So reply to a packet that was received via WAN1 might be sending out via WAN2. To avoid this we need to do policy based routing.

The following steps will show how to mark router’s incoming connection to pass it over proper gateway.

Mangle Rule to Mark Router’s Incoming Connections

We have created policy to pass router’s incoming packets to the respected WAN interface. Now we will create routing based on this policy.

Route List with Policy Based Routing

Policy based routing to get router properly from public network has been completed. Now ECMP load balancing will affect no more on getting router from public network.

If you face any confusion to follow the above steps, watch the following video on MikroTik ECMP Load Balancing with Failover over two unequal gateways. Hope it will reduce your any confusion.

How to configure DUAL WAN Load Balancing with Failover using ECMP Method has been discussed in this article. I hope you will now be able to configure load balancing with ECMP method properly. However, if you face any confusion to configure DUAL WAN Load Balancing using ECMP method, feel free to discuss in comment or contact with me from Contact page. I will try my best to stay with you.

Exit mobile version