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

2011-03-01 First thing in the planned asterisk clea ...
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 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 =>


And using it in extensions.conf for dialing from the pcgg demo asterisk to extensions on
exten => 8100,1,Dial(IAX2/link2idefix/${EXTEN})
Context idefix-in in extensions.conf is a simple one:

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
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:

include => localnumbers
include => localscripts
Dialing from 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:
; 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/
; Macro(remoteexten,IAX2/

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 - and Asterisk cmd Dial -

Tags: ,

IPv6 check

Running test...
, reachable as PGP encrypted e-mail preferred. PGP key 5BA9 368B E6F3 34E4 local copy PGP key 5BA9 368B E6F3 34E4 via keyservers

Meningen zijn die van mezelf, wat ik schrijf is beschermd door auteursrecht. Sommige publicaties bevatten een expliciete vermelding dat ze ongevraagd gedeeld mogen worden.
My opinions are my own, what I write is protected by copyrights. Some publications contain an explicit license statement which allows sharing without asking permission.
Other webprojects: Camp Wireless, wireless Internet access at campsites, The Virtual Bookcase, book reviews
This page generated by $Id: newsitem.cgi,v 1.58 2022/12/12 15:34:31 koos Exp $ in 0.008624 seconds.