Home » MikroTik Router » MikroTik ECMP Load Balancing and Link Redundancy

MikroTik ECMP Load Balancing and Link Redundancy

Load balancing and link redundancy are the main concern topics to any network administrator of any ISP company or any enterprise office. Because network administrators always want to live his/her network 24/7. If you have multiple WAN connections in your MikroTik router, you can easily make a load balancing network as well as link redundancy too. In my previous article, I have explained how to make a load balancing network over multiple gateways with policy based routing in MikroTik router. With the configuration that I have explained in my last article you can only make a load balancing network but link redundancy is not possible simultaneously. It was a limitation of that network but today I will show you how to make a load balancing network as well as link redundancy over multiple gateways using ECMP configuration in MikroTik router. So, keep reading the rest of this article if you want to make a load balancing as well as link redundancy network with ECMP in MikroTik router.

ECMP Strategy in MikroTik Router

ECMP stands for Equal-Cost Multi-Path routing. ECMP is a routing strategy where next-hop packet forwarding to a single destination can occur over multiple best paths. Multi-path routing can be used in conjunction with most routing protocols. So, we will apply multi-path routing strategy in our MikroTik router so that our network traffic can go through multiple gateways. ECMP can substantially increase bandwidth by load-balancing traffic over multiple paths; however, ECMP strategy may face significant problems when it will be deployed in practice. In some specific network, ECMP may raise some issues. So, PCC load balancing configuration will be best solution for that specific network.

5 Steps to Configure Load Balancing and Link redundancy Network with ECMP

We will now configure a load balancing as well as link redundancy network with ECMP strategy in MikroTik router. We will configure our MikroTik router according to the below simple office network diagram where multiple WAN connections that means multiple ISP connections are available for accessing internet.

Load Balancing and Link Redundancy Network

Load Balancing and Link Redundancy Network

In this network diagram, there are two ISP connections which are connected to ether1 port and ether2 port of a MikroTik router and these ports are using as the WAN port of this router. A number of hosts are connected to this MikroTik router through a network switch and the uplink port of this switch is connected to the ether10 port which is using as the LAN port of this router.

The complete ECMP configuration for a load balancing and link redundancy network according to the above network diagram can be divided into 5 steps.

  1. Assigning WAN and LAN IP Addresses
  2. DNS Configuration
  3. NAT Configuration
  4. Mangle Rule Creation
  5. Route Configuration

Now we will do the above steps in a MikroTik router to configure a load balancing and link redundancy network successfully.

Step 1. Assigning WAN and LAN IP Addresses

For configuring a perfect load balancing and link redundancy network with ECMP routing, you have to assign WAN and LAN IP addresses in your MikroTik Router first. As you have two ISP connections in your network, you must have two WAN IP addresses as well as two gateway addresses. For the configuration of this article, I am using below two WAN IP addresses and two gateway addresses for different ISP connections.

  1. WAN1 IP Address: 172.22.15.221/24 and Gateway:172.22.15.1
  2. WAN2 IP Address: 192.168.168.210/24 and Gateway:192.168.168.254

I am using these WAN IP addresses and Gateway address for the configuration of this article as well as the video tutorial that I will upload in my channel but in practical your WAN IP addresses and Gateway addresses must be different and these will be provided by your ISP Company. However, you also have a LAN network with a large number of hosts. For the configuration of this article, I am assuming that the LAN IP block and the gateway will be like below.

  1. IP Block: 192.168.10.0/24
  2. Gateway: 192.168.10.254

