How to get started with Asterisk


Author: Martin List-Petersen - martin at list-petersen dot dk
The newest version of this document can allways be found at http://www.marlow.dk/asterisk

Version: 0.19
Created: November 17th, 2003
Last updated: May 10th, 2005

Acknowledgements: This document describes a limited set of the the setup, that can be done with Asterisk and walks you through some scenarios, that you not might find documented elsewhere, because they include third party patches/addons.
This document is provided AS IS, of course. Feel free to use the info provided here, but don't blame me, if it doesn't work. Feedback however is allways appreciated. I can't be made responsible for data loss or other damages in any way. Be aware, that this document is based on Debian and the packages provided for Debian. It might though be useful for asterisk in general.

A word to begin with

Asterisk has gotten pretty mature since the project started and is nearing the 1.0 release. The only problem is, that the configuration and documentation is scattered around in various places on the internet. There is a draft of version 2 of the handbook, but that was not as fullfilling, as i would have wanted.

This documentation will be improved somewhat in the future, but only hold the absolutely basics, since my writing efforts are more concentrated on getting the Hitchhikers Guide to Asterisk to a point where it would be a true alternative or replacement to the official documentation done by Digium.

Content



Talk

History

Debian Repositories for Asterisk


I keep my own Debian Repositories for Asterisk Debian packages, because i use things like bristuff (zaptel support for hfc-s based cards) and a couple of other third party addon's. These packages are compiled against testing, but work both for testing and sid. I usually keep the packages around for i386 and alpha platforms.
If you want to use the same feature-set or play around with some cvs-snapshots, then you can add them by adding the following lines to your /etc/apt/sources.list:

CVS stable branch

I used to maintain packages for the stable branch, but the packages in Debian now fully support bristuff, so there is no need to do this anymore.

CVS HEAD branch
	deb ftp://debian.marlow.dk/ sid asterisk-common asterisk-head
	deb-src ftp://debian.marlow.dk/ sid asterisk-common asterisk-head
		
Generic stuff, usually works with any asterisk, depending on featureset (asterisk-common) I do also keep some older h323 and pt/pw libraries around here, but they are not really used anymore in any of my recent packages.

The simple approach

Using Asterisk as a SIP gateway

Now that you've got asterisk installed it's just get the configuration done.

SIP

sip.conf - Download here
[general]
port = 5060                 ; port to bind for sip connections
bindaddr = 0.0.0.0          ; ip to bind for sip connections
context = from-sip          ; default context for incoming sip calls
;
disallow = all              ; disallow all codecs, we want to enable, 
allow    = gsm              ; what we deem is necessary
allow    = ilbc
allow    = speex
allow    = g729             ; g729 only works for pass-thru, if you haven't bought a license
allow    = g726
allow    = ulaw             ; i would normally not allow ulaw, because it's high bandwidth,
                            ; but if you want to use free world dialup services, it's the
                            ; only codec they support
;
register => 12345:not_my_password@fwd.pulver.com/marlow-fwd                    ; these make it possible to get calls
register => 17471234567:not_my_password_either@proxy01.sipphone.com/marlow-sip ; in from these services.
;
;
; Dial out to fwdnet
;
[fwd]
  type=peer
  secret=not_my_password
  host=fwd.pulver.com
;
;
; Dial out to sipphone.com
;
[sipphone]
  type=peer
  secret=not_my_password_either
  host=proxy01.sipphone.com
;
;
; This is a local extension running kphone, firefly or likewise
;
[marlow]
  callerid=("Martin List-Petersen" <3986>)
  type=friend
  secret=not_my_password_anyway
  host=dynamic
  context=intern
; canreinvite=no ; "canreinvite=no" is needed, so that all calls allways go through asterisk. This is
;                  needed, when you have the SIP client on the LAN and want to use asterisk as a proxy.
;
; qualify=200
; nat=yes        ; these two are needed, if you asterisk box sits on a public ip
;                  and your sip client/ata box/ip phone behind a nat firewall
;                  usually you would not need a stun server then.
    

Extensions


extensions.conf - Download here
[general]
  static=yes
  writeprotect=no

