Penguin

Note - most, if not all asterisk config files you need to change should be in /etc/asterisk

I recommend installing the asterisk sample configuration files, to achieve this in the asterisk source directory type

make samples

You probably want to rename the ones we are modifying to .conf.old, so rename extensions.conf.old
cd /etc/asterisk for i in *; do cp $i $i.old; done

Then create a new one as below. This means the asterisk samples are still there to refer to if you want to see more options, and the modules etc should all be setup correctly (we dont change these yet).

The first step is to configure each phone device in the extensions.conf. Each phone device should be assigned to an extension as below

 [globals]
 PHONES1=SIP/2201
 PHONES1VM=2201

This means that there will be a SIP channel on extension 2201, and its voicemail will be stored in voicemail box 2201

you can keep going and assigning all your phones into their own extensions by simply increasing the numbers

 PHONES2=SIP/2202
 PHONES2VM=2202
 PHONES3=SIP/2203
 PHONES3VM=2203

  ..etc..

 ;This will create a macro we will use in the dialling plan
 [macro-vmessage]
 exten => s,1,VoiceMail2(u${ARG1})
 exten => s,2,Playback(groovy)
 exten => s,3,Playback(goodbye)
 exten => s,4,Hangup

; ----------------------------------------------%%%
; DEFINE EXTENSIONS%%%
; ----------------------------------------------%%%
 [home]
 ; Next, add an extension for voicemail .
 ; now if we dial 8, we can check voicemail.
 ;
 exten => 8,1,VoiceMailMain2
 exten => 8,2,Hangup
 ; Add some more extensions for the two lines. Now we'll be able to call one line from the other.
 ; And if no one answers, it will go to the mailbox for that line.
 ;
 ; Line 1
 ;
 exten => 2201,1,Dial(${PHONES1},20,Ttm)
 exten => 2201,2,Macro(vmessage,${PHONES1VM})
 exten => 2201,3,Hangup
 ;
 ; Line 2
 ;
 exten => 2202,1,Dial(${PHONES2},20,Ttm)
 exten => 2202,2,Macro(vmessage,${PHONES2VM})
 exten => 2202,3,Hangup
 ;
 ; Line 3
 ;
 exten => 2203,1,Dial(${PHONES3},20,Ttm)
 exten => 2203,2,Macro(vmessage,${PHONES3VM})
 exten => 2203,3,Hangup
; ----------------------------------------------
; END DEFINE EXTENSIONS
; ----------------------------------------------

In sip.conf we want to setup the secrets so each phone can authenticate onto the line we just assigned in extensions.conf
WS - I find that encapsulating the SIP references with what extension it belongs to useful as well.
This makes reading the config file easier for someone who may need to alter it other than yourself
The same has been added to other parts of this example code.

;------------------------------------------------
; RECEPTIONIST - JULIE - EXT. 2202
; <extension use> - <users name> - <extension number>
;------------------------------------------------
 [general]
 ;make sure to add this line, otherwise things dont work as proved by weeks of debugging
 port=5060
 ;We want to configure each of the extensions we setup in extensions.conf like this one below (as a simple base)
 [2202]
 type=friend
 ;Dynamic means you can connect from any IP, you can use host=192.168.1.1 (to limit to that ip)
 host=dynamic
 context=home
 ;note - the PASSWORD below you would put in the password this phone uses to authenticate to the server
 secret=PASSWORD
 callerid="Name you want displayed" <2202>
 mailbox=2202
 dtmfmode=rfc2833
 nat=0
 ;context=home  (this means that this unit is setup in the dial plan, which we have yet to setup)%%%
;------------------------------------------------
; END RECEPTIONIST
;------------------------------------------------

keep adding these sip.conf sections for each SIP unit we are adding to the network.

voicemail is the next section to setup, and just as in the other sections it doesnt take long

As long as we define them here, Asterisk will automatically create mailbox directories (under /var/spool/asterisk/voicemail).

