Page 1 of 1

Best load balancing method for 4 WAN links

Posted: Mon Dec 30, 2013 7:14 am
by sporkman
I was reviewing the various load-balancing options for multiple links (ECMP, PCC, nth), and they all seem reasonable.

What I'm wondering is with each line being 15/2, whether the matter of which method is most efficient comes into play. Hardware is the RB2011.

Also I'd really like to shoot for the most seamless end user experience over speed - the air links on the other side of this are not incredibly high-bandwidth, so strict per-packet is not really going to give people better speed. More important is that their Netflix, SSL-secured banking sessions, and VoIP work without interruption when the 10 minute route table flush happens

If 3 out of 4 lines go down, I still want everyone running through the remaining circuit.

What's my best option in that scenario?

Re: Best load balancing method for 4 WAN links

Posted: Mon Dec 30, 2013 10:23 am
by c0d3rSh3ll
The best method is pcc. In the mangle pcc section use "both addres and port" or "dst address"

Send from my mobile phone using Tapatalk.

Re: Best load balancing method for 4 WAN links

Posted: Thu Jan 02, 2014 1:40 pm
by tiernano
as c0d3rSh3ll mentions, PCC is what i am using with both addresses and ports being used. As for seamless for the user, it works 95% of the time without any issues... I have had to set up a set of rules to send specific addresses over a specific connection, mainly for issues with session state... for example, the mikrotik forums do not like you hitting them from different addresses, so i needed to tell my router to send all traffic going to the mikrotik routers though a particular WAN link...

example is available here: https://gist.github.com/tiernano/8217968

I have 3 connections myself (2@200mb/10mb and 1 @70/20). this is done as follows:

https://gist.github.com/tiernano/8218016

If you have any questions, give me a shout. I am planning on wiriting up a proper explanation of how this works eventually...

Re: Best load balancing method for 4 WAN links

Posted: Thu Jan 02, 2014 2:42 pm
by efaden
Have you seen the bandwidth method from the tiktube presentation? I'll post a link when I get to my computer.

Sent from my SCH-I545 using Tapatalk

Re: Best load balancing method for 4 WAN links

Posted: Thu Jan 02, 2014 4:07 pm
by efaden
Have you seen the bandwidth method from the tiktube presentation? I'll post a link when I get to my computer.

Sent from my SCH-I545 using Tapatalk

http://mum.mikrotik.com/presentations/US12/tomas.pdf

I actually helped someone else on the forums extend that to work on 30 or so ADSL connections.

Re: Best load balancing method for 4 WAN links

Posted: Thu Jan 02, 2014 4:46 pm
by tomaskir
There is no BEST load-balancing method. Which one you choose should depend on your needs and what connections you have.
If the connections are 1:1 speed-wise, PCC will be good, if they are un-similiard, then bandwidth-based will be better.

Re: Best load balancing method for 4 WAN links

Posted: Fri Jan 03, 2014 12:36 pm
by beeman
I have used Tomaskir's load balancing video & slides for a 2 WAN setup. http://tiktube.com/video/DofH3iFnjDJomG ... uKlEoLqHq=

I need to use VPN (IPsec attempted) to connect 4 routers for WISP monitoring purposes. I cannot figure out how to 'require' the VPN connections to use one WAN over the other.

Is it impossible using Tomas's load balancing system? :(

Re: Best load balancing method for 4 WAN links

Posted: Fri Jan 03, 2014 1:49 pm
by tomaskir
It is possible, and it is very easy.

If you are talking about IPSec responder:
The responder will use the WAN on which the IPSec connection is establisthed.
That is handled by the WAN->ROS mangle chain already.

If you are talking about the IPSec iniciator:
Simply create a route in the main routing table for the IPSec responder's IP and point that route out a specific gateway.
Or work it into the mangle, but by default, ROS itself uses the main routing table in my setup.

Re: Best load balancing method for 4 WAN links