[globals]
  ;
  ; The name to use on callerid
  ;
  MARLOW_CID=Martin List-Petersen

  ; FWD ID for callerid
  ;
  MARLOW_FWD=12345

  ; sipphone ID for callerid
  ;
  MARLOW_SIPPHONE=17471234567

[internal]
  ;
  ; local extensions
  ;
  exten => 3986,1,Dial(SIP/marlow,60)           ; call SIP extension "marlow" for 60 seconds,
                                                ; if extension 3986 is called
	exten => 3986,2,Voicemail(u3986)              ; if we can't connect to "marlow" or after seconds 
                                                ; go to the unavail VM
	exten => 3986,102,Voicemail(b3986)            ; if busy, go to the busy VM

  ;
  ; Voicemail System
  ;
  exten => 9999,1,VoiceMailMain(${CALLERIDNUM}) ; extension 9999 is the VM system,
                                                ; go directly to callers VM
  exten => 9999,2,Hangup

[from-sip]
  ;
  ; default extension for calls from SIP
  ;
  exten => s,1,Dial(Local/3986@internal/n)

  ;
  ; calls from Free World Dialup (FWD)
  ;
	exten => marlow-fwd,1,SetCIDName(FWD - ${CALLERIDNAME}) ; indicate that the call came through FWD
  exten => marlow-fwd,2,Dial(Local/3986@internal/n)

  ;
  ; calls from sipphone
  ;
	exten => marlow-sip,1,SetCIDName(SIP - ${CALLERIDNAME}) ; indicate that the call came through sipphone
  exten => marlow-sip,2,Dial(Local/3986@internal/n)

[outbound-internal]
  ;
  ; include local extensions
  ; 
  include => internal

  ;
  ; include SIP accounts
  ;
  include => fwdnet
  include => sipphone

  ;
  ; include tollfree calls
  ;
  include => tollfree

[default]
  ;
  ; include from-sip for default. We don't use it, but it might be a good idea
  ;
  include => from-sip

[fwdnet]
  ;
  ; fwdnet extensions
  ;
  exten => _1393.,1,SetCallerID(${MARLOW_CID} <${MARLOW_FWD}>)   ; set my callerid and name for FWD
  exten => _1393.,2,Dial,SIP/${EXTEN:4}@fwd                      ; dial the number i wish to dial on FWD
  exten => _1393.,3,Playback(invalid)                            ; this did not work out
  exten => _1393.,4,Hangup
  exten => _1393.,103,Busy                                       ; the destination was busy
                                                                 ; dial jumps to +101 if busy

[sipphone]
  ;
  ; sipphone extension
  ;
  exten => _1747.,1,SetCallerID(${MARLOW_CID} <${MARLOW_SIPPHONE}>)
  exten => _1747.,2,Dial,SIP/${EXTEN:4}@sipphone
  exten => _1747.,3,Playback(invalid)
  exten => _1747.,4,Hangup
  exten => _1747.,103,Busy
  