We have got our WAN IP addresses and LAN IP block. Now I will show you how to assign these WAN IP addresses and LAN IP block in your MikroTik router. Follow my bellow steps to assign WAN IP addresses and LAN gateway address in your MikroTik router.

  1. Login to your MikroTik router with Winbox software. If you don’t have Winbox software in your collection, download Winbox from this site and then login to your router with username and password. If you are new in this article as well as MikroTik router configuration, follow my article about MikroTik router basic configuration which will guide you how to configure MikroTik router from very beginning.
  2. Go to IP > Addresses menu item from the winbox left menu bar. Address List window will appear.
  3. Now click on add new button (PLUS Sign). New Address window will appear. Put your WAN1 IP address (in this article: 172.22.15.221/24) in Address input box and choose WAN1 interface (in this article: ether1) from Interface drop-down menu and then click Apply and OK 
  4. Similarly, click on add new button again and put your WAN2 IP address (in this article: 192.168.168.210/24) in Address input field and choose WAN2 interface (in this article: ether2) from Interface drop-down menu and then click Apply and OK button.
  5. Again, click on add new button and put your LAN gateway IP (in this article: 192.168.10.254/24) in Address input field and choose your LAN interface (in this article: ether10) from Interface drop-down menu and then click Apply and OK button.

Assigning WAN and LAN IP addresses in our MikroTik router has been completed. Now we will configure DNS server in our next step.

Step 2. DNS Server Configuration

DNS is not a mandatory configuration in MikroTik router but it is necessary for a complete MikroTik router configuration. Optionally, you can turn your MikroTik router into a DNS server which will be beneficial for your network. So, if you want to set DNS IP for your MikroTik router as well as want to turn your MikroTik router into a DNS server, follow my below simple steps.

  1. Go to IP > DNS menu item. DNS Settings window will appear. Put your DNS server IP that is provided to you by your ISP or you can use public DNS server IP 8.8.8 in Servers input field.
  2. Optionally, you can click on Allow Remote Requests checkbox to turn your MikroTik router into a DNS server. But you have to block DNS requests from outside of your LAN otherwise your MikroTik will be used as a DNS server by the public users if they know your MikroTik’s public IP. Follow my article about MikroTik router basic configuration that will show you the steps to block DNS requests from public network.
  3. Now click Apply and OK button.

DNS configuration in MikroTik router has been completed. Now we will create masquerade NAT rule so that our LAN users can access internet through our MikroTik router.

Step 3. NAT Configuration

Now we will create two masquerade NAT rules in our MikroTik router so that our LAN users can access internet through the both ISP connections. That means, if any packet leaves via ether1, it will be NATed to ISP1gateway IP address and similarly if any packet leaves via ether2, it will be NATed to ISP2 gateway IP address. Follow my below steps to create two masquerade NAT rule in your MikroTik router.

  1. Go to IP > Firewall menu option. Firewall window will appear. Click on NAT tab in this window and then click on add new button (PLUS Sign). New NAT Rule window will appear now. Under General tab, choose srcnat from Chain drop-down menu and choose your ISP1 interface (in this article: ether1) from Interface drop-down menu. Now click on Action tab and choose masquerade from Action drop-down menu and then click Apply and OK button.
  2. Similarly, click on add new button (PLUS Sign) again. New NAT Rule window will appear. Under General tab, choose srcnat from Chain drop-down menu and choose your ISP2 interface (in this article: ether2) from Interface drop-down menu. Now click on Action tab and choose masquerade from Action drop-down menu and then click Apply and OK button.

NAT rule configuration for two WAN connections of our MikroTik router has been completed. Now we will create Mangle rules to mark connection and routing for our MikroTik router.

Step 4. Mangle Rule Creation

