Sunday, January 15, 2012

Configuring Asterisk from the Ground Up (1/2)



Disclaimer: I recommend and acknowledge www.voip-info.org as my comprehensive online reference to the details on Asterisk. 
Also, blogspot doesn't seems to like "<" and ">" symbols. For the time being, I have replaced these symbols with "{" and "}"


Overview
This is the first part of the Asterisk build guide, which covers setting Asterisk to accept SIP, Skinny (Cisco) and PSTN devices' registration, and building a dial plan with Voicemail function. 

It is assumed the operating system and Asterisk have been successfully installed on the system. (My FreeBSD Operating System is 8.0 and Asterisk version is 1.4.26.2). OS and ports installation are out of scope to this port...  


The basic concepts of configuring Asterisk (and the gotchas) are illustrated through the following example: 

In a nutshell, the Asterisk can be understood to be as simple as a dial plan dictating the behaviors of multiple clients. 


This Asterisk server has three clients: 

1.     SIP Phone – X-LiteWindows Program, X-Lite
2.     Cisco IP Phone – IP Blue (Windows program, IP Blue- 30 days trial)**3.     PSTN Phone*** – Dual Phone for Skype, but I use only the landline connection to Asterisk server Digium Clone (OpenVox) FXO port. For more information refer to my other post.

Note:
* For a full list of VoIP and soft phones supported by Asterisk, see this voip-info link

** I tried the following IP Blue packages on my Windows Vista:
IPB Softphone Advanced 2.15.26.37 Setup                  - Works OK
IPB Softphone 508  2.15.35.49 Setup                             - crashes on Vista

SCCP module is also available, although it does not come with my distribution of Asterisk by default. It can be downloaded from sourceforge and be compiled to replace of skinny.conf.

*** w.r.t. the PSTN component in the Asterisk server, Zapata.conf is to be replaced by chan_dahdi.conf

SIP/ Skinny/ PSTN Devices - Asterisk Configurations
The configuration files are located under the directory (/usr/local/etc/asterisk)

1. SIP client - sip.conf
[xlite]                ; Make sure the User ID entered on XLite client matches this value
type=friend                       ; Same context used for both inbound and outbound calls
regexten=1234                     ; When they register, create extension 1234
host=dynamic                      ; This device needs to register
disallow=all
allow=gsm                         ; GSM consumes far less bandwidth than ulaw
allow=ulaw
allow=alaw
;context=default

2. SCCP client - skinny.conf
[ipblue]
type=7960
;context=default
line=1000            ; Dial(Skinny/1000@ipblue)
device=SEP00215D2B1296

