I have a mikrotik routerboard configured as load balancer with two WANs connections. I need 70% of the traffic to go through the first WAN and 30% through the second WAN. Can it be done by mikrotik os ?
Here is an example of how you could add more weight on your WAN 1 Interface :
add chain=prerouting in-interface=LAN connection-mark=no-mark dst-address-type=!local \
per-connection-classifier=both-addresses:4/0 action=mark-connection new-connection-mark=ISP1_conn
add chain=prerouting in-interface=LAN connection-mark=no-mark dst-address-type=!local \
per-connection-classifier=both-addresses:4/1 action=mark-connection new-connection-mark=ISP1_conn
add chain=prerouting in-interface=LAN connection-mark=no-mark dst-address-type=!local \
per-connection-classifier=both-addresses:4/2 action=mark-connection new-connection-mark=ISP1_conn
add chain=prerouting in-interface=LAN connection-mark=no-mark dst-address-type=!local \
per-connection-classifier=both-addresses:4/3 action=mark-connection new-connection-mark=ISP2_conn
But notice that you only add a weight, meaning you increase the posibility.
Start from this point: Balance traffic between 2 WLAN is impossible if you do not know before how much traffic pass, and without destroy instaured connections.
You can “manage” only how many connection go to WAN1 and how many on WAN2, without know before how much data use that connections.
A 66% to 33% is very easy.
Mangle: two rules that mark traffic by PCC and don’t set Passtrough in the Action tab. If you PCC mark them for wan 1 then you have 66% going through that. First line PCC 2/0 and the second line 2/1. 33% Of the traffic should be PCC marked in the third line but you don’t need to set the PCC because already 66% is filtered out of the traffic won’t reach this line.
Borrowing the lines that Zacharias put in the posting above:
add chain=prerouting in-interface=LAN connection-mark=no-mark dst-address-type=!local \
per-connection-classifier=both-addresses-and-ports:2/0 action=mark-connection new-connection-mark=ISP1_conn
add chain=prerouting in-interface=LAN connection-mark=no-mark dst-address-type=!local \
per-connection-classifier=both-addresses-and-ports:2/1 action=mark-connection new-connection-mark=ISP1_conn
add chain=prerouting in-interface=LAN connection-mark=no-mark dst-address-type=!local \
action=mark-connection new-connection-mark=ISP2_conn
I like to use also the ports of the connections for PCC.
@msatter something is strange…
2/0 & 2/1 = 50% + 50%…
instead
3/0, 3/1, 3/2 = 33,3_% + 33,3_% + 33,3_%
for do 66,6_% / 33.3_% must used 3/0 & 3/1 omitting 3/3
Why lost time and first mark connection, then mark marked connection with mark route,
Instead of directly mark route?
/ip firewall mangle
add action=mark-routing chain=prerouting dst-address-type=!local in-interface=LAN new-routing-mark=ISP1_table passthrough=yes \
per-connection-classifier=both-addresses:3/0 routing-mark=!main
add action=mark-routing chain=prerouting dst-address-type=!local in-interface=LAN new-routing-mark=ISP1_table passthrough=yes \
per-connection-classifier=both-addresses:3/1 routing-mark=!main
add action=mark-routing chain=prerouting dst-address-type=!local in-interface=LAN new-routing-mark=ISP2_table passthrough=yes \
routing-mark=!main
And there is he again having his say about any other poster. Sorry, I won’t open you dribble.
You just make a shit figure to write like this, (100/2) = 50 and (100-(50*2)) = 0 in my house…
Even if I were the person who writes the most bullshit in the world, you are not perfect, you can make mistakes like anyone else,
indeed you make more mistakes because you are just presumptuous that no one can correct you and that everything you write is correct.
2/0 & 2/1 = 50% + 50%…
instead
3/0, 3/1, 3/2 = 33,3_% + 33,3_% + 33,3_%for do 66,6_% / 33.3_% must used 3/0 & 3/1 omitting 3/3
@rextended how exactly did you make these calculations ?
The hashing algorithm used on PCC does not divide the traffic equally…
So this : 2/0 & 2/1 = 50% + 50%… is not true…
From my post #3 on this topic:
Start from this point: Balance traffic between 2 WLAN is impossible if you do not know before how much traffic pass, and without destroy instaured connections.
You can “manage” only how many connection go to WAN1 and how many on WAN2, without know before how much data use that connections.
Official description:
per-connection-classifier (ValuesToHash:Denominator/Remainder; Default: )
PCC matcher allows division of traffic into equal streams with ability to keep packets with specific set of options in one particular stream.
Official Wiki
https://wiki.mikrotik.com/wiki/Manual:PCC
Official help
https://help.mikrotik.com/docs/display/ROS/Firewall+Marking#FirewallMarking-LoadBalancingWithPerConnectionClassifier
Page 51 and on
https://mum.mikrotik.com/presentations/US12/steve.pdf
and this
https://mum.mikrotik.com/presentations/ZA13/bisschoff.pdf
and other dozen MikroTik / MUM documents…
If works on this way, ignoring the differencies from methods,
the methods convert (for example) src-address to one 32 bit hash,
then divide it to first number (for ex. 2/x)
and compare the reminder to the next number (for example x/1), if equal are matched, then not.
if the denominator be 2, only 2 type of reminder can be possible, 0 and 1
if the denominator be 3, only 3 type of reminder can be possible, 0, 1, 2
if the denominator be 4, only 4 type of reminder can be possible, 0, 1, 2, 3
and so on.
Is not an exact division, but for statistic use 2/0 & 2/1 match 100% the connections and the probability for 2 reminder are 50% / 50%
Sorry if my english can’t permit me to explain better
Hmm to achieve 66 percent isnt it a matter of creating enough streams and then assigning them to the WAN appropriately.
Ex. 3 wans…
4/0 WAN1
4/1 WAN2
4/2 WAN3
4/3 WAN3
4/4 WAN3
Consider that its really 5 streams 1/5 to WAN1 1/5 to WAN2 and 3/5 to WAN2 (20:20:60)
Also I would mix it up as well so WAN 3 is evenly distributed during a cycle. ----> 4/0 to wan3, 4/1 to wan2, 4/2 to wan3, 4/3 to wan2 4/4 to wan3
in this case two wans and op wants 70:30
what fraction yields 70% 10 streams…
9/0 - W1
9/1 - W1
9/2- W2
9/3 - W1
9/4- W1
9/5- W2
9/6 - W1
9/7 - W1
9/8 - W2
9/9 - W1
Is probaly than I haved a better idea for 2 WAN 66.6_% / 33.3_%:
Do not mark nothing except 1/3 of connections… only 1 rule and only 1 extra routing table…
/ip firewall mangle
add action=mark-routing chain=prerouting dst-address-type=!local in-interface=LAN new-routing-mark=ISP2_table passthrough=yes
per-connection-classifier=both-addresses:3/0 routing-mark=!ISP2_table
This means that two completely unrelated connections could match the same PCC matcher, and would be put on the same line. PCC works better the more connections you put across it so that the hash function has more chances to produce different outputs.
Source : https://update.mikrotik.com/wiki/How_PCC_works_(beginner)
Since two connection can produce the same output, you can’t say that you can achieve an exact 50% - 50% load distribution… There is the chance, but it is not sure…
The more the connections the greater the chance for an even distribution …
Quite even with PCC both-addresses-and-ports (bytes and packets displayed, period less than two days):