Posted: Fri Jan 03, 2014 3:40 pm
by beeman
Thanks for quick response tomaskir but please could you elaborate -remember I have only just started on ROS?

Re: Best load balancing method for 4 WAN links

Posted: Fri Jan 03, 2014 6:52 pm
by tomaskir
There is no simple answer to your question, it depends on your configs and topology.

Go through the presentation and the video, study it a bit, learn and test.
Then if you undrstand how it works, the things I wrote in the last post will tell you how to solve your problem.
Its better in the long run to learn it :)

Re: Best load balancing method for 4 WAN links

Posted: Fri Jan 03, 2014 9:31 pm
by karina
I have found issues with what I call dynamic load balancing techniques as explained above. Like pcc etc. Things like making sure some connections always use the same wan add a layer of complexity. My method is simply deviding the client ip address,s into blocks and sending them out to different wants with simple mangle and routing rules

Re: Best load balancing method for 4 WAN links

Posted: Thu Jan 09, 2014 3:11 am
by sporkman
I have found issues with what I call dynamic load balancing techniques as explained above. Like pcc etc. Things like making sure some connections always use the same wan add a layer of complexity. My method is simply deviding the client ip address,s into blocks and sending them out to different wants with simple mangle and routing rules
First, thanks all for the info and discussion. PCC looks like the best fit.

However, the above quoted post sounds interesting - I'm dealing with 4 equal speed links, and with all the CPE running at relatively low speeds (compared to the individual backhaul links), so divvying things up based on the source IP seems like it would help with my main goal which is to not cause chaos with those visiting any sites that don't like a client switching IPs mid-session. From what I see, it's not terribly difficult to incorporate that source IP scheme with failover, so if one link drops, the subs passing over that link failover to another.

Re: Best load balancing method for 4 WAN links

Posted: Tue Jan 14, 2014 10:13 am
by sadeghnakhjavani
as c0d3rSh3ll mentions, PCC is what i am using with both addresses and ports being used. As for seamless for the user, it works 95% of the time without any issues... I have had to set up a set of rules to send specific addresses over a specific connection, mainly for issues with session state... for example, the mikrotik forums do not like you hitting them from different addresses, so i needed to tell my router to send all traffic going to the mikrotik routers though a particular WAN link...

example is available here: https://gist.github.com/tiernano/8217968

I have 3 connections myself (2@200mb/10mb and 1 @70/20). this is done as follows:

https://gist.github.com/tiernano/8218016