In addition to setting up Skinny module, tftp server has to be setup (because skinny client downloads an XML file which defines the Call Manager's IP address and port):

I installed the tftp port (/usr/ports/ftp/tftp-hpa)

/etc/inetd.conf
tftp    dgram   udp     wait    root    /usr/libexec/tftpd      tftpd -l -s /tftpboot
#tftp   dgram   udp6    wait    root    /usr/libexec/tftpd      tftpd -l -s /tftpboot

/etc/rc.conf
inetd_enable="YES"      # Inetd for TFTP server (Skinny)

The XML file (for Skinny client) is named as "SEP.cnf.xml"
It is placed under the /tftpboot/ directory. A sample file is shown beneath (Call Manager's parameters are colored in red)
 {device}
 {devicePool}
  {callManagerGroup}
   {members}
    {member  priority="0"}
     {callManager}
      {ports}
       {ethernetPhonePort}2000{/ethernetPhonePort}
      {/ports}
      {processNodeName}192.168.10.154{/processNodeName}
     {/callManager}
    {/member}
   {/members}
  {/callManagerGroup}
 {/devicePool}
 {versionStamp}{Jan 28 2008 19:01:00}{/versionStamp}
 {loadInformation}{/loadInformation}
 {userLocale}
  {name}{/name}
  {langCode}en{/langCode}
 {/userLocale}
 {networkLocale}{/networkLocale}
 {idleTimeout}0{/idleTimeout}
 {authenticationURL}{/authenticationURL}
 {directoryURL}{/directoryURL}
 {idleURL}{/idleURL}
 {informationURL}{/informationURL}
 {messagesURL}{/messagesURL}
 {proxyServerURL}{/proxyServerURL}
 {servicesURL}{/servicesURL}
{/device}



Note: asterisk must be restarted for the skinny configurations to take effect, a reload just won’t work (link)
home-unix6*CLI> skinny show devices
Name                 DeviceId         IP              Type            R NL
-------------------- ---------------- --------------- --------------- - --
ipblue               SEP00215D2B1296  192.168.10.45   7960            Y  1
home-unix6*CLI> skinny show lines
Device Name          Instance Name                 Label
-------------------- -------- -------------------- --------------------
ipblue                      1 1000

3. Zapata.conf
I have covered the zapata.conf file in a previous post so it is added beneath only for reference:
[channels]
; OpenVox User Manual
; Span 1: WCTDM/0 "Wildcard TDM400P REV E/F Board 1" (MASTER)
signalling=fxo_ks
adsi=yes
pulse=yes
context=default
channel => 1

Extensions - Basics
extensions.conf
[default]
exten => 1234,1,Dial(SIP/xlite)          ;;; SIP client
exten => 5678,1,Dial(DAHDI/1-1)          ::: PSTN client
exten => 1000,1,Dial(Skinny/1000@ipblue) ;;; Skinny client

I didn't define any "context" for the clients, so they will all use the default context. 
The setup above allows all three devices to be registered to the Asterisk server and call each other using their corresponding extensions.

Extensions - More Details
For example, I would like to SIP client to ring for 10s. If nobody picks up the call, then a voice menu is played to the called, where he/she can choose to either leave a voice mail, or try calling the land-line (or hangup). 


The implementation example is as follows (please read the comments for further details):
;;; exten syntax
; exten => id, priority, command

[default]
;;; Default dialplan
exten => 5678,1,Dial(DAHDI/1)
exten => 1000,1,Dial(Skinny/1000@ipblue)

exten => 1234,1,Dial(SIP/xlite,10)              ; SIP client rings for 10s
exten => 1234,2,Answer
exten => 1234,3,Goto,xlite-menu|s|1             ; If the call is unanswered,
                                                ; it will be forwarded to "xlite-menu"
[xlite-menu]
exten => s,1,Background(/tmp/menu)       ; Play "menu" message
exten => s,2,WaitExten(10)               ; Wait for user input for 10s
exten => 1,1,Voicemail(1@default)        ; user-id@context
exten => 2,1,Dial(DAHDI/1-1)
exten => 9,1,Hangup
exten => i,1,Goto(s,1)                   ; "i" stands for invalid entry,
                                         ; play "menu" message again
exten => t,1,Goto(s,1)                   ; "t" stands for timeout,
                                         ; play "menu" message again

;;; 8500 to access Voicemail
exten => 8500,1,VoicemailMain


One line has been added to the voicemail.conf file: 
[default]

1 => 1234,Example Mailbox,root@localhost
; Syntax: user-id => pin, mailbox, user

When the user dials 8500 to access his/her voicemail, voicemail prompts for user-id and pin as defined above.To record your own welcome message, add the following to extensions.conf
[default]
;;; Record voicemail
; Record voice file to /tmp directory
  exten => 205,1,Wait(2) ; Call 205 to Record new Sound Files
  exten => 205,2,Record(/tmp/asterisk-recording:ulaw) ; Press # to stop recording
  exten => 205,3,Wait(2)
  exten => 205,4,Playback(/tmp/asterisk-recording) ; Listen to your voice
  exten => 205,5,wait(2)
  exten => 205,6,Hangup

Remember to change the file name from “asterisk-recording” to “menu” (or whichever name defined in the Background() call. 

[Giving credit to the references I used IVR menu, Voicemail and Dialplan]




Note: a follow up post re: Xlite and IPBlue interworking... 

No comments:

Post a Comment