How does switch work?


#1

I couldn’t find information on the wiki or in the documentation… Does anybody know how switch statement works?

Does it directly switches (passes/redirects) the call to another asterisk server? If the both the source extension and target extension on the other support native iax transfers, then does the call go p2p after being setup?


#2

What “switch” statement? Where did you come across it?


#3

switch can be used to connect two * servers.
voip-info.org/tiki-index.php … s#comments
Read the comments before if you want to use it.
C.


#4

:arrow_right: First command: switch used for realtime
extesions.conf

[some_context]
switch => Realtime/@family

reference:http://www.asteriskguru.com/tutorials/realtime_pgsql.html

:arrow_right: Second command: Switch option permits a server to share his dialplan with another server (ServerA>ServerB). Note that reciprocal switch statements are not allowed (ServerA>ServerB and ServerB>ServerA).

switch => IAX2/:[]@/

Note that and need to be declared in iax.conf
of the remote server ().

reference:http://www.asteriskguru.com/tutorials/extensions_conf.html


#5

think of 3 registration servers:

server1 registers extensions 1000-1999
server2 registers 2000-2999
server3 registers 3000-3999

all these servers have switch to servermain.
servermain is being used for sharing the dialplan which has the following
kind of extensions.conf:

exten => _1XXX,1,Dial(IAX2/myserver:password1@server1/${EXTEN:1},30,r)
exten => _1XXX,3,Congestion

exten => _2XXX,1,Dial(IAX2/myserver:password2@server2/${EXTEN:1},30,r)
exten => _2XXX,2,Congestion

exten => _3XXX,1,Dial(IAX2/myserver:password3@server3/${EXTEN:1},30,r)
exten => _3XXX,2,Congestion

then if user at extension 1541 wants to call 2645, will the call finally be delivered through server2?

If all extensions support native iax transfers, will that call go p2p after setup?

Thanks for all the info…


#6

[quote=“teohal”] exten => _1XXX,1,Dial(IAX2/myserver:password1@server1/${EXTEN:1},30,r)
exten => _1XXX,3,Congestion

exten => _2XXX,1,Dial(IAX2/myserver:password2@server2/${EXTEN:1},30,r)
exten => _2XXX,2,Congestion

exten => _3XXX,1,Dial(IAX2/myserver:password3@server3/${EXTEN:1},30,r)
exten => _3XXX,2,Congestion

then if user at extension 1541 wants to call 2645, will the call finally be delivered through server2?[/quote]
That looks about right, except you probably want ${EXTEN} rather than ${EXTEN:1}. Also, of course, you don’t want to make an IAX connection to the server that this dialplan is running on - whichever extensions are on that server wouldn’t need the Dial() entry here.

That depends on the setting(s) of notransfer= in iax.conf.