Configuring asterisk - part 2
April 18, 2018
To recap, this is what I am setting up:
Figure 1 - asterisk Network |
extensions.conf
In the previous post, we covered the settings in sip.conf. Now we continue.In asterisk terminology, an extension is not a phone connected to a cable, but refers to a sequence of steps that will be executed when someone dials that extension number. Hence extensions.conf specifies the services your devices can have.
The out-of-the-box copy of extensions.conf contains lots of settings, but most are not required in my simple use scenario. Again, I use the grep command to filter out all the commented lines to create a new copy of extensions.conf. Then I comment out/delete all settings except for those under [general] and [globals].
I then add the following line so as to store my customized configuration in extensions_custom.conf instead. This is just a personal preference.
#include "extensions_custom.conf"
So for example to set up a simple demonstration to play the tt-allbusy.gsm sound file when extension 3001 (context from-internal) dials the number 8888:
[from-internal]
exten = 8888,1,Answer
exten = 8888,n,Playback(tt-allbusy)
exten = 8888,n,Hangup
- As I am defining services for my device 3001,
[from-internal]
has to match the context defined in sip.config for extension 3001. - The first field
8888
means that this line is invoked when the extension number 8888 is dialed. - The second field,
1
, or the lowest integer, means that this is the first step, or priority 1, to be executed. Each subsequent step should have a larger integer in that field. To make it easier,n
ext can be used instead. asterisk will go through the file and find all lines for extension 8888 with stepn
, executing them in the order found. - The third field is the application to execute.
Answer
,Playback
andHangup
look pretty self explanatory and are explained here.
More documentation on dial plan formats can be found here. The newer method of using
same => n,
may be easier and less error prone.Run
reload
at the asterisk command line to make the updated dial plan available.
The dial plan to allow an extension in the
from-internal
context to dial another 3000 series number can be:
exten = _30XX,1,Answer
exten = _30XX,n,Dial(SIP/${EXTEN},300)
exten = _30XX,n,Hangup
- The underscore means to treat it as a pattern matching expression. X means an integer from 0 to 9. So _30XX will match 3001, 3008 and so on.
- The
Dial
application is defined here.${EXTEN}
is variable substitution and the extension dialed. If 3008 is dialed, 3008 is substituted. Dial expects a device name in the first parameter, so in this case it is contacting SIP/3008.
Next, I am going to describe how a LinkSys (aka Cisco, aka Sipura) ATA can be added to make calls through an analog telephone line.
Comments
Post a Comment