Wednesday, February 28, 2018

Load Balancing and Link Redundancy Over Two ISP's with Mikrotik ECMP.



We take our time in talking about Load balancing and link redundancy because these are the main concerns and worrisome topics of almost all network administrator of any ISP company or any enterprise office.
The reason is because network administrators always wants their network to remain up all day long. If you have multiple WAN connections in your MikroTik router, you can easily make a load balancing network, (just like we did in our previous tutorial) as well as link redundancy also. In my previous article.





 I tried my best to explained how to make a load balancing network over multiple gateways using 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 might not be possible at once. Actually that was  a draw back to that network. But all the same here in this tutorial are all you need to make a load balancing network as well as link redundancy over multiple gateways using ECMP configuration in MikroTik router.

ECMP Configuration.
Before I start I will like us to look at ECMP as a concept. ECMP generally stands for Equal-Cost Multi-Path routing.
In one word ECMP is a routing strategy used in mikrotik routers, where the next-hop count 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 this concept of multi-path routing strategy in our MikroTik router so that our network traffic can go through multiple gateways. One the good features I see using ECMP is that can substantially increase bandwidth by load-balancing traffic over multiple paths.
We will now configure a load balancing as well as link redundancy network with ECMP strategy in MikroTik router.
Load Balancing and Link Redundancy Network
Link redundancy applies in a scenario were, 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 expected to be connected to this MikroTik router through a network switch and the uplink port of this switch is connected to the ether4 port which is using as the LAN port of this router.

When applying ECMP configuration for a load balancing and link redundancy the previous tutorial need to be involved so I advice you read the tutorial before this one. The entire configuration is divided into segments, but here I will start the configuration from the Mangle rule option all other configurations has being done earlier.
After assigning WAN and LAN IP, DNS, and NAT rules we will have an important configuration which will segment the network and allow it for redundancy. So now we will start by creating  two connections marking rules and two routing marking rules for our MikroTik router so that it can effectively send and receive signal fro and to the internet properly through the two ISP connections.

Mangle Rule Creation
Go to IP > Firewall menu option and click on Mangle Now click on add new button (+ Sign).
New Mangle Rule window will appear now. beneath General tab choose input from Chain drop-down  menu and choose your ISP1 interface ( 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.
Click on add new button (+) again and choose input from Chain drop-down menu and then choose your ISP2 interface ( 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.

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 (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 (to_isp1) as you like in New Routing Mark input field and uncheck the Passthrough checkbox and then click Apply and OK button.
Click on add new button (+) Under General tab, choose output from Chain drop-down menu and choose your ISP2 connection mark (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 (to_isp2) as you like in New Routing Mark input box and uncheck the Passthrough checkbox. Click Apply and OK button.

The Mangle rule we created now is what we need  for proper connection and.
The last thing we will do is to configure  routing in our MikroTik router so that network traffic can be routed properly.
We will now configure routes in a way that MikroTik router sends traffic through multiple ISP gateways properly. Note that link redundancy applies here.





Route Configuration
Go to IP > Routes menu option. Route List window will appear. Click on add new button (+ Sign). New Route window will appear. Put your ISP1 gateway IP (e.g 192.168.88.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. we are going to  choose ping,  from Check Gateway drop-down menu and click Apply and OK. Now what this does is what will call keep alive. It will keep pinging the ISP’s and send traffic out as soon as it get respond from anyone.
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 on Apply and OK.

Click on add new button (+) and put your ISP2 gateway IP (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 then click on Apply and OK.

According to this configuration half of this 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 you’re 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 above tutorial covers all you need for load balancing and link redundancy using ECMP on mikrotik.
Stay with us as we bring you PCC load balancing configuration will be best solution for every network.



No comments:

Post a Comment