Monday, March 12, 2012

Install Asterisk in Debian based systems like Ubuntu, BOSS linux, etc.

Asterisk installation steps

It is recommended to use the most recent version of Asterisk, Dahdi and libpri for the best result.

  • Libpri

    • wget http://downloads.digium.com/pub/telephony/ libpri/libpri-X.X.current.tar.gz

    • tar -zxvf libpri-X.X-current.tar.gz

    • cd libpri-X.X.X/

    • make clean

    • make install

  • DAHDI

    • wget http://downloads.digium.com/pub/telephony/ dahdi-linux-complete/dahdi-linux-complete- current.tar.gz

    • tar -zxvf dahdi-linux-complete-current.tar.gz

    • cd dahdi-linux-complete-X.X.X+X.X.X

    • make all

    • make install

    • make config

  • Asterisk

    • wget http://downloads.digium.com/pub/telephony/ asterisk/asterisk-X.X-current.tar.gz

    • tar -zxvf asterisk-X.X-current.tar.gz

    • cd asterisk-X.X.X/

    • ./configure

    • make menuconfig

    • make

    • make install

    • make samples

    • make config

Asterisk Files and Directories

After proper installation asterisk files can be seen in following locations.

  • /usr/sbin/asterisk

    • The Asterisk binary.

  • /etc/asterisk

    • Asterisk configuration files.

  • /usr/lib/asterisk/modules/

    • Loadable modules for applications, codecs etc.

  • /var/lib/asterisk/sounds/

    • Asterisk sound prompts.

  • /var/lib/asterisk/moh

    • Hold music

  • /var/spool/asterisk/

    • Call information, Voicemail and User greetings.

  • /var/log/asterisk

    • Asterisk logs

  • /var/log/asterisk/cdr-csv

    • Call detail records


Starting Asterisk

After installing asterisk use the following commands for starting and stopping and restarting the application.

  • /usr/sbin/asterisk

    • Run asterisk as a daemon from command prompt.

  • /etc/init.d/asterisk stop

    • Stop asterisk from command prompt

  • /etc/init.d/asterisk restart

    • Restart asterisk from command prompt

Asterisk CLI

Following is the command to connect to asterisk's CLI and some common CLI commands.

  • asterisk -vvvr

    • Connect to asterisk CLI while asterisk is running.

  • core stop now

    • CLI command to stop asterisk.

  • core set verbose 5

    • Set verbose level in CLI

  • core set debug 5

    • Set debug level in CLI


Adding a phone to Asterisk

Edit the channel configuration fie for the phone type used.

  • SIP based VoIP phone

    • configure /etc/asterisk/sip.conf

  • Analog phone

    • configure connected analog line in /etc/asterisk/chan_dahdi.conf

    • configure connected analog hardware in /etc/dahdi/system.conf


Adding SIP phone

Add following configuration to /etc/asterisk/sip.conf

[name] ; Account name

type=friend ; Account type

host=dynamic ; How to register

context=users ; Context name

secret=secret ;Account password


Next add extension to /etc/asterisk/extensions.conf under users contextwhich directs calls to new phone.

Exten => 500,1,Dial(SIP/name,30) ;Ring cdac for 30 seconds


Next configure the soft phone or the IP phone with same settings and register it with the asterisk server.



Configuring DAHDI and Asterisk for Analog and PRI calls

Two configuration files needed to be changed for getting Analog and Digital cards working with Asterisk.

  • /etc/dahdi/system.conf

    • Analog and Digital cards configuration are done in system.conf. Configuration can be entered manually or can be generated automatically by giving the command “dahdi_genconf -v” in command prompt.

    • Sample code is given below:

span=2,1,0,ccs,hdb3 # Configure to E1 span

bchan=5-19,21-35 # Define Bearer channels

dchan=20 # Define Delta channel

fxoks=1 # FXO signalling for FXS

fxsks=4 # FXS signalling for FXO

echocanceller=mg2,5-19,21-35 ,1,4


  • /etc/asterisk/chan_dahdi.conf

    • Configure the chan_dahdi.conf so that asterisk knows how to use the hardware and the features associated with the channels.

    • Sample code is given below:

group=1 ; FXS port uses FXO signalling

context=users

signalling=fxo_ks

channel => 1

group=2 ; FXO port uses FXS signalling

context=from_outside

signalling=fxs_ks

channel=>4

group=3 ; B-channel in chan_dahdi.conf

echocancel = yes

signalling = pri_cpe

switchtype = euroisdn

context = incoming

channel = 5-19,21-35


Save the configuration files and restart Asterisk for the changes to DAHDI will get affected. For using the analog line alter the extension to send the calls to this phone using the DAHDI line group 1 “DAHDI/g1”. For sending out calls on the analog line alter the dial plan using the DAHDI line group 2 “DAHDI/g2”.

For E1 connection make sure that the link is out of alarm. Use the command line tool dahdi_tool to check E1 card is out of alarms. Once the PRI is up and looking good, alter the dialplan so that the calls are sent across E1 line.

No comments:

Post a Comment