Now we will create two connection marking rules and two routing marking rules for our MikroTik router so that it can communicate to the internet properly through the two ISP connections. Follow my below steps to create connection marking rule and routing marking rule for your MikroTik router.

  1. Go to IP > Firewall menu option and click on Mangle Now click on add new button (PLUS Sign). New Mangle Rule window will appear now. Under General tab choose input from Chain drop-down menu and choose your ISP1 interface (in this article: ether1) from In. Interface drop-down menu. Now click on Action tab and choose mark connection from Action drop-down menu and put connection name as isp1_conn or whatever string you like in New Connection Mark input field and then uncheck the Passthrough check box. Click on Apply and OK button.
  2. Click on add new button (+) again and choose input from Chain drop-down menu and then choose your ISP2 interface (in this article: ether2) from Interface drop-down menu. Now click on Action tab and choose mark connection from Action drop-down menu and put connection name as isp2_conn in New Connection Mark input field and uncheck the Passthrough checkbox and then click Apply and OK button.
  3. Again, click on add new button (+) and choose output from Chain drop-down menu and then click on Connection Mark drop-down menu and choose your ISP1 connection mark (in this article: isp1_conn) that you have created in first step under General Now click on Action tab and choose mark routing from Action drop-down menu and put routing mark name (in this article: to_isp1) as you like in New Routing Mark input field and uncheck the Passthrough checkbox and then click Apply and OK button.
  4. Click on add new button (+) Under General tab, choose output from Chain drop-down menu and choose your ISP2 connection mark (in this article: isp2_conn) that you have created in second step. Now click on Action tab and choose mark routing from Action drop-down menu and then put routing mark name (in this article: to_isp2) as you like in New Routing Mark input box and uncheck the Passthrough checkbox. Click Apply and OK button.

Mangle rule creation for proper connection and routing marking has been completed. Now we will configure routing in our MikroTik router so that network traffic can be routed properly.

Step 4. Route Configuration

We will now configure routes in MikroTik router so that traffics can pass through multiple ISP gateways properly. Follow my below steps to configure routes in your MikroTik router for a load balancing and link redundancy network.

  1. Go to IP > Routes menu option. Route List window will appear. Click on add new button (PLUS Sign). New Route window will appear. Put your ISP1 gateway IP (in this article: 172.22.15.1) in Gateway input box and then click on Add new value button located after gateway input box and put your ISP2 gateway IP (192.168.168.254) in new Gateway input box. Now choose ping from Check Gateway drop-down menu and click Apply and OK
  2. Click on add new button (+) again and put your ISP1 gateway IP in Gateway input box and then choose your ISP1 routing mark (in this article: to_isp1) from Routing Mark drop-down menu. Click Apply and OK
  3. Again, click on add new button (+) and put your ISP2 gateway IP (in this article: 192.168.168.254) in Gateway input box and choose your ISP2 routing mark (in this article: to_isp2) from Routing Mark drop-down menu. Now click Apply and OK

Route configuration in your MikroTik router has been completed. According to this configuration half of your network traffic will pass through ISP1 connection and rest half network traffic will pass through ISP2 connection. So, you will get a perfect load balancing network with this ECMP configuration. Now, if any connection of your ISP connections is disconnected by any reasons, your network traffic will pass through the ISP connection which is live. Your MikroTik router will check ISP gateways by ping and if any ISP gateway is disconnected, it will be disabled from route list and traffic will be passed through another gateway. When your disconnected ISP will be alive, it will be enabled again in route list and traffic will pass through both of your ISP connections. So, you will get a perfect link redundancy or failover network by the above ECMP configuration.

The ECMP configuration that we have done in the above steps will send network traffics through both ISP connections equally. That means, one packet among every two packets will be sent through ISP1 connection and another packet will be sent through ISP2 connection. So, you should have equal bandwidth connection from both ISP Company. Otherwise, your bandwidth will be wasted.  But if you have unequal bandwidth connection from these two ISP Company, how do you reduce your bandwidth waste?

In this case, we can apply a strategy in our route configuration. Look carefully to the first step in route configuration where ISP1 gateway is assigned once and similarly ISP2 gateway is assigned once. But if you have unequal bandwidth purchase such as ISP1 has 2Mbps bandwidth and ISP2 has 10Mbps bandwidth, you have to find out the ratio of these two bandwidths. In this example, the bandwidth ratio of ISP1 and ISP2 is 1:5. So, you should put ISP1 gateway once and ISP2 gateway 5 times by adding new value in gateway input box. Then, first packet among 6 packets will be sent through ISP1 connection and remaining 5 packets will be sent through ISP2 connection and this rotation will be continued in your MikroTik router. So, your bandwidth will not be wasted more.