If you have any questions, give me a shout. I am planning on wiriting up a proper explanation of how this works eventually...
Hi and Thank you for this post
I have a problem with PCC.
We have 4 unequal WAN connection from different ISPs. I config our RB2011U for PCC loadBalancing according to the MikroTik website article (http://wiki.mikrotik.com/wiki/Manual:PCC) and everything is good.
But I have 2 questions :
How can I route the traffic of a specific host (192.168.1.50) from LAN to WAN1 link forever?
How can I force FTP traffic go through WAN2 link and use WAN3 link as failover link?
This is my config:
/interface
set name=LAN numbers=5
set name=WAN1 numbers=6
set name=WAN2 numbers=7
set name=WAN3 numbers=8
set name=WAN4 numbers=9
/ip address
add address=192.168.1.1/24 network=192.168.1.0 broadcast=192.168.1.255 interface=LAN
add address=10.10.10.1/29 network=10.10.10.0 broadcast=10.10.10.7 interface=WAN1
add address=10.10.20.1/29 network=10.10.20.0 broadcast=10.10.20.7 interface=WAN2
add address=10.10.30.1/29 network=10.10.30.0 broadcast=10.10.30.7 interface=WAN3
add address=10.10.40.1/29 network=10.10.40.0 broadcast=10.10.40.7 interface=WAN4
/ip firewall mangle
add chain=input in-interface=WAN1 action=mark-connection new-connection-mark=WAN1_Connection
add chain=input in-interface=WAN2 action=mark-connection new-connection-mark=WAN2_Connection 
add chain=input in-interface=WAN3 action=mark-connection new-connection-mark=WAN3_Connection 
add chain=input in-interface=WAN4 action=mark-connection new-connection-mark=WAN4_Connection 
add chain=output connection-mark=WAN1_Connection action=mark-routing new-routing-mark=Route_To_WAN1 
dd chain=output connection-mark=WAN2_Connection action=mark-routing new-routing-mark=Route_To_WAN2 
add chain=output connection-mark=WAN3_Connection action=mark-routing new-routing-mark=Route_To_WAN3 
add chain=output connection-mark=WAN4_Connection action=mark-routing new-routing-mark=Route_To_WAN4 
add chain=prerouting in-interface=LAN dst-address=10.10.20.0/29 action=accept 
add chain=prerouting in-interface=LAN dst-address=10.10.30.0/29 action=accept
add chain=prerouting in-interface=LAN dst-address=10.10.40.0/29 action=accept 
add chain=prerouting in-interface=LAN dst-address=10.10.50.0/29 action=accept 

add chain=prerouting dst-address-type=!local in-interface=LAN per-connection-classifier=both-addresses-and-ports:11/0 action=mark-connection new-connection-mark=WAN1_Connection passthrough=yes 
add chain=prerouting dst-address-type=!local in-interface=LAN per-connection-classifier=both-addresses-and-ports:11/1 action=mark-connection new-connection-mark=WAN1_Connection passthrough=yes 
add chain=prerouting dst-address-type=!local in-interface=LAN per-connection-classifier=both-addresses-and-ports:11/2 action=mark-connection new-connection-mark=WAN1_Connection passthrough=yes 
add chain=prerouting dst-address-type=!local in-interface=LAN per-connection-classifier=both-addresses-and-ports:11/3 action=mark-connection new-connection-mark=WAN1_Connection passthrough=yes 
add chain=prerouting dst-address-type=!local in-interface=LAN per-connection-classifier=both-addresses-and-ports:11/4 action=mark-connection new-connection-mark=WAN2_Connection passthrough=yes 
add chain=prerouting dst-address-type=!local in-interface=LAN per-connection-classifier=both-addresses-and-ports:11/5 action=mark-connection new-connection-mark=WAN2_Connection passthrough=yes 
add chain=prerouting dst-address-type=!local in-interface=LAN per-connection-classifier=both-addresses-and-ports:11/6 action=mark-connection new-connection-mark=WAN2_Connection passthrough=yes 
add chain=prerouting dst-address-type=!local in-interface=LAN per-connection-classifier=both-addresses-and-ports:11/7 action=mark-connection new-connection-mark=WAN2_Connection passthrough=yes 
add chain=prerouting dst-address-type=!local in-interface=LAN per-connection-classifier=both-addresses-and-ports:11/8 action=mark-connection new-connection-mark=WAN3_Connection passthrough=yes 
add chain=prerouting dst-address-type=!local in-interface=LAN per-connection-classifier=both-addresses-and-ports:11/9 action=mark-connection new-connection-mark=WAN3_Connection passthrough=yes 
add chain=prerouting dst-address-type=!local in-interface=LAN per-connection-classifier=both-addresses-and-ports:11/10 action=mark-connection new-connection-mark=WAN4_Connection passthrough=yes

add chain=prerouting connection-mark=WAN1_Connection in-interface=LAN action=mark-routing new-routing-mark=Route_To_WAN1
add chain=prerouting connection-mark=WAN2_Connection in-interface=LAN action=mark-routing new-routing-mark=Route_To_WAN2
add chain=prerouting connection-mark=WAN3_Connection in-interface=LAN action=mark-routing new-routing-mark=Route_To_WAN3
add chain=prerouting connection-mark=WAN4_Connection in-interface=LAN action=mark-routing new-routing-mark=Route_To_WAN4

/ip route
add dst-address=0.0.0.0/0 routing-mark=Route_To_WAN1 gateway=10.10.10.6 check-gateway=ping 
add dst-address=0.0.0.0/0 routing-mark=Route_To_WAN2 gateway=10.10.20.6 check-gateway=ping
add dst-address=0.0.0.0/0 routing-mark=Route_To_WAN3 gateway=10.10.30.6 check-gateway=ping 
add dst-address=0.0.0.0/0 routing-mark=Route_To_WAN4 gateway=10.10.40.6 check-gateway=ping 

add dst-address=0.0.0.0/0 gateway=10.10.10.6 distance=1 check-gateway=ping 
add dst-address=0.0.0.0/0 gateway=10.10.20.6 distance=2 check-gateway=ping
add dst-address=0.0.0.0/0 gateway=10.10.30.6 distance=3 check-gateway=ping 
add dst-address=0.0.0.0/0 gateway=10.10.40.6 distance=4 check-gateway=ping 

/ip firewall nat
add chain=srcnat out-interface=WAN1 action=masquerade
add chain=srcnat out-interface=WAN2 action=masquerade
add chain=srcnat out-interface=WAN3 action=masquerade
add chain=srcnat out-interface=WAN4 action=masquerade
Sadegh.Nakhjavani@GMail.com

Re: Best load balancing method for 4 WAN links

Posted: Wed Dec 17, 2014 12:30 pm
by tpfresh
Hi ALL

i reading your Load balance Bandwidth base Method(MUM_US12)
http://mum.mikrotik.com/presentations/US12/tomas.pdf
but i don't understand this
i connect internet by PPPoe-Client(pppoe-out1,2,3) and I have to do anything at this stage ?
thank you
/ipfirewall address-list
addaddress=1.1.1.0/24 list=Connected
addaddress=2.2.2.0/24 list=Connected
addaddress=192.168.22.0/24 list=Connected
addaddress=192.168.22.0/24 list=LAN
/ipfirewall mangle
addchain=preroutingsrc-address-list=Connected
dst-address-list=Connected action=accept

Re: Best load balancing method for 4 WAN links

Posted: Wed Dec 17, 2014 1:10 pm
by nick3dos

Re: Best load balancing method for 4 WAN links

Posted: Wed Dec 17, 2014 3:30 pm
by tpfresh
Thank you nick3dos but not it i mean it is PCC not Bandwidth base

Re: Best load balancing method for 4 WAN links

Posted: Wed Dec 17, 2014 3:34 pm
by tomaskir
Hi ALL

i reading your Load balance Bandwidth base Method(MUM_US12)
http://mum.mikrotik.com/presentations/US12/tomas.pdf
but i don't understand this
i connect internet by PPPoe-Client(pppoe-out1,2,3) and I have to do anything at this stage ?
thank you
/ipfirewall address-list
addaddress=1.1.1.0/24 list=Connected
addaddress=2.2.2.0/24 list=Connected
addaddress=192.168.22.0/24 list=Connected
addaddress=192.168.22.0/24 list=LAN
/ipfirewall mangle
addchain=preroutingsrc-address-list=Connected
dst-address-list=Connected action=accept
If using PPPoE, add only your LAN's subnet into the "Connected" address-list.

Re: Best load balancing method for 4 WAN links

Posted: Wed Dec 17, 2014 6:18 pm
by tpfresh
thank you tomaskir

i try to contact you in facebook & email in article :(
i meet this topic in seartch by google keyword "mikrotik load balance bandwidth base tomas" :lol: :lol:

Re: Best load balancing method for 4 WAN links

Posted: Thu Dec 18, 2014 2:52 pm
by mrkempis
any tips on how to mark the packet using sir tomas bandwidth based load balance

Re: Best load balancing method for 4 WAN links

Posted: Sat Dec 20, 2014 7:35 am
by tpfresh
hi tomaskir

i have a question but if i have internet 3 line ? in your LB bandwidth based method
i must set in tool--> Traffic monitor ?
if it have 2 internet line ok i understand

but 3 internet line How should I set up?

10MB x 10MB x 10MB


Thank you :D