Asterisk PBX on Debian Stable Part 1

What this guide is:

This is basically a step by step reference of an Asterisk PBX quick start setup for anybody who wants to try it out, or if you are going to work for a company which sets up Asterisk PBX telephone systems.

What this guide isn’t:

This is by no means a complete guide, although it is an ongoing reference which I will add to it as I see fit.

Asterisk Docs and Info:

Asterisk is a hugely versatile and complete Open Source telephony system which already has its own documentation, man pages (man asterisk), support forums and wiki.

Debian:

This guide supposes that you have Debian Stable (Currently Lenny) installed, either as your main OS or as a server on the network.

Install and test Asterisk: (Do all the following as root, not with sudo)

apt-get install asterisk asterisk-dev asterisk-dbg asterisk-h323 asterisk-mp3 libasterisk-agi-perl asterisk-doc

We use Perl scripts for automated dialers and other advanced options, so I have added the Perl modules, that’s up to you. You may also like to do an “apt-cache search asterisk” if you need any language-specific files. As I am in Spain, I also add “asterisk-prompt-es”.

Test Asterisk (still as root)

asterisk -vvvvc

As I already have Asterisk installed, it automatically loads at boot, so the message I get is that it is already running:

ricpru:~# asterisk –vvvvc
Asterisk already running on /var/run/asterisk/asterisk.ctl.  Use ‘asterisk -r’ to connect.

So I do as it says:

ricpru:~# asterisk -r
Asterisk 1.4.21.2~dfsg-3+lenny1, Copyright (C) 1999 – 2008 Digium, Inc. and others.
Created by Mark Spencer <markster@digium.com>
Asterisk comes with ABSOLUTELY NO WARRANTY; type ‘core show warranty’ for details.
This is free software, with components licensed under the GNU General Public
License version 2 and other licenses; you are welcome to redistribute it under
certain conditions. Type ‘core show license’ for details.
==============================================
This package has been modified for the Debian GNU/Linux distribution
Please report all bugs to http://bugs.debian.org/asterisk
==============================================
Connected to Asterisk 1.4.21.2~dfsg-3+lenny1 currently running on ricpru (pid = 1844)

And I am left with the Asterisk prompt:

ricpru*CLI>

Asterisk is installed and working!

So now what?

First you need to get used to the config files. Then you need to select a phone. Asterisk works with Softphones , Analogue phones, IP phones, Mobile phones, Fax machines, basically anything that can be connected to a network or has an IP address and can make a call or send data.

Where are the config files?

ls /etc/asterisk

Yup, they all end in .conf and there are loads of them! Don’t panic! We are only going to start with a IAX/SIP Software Phone, which is the most basic to configure.

adsi.conf cdr_odbc.conf  features.conf  logger.conf  phone.conf  skinny.conf adtranvofr.conf  cdr_pgsql.conf   festival.conf  manager.conf  privacy.conf  sla.conf agents.conf         cdr_tds.conf  followme.conf  manager.d  queues.conf  smdi.conf alarmreceiver.conf  codecs.conf  func_odbc.conf  meetme.conf  res_odbc.conf  telcordia-1.adsi alsa.conf           dnsmgr.conf  gtalk.conf  mgcp.conf  res_pgsql.conf   udptl.conf amd.conf  dundi.conf   h323.conf  misdn.conf  res_snmp.conf  users.conf asterisk.adsi enum.conf  http.conf       modules.conf  rpt.conf  voicemail.conf asterisk.conf  esel.conf  iax.conf musiconhold.conf  rtp.conf  vpb.conf cdr.conf  extconfig.conf   iaxprov.conf  muted.conf  say.conf  watchdog.conf cdr_custom.conf  extensions.ael   indications.conf  osp.conf  sip.conf  zapata.conf cdr_manager.conf  extensions.conf  jabber.conf  oss.conf        sip_notify.conf

Software SIP/IAX phones:

Skype, Ekiga, etc etc….. there are loads, Google them and choose what you want. Personally I prefer VoixPhone. It’s easy to install and has a lot of features including IAX and SIP, but it’s all a matter of personal choice. The reason I want a phone with IAX is that we also use those configs for Hard Phones such as the Thomson ST2030 IP phone.

Download VoixPhone from HERE, Unpack it, Chmod -x it, and ./ Install it.

