First thing in the planned asterisk clea ... / 2011-03-01

2011-03-01 First thing in the planned asterisk clea ... 9 years ago
First thing in the planned asterisk cleanup: IAX2 trunking. It took me a few tries and some debugging settings to get it right. So I'm sharing it with the world.

First of all a description of the setup: the pcgg demo asterisk which can hang out wherever on the Internet behind a NAT router. The other asterisk is pbx.idefix.net which lives at a fixed IP. So the config on the dynamic host is to register with the static host. Relevant parts of iax.conf on the pcgg demo asterisk:
register => link2idefix:secret@pbx.idefix.net

..

[link2idefix]
type=friend
username=link2idefix
secret=secret
auth=md5
context=idefix-in
host=pbx.idefix.net
trunk=yes
qualify=yes
And using it in extensions.conf for dialing from the pcgg demo asterisk to extensions on pbx.idefix.net:
exten => 8100,1,Dial(IAX2/link2idefix/${EXTEN})
Context idefix-in in extensions.conf is a simple one:
[idefix-in]

include => localnumbers
But I like to create separate contexts for different incoming links. Most will include one or more contexts of usable numbers.

The other end looks quite similar. Part of iax.conf on pbx.idefix.net:
[link2idefix]
type=friend
host=dynamic
context=pcgg-in
username=link2idefix
auth=md5
secret=secret
trunk=yes
Naming the context different from the username gave errors like:
chan_iax2.c:5355 register_verify: No registration for peer 'link2idefix' (from xx.yy.zz.pp)
So that is why those are the same. The pcgg-in context is similar:
[pcgg-in]

include => localnumbers
include => localscripts
Dialing from pbx.idefix.net to the pcgg demo asterisk is also simple. An entry in extensions.conf:
exten => _800[045],1,Dial(IAX2/link2idefix/${EXTEN})
Which indeed fails when the other exchange hasn't registered itself. To improve this (and give a reasonable error tone or audio message when this happens) I wrote a macro to deal with the return status from the Dial() command:
[macro-remoteexten]
;
; dial a remote extension (another asterisk or over sip trunk)
; ${ARG1} - Dialstring (IAX2/link2idefix/8100)
;
; ${CALLERID} is untouched and supposed to be set correctly already
;
; typical uses
;
; Macro(remoteexten,IAX2/link2idefix/${EXTEN})
; Macro(remoteexten,SIP/voip.phonecaster.de/49931663991377)
; Macro(remoteexten,IAX2/cnetguest@projectmf.homelinux.com/17622600)

exten => s,1,Progress()
exten => s,2,Dial(${ARG1},30)           ; Ring the remote, 30 seconds maximum
exten => s,3,Goto(s-${DIALSTATUS},1)            ; Jump based on status (NOANSWER,BUSY,CHANUNAVAIL,CONGESTION,ANSWER)
exten => s-BUSY,1,Playtones(busy)
exten => s-BUSY,n,Wait(120)
exten => s-CHANUNAVAIL,1,Playtones(info)
exten => s-CHANUNAVAIL,n,Wait(120)
exten => s-CONGESTION,1,Playtones(congestion)
exten => s-CONGESTION,n,Wait(120)
Which changes the above to:
exten => _800[045],1,Macro(remoteexten,IAX2/link2idefix/${EXTEN})
This makes the result of dialing a lot better to understand. Another upgrade would be nice audio messages. Or not completely nice ones, such as this "Due to the earthquake in the area you are calling, your call cannot be completed as dialed".

Lots of use of Asterisk config iax.conf - voip-info.org and Asterisk cmd Dial - voip-info.org

Tags: ,

, reachable as koos+website@idefix.net. PGP encrypted e-mail preferred.

PGP key 5BA9 368B E6F3 34E4 local copy PGP key 5BA9 368B E6F3 34E4 via keyservers pgp key statistics for 0x5BA9368BE6F334E4 Koos van den Hout
RSS
Other webprojects: Camp Wireless, wireless Internet access at campsites, The Virtual Bookcase, book reviews
This page generated in 0.004678 seconds.