The ECMP load balancing and link redundancy configuration that we have completed in the above steps will work perfectly most of the cases (98%) but in some special cases it may raise some issues. If you face any issue for launcing a large network with ECMP configuration, I will suggest to use MikroTik PCC configuration which will run a load balancing and link redundancy network without any issue.

If you follow above 5 steps, you can easily configure a load balancing and link redundancy network in your MikroTik router. However, if you face any problem to do above 5 steps successfully, you can follow my below video tutorial about MikroTik ECMP load balancing and link redundancy. I hope, it will show you proper guide to configure a load balancing and link redundancy network in MikroTik router.

MikroTik ECMP load balancing and link redundancy configuration has been explained in this article. I hope, you are now able to make a load balancing and failover network with your MikroTik router sucessfully. However, if you face any problem to configure a load balancing and link redundancy network with your MikroTik router, feel free to discuss in comment or contact with me from Contact page. I will try my best to stay with you.

mikrotik-ecmp-load-balancing-and-link-redundancy

ABOUT ME

I, Md. Abu Sayeed, am a system administrator. I like to share knowledge that I am learning from my daily experience. As a system administrator, I like to play with computer networking, Redhat Linux , Windows server, physical server and storage, virtual technology and other system related topics. I hope, my daily experiences that I am sharing in this website will be beneficial for you. So, if this article is helpful for you, don't forget to give a positive feedback by sharing on your favorite social media or liking our Facebook Page. You can also keep subscribed to our website for getting email notification of new post by providing your name and email address in Subscription Page.   

11 comments

  • plitzkin

    Hey, What should I do if my 2 wans have dhcp connection? Im confused.

    • Go to IP > DHCP Client and click on PLUS SIGN to add your DHCP Interface But Load balancing with DHCP WAN will be difficult bro. Try to use static IP for your WAN and it will be better for you.

  • Aulia K F

    Hello, I wanna ask you a question, I dont use the “check-gateway” you said above but the failover is still running, do you know why this could happen?

  • hector fragoso

    Hello, what happen if the ISP is active but dont have internet?
    this happened very often and the lan become so slow,

    i have 4 ISP and want to redirect all lan trafic to load balance between ISP1, ISP2 and ISP3, and leave ISP4 for backup only but only for 2 local pcs

    • Dear,
      you have a complex network. Load balancing is a complex task. you have to research about your problem with your local expert guy. I think they research your problem and give you perfect solution.

  • César Montes

    Hello Sayed,

    Thanks for another great tutorial! I am currently trying it, but I have a problem as my two internet connections have not static IP; how shall we configure it so the router handle any IP that the ISP gaves to him?

    Looking forward to hearing from you.

    Kindly,
    César.-

  • César Montes

    Thanks for your reply Sayeed!

    I have followed your tutorial but something is wrong; at the moment I tried to route the connections it tells me that wan1 and wan2 are unreacheable. I think it happens because the Gateway provided by my ISP varies from the IP. For example, IP 192.168.85.3, DG 192.53.2.3.

    Either way, I think I shall proceed with dynamic IP as my ISP changes both IP and DG everyday. Is there a way you can take a look at my config? I am trying to do this: https://onedrive.live.com/?authkey=%21ALMuGDQzuAs2s3A&cid=DD20073D74C28CAB&id=DD20073D74C28CAB%2157878&parId=root&o=OneUp
    Do not worry for the printer, as I believe I can conenct it to the Switch and it will get an automatic IP address

  • Mengthai

    Hello brother!

    May we can do a load balancing with different speed?
    Ex:
    ISP1=10M
    ISP2=30M
    If we can do, how is processing? smooth or not?

    Thanks you!

Leave a Reply

Your email address will not be published. Required fields are marked *

*