*HINT* I installed VoixPhone to /usr/local/bin as opposed to /usr/local which is the default and created a launcher called voix. This way I can launch the VoixPhone executable as voix from the command line.

Create an empty launcher file:

vim /usr/local/bin/voix

Insert this text:

# cat >/usr/local/bin/voix <<EOF
#!/bin/sh
/usr/local/bin/voixphone/VoixPhone
EOF

Then make it executable:

chmod 755 /usr/local/bin/voix

*64bit Hint* VoixPhone is a 32bit app. If you are running a 64bit system, install the ia32 libs:

apt-get install ia32-libs ia32-libs-gtk

Part 2 – Configuring Asterisk and your new VoixPhone:

PART 2 Coming soon………………………

In the meantime, have a read of this PDF Handbook and My Asterisk Bible :-)

Asterisk PBX Manager

Monitoring Asterisk and Executing Commands

The manager is a client/server model over TCP. With the manager interface, you’ll be able to control the PBX, originate calls, check mailbox status, monitor channels and queues as well as execute Asterisk commands.

AMI is the standard management interface into your Asterisk server. You configure AMI in manager.conf. By default, AMI is available on TCP port 5038 if you enable it in manager.conf.

Events, Actions and Responses

AMI receive commands, called “actions”. These generate a “response” from Asterisk. Asterisk will also send “Events” containing various information messages about changes within Asterisk. Some actions generate an initial response and data in the form list of events. This format is created to make sure that extensive reports do not block the manager interface fully.

Management users are configured in the configuration file manager.conf and are given permissions for read and write, where write represents their ability to perform this class of “action”, and read represents their ability to receive this class of “event”.

Asterisk Documentation: http://www.asterisk.org/docs

Asterisk CLI Commands

At work we setup Asterisk PBX phone systems along with our own Perl scripts for various purposes. Asterisk is an open source PBX phone system that works with Soft Phones and Hard Phones. I installed and setup Asterisk on my work laptop with a software VoixPhone (SIP/IAX).

The one thing with Asterisk is that each update introduces a few changes, mainly the choice of CLI commands to debug or find certain information.

This post is basically a quick reference to the current Asterisk CLI commands. If you are interested in taking a look at Asterisk (it’s in the Debian repos) and/or the VoixPhone software SIP/IAX phone, see these links:

VoixPhonehttp://www.voixphone.com/

Asteriskhttp://www.asterisk.org/

Debian Repohttp://packages.debian.org/search?keywords=asterisk

Current CLI Commands: ( Courtesy of: asteriskglobe.blogspot.com )

! – Execute a shell command
abort halt – Cancel a running halt
cdr status – Display the CDR status
feature show – Lists configured features
feature show channels – List status of feature channels
file convert – Convert audio file
group show channels – Display active channels with group(s)
help – Display help list, or specific help on a command
indication add – Add the given indication to the country
indication remove – Remove the given indication from the country
indication show – Display a list of all countries/indications
keys init – Initialize RSA key passcodes
keys show – Displays RSA key information
local show channels – List status of local channels
logger mute – Toggle logging output to a console
logger reload – Reopens the log files
logger rotate – Rotates and reopens the log files
logger show channels – List configured log channels
meetme – Execute a command on a conference or conferee
mixmonitor – Execute a MixMonitor command.
moh reload – Music On Hold
moh show classes – List MOH classes
moh show files – List MOH file-based classes
no debug channel (null)
originate – Originate a call
realtime load – Used to print out RealTime variables.
realtime update – Used to update RealTime variables.
restart gracefully – Restart Asterisk gracefully
restart now – Restart Asterisk immediately
restart when convenient – Restart Asterisk at empty call volume
sla show – Show status of Shared Line Appearances
soft hangup – Request a hangup on a given channel
stop gracefully – Gracefully shut down Asterisk
stop now – Shut down Asterisk immediately
stop when convenient – Shut down Asterisk at empty call volume
stun debug – Enable STUN debugging
stun debug off – Disable STUN debugging
udptl debug – Enable UDPTL debugging
udptl debug ip – Enable UDPTL debugging on IP
udptl debug off – Disable UDPTL debugging

AEL commands

