The Loomiverse

The universe according to Loom

Entries Comments



Configuring Asterisk – Part 4

12 February, 2009 (10:41) | Uncategorized | By: loom

So now we have some local extensions, a SIP connection to Pennytel and an IAX trunk to another trixbox. The the magic which ties this all together all happens in extensions.conf

As in my previous posts, I have created a file called extensions_local.conf under /etc/asterisk and included it in my extensions.conf file using

#include extensions_local.conf

This file is broken into a series of sections – called contexts.  There should be a section for each “context=” line in the sip_local.conf  and iax_local.conf files.

In my case, they are

  • from-internal
  • from-remote
  • incoming-call


The context= lines match to the sections in the extesnsions_local.conf file, and tell Asterisk where to start processing rules when someone picks up an extension, or dials in.

Starting with the last context first, when we recieve a call on the SIP line from PennyTel
[incoming-call]
exten => _X.,1,Dial(SIP/1000&SIP/1001)

The [square brackets] mark the beginning of a section

the “exten => ” consists of three parts, a pattern to match, an execution order and a command to execute.  The pattern is “_X.”  which matches all incoming numbers.  Since the is only one rule here, it will get executed. The command is “Dial(SIP/1000&SIP/1001)”  This tells asterisk to Call extensions 1000 and 1001 and connect the call to the first one which answers.

The next section is [from-remote] – calls from our IAX2 trunk to another Asterisk server

[from-remote]
include => incoming-call

This section is fairly straight forward the “include =>” line tells asterisk to include all of the rules under incoming-call in this section as well.  So Calls from out PennyTel number or friendly Asterisk box will cause both of our local extensions to ring.

Now the from-internal section.  These rules are processed when someone picks up one of our extensions and starts dialling.

[from-internal]
exten => 1000,1,Dial(SIP/1000)
exten => 1001,1,Dial(SIP/1001)
include => to-remote
include => dial-out

The first two lines allow the extensions to call each other.  The includes are there to make the file more manageable, I could have kept everything in one section, but I prefer to break things down by function.

The final two sections are below.

[dial-out]
exten => 000,1,Dial(SIP/PennyTel/000)
exten => _0011,1,Dial(SIP/PennyTel/${EXTEN:4})
exten => _0NXXXXXXXX,1,Dial(SIP/PennyTel/61${EXTEN:1})
exten => _ZXXXXXXX,1,Dial(SIP/PennyTel/613${EXTEN})
exten => _1300XXXXXX,1,Dial(SIP/PennyTel/61${EXTEN})
exten => _1800XXXXXX,1,Dial(SIP/PennyTel/61${EXTEN})

[to-remote]
exten =>_8XXXX,1,Dial(IAX2/ToRemote/${EXTEN:1})

The pattern matching rules are quite powerful, more detail can be found here.

Possibly Related Posts:


Write a comment





CAPTCHA image