MikroTik DSL load balancing

Hi, I have two 4mbps ADSL connections with 5 public IP addresses each. these two dsl lines are connected to a RB493 running RouterOS 4.6, also connected to it is a ethernet connection to the main tower providing users with internet connectivity. the problem is load balancing the network load across the two dsl lines so that one doesn’t work harder than the other. the setup looks as follow.

ADSL Router 1 (196.212.122.81) (connected to RB493)
ADSL Router 2 (196.213.208.145) (connected to RB493)

RB493 : 196.212.122.82 (accessible from internet)
: 196.213.208.146 (accessible from internet)
: 12.63.124.254 (accessible from wifi network as primary default gateway)

the rb493 is currently setup with 2 default gateways (one for each dsl line) but being mostly from a cisco background i don’t entirely understand the whole mark-routing etc. configuration for this current setup. i need a way to implement this using layer 7 protocols i.e. ssl and some other services need to init sessions on a specific line as the source ip’s cant differ and non-secure services like normal HTTP can init from any available line. the other side of it is that (if possible we want some form of fail-over arrangement between the two lines so should one go down that the other is used.) and lastly, it is also necessary to prioritize some services like SIP using L7 and queues.

Thank you in advance

in the new routeros versions, u do not have to mark any packets to obtain a load balance. you could simply add 2 gateways in your ip route to get your load balance work
however, you could also do it in other ways such as mark client’s ip addresses and forward each pool to a different route, or also mark certain ports and forward each port to a gateway
tell me what you want and i will give you the exact configuration based on ur clients ip addresses and internet ip addresses

Hi, thnx for the quick response.
i think a port based config should work, so in other words, i would like to have some priority services like dns, sip, pop3, smtp, http & https (requests from 17.35.123.0/24) and skype (via L7 protocol) run via one line (the 196.212.122.81 gw) and all other services including http & https requests from 17.35.124.0/24 across the other line (196.213.208.145 gateway).

here’s the L7 proto for Skype

/ip firewall layer7-protocol
add comment="" name=skypeout regexp="^(\01.\?.\?.\?.\?.\?.\?.\?.\?\01|\02.\?.\
   \?.\?.\?.\?.\?.\?.\?\02|\03.\?.\?.\?.\?.\?.\?.\?.\?\03|\04.\?.\?.\?.\?.\?.\
   \?.\?.\?\04|\05.\?.\?.\?.\?.\?.\?.\?.\?\05|\06.\?.\?.\?.\?.\?.\?.\?.\?\06|\
   \07.\?.\?.\?.\?.\?.\?.\?.\?\07|\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.\?.\?.\?.\?\F2|\F3.\?.\?.\?.\?.\?.\?.\?.\?\F3|\F4.\?.\?.\?.\?.\?.\
   \?.\?.\?\F4|\F5.\?.\?.\?.\?.\?.\?.\?.\?\F5|\F6.\?.\?.\?.\?.\?.\?.\?.\?\F6|\
   \F7.\?.\?.\?.\?.\?.\?.\?.\?\F7|\F8.\?.\?.\?.\?.\?.\?.\?.\?\F8|\F9.\?.\?.\?\
   .\?.\?.\?.\?.\?\F9|\FA.\?.\?.\?.\?.\?.\?.\?.\?\FA|\FB.\?.\?.\?.\?.\?.\?.\?\
   .\?\FB|\FC.\?.\?.\?.\?.\?.\?.\?.\?\FC|\FD.\?.\?.\?.\?.\?.\?.\?.\?\FD|\FE.\
   \?.\?.\?.\?.\?.\?.\?.\?\FE|\FF.\?.\?.\?.\?.\?.\?.\?.\?\FF)"
add comment="" name=skypetoskype regexp="^..\02............."
/

again, thnx, lemme know if there’s anything else you require.

http://wiki.mikrotik.com/wiki/Per-Traffic_Load_Balancing
check this link it is most suitable to u.
you will find all required information, and if u still need help feel free to tell me

hi, i just implemented → http://wiki.mikrotik.com/wiki/Per-Traffic_Load_Balancing down to the letter and the requests (packets) are going through all the rules but absolutely nothing exits to the WAN, not even ICMP (from inside the network i cant even ping any address past the rb493). i’ve double checked and didn’t miss anything on the link you’ve posted… what do you think went wrong?

I almost had the same problem, BUT !! I have two separate DSL lines from the same ISP both, and I always get SAME GATEWAY ip address for each. Problem is that after the second line has been built up by PPPoE all traffic goes on the new line, even though if I force adding two times the same gateway address for dst 0.0.0.0/0 packets.

Question: How is it possible to handle two DSL lines by load balancing, when both gateway addresses are identical, so that equal-cost-multipath-routing does not work anyaway in this case?

Your comment are also welcome on this problem.

Rgds,
pery

use v4 and set (via Terminal) ‘gateway=IP_address%interface’

for example, for ECMP you should use ‘gateway=192.168.0.1%ether1,192.168.0.1%ether2’

Hi Pery,
I am in the same situation. There is a syntax for this; e.g.:

/ ip route
add dst-address=0.0.0.0/0 gateway=12.34.56.78%ether1,12.34.56.78%ether2

Note that Winbox does not (as of ROS 4.6) handle this “%” syntax. Using winbox to modify a route that uses this syntax, even to disable and re-enable it, will strip off the % suffix, and you’ll have the pleasure of re-typing it.

you cannot use L7 to select gateway until you don’t use NAT

L7 works on established connections

by this way I can have load balance and failover combined?

Thanks!

sure, but if you’re using NAT, long-time connections will break periodically. so you’d better use http://wiki.mikrotik.com/wiki/PCC#Application_Example_-_Load_Balancing

I used this config for a long time but I had problems with VoIP services… When one WAN was down and got UP again the VoIP connection states were confused…

What do you suggest regarding the PCC classifier???

src-address
dst-address
both-addresses
etc…

src-address is the most universal