Asterisk

Using Asterisk as a UAC (User agent client)

 

Requirements

  1. Broadband internet connection (at least 128k).
  2. A pc with linux and asterisk installed on it. For asterisk installation read chapter 3 of the book Asterisk the future of Telephony.
  3. A fair understanding of asterisk and its configuration files.
        
      

SIP Configuration

 

Asterisk SIP configuration is done is sip.conf file which is located in /etc/asterisk/sip.conf. There are two sections in this file:
;####################START OF SIP.CONF#####################
[general]
;In this section you configure your general sip parameters and the registration string which is used to register your asterisk server with ours. Here are few sip parameters, which we will use in our general section.
bindport=5060 ;you can use different port if the default is blocked
bindaddr=0.0.0.0 ;binds to all

 

;this is for codec negotiation between the useragent and asterisk
disallow=all
allow=ulaw
allow=alaw
allow=g729
allow=gsm

 

context=incoming-axvoice ;default context where incoming calls are passed. this should be the context where your local user’s extensions reside

 

register=> USERNAME:PASSWORD@magnum.axvoice.com

 

registertimeout=10 ;seconds, you can change it to whatever you like
registerattempts=10 ;set it to zero for infinite attempts if registration keeps on failing.

 

 

[outbound-trunk]
;this is the second section of you sip.conf file. Here you can create your trunk through which you will throw your outgoing calls to axvoice.
host=magnum.axvoice.com
username=your username
secret=your SIP password
fromuser=your username
type=peer
dtmfmode=rfc2833
canreinvite=yes


[line1]
;creating your local user named line1
userid=line1
secret=1234
type=friend ;can send and receive calls
host=dynamic ;can register from any ip address
context=incoming-axvoice ;this is where this users local extension is defined
call-limit=2

 

;similarly
[line2]
;creating your local user named line1
userid=line2
secret=1234
type=friend ;can send and receive calls
host=dynamic ;can register from any ip address
context=incoming-axvoice ;this is where this users local extension is defined
call-limit=2

 

;#############END OF SIP.CONF##############################

 

You can copy paste all the above sip configuration from the start to end and replace it with your current sip configuration file. But do not forget to use your USERNAME and PASSWORD in the register command. Reload your new sip.conf settings using the following command:
*CLI>sip reload

 

After that you may want to check whether your asterisk server registered with the axvoice server or not. For doing that, issue the following command on the asterisk cli:
*CLI>sip show registry

 

the output will look like this:

 

If under “State”, it shows “Not Registered” then wait for some time and issue the command again. If still it shows “Not Registered” or “Failed” then change your credentials in the “register” command in sip.conf file and the try again.

 

Configuring Asterisk Dialplan

    
In the dialplan you tell asterisk what to do with a call when it receives one. Dialplan is created in the file called extensions.conf which is located in /etc/asterisk/extensions.conf. You can create your own dialplan at the end of this file. So whatever we tell you to write in this file you have to write at the end of this file.

 

;##################Here is the dialplan##############
 

[incoming-axvoice]
;first creating extensions for your local users
exten=> 212,1,Dial(SIP/line1,60,Tt)
exten=> 212,2,Hangup()

 

;second user
exten=> 213,1,Dial(SIP/line2,60,Tt)
exten=> 213,2,Hangup()

 

;for voicemail
exten=> 9000,1,Dial(SIP/${EXTEN}@outbound-trunk)
exten=> 9000,2,Hangup

 

;All other extensions fall here
exten=> _X.,1,Dial(SIP/${EXTEN}@outbound-trunk)
exten=> _X.,2,Hangup
 

;################END OF DIALPLAN####################

 

You can copy paste all of the above dialplan configuration at the end of your /etc/asterisk/extensions.conf file.