Link to home
Create AccountLog in
Avatar of Shaun Wingrin
Shaun WingrinFlag for South Africa

asked on

Asterisk network interface selection to load balance accross 2 or more ADSL lines

Hi,

I have a bandwidth limitation and need to carry 8 simultaneous calls. Each of the ADSL lines available can carry a maximum of 4 simultanous calls.Any idea how to setup Asterisk so that the IAX2/SIP calls are sent down two seperate network interfaces (connected to ADSL) and thereby allowing agregating the bandwidth. There is only one ip to send the calls to as the Asterisk sends all calls to the central Asterisk server and they are then forwarded from there. I was thinking of setting up two IAX2 trunks with different ports and then natting the IAX2 port on the linux server and forcing the traffic down an ip interface based on the port. Not that I know how to do this.

 However the one problem I have is how to ensure that Asterisk splits the calls over the two IAX trunks?

Any suggestions welcome.
Avatar of Member_2_1968385
Member_2_1968385
Flag of United Kingdom of Great Britain and Northern Ireland image

Unless you can do some clever tricks in your NAT/firewall device, I don't think you will be able to separate the routes based on port number - you need 2 different destination IP addresses to send to; alternatively, 2 different 'source' devices doing the sending.

You can do a kind of load balancing in asterisk by using a global variable that increments each time a new call arrives, then using gotoif to select a different path depending whether the variable is odd or even (perhaps using the modulus math operand):
http://www.voip-info.org/wiki-Asterisk+Dialplan+Globals
http://www.voip-info.org/wiki/view/Asterisk+cmd+GotoIf
http://www.voip-info.org/wiki/view/Asterisk+func+math

Another solution might be to randomly select the outbound route:
http://www.voip-info.org/wiki/view/Asterisk+cmd+Random
Avatar of Shaun Wingrin

ASKER

This is a valuable answer. How can I limit the number of simultaneous calls  to say four? The ADSL line can only carry 4 simultaneous calls and with the dialling as above if there are a number of long calls then one of the channels may have too many calls on it... How can I see how many calls are going to a particular host? Based on this how can I choose where to send the next call? With this setup I can place the call to a particular host so as to properly load balance...
ASKER CERTIFIED SOLUTION
Avatar of Member_2_1968385
Member_2_1968385
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
See answer
Thank you for the informative advice. In my case its not so much an issue of load balancing as just ensuring that no more than 4 calls are carried by one adsl line at any one time. It seems ti me the easiest way is to count how many calls are active on an IAX2 trunk and based on this descide where to send the next call. Is there any way to get a count of the calls on each trunk?

I'm using IAX2. Am I correct in saying that there is no way to limit the number of iax2 calls allowed on a trunk?
However the one problem I have is how to ensure that Asterisk splits the calls over the two IAX trunks. This solution assumes SIP. Will it work for IAX?