[asterisk-users] SIP Load Balancing

Zeeshan Zakaria zishanov at gmail.com
Thu Oct 28 13:07:38 CDT 2010


Actually it was not so difficult to understand what Roger said, but let me
expand it further (the way I would do it):

First of all setup a global variable TRUNK in extension.conf;
[globals]
TRUNK=0;

Then use your dialplan like this:

exten => NXXNXXXXX,1,GotoIf($["${TRUNK}"="0"]?trunk1:trunk2)

exten => NXXNXXXXX,n(trunk1),SetGlobalVar(TRUNK=1])
exten => NXXNXXXXX,n,Dial(SIP/${DIALEDNUM}@2.4.6.8 <DIALEDNUM%7D at 2.4.6.8>)

exten => NXXNXXXXX,n(trunk2),SetGlobalVar(TRUNK=0)
exten => NXXNXXXXX,n,Dial(SIP/${DIALEDNUM}@1.2.3.4 <DIALEDNUM%7D at 1.2.3.4>)


I used global variable because otherwise your variable will always reset
itself on a start of a call and will always stay 0.

If you want to add more trunks in the future, you can expand this logic
using:
SetGlobalVar(TRUNK=$[${TRUNK}+1]

and for every trunk number, go to a different line of the context. In the
end, make sure to set the TRUNK variable back to 0.

Using a macro for dialing would be even a better idea, but that would make
it more complicated for you at this time. Keep it simple for only two
trunks.

Sincerely,

Zeeshan A Zakaria

www.ilovetovoip.com
www.pbxforall.com (beta)

On Thu, Oct 28, 2010 at 1:12 PM, Tim King <tim at compnetwork.net> wrote:

> Sorry for the confusion, but the last sentence throws me off. "Translation
> of this to dialplan logic is left as an exercise for the
> student." Is this example from some sort of book or is this a way of saying
> I am left to figure the rest out??
>
> I was hoping to find a simple example of how this works.
>
>
> On Thu, Oct 28, 2010 at 11:24 AM, Roger Burton West <roger at firedrake.org>wrote:
>
>> On Thu, Oct 28, 2010 at 11:08:12AM -0400, Tim King wrote:
>> >I have a very simple setup with two SIP routes to my carrier. I need to
>> have
>> >every other phone call placed to that carrier go to a different address.
>>
>> I think what you need to do here is check/set a variable in the astdb.
>>
>> (If the variable is 1, set it to 2 and route via A; otherwise, set it to
>> 1 and route via B.)
>>
>> Translation of this to dialplan logic is left as an exercise for the
>> student.
>>
>> R
>>
>> --
>> _____________________________________________________________________
>> -- Bandwidth and Colocation Provided by http://www.api-digital.com --
>> New to Asterisk? Join us for a live introductory webinar every Thurs:
>>               http://www.asterisk.org/hello
>>
>> asterisk-users mailing list
>> To UNSUBSCRIBE or update options visit:
>>   http://lists.digium.com/mailman/listinfo/asterisk-users
>>
>
>
> --
> _____________________________________________________________________
> -- Bandwidth and Colocation Provided by http://www.api-digital.com --
> New to Asterisk? Join us for a live introductory webinar every Thurs:
>               http://www.asterisk.org/hello
>
> asterisk-users mailing list
> To UNSUBSCRIBE or update options visit:
>   http://lists.digium.com/mailman/listinfo/asterisk-users
>



-- 
Zeeshan A Zakaria
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.digium.com/pipermail/asterisk-users/attachments/20101028/b1e42813/attachment.htm 


More information about the asterisk-users mailing list