[tollfree]
  ;
  ; terminate toll-free no.'s via fwdnet
  ;

  ;
  ; US toll free access
  ;
  ; +1-800
  exten => _1800.,1,SetCallerID(<${MARLOW_FWD}>)
  exten => _1800.,2,Dial,SIP/*${EXTEN}@fwd
  exten => _1800.,3,Playback(invalid)
  exten => _1800.,4,Hangup
  exten => _1800.,103,Busy

  ; +1-866
  exten => _1866.,1,SetCallerID(<${MARLOW_FWD}>)
  exten => _1866.,2,Dial,SIP/*${EXTEN}@fwd
  exten => _1866.,3,Playback(invalid)
  exten => _1866.,4,Hangup
  exten => _1866.,103,Busy

  ; +1-877
  exten => _1877.,1,SetCallerID(<${MARLOW_FWD}>)
  exten => _1877.,2,Dial,SIP/*${EXTEN}@fwd
  exten => _1877.,3,Playback(invalid)
  exten => _1877.,4,Hangup
  exten => _1877.,103,Busy

  ; +1-888
  exten => _1888.,1,SetCallerID(<${MARLOW_FWD}>)
  exten => _1888.,2,Dial,SIP/*${EXTEN}@fwd
  exten => _1888.,3,Playback(invalid)
  exten => _1888.,4,Hangup
  exten => _1888.,103,Busy

  ;
  ; Netherlands toll free access
  ;
  exten => _31800.,1,SetCallerID(<${MARLOW_FWD}>)
  exten => _31800.,2,Dial,SIP/*${EXTEN}@fwd
  exten => _31800.,3,Playback(invalid)
  exten => _31800.,4,Hangup
  exten => _31800.,103,Busy

  ;
  ; France toll free access
  ;
  exten => _33800.,1,SetCallerID(<${MARLOW_FWD}>)
  exten => _33800.,2,Dial,SIP/*${EXTEN}@fwd
  exten => _33800.,3,Playback(invalid)
  exten => _33800.,4,Hangup
  exten => _33800.,103,Busy

  ;
  ; UK toll free access
  ;
  ; +44 500
  exten => _44500.,1,SetCallerID(<${MARLOW_FWD}>)
  exten => _44500.,2,Dial,SIP/*${EXTEN}@fwd
  exten => _44500.,3,Playback(invalid)
  exten => _44500.,4,Hangup
  exten => _44500.,103,Busy

  ; +44 800
  exten => _44800.,1,SetCallerID(<${MARLOW_FWD}>)
  exten => _44800.,2,Dial,SIP/*${EXTEN}@fwd
  exten => _44800.,3,Playback(invalid)
  exten => _44800.,4,Hangup
  exten => _44800.,103,Busy

  ; +44 808
  exten => _44808.,1,SetCallerID(<${MARLOW_FWD}>)
  exten => _44808.,2,Dial,SIP/*${EXTEN}@fwd
  exten => _44808.,3,Playback(invalid)
  exten => _44808.,4,Hangup
  exten => _44808.,103,Busy
    

Starting it up


After restarting asterisk with /etc/init.d/asterisk restart you can connect to the console with asterisk -r as root. Gives you a lot of monitoring and configuration possibilities.

Building the zaptel modules Debian style


Requirements

You need to install the kernel source code and configure it with make-kpkg. Any kernel version available from Debian or kernel.org should do, depending on what kernel you have installed. If you have installed a binary kernel, you can allways fetch the correct source for that, and configure it as appropriate.

What kernel version you have is shown by typing uname -r.

Sample compile run

Let's assume, that you have one of the default Debian kernels installed, called 2.4.26-1-686. Install the kernel-source with apt-get install kernel-source-2.4.26. Download also the kernel-package with apt-get install kernel-package since it includes all essentials needed for creating a new kernel.

The kernel-source is downloaded to a file called /usr/src/kernel-source-2.4.26.tar.bz2, cd to /usr/src, untar the file (tar -xjf kernel-source-2.4.26.tar.bz2) and cd to /usr/src/kernel-source-2.4.26.

We now need to prepare this kernel for you current configuration. Copy /boot/config-2.4.26-1-686 to .config (cp /boot/config-2.4.26-1-686 /usr/src/kernel-source-2.4.26/.config). That should be about it for now.

Install the package zaptel-source out of my repository, this will leave you with a file called /usr/src/zaptel.tgz, cd to /usr/src, tar -xzf zaptel.tgz and it installs the zaptel modules in /usr/src/modules/zaptel.

The actual compilation of the modules begins:
cd /usr/src/kernel-source-2.4.26 and do a make-kpkg --append-to-version "-1-686" --revision 2.4.26-1 --config old configure. Then proceed with make-kpkg --append-to-version "-1-686" --revision 2.4.26-1 modules-image.

After the process has finished, it should leave you with a package called zaptel-modules-2.4.26-1-686_1.0.2-1_i386.deb. The name may vary depending on what source package you installed, after all this is just a sample run.

This new package can now be installed with dpkg -i packagename and you can then add the modules with modprobe (remember to at them to /etc/modules also) or modconf.

Links


Website last modified: Jan 8th, 2007 - 1:39 PM  GMT.
(C)opyright 1997 - 2007  by Martin List-Petersen
IPv6 Ready Hosting by TuxBoxValid HTML 4.01!Valid CSS!