Table of Contents

WARNING! THIS INFORMATION IS OUTDATED!

Update 2010-12-15: sorry this stuff gets outdated so soon ;), I'll have a look into all the recent Asterisk changes soon.. Update 2023-02-280: yeah this is getting really ancient. Leaving it just for reference, but be warned that this will not work on recent versions of Asterisk!

Introduction

the Asterisk PBX logo, property of Digium A step-by-step practical guide to installing & configuring Asterisk PBX 1.4, complete with fully commented dialplans and documentation, by Sebastiaan Giebels [sgie bels_asteriskATpc probleemloos.nl].

This will probably always be 'Work in progress', but I think it's pretty usable. I would welcome any comments or corrections. By continuing reading you agree to the disclaimer.

I urge you to read 'Asterisk - The Future of Telephony' or 'Asterisk: The Definitive Guide' This guide will only provide some configuration examples, as I will assume you understand the Asterisk* basics.

You can find a lot of documentation here: http://www.voip-info.org There are a few video's online, the best I've seen is from SYStM http://revision3.com/systm/asterisk/ (I suggest you download the xvid 'large' version). A few others you can find by searching for 'asterikast' or 'fosdem 2006 asterisk'.

We are not endorsed by or affiliated with Digium, the company behind Asterisk.

Introduction

I work in Eindhoven (The Netherlands) at a local branch of the IT firm, PC Probleemloos, providing services ranging from computer installation/setup/maintenance/repair to harddisk data recovery (in cooperation with Data Recovery Centrale).

Because I'm pretty technical I'm able to help my customers configure their tv's & VCR's, installing phonelines, faxes & answering machines, where simply reading a manual is enough to get things up and running. Things got interesting there when some online services (like VoipBuster and other Betamax VOIP providers) started offering calling to regular phones over the internet (internet telephony) over the SIP protocol. I have used Skype in the past, but only to call other Skype users. With the new SIP providers, calling became cheaper than ever, and when I heard of Asterisk the first time (version 1.2 at the time), not only was I able to save costs for me and my company, PC Probleemloos, but I kept finding more and more uses for it since.

Installation

Installation is simple, configuration is a whole different story..

Basic configuration

To make things easy, I'll commence with very simple dialplans & sip devices, and from there I will add things like SIP hardphones/hardware, voicemail, call forwarding, etc. piece by piece along the way. For every example, I'll provide the configuration files (often only sip.conf and extensions.conf). Copy them to the asterisk configuration directory, restart/reload asterisk, and things should work.

This very basic guide should get you up and running, without worrying about all the advanced configuration option.

Step 1: Bare basics, Asterisk and the X-Lite softphone

http://asteriskvoip.blogspot.com/2006/02/help-article-configuring-x-lite-for.html

Download X-Lite at http://www.counterpath.com/xlitedownload.html (I'll be using v3.0 for Windows troughout this guide), install it and reboot if you're asked to On Linux/Gnome there is Ekiga, and probably some others.

Configure Asterisk*, files are in /usr/local/etc/asterisk/

sip.conf: [general] bindaddr=0.0.0.0 ;use the IP address of your asterisk server, or 0.0.0.0 for any interface bindport=5060 ;port 5060 is standard for SIP, change only if you know what you're doing context=default ;when a call comes in from the internet to your asterisk server (=inbound) ;determines to which section in extensions.conf it is sent ;don't know what it's exacly good for: allowoverlap=no ; Disable overlap dialing support. (Default is yes)   [xlite1] type=friend ;allow user to make calls and to be called host=dynamic ;This device needs to register, no fixed ip secret=xlite1 ;password to register disallow=all ;disallow all codecs, except the following 3: allow=gsm ;GSM consumes far less bandwidth than ulaw allow=ulaw allow=alaw

extensions.conf: [general] static=yes writeprotect=no clearglobalvars=no   [globals]   [demo] exten => _X.,1,Answer ; Answer the line exten => _X.,n,BackGround(demo-congrats) ; Play a congratulatory message exten => _X.,n,Hangup ; Hang them up.   [default] include => demo Restart asterisk to reload the new configuration.

Connect to the asterisk console, and set verbosity to level 3:

asterisk -rvvv

You'll see some messages, and on the last line you'll see the Command Line Interface (CLI) prompt: freebsd62*CLI>

