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. This is what I need the call flow to look like. I have spent many hours searching and have not found a working example. Call1 exten => NXXNXXXXX,2,Dial(SIP/${DIALEDNUM}@2.4.6.8<DIALEDNUM%7D at 2.4.6.8> ) Call2 exten => NXXNXXXXX,2,Dial(SIP/${DIALEDNUM}@1.2.3.4<DIALEDNUM%7D at 1.2.3.4> ) Call3 exten => NXXNXXXXX,2,Dial(SIP/${DIALEDNUM}@2.4.6.8<DIALEDNUM%7D at 2.4.6.8> ) Call4 exten => NXXNXXXXX,2,Dial(SIP/${DIALEDNUM}@1.2.3.4<DIALEDNUM%7D at 1.2.3.4> ) Call5 exten => NXXNXXXXX,2,Dial(SIP/${DIALEDNUM}@2.4.6.8<DIALEDNUM%7D at 2.4.6.8> ) Call6 exten => NXXNXXXXX,2,Dial(SIP/${DIALEDNUM}@1.2.3.4<DIALEDNUM%7D at 1.2.3.4> ) Call7 exten => NXXNXXXXX,2,Dial(SIP/${DIALEDNUM}@2.4.6.8<DIALEDNUM%7D at 2.4.6.8> ) Call8 exten => NXXNXXXXX,2,Dial(SIP/${DIALEDNUM}@1.2.3.4<DIALEDNUM%7D at 1.2.3.4> ) .......................... -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.digium.com/pipermail/asterisk-users/attachments/20101028/f7d86121/attachment-0001.htm
----- Original Message ----- 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. This is what I need the call flow to look like. I have spent many hours searching and have not found a working example. Call1 exten => NXXNXXXXX,2,Dial(SIP/${ DIALEDNUM}@2.4.6.8 ) Call2 exten => NXXNXXXXX,2,Dial(SIP/${ DIALEDNUM}@1.2.3.4 ) Call3 exten => NXXNXXXXX,2,Dial(SIP/${ DIALEDNUM}@2.4.6.8 ) Call4 exten => NXXNXXXXX,2,Dial(SIP/${ DIALEDNUM}@1.2.3.4 ) Call5 exten => NXXNXXXXX,2,Dial(SIP/${ DIALEDNUM}@2.4.6.8 ) Call6 exten => NXXNXXXXX,2,Dial(SIP/${ DIALEDNUM}@1.2.3.4 ) Call7 exten => NXXNXXXXX,2,Dial(SIP/${ DIALEDNUM}@2.4.6.8 ) Call8 exten => NXXNXXXXX,2,Dial(SIP/${ DIALEDNUM}@1.2.3.4 ) .......................... -- _____________________________________________________________________ -- 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 Your own internal DNS and give those IPs a single name ? -- Thanks, Phil -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.digium.com/pipermail/asterisk-users/attachments/20101028/770ccaea/attachment.htm
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
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 >-------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.digium.com/pipermail/asterisk-users/attachments/20101028/00081b03/attachment.htm
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
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. > > This is what I need the call flow to look like. I have spent many hours > searching and have not found a working example. > Call1 exten => NXXNXXXXX,2,Dial(SIP/${DIALEDNUM}@2.4.6.8<DIALEDNUM%7D at 2.4.6.8> > ) > Call2 exten => NXXNXXXXX,2,Dial(SIP/${DIALEDNUM}@1.2.3.4<DIALEDNUM%7D at 1.2.3.4> > ) > Call3 exten => NXXNXXXXX,2,Dial(SIP/${DIALEDNUM}@2.4.6.8<DIALEDNUM%7D at 2.4.6.8> > ) > Call4 exten => NXXNXXXXX,2,Dial(SIP/${DIALEDNUM}@1.2.3.4<DIALEDNUM%7D at 1.2.3.4> > ) > Call5 exten => NXXNXXXXX,2,Dial(SIP/${DIALEDNUM}@2.4.6.8<DIALEDNUM%7D at 2.4.6.8> > ) > Call6 exten => NXXNXXXXX,2,Dial(SIP/${DIALEDNUM}@1.2.3.4<DIALEDNUM%7D at 1.2.3.4> > ) > Call7 exten => NXXNXXXXX,2,Dial(SIP/${DIALEDNUM}@2.4.6.8<DIALEDNUM%7D at 2.4.6.8> > ) > Call8 exten => NXXNXXXXX,2,Dial(SIP/${DIALEDNUM}@1.2.3.4<DIALEDNUM%7D at 1.2.3.4> > ) > ..........................If your goal is really load balancing, not just alternating between providers, you might look at the GROUP* functions. Otherwise, if you hit a stretch where you have, e.g., several even-numbered calls of long duration mixed with short odd-numbered calls, most of your traffic will wind up on the same route. -- Barry
Its not so much me load balancing but the carrier requires that every other call I send goes to the other address.. On Thu, Oct 28, 2010 at 2:36 PM, Barry Miller <asterisk-users at notanet.net>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. > > > > This is what I need the call flow to look like. I have spent many hours > > searching and have not found a working example. > > Call1 exten => NXXNXXXXX,2,Dial(SIP/${DIALEDNUM}@2.4.6.8<DIALEDNUM%7D at 2.4.6.8> > <DIALEDNUM%7D at 2.4.6.8 <DIALEDNUM%257D at 2.4.6.8>> > > ) > > Call2 exten => NXXNXXXXX,2,Dial(SIP/${DIALEDNUM}@1.2.3.4<DIALEDNUM%7D at 1.2.3.4> > <DIALEDNUM%7D at 1.2.3.4 <DIALEDNUM%257D at 1.2.3.4>> > > ) > > Call3 exten => NXXNXXXXX,2,Dial(SIP/${DIALEDNUM}@2.4.6.8<DIALEDNUM%7D at 2.4.6.8> > <DIALEDNUM%7D at 2.4.6.8 <DIALEDNUM%257D at 2.4.6.8>> > > ) > > Call4 exten => NXXNXXXXX,2,Dial(SIP/${DIALEDNUM}@1.2.3.4<DIALEDNUM%7D at 1.2.3.4> > <DIALEDNUM%7D at 1.2.3.4 <DIALEDNUM%257D at 1.2.3.4>> > > ) > > Call5 exten => NXXNXXXXX,2,Dial(SIP/${DIALEDNUM}@2.4.6.8<DIALEDNUM%7D at 2.4.6.8> > <DIALEDNUM%7D at 2.4.6.8 <DIALEDNUM%257D at 2.4.6.8>> > > ) > > Call6 exten => NXXNXXXXX,2,Dial(SIP/${DIALEDNUM}@1.2.3.4<DIALEDNUM%7D at 1.2.3.4> > <DIALEDNUM%7D at 1.2.3.4 <DIALEDNUM%257D at 1.2.3.4>> > > ) > > Call7 exten => NXXNXXXXX,2,Dial(SIP/${DIALEDNUM}@2.4.6.8<DIALEDNUM%7D at 2.4.6.8> > <DIALEDNUM%7D at 2.4.6.8 <DIALEDNUM%257D at 2.4.6.8>> > > ) > > Call8 exten => NXXNXXXXX,2,Dial(SIP/${DIALEDNUM}@1.2.3.4<DIALEDNUM%7D at 1.2.3.4> > <DIALEDNUM%7D at 1.2.3.4 <DIALEDNUM%257D at 1.2.3.4>> > > ) > > .......................... > > If your goal is really load balancing, not just alternating between > providers, you might look at the GROUP* functions. Otherwise, if you > hit a stretch where you have, e.g., several even-numbered calls of long > duration mixed with short odd-numbered calls, most of your traffic will > wind up on the same route. > > -- > Barry > > -- > _____________________________________________________________________ > -- 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 >-------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.digium.com/pipermail/asterisk-users/attachments/20101028/896c9910/attachment.htm
I updated it as follows and I am still only getting the SayNumber(2) [tim] exten => _X.,1,GotoIf(${SET(DB(avoics/route)=$[!0${DB(avoics/route)}])}?route1:route2) exten => _X.,n(route1),SayNumber(1) exten => _X.,n,Hangup() exten => _X.,n(route2),SayNumber(2) exten => _X.,n,Hangup() On Thu, Oct 28, 2010 at 3:05 PM, Tilghman Lesher <tlesher at digium.com> wrote:> On Thursday 28 October 2010 13:32:51 Tim King wrote: > > Thanks For The replies. I have tried piecing the samples together. Just > > for testing purposes i have created the following. > > > > [test] > > exten => > > _X.,1,GotoIf(${SET(DB(avoics/route)=$[!0${DB(avoics/route)}])}?route1:ro > > ute2) exten => _X.,n(route1),Set(DB(avoics/route)=1) > > exten => _X.,n,SayNumber(1) > > exten => _X.,n,Hangup() > > exten => _X.,n(route2),Set(DB(avoics/route)=0) > > exten => _X.,n,SayNumber(2) > > exten => _X.,n,Hangup() > > > > The idea is if I continue dialing any number into this context I should > > hear 1 2 1 2 1 2 > > > > Currently it is skipping to 2 as it should be since my database shows: > > /avoics/route : 1 > > > > It appears there is something wrong with my set command? > > You can drop your separate Set application. The SET() dialplan function > does the alternation for you. > > -- > Tilghman Lesher > Digium, Inc. | Senior Software Developer > twitter: Corydon76 | IRC: Corydon76-dig (Freenode) > Check us out at: www.digium.com & www.asterisk.org > > -- > _____________________________________________________________________ > -- 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 >-------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.digium.com/pipermail/asterisk-users/attachments/20101028/89e82f44/attachment.htm
It seems that the GotoIf(${SET(DB(avoics/route)=$[!0${DB(avoics/route)}])}?route1:route2) is always returning false as if the SET command is not returning a value nor is it changing the value in the DB. Will this not work because I am running Asterisk 1.4.25.1?? On Thu, Oct 28, 2010 at 3:15 PM, Tim King <tim at compnetwork.net> wrote:> I updated it as follows and I am still only getting the SayNumber(2) > > [tim] > > exten => > _X.,1,GotoIf(${SET(DB(avoics/route)=$[!0${DB(avoics/route)}])}?route1:route2) > exten => _X.,n(route1),SayNumber(1) > exten => _X.,n,Hangup() > exten => _X.,n(route2),SayNumber(2) > exten => _X.,n,Hangup() > > > > > On Thu, Oct 28, 2010 at 3:05 PM, Tilghman Lesher <tlesher at digium.com>wrote: > >> On Thursday 28 October 2010 13:32:51 Tim King wrote: >> > Thanks For The replies. I have tried piecing the samples together. Just >> > for testing purposes i have created the following. >> > >> > [test] >> > exten => >> > _X.,1,GotoIf(${SET(DB(avoics/route)=$[!0${DB(avoics/route)}])}?route1:ro >> > ute2) exten => _X.,n(route1),Set(DB(avoics/route)=1) >> > exten => _X.,n,SayNumber(1) >> > exten => _X.,n,Hangup() >> > exten => _X.,n(route2),Set(DB(avoics/route)=0) >> > exten => _X.,n,SayNumber(2) >> > exten => _X.,n,Hangup() >> > >> > The idea is if I continue dialing any number into this context I should >> > hear 1 2 1 2 1 2 >> > >> > Currently it is skipping to 2 as it should be since my database shows: >> > /avoics/route : 1 >> > >> > It appears there is something wrong with my set command? >> >> You can drop your separate Set application. The SET() dialplan function >> does the alternation for you. >> >> -- >> Tilghman Lesher >> Digium, Inc. | Senior Software Developer >> twitter: Corydon76 | IRC: Corydon76-dig (Freenode) >> Check us out at: www.digium.com & www.asterisk.org >> >> -- >> _____________________________________________________________________ >> -- 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 >> > >-------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.digium.com/pipermail/asterisk-users/attachments/20101028/f857f245/attachment.htm