Each line is a different WAN and you need a SingleWAN address list for sites who don’t like you changing the source-address all the time. You can avoid this by not using the ports but then the spreading is not that nice.
Each line is a different WAN and you need a SingleWAN address list for sites who don’t like you changing the source-address all the time.
I do agree, both addresses and ports does create a more even load distribution.
As you said, there will be a problem with sites that do not like seeing a different source address all the time …
You extract from different context the text and paste here for why?
In our example, 3 % 3 = 0, and 6 % 3 = 0; we get back 0 when we feed it a 3 as well as when we feed it a 6.
I do not use 3/0 and 6/0 at same time, like the example used inside.
If you read again my post, nothing is exact, but have chances 2/0 + 2/1 = 100% for sure and 50% / 50% probability/chances
What exactly are you talking about ?because am totally confused…
I pasted the text and the source where it belongs so that it is easier for you to read…
Did you even see the word source ? Provided with a link ? Indicating where that text belongs to…
That was an example, even if it is 2/0 or 2/1 you get the probability of 50-50 … it is not guarandeed even distribution…
If there are 10 connections inside your network, 2/0 , 2/1 wont guarantee that five will go through isp1 and the other five through isp2…
It’s why I write probability/chance and not “absolute and certain certainty that not even God can do otherwise”.
For me the discussion is over, I do not intend to go further on this topic,
I trust more than what is said at the MUM and by the MikroTik documentation, instead of what you try to make it look like you say.
The reason does not interest me, in this case, so much so that you are not a customer who has to pay me and who objects to not pay,
and neither am I your teacher who must insist on making you understand the what’s this.
Nothing personal, really.
Page 126, indicates that using both addresses and ports gives you better possibility for even distribution.
So, using lets say src address or both addresses the possibilities are less.
But ofcorse, increasing the number of connections you increase the possibilities of even distribution.
https://mum.mikrotik.com/presentations/US12/steve.pdf
Also, in the mikrotik wiki,
https://update.mikrotik.com/wiki/How_PCC_works_(beginner)
Is indicated that different inputs can produce same output. I already mentioned an example earlier. So 2 diferent connections can go out through the same ISP… where is even distribution ?
I dont have any interest of you teaching me. I just pointed that the connections cant exactly be 50-50% or
33,3_% + 33,3_% + 33,3_% as you keep saying, and they are not, because we have to do with probabilities and not with exact numbers… someone reading your first posts that you say : 2/0 & 2/1 = 50% + 50%, obviously will think that the connections are 100% percent equally divided… that was my disagreement only…
This post you wrote explains exactly why I don’t want to go back to the subject anymore.
At this point I write it: you seem like an idiot, you continue to underline to me the probabilities as if I hadn’t never written it all the time.
But do you know how to read or do you do it just to bother?
2/0 + 2/1 = 100% of the connections. Is nothing you can do or write for change this.
And this is not an opinion, but is mathematics.