Edit voicemail.conf, again in /etc/asterisk

 [general]
 ; Choose a format to save voicemails as, I use gsm format, it ends up with small files
 format=gsm
 ;
 ; if you set this to yes, the voicemail is attached as a file (so
 ; you can play it from your email directly, you may  want to turn
 ; this off if your email is on another server or limited for space
 ; or for various other reasons.
 ;
 attach=yes
 ;
 ; Each mailbox is listed in the form  <mailbox>=<password>,<name>,<email>,<pager_email>
 ; if the e-mail is specified, a message will be sent when a message is received, to the given mailbox.
 ; If pager is specified, a message will be sent there as well.
 ;
 [home]
 2201 => 1234,JON,JON@test.com
 2202 => 1234,Name,BOB@test.com,bobs_pager@test.com

Once we are up to here, hopefully (if i havent cut too much out of the samples files as im adding them to the wiki) have a system where we can register sipphones to the asterisk server, and the asterisk server will let you dial from one units extension to the other units extension.. first however we need to start the asterisk server (or reload the configuration if its already running)

if asterisk is not already running, run it now (you may need to be root)

/usr/sbin/asterisk

if it is already running, reconnect to the asterisk server (then issue the reload command)

/usr/sbin/asterisk -r reload

while in asterisk try taking a look at the dialplan (so we can work out how this Asterisk thing works Hopefully your dial plan will look something like this (if I haven't screwed up)

 show dialplan

 [ Context 'home' created by 'pbx_config' ]
  '2201' =>         1. Dial(${PHONES1}|20|Ttm)                    [pbx_config]
                    2. Macro(vmessage|${PHONES1VM})               [pbx_config]
                    3. Hangup()                                   [pbx_config]
  '2202' =>         1. Dial(${PHONES2}|20|Ttm)                    [pbx_config]
                    2. Macro(vmessage|${PHONES2VM})               [pbx_config]
                    3. Hangup()                                   [pbx_config]
  '2203' =>         1. Dial(${PHONES3}|20|Ttm)                    [pbx_config]
                    2. Macro(vmessage|${PHONES3VM})               [pbx_config]
                    3. Hangup()                                   [pbx_config]
  '8' =>            1. VoiceMailMain2()                           [pbx_config]
                    2. Hangup()                                   [pbx_config]
  Include =>        'dialout'                                     [pbx_config]

If your dialplan looks something like this now feel free to take whichever sip client you would like, point it to the sip server and see if you can register the client, using 2201 (or whichever extensions you have used), and the secrets you set in sip.conf as your password. If you can register 2 machines, or 2 clients, or if your client lets you setup lets you register different profiles you should be able to register them both, and even ring from one extension to the other. you should also be able to leave voicemail and check the voicemail by dialling the voicemail system on extension 8.


STAGE ONE COMPLETE

Ensure that you have an internally working system before going onto the next steps.


Adding FWD to the callplan and reveiving incoming FWD calls.

To add dialling from and to FreeWorldDialUp, we need to make Asterisk register to the FWD servers with the correct password and username; we also need to make FWD ring the correct phones when Asterisk receives a call from FWD. To do this we need to add the following lines to extensions.conf. This configuration assumes that you also have an extension with the same number as your FWD user ID; if you do not already have this extension you should add it using the templates in the previous section.

 <in globals section>
 FWDUSERID=<FWDUSERNUMBER>
 MYNAME=<NAME>
 MYPHONE=<MYPHONENUMBER>

 <in dialout context>
 ; If someone dials a "7" in front of their number, send to Free World Dialup
 include => fwd-forced
 include =>from-sip

 <in context definition part of config file>
 [fwd-forced]
 ; Check to see if the called number starts with a "7" and
 ; if so, set the call parameters and bounce the call to the
 ; Free World Dialup SIP server.
 ;
 ; NOTE: Calls to unknown users will result in "invalid extension"
 ; message being played.
 ;
 exten => _7.,1,SetCallerID(${FWDUSERID})
 exten => _7.,2,SetCIDName(${MYNAME})
 exten => _7.,3,Dial(SIP/${EXTEN:1}@fwd)
 exten => _7.,4,Playback(invalid)
 exten => _7.,5,Hangup

 [from-sip]
 ; To receive calls inbound from FWD, we set the extension
 ; to our FWD user ID, in this case 94896
 ; Changing the "Dial"
 ; directive to something like this:
 ; Dial(${PHONES1}&${PHONES2},15,Ttm)
 ; would cause both lines to ring
 ;exten => 94896,1,Dial(${PHONES2}&${PHONES1},15,Ttm)
 ;exten => 94896,2,Voicemail2(u${PHONES1VM})
 ;exten => 94896,3,Hangup
 ;
 exten => ${FWDUSERID},1,Dial(${PHONES1}&${PHONES2},30,Ttm)
 exten => ${FWDUSERID},2,Voicemail2(u${PHONES1VM})
 exten => ${FWDUSERID},3,Hangup

 <in home context of extensions.conf>
 include => dialout

in sip.conf we have to setup the passwords etc for the FWD account this is done as below

 ; Here we register our FWD phone number so that when someone calls it,
 ; we'll be able to receive that incoming call over SIP.
 ;
 register=<FWDUSERID>:<FWDPASSWORD>@fwd.pulver.com/<FWDUSERID>
 ;
 ; Next we set up some more info for FWD . this part is what will
 ; allow us to make outgoing calls over SIP using FWD.
 ;
 [[fwd]
 type=friend
 secret=<FWDPASSWORD>
 username=<FWDUSERID>
 host=fwd.pulver.com
 dtmfmode=inband
 context=home
 nat=yes
 canreinvite=no
 disallow=all
 allow=all

AsteriskSipPhoneSetup