Back to X-Lite, open it and go to the configuration Click 'Add..' Display Name: X-Lite1 User name: xlite1 Password: xlite1 Authorization user name: <leave empty> Domain: <ipaddres.ofyour.asterisk.server> ?? Domain Proxy -> Enable "Register with domain and receive incoming calls" Send outbound via: proxy, Address: <ipaddress.ofyour.asterisk.server> Dialing plan (default setting): #1\a\a.T;match=1;prestrip=2; Click Apply/OK

The X-Lite window should show 'Ready - Your username is: xlite1', and in the asterisk console, you should see the following lines: -- Registered SIP 'xlite1' at <xlite.client.ip.address> port 33064 expires 3600 -- Saved useragent "X-Lite release 1011s stamp 41150" for peer xlite1

Now place your first call: Click on the green 'off hook' symbol, enter any multi-digit number and click the green symbol again. You should hear the 'Contratulations …' message, just like we programmed in extensions.conf.

Step 2: Adding another softphone

Making calls between softphones

Step 3: SIP providers

VoIP service connection FWD step 3: 1 softphones 1 hardphone

Step 4: Betamax SIP providers

VoipBuster, VoipCheap, VoipDiscount

Calling out Calls coming in CallerID Accounting(?) SMS

Step 5: Grandstream GXP-2000

1 hardphone 1 softphone?