ael debug contexts – Enable AEL contexts debug (does nothing)
ael debug macros – Enable AEL macros debug (does nothing)
ael debug read – Enable AEL read debug (does nothing)
ael debug tokens – Enable AEL tokens debug (does nothing)
ael nodebug – Disable AEL debug messages
ael reload – Reload AEL configuration

Agents commands

agent logoff – Sets an agent offline
agent show – Show status of agents
agent show online – Show all online agents

AGI commands

agi debug – Enable AGI debugging
agi debug off – Disable AGI debugging
agi dumphtml – Dumps a list of agi commands in html format
agi show- List AGI commands or specific help
dnsmgr reload – Reloads the DNS manager configuration
dnsmgr status – Display the DNS manager status
http show status – Display HTTP server status

Console commands

console active – Sets/displays active console
console answer – Answer an incoming console call
console autoanswer – Sets/displays autoanswer
console boost – Sets/displays mic boost in dB
console dial – Dial an extension on the console
console flash – Flash a call on the console
console hangup – Hangup a call on the console
console mute – Disable mic input
console send text – Send text to the remote device
console transfer – Transfer a call to a different extension
console unmute – Enable mic input

Core related commands

core clear profile – Clear profiling info
core set debug channel – Enable/disable debugging on a channel
core set debug – Set level of debug chattiness
core set debug off – Turns off debug chattiness
core set global – Set global dialplan variable
core set verbose – Set level of verboseness
core show applications – Shows registered dialplan applications
core show application – Describe a specific dialplan application
core show audio codecs – Displays a list of audio codecs
core show channels – Display information on channels
core show channel – Display information on a specific channel
core show channeltypes – List available channel types
core show channeltype – Give more details on that channel type
core show codecs – Displays a list of codecs
core show codec – Shows a specific codec
core show config mappings – Display config mappings (file names to config engines)
core show file formats – Displays file formats
core show file version – List versions of files used to build Asterisk
core show functions – Shows registered dialplan functions
core show function – Describe a specific dialplan function
core show globals – Show global dialplan variables
core show hints – Show dialplan hints
core show image codecs – Displays a list of image codecs
core show image formats – Displays image formats
core show license – Show the license(s) for this copy of Asterisk
core show profile – Display profiling info
core show switches – Show alternative switches
core show threads – Show running threads
core show translation – Display translation matrix
core show uptime – Show uptime information
core show version – Display version info
core show video codecs – Displays a list of video codecs
core show warranty – Show the warranty (if any) for this copy of Asterisk

Database commands

database del – Removes database key/value
database deltree – Removes database keytree/values
database get – Gets database value
database put – Adds/updates database value
database show – Shows database contents
database showkey – Shows database contents

Dialplan commands

dialplan add extension – Add new extension into context
dialplan add ignorepat – Add new ignore pattern
dialplan add include – Include context in other context
dialplan reload – Reload extensions and *only* extensions
dialplan remove extension – Remove a specified extension
dialplan remove ignorepat – Remove ignore pattern from context
dialplan remove include – Remove a specified include from context
dialplan save – Save dialplan
dialplan show – Show dialplan

DUNDI commands

dundi debug – Enable DUNDi debugging
dundi flush – Flush DUNDi cache
dundi lookup – Lookup a number in DUNDi
dundi no debug – Disable DUNDi debugging
dundi no store history – Disable DUNDi historic records
dundi precache – Precache a number in DUNDi
dundi query – Query a DUNDi EID
dundi show entityid – Display Global Entity ID
dundi show mappings – Show DUNDi mappings
dundi show peers – Show defined DUNDi peers
dundi show peer – Show info on a specific DUNDi peer
dundi show precache – Show DUNDi precache
dundi show requests – Show DUNDi requests
dundi show trans – Show active DUNDi transactions
dundi store history – Enable DUNDi historic records

GTalk & Jabber commands

gtalk reload – Enable Jabber debugging
gtalk show channels – Show GoogleTalk Channels
jabber debug – Enable Jabber debugging
jabber debug off – Disable Jabber debug
jabber reload – Enable Jabber debugging
jabber show connected – Show state of clients and components
jabber test – Shows roster, but is generally used for mog’s debugging.

IAX2 commands

iax2 provision – Provision an IAX device
iax2 prune realtime – Prune a cached realtime lookup
iax2 reload – Reload IAX configuration
iax2 set debug – Enable IAX debugging
iax2 set debug jb – Enable IAX jitterbuffer debugging
iax2 set debug jb off – Disable IAX jitterbuffer debugging
iax2 set debug off – Disable IAX debugging
iax2 set debug trunk – Enable IAX trunk debugging
iax2 set debug trunk off – Disable IAX trunk debugging
iax2 show cache – Display IAX cached dialplan
iax2 show channels – List active IAX channels
iax2 show firmware – List available IAX firmwares
iax2 show netstats – List active IAX channel netstats
iax2 show peers – List defined IAX peers
iax2 show peer – Show details on specific IAX peer
iax2 show provisioning – Display iax provisioning
iax2 show registry – Display IAX registration status
iax2 show stats – Display IAX statistics
iax2 show threads – Display IAX helper thread info
iax2 show users – List defined IAX users
iax2 test losspct – Set IAX2 incoming frame loss percentage

Manager commands

manager show command – Show a manager interface command
manager show commands – List manager interface commands
manager show connected – List connected manager interface users
manager show eventq – List manager interface queued events
manager show users – List configured manager users
manager show user – Display information on a specific manager user

MGCP commands

mgcp audit endpoint – Audit specified MGCP endpoint
mgcp reload – Reload MGCP configuration
mgcp set debug – Enable MGCP debugging
mgcp set debug off – Disable MGCP debugging
mgcp show endpoints – List defined MGCP endpoints

Module management

module load – Load a module by name
module reload – Reload configuration
module show – List modules and info
module show like – List modules and info
module unload – Unload a module by name

PRI commands

pri debug span – Enables PRI debugging on a span
pri intense debug span – Enables REALLY INTENSE PRI debugging
pri no debug span – Disables PRI debugging on a span
pri set debug file – Sends PRI debug output to the specified file
pri show debug – Displays current PRI debug settings
pri show spans – Displays PRI Information
pri show span – Displays PRI Information
pri unset debug file – Ends PRI debug output to file

Queue commands

queue add member – Add a channel to a specified queue
queue remove member – Removes a channel from a specified queue
queue show – Show status of a specified queue
rtcp debug ip – Enable RTCP debugging on IP
rtcp debug – Enable RTCP debugging
rtcp debug off – Disable RTCP debugging
rtcp stats – Enable RTCP stats
rtcp stats off – Disable RTCP stats
rtp debug ip – Enable RTP debugging on IP
rtp debug – Enable RTP debugging
rtp debug off – Disable RTP debugging
say load – Set/show the say mode
show parkedcalls – Lists parked calls
show queue – Show information for target queue
show queues – Show the queues

SIP commands

sip history – Enable SIP history
sip history off – Disable SIP history
sip notify – Send a notify packet to a SIP peer
sip prune realtime – Prune cached Realtime object(s)
sip prune realtime peer – Prune cached Realtime peer(s)
sip prune realtime user – Prune cached Realtime user(s)
sip reload – Reload SIP configuration
sip set debug – Enable SIP debugging
sip set debug ip – Enable SIP debugging on IP
sip set debug off – Disable SIP debugging
sip set debug peer – Enable SIP debugging on Peername
sip show channels – List active SIP channels
sip show channel – Show detailed SIP channel info
sip show domains – List our local SIP domains.
sip show history – Show SIP dialog history
sip show inuse – List all inuse/limits
sip show objects – List all SIP object allocations
sip show peers – List defined SIP peers
sip show peer – Show details on specific SIP peer
sip show registry – List SIP registration status
sip show settings – Show SIP global settings
sip show subscriptions – List active SIP subscriptions
sip show users – List defined SIP users
sip show user – Show details on specific SIP user

Skinny commands

skinny reset – Reset Skinny device(s)
skinny set debug – Enable Skinny debugging
skinny set debug off – Disable Skinny debugging
skinny show devices – List defined Skinny devices
skinny show lines – List defined Skinny lines per device

Voicemail commands

voicemail show users – List defined voicemail boxes
voicemail show users for – List defined voicemail boxes for target context
voicemail show zones – List zone message formats

Zaptel commands

zap destroy channel – Destroys a channel
zap restart – Fully restart zaptel channels
zap show cadences – List cadences
zap show channels – Show active zapata channels
zap show channel – Show information on a channel
zap show status – Show all Zaptel cards status