Step 6: Linksys/Cisco/Sipura SPA-3000 (I'll refer to it as 'spa3k')

1 ata (spa3k) 1 softphone?

Step 7: CallerID

It's nice to see who is calling you.

Replace '^0031' with '0'? Replace known numbers with names? Allow some callers with specific CallerID's into an other menu Differentiate between area codes inside the dialplan

VoipBuster PHP script

I'm using voipbuster Asterisk routes my outgoing VOIP calls trough VoipBuster, a BetaMax service (I think they also run VoipCheap, VoipStunt, and a few other websites, which basically provide the same services, although with different pricing schemes)

Voipbuster is also usable when you don't have SIP phones: you can use the website to connect two ordinary landlines, and they even have a local telephone number here in the Netherlands, which you can call and from there call any number, enjoying cheaper rates.

They have a website (at www.voipbuster.com) where you can find the charges/rates for each number. Here you can also configure your account settings, send SMS messages, change forwarding settings, initiate outgoing calls, view your last calls, upgrade your prepaid-credit, etc.

Some more information about BetaMax: http://www.myvoipprovider.com/blogcategory/Betamax/

I've hacked together a PHP script for VoipBuster, which you can use to do all of the above things from either the command line, a website, or from within Asterisk itself (using AGI script functions). It will probably also work with VoipCheap, VoipStunt, and the other BetaMax services with just a few modifications.

Work in progress: Click to download my VoipBuster (and any other Betamax service like voipstunt, voipcheap, poivy) PHP script to send SMS messages, change forwarding settings, initiate outgoing calls, view remaing credit amount, etc.

Frequently Encountered Problems

Asterisk using up to 100% processor time: 13592 root 1 132 0 26132K 400K RUN 503:11 97.56% asterisk

http://www.dartsplayer.com/wi-fi/voip/linksys_dialplan.html

sip: gs2k (4x?) spa3k i/o voipbuster voor inkomend voipdiscount voor uitgaand

Budgetphone SIP configuration with SPA3K

October 2007 I terminated my KPN (largest dutch telco provider) account, and switched to VoIP. Budgetphone.nl is a service which took over the telephone number and makes it accessible trough SIP. The company does have some dial-out plan, but it's more expensive than some other sip services (sipstunt, sipdiscount), so I'll just configure Budgetphone for incoming calls.

Most of the settings here are discovered trough forum messages, no guarantees it's correct. Anyway: it works here. First I've tested the sip settings with X-lite. It's easier to configure X-Lite, as it has less settings. Configuring the Linksys SPA3000 with the budgetphone.nl SIP provider.

In The 'Line 1'-tab of the Sipura SPA web configuration (advanced view):

Proxy and registration
Proxy: budgetphone.nlUse Outbound Proxy: yes
Outbound Proxy: sip.budgetphone.nlUse OB Proxy In Dialog: yes
Register: yesMake Call Without Reg: no
Register Expires: 3600Ans Call Without Reg: no
Subscriber Information
Display Name: 31402431941User ID: 31402431941
Password: <your password>Use Auth ID: no
Auth ID:
VoIP Fallback To PSTN
Auto PSTN Fallback: no

(Fallback Wouldn't work anyway, as I terminated the KPN account for the non-VOIP pstn line service, and the line is solely used for ADSL/DLS right now)

http://www.taet.com.au/dp.nsf/SPADialPlan?OpenForm

Gateway Accounts

Gateway 1: sip.example.org GW1 NAT Mapping Enable: GW1 Auth ID: spa3k GW1 Password: <secret>

Dial Plan

Dial Plan: ? Enable IP Dialing: yes Emergency Number: <leave empty, we'll handle this trough Asterisk*

http://www.voip-info.org/wiki/view/Sipura+3000

http://www.voip-info.org/wiki/index.php?page=Asterisk&utm_source=voip-info&utm_medium=navbox&utm_content=Asterisk

Softphones SIP VoIP FreeBSD

For FreeBSD, there are a few softphones. I've tried twinkle and ekiga, but both would make to the asterisk server running on the same host. I have tried adjusting the udp 5060 port in Twinkle, but it didn't start anymore.

If you want to give them a try, here's how:

Installing twinkle: portinstall twinkle

As root:

portinstall libosip
portinstall ekiga

As regular user:

ekiga

The 'First Time Configuration Assistant' starts, select 'I do not want to sign up for the ekiga.net free service'

freebsd62*CLI> sip reload Reloading SIP

== Parsing '/usr/local/etc/asterisk/sip.conf': Found
== Parsing '/usr/local/etc/asterisk/users.conf': Found
== Parsing '/usr/local/etc/asterisk/sip_notify.conf': Found

freebsd62*CLI>

freebsd62*CLI> core set debug 9999 Core debug is at least 9999

http://www.voip-info.org/tiki-index.php?page=Asterisk%20config%20extensions.conf

Visual Dialplan (first look = great!, price = probably worth it) URL: http://www.apstel.com/products/vdp/vdp.jsp

/* dig 1.4.9.1.3.4.2.0.4.1.3.e164.org. NAPTR works: dig 8.6.9.0.8.4.1.4.6.1.3.e164.org. NAPTR dig 1.4.8.4.4.8.8.4.8.1.3.e164.org. NAPTR dig 5.6.7.6.1.4.8.0.4.1.3.e164.org. NAPTR dig sebastiaan.pcprobleemloos.nl. NAPTR */

sip.conf: [spa3k] type=friend username=spa3k secret=<password_for_spa3k_device> ;regexten=3000 ; When they register, create extension 3000 host=dynamic ; This device needs to register disallow=all allow=ulaw allow=alaw allow=gsm ; GSM consumes far less bandwidth than ulaw

extensions.conf: [spa3k] exten => s,1,Answer exten => s,2,Playback(tt-weasels) exten => s,n,Hangup

asterisk -rvvv

sip reload extensions reload

SPA3k configuration page, tab 'Line1':

Gateway Accounts Gateway 1: spa3k@sip.example.org GW1 NAT Mapping Enable: no (I'm not in a NAT network) GW1 Auth ID: spa3k GW1 Password: <password_for_spa3k_device>

spa3k dialplan (replace sip.example.org with the address of your asterisk server): (S0<:@gw1>) or (S0<:3000@sip.example.org:5060>) but this doesn't do authentication Save & reboot the device

Go to asterisk,

sip show registry

As some people store passwords in their sip configuration files, it's wise to disable 'others' from viewing those files.

chmod o-r /usr/local/etc/asterisk/sip.con*

Basic configuration examples

Empty

extensions.conf:

[general]
static=yes
writeprotect=no

sip.conf:

[general]
context=default
port=5060
bindaddr=0.0.0.0
disallow=all
allow=ulaw
allow=alaw
allow=gsm

Softphones

CounterPath X-Lite



SIP providers

VoipBuster

register => <username>:<password>@sip1.voipbuster.com
[voipbuster]
username=<username>
secret=<password>
type=friend             ;I have a VOIP-IN number, so I'll be both receiving calls from, 
;			and sending calls to this SIP provider
host=sip1.voipbuster.com
context=<default>
insecure=very
qualify=yes

I've put the allow/disallow settings in [general], see below

make sure you use the right sip server (sip1.voipbuster.com, and not sip.voipbuster.com) make sure you have 'insecure=very'

? fromuser=<username>

Budgetphone

(http://www.budgetphone.nl/page.php?page=faq&q=119):

sip.conf (replace '31number' and 'mypassword' with your values.):

register => <31nubmer>@budgetphone.nl:<mypassword>:<31number>@sip.budgetphone.nl/<31number>

[budgetphone]
type=user		;I'll just be receiving calls from BudgetPhone, so just 'user' instead of 'friend' or 'peer'
host=sip.budgetphone.nl
fromdomain=budgetphone.nl
fromuser=<31number>
username=<31number>
insecure=very
secret=<mypassword>
qualify=no
port=5060
context=from-budgetphone

As I'll only be receiving calls through budgetphone.nl, I've set 'type=user' instead of 'type=friend'.

extensions.conf:

[from-budgetphone]
exten => 31number,1,Answer
exten => 31number,n,Playback(demo-congrats) ; Play a congratulatory message
exten => 31number,n,Hangup

The 'context' doesn't seen to work properly though, calls come in at the 'default' section in extensions.conf. I've chosen to redirect them to the from-budgetphone,31number,1 section:

[default]
exten => 31number,1,Set(cNum=${SIP_HEADER(TO):5:11})
exten => 31number,n,GotoIf($["${cNum}"="31number"]?from-budgetphone,31number,1)

Asterisk Extensions.conf examples

Recording incoming and outgoing calls

Make sure you have 'sox' installed. It is needed to combine the 2 audio files (one for each side talking) into one file. For Debian & Ubuntu:

apt-get install sox libsox-fmt-all

Add these lines to your dialplan (replacing 's,n' with the correct extension & order):

exten => s,n,set(CallSavePath=/mnt/some/big/place/to/store/files/)
exten => s,n,set(CallTime=${STRFTIME(${EPOCH},GMT-2,%C%y%m%d%H%M)})
exten => s,n,Set(CALLFILENAME=${CallSavePath}${CallTime}${EXTEN})
exten => s,n,Monitor(wav,${CALLFILENAME},m)

I should turn this into a macro, once I know how they work. Change: '/mnt/some/big/place/to/store/files/' to the path where you wish to store the .wav files of each conversation. Make sure you have enough diskspace. Adjust 'GMT-2' in the second line too, and please verify the result (especially check if summer/winter time works ok)

Grandstream GXP-2000

sip.conf:

; /etc/asterisk/sip.conf
[general]
context=default ;If no context declared, use this as default.
srvlookup=yes   ; (why?)
srvlookup=no	;budgetphone?
canreinvite=no ;all audio goes trough asterisk, keeps asterisk in the
	;audio path, instead of letting the two (trunks?) connecting directly to eachother.

; The settings below usually go into the individual sections, but because they are all the same, I put them in [general]
port=5060	;
disallow=all	;disallow all codecs, then allow just the ones I like to use.
allow=alaw
allow=ulaw
allow=gsm                      ; GSM consumes far less bandwidth than ulaw
[grandstream]
type=friend	;calls in both directions
username=grandstream
secret=mypassword
;host=<full.hostname.com>	;no registration required, asterisk connects if required
host=dynamic			; This device needs to register with asterisk.
allow=gsm                      ;GSM consumes far less bandwidth than ulaw.
context=default			;where in extensions.conf calls coming from the device should go.

todo: Grandstream screenshots of web configuration interface

Grandstream GXP-2000 Auto-pickup / auto-answer

You can have your Grandstream GXP-2000 to auto-answer incoming calls.

In the Grandstream web-interface, go to the correct account, and look for the following settings: Auto Answer: set to 'No' (=default) (unless you want to auto-answer ALL calls, then set it to 'Yes') Allow Auto Answer by Call-Info: set to 'Yes'. Save & reboot.

If you have disabled 'Auto Answer', but enabled “Allow Auto answer by Call-Info”, you can use the following commands in your dialplan to have the phone pick-up the call automatically:

exten => s,n,Set(__SIPADDHEADER=Call-Info: answer-after=0)
exten => s,n,Set(__SIP_URI_OPTIONS=intercom=true)
exten => s,n,Set(__ALERT_INFO=Ring Answer)
exten => s,n,Dial(SIP/<your_grandstream_device>)

Give Asterisk a 'extensions reload' command, and test if it works.

todo: grandstream screenshots of web configuration interface

Nokia E51 VoIP over WiFi

I've got a new Nokia E51 phone, with WiFi and VoIP (over WiFi). It has SIP support, so I can connect it to my Asterisk PBX. I assume this works for the other E-series and N-series Nokia devices too.

;Configration URL's:
;http://www.voip-wiki.nl/doku.php?id=nokiae70
;http://www.pdashop.nl/vragen/25862/31747
;
[nokia]
username=nokia
secret=<mypassword>
host=dynamic	;This phone registers with asterisk, not the other way around
type=friend	;2-way calls: from nokia to asterisk, and from asterisk to the nokia phone
qualify=yes	;Important: Asterisk will regularly contact the nokia phone to make sure it's still there 
		;(in case your get out of range of the WiFi access point)
notransfer=yes	;?
disallow=all
allow=alaw	;I wil just use 'alaw': because it's a wifi network, enough bandwidth is available
context=<context>	;Adjust this according to extensions.conf configuration

Change <context> and <mypassword>. Make sure you use the same username and password when configuring your Nokia.

todo: nokia screenshots of configuration

PORTech GSM VoIP Gateway MV-370, MV-372, MV-374

I bought a MV-372 on Ebay, to send calls to my mobile number to Asterisk. I was convinced to spend money on it, as I've learned that the new firmware did have support for sending and receiving SMS messages (other manufacturers devices often lack this, in my view, essential feature). Their website (http://www.portech.com.tw) is in english, and even with the badly written instructions, I've managed to get it to send/receveive SMS text mesasges from my mobile number. To connect the 'voice' part with SIP to Asterisk, I used the following configuration in sip.conf:

;PORTech GSM VOIP Gateway MV-370 / MV-372 / ...
[portech]
username=<portech>
fromuser=<portech>
secret=<mypassword>	;Asterisk extension password
type=friend
;
;regexten=portech	;When they register, create extension 'portech'
call-limit=1		;(?required?) Limit to 1 call max  
callerid=PORTech MV-372 ;(?required?)
host=dynamic		;the device registers with Asterisk, not the other way around.
nat=no			;My MV-372 is not behind a NAT router
canreinvite=no		;Typically set to NO if behind NAT
insecure=very
qualify=yes
dtmfmode=inband		;Very important for DISA to work
;
disallow=all		;disallow all codecs
allow=ulaw		;ulaw = prefered codec for DTMF detection
allow=alaw
context=<portech>		;Incoming calls context (does this work, or do calls still go to 'default'?

Make sure to use the same 'username'-, 'fromuser'-, and 'secret'-values as you've setup on the webinterface of the PORTech device. Adjust any other values between '<' '>' brackets.

todo: screenshots website PORTech mv-372 web configuration panel

= URLS: =

http://portech.com.tw

http://www.voip-info.org/wiki/view/Setup+MV-370+GSM+Gateway+with+Asterisk

http://www.trixbox.org/forums/trixbox-forums/trunks/portech-mv-372-trunk

http://www.ip-phone-forum.de/showthread.php?t=160116

Linksys SPA-3000

Formerly a product from a company named 'Sipura', now taken over by Linksys (which in turn is taken over by Cisco), the SPA3000 (or SPA3K as some call it)

[<spa3k>]
username=<spa3k>
fromuser=<spa3k>
secret=<mypassword>
type=friend			;I'll receiving incoming calls on this sip gateway, as well as sending calls out.
host=dynamic                    ;This device needs to register, no fixed ip
disallow=all                    ; need to disallow=all before we can use allow=
allow=ulaw                      ; Note: In user sections the order of codecs
allow=alaw                      ; listed with allow= does NOT matter!
allow=g723.1                    ; Asterisk only supports g723.1 pass-thru!
allow=g729                      ; Pass-thru only unless g729 license obtained
allow=gsm
context=<default>
call-limit=2			;?

todo: SPA-3000 web interface screenshots

Unsorted

Click To call/dial, an Asterisk Desktop dial script for (greasemonkey) Firefox

URLS: http://www.voipjots.com/2006/02/click-to-call-with-your-asteriskhome.html

http://www.yaptele.com/asterisk-firefox-click-to-dial-ajax-script

http://sipx-wiki.calivia.com/index.php/Main_Page

http://www.voipuser.nl/Sipura%20SPA%203000.htm +SPA3000 + voipbuster-out, budgetphone-in

http://www.myvoipprovider.com/option,com_myblog/show,betamax-voip-credit---scam---fraud---cheating.html/Itemid,130/

~~DISCUSSION|Please leave a comment or any feedback!~~