Creating the custom recording.

Edit /etc/asterisk/extensions.conf

Go to bottom of [mycontext] insert before [voipms-outbound]

insert the following to create the recording:

; Create Recording

exten => 299,1,Answer

exten => 299,n,Wait(2)

exten => 299,n,Record(ast-rec%d.wav)

exten => 299,n,Playback(beep)

exten => 299,Wait(2)

exten => 299,n,Playback(${RECORDED_FILE})

exten => 299,n,Wait(2)

exten => 299,SayAlpha(${RECORDED_FILE})

exten => 299,n,Wait(2)

exten => 299,n,Hangup

recordings live in


mkdir custom

mv wav file to custom/with new name if needed

[root@localhost custom]# pwd


[root@localhost custom]# ls


[root@localhost custom]#

Can also use voicemail box for recordings it stores those files in the following directory


You can then go to your mailbox INBOX and see the wav files and mv msg0002.wav /var/lib/asterisk/sounds/custom/another-custom-recording.wav

Creating the custom SIP/Extensions/Voicemail/Followme

rename the sip.conf to sip.conf_orig.txt

rename the extensions.conf to extensions.conf_orig.txt

rename the voicemail.conf to voicemail.conf_orig.txt

rename the followme.conf to followme.conf_orig.txt

Recreate with the following attached files making changes to needed areas

Asterisk Sample Config

Lecture and Lab: Use sample config files to build a working PBX



    • sip.conf – SIP peers for extensions and carriers
    • extensions.conf – Phone system dialplan for call routing
    • voicemail.conf – Voicemail users
    • followme.conf – Route unaswered calls to a user’s mobile phone


  • Leave rest as default
  • This config is for SIP only PBX
  • No GUI interface for end users
  • All configuration is done using text config files


  • Make a custom recording for your auto attendant greetings
  • Configure voicemail accounts
  • Record name for voicemail account, option 3
  • Record unavailable greeting for voicemail, option 1


  • Edit extensions.conf to route your inbound phone numbers
  • Edit extensions.conf to set outbound caller ID numbers
  • Edit followme.conf to dial alternate phone number if not answered

Codec Options:

  • G.711: Most common codec (ulaw/alaw), 64 kbit/s bitrate, free
  • G.729: Second most common codec, 8kbit/s bitrate, $ licensed
  • GSM: Common low bandwidth codec, 13 kbit/s bitrate, free
  • Many others with lower bitrates to higher bitrates for better quality
  • .
      • .711
      • LPC10
      • GSM
      • iLBC
      • G.726
      • G.722
      • ADPCM

Codecs reside in /usr/lib/asterisk/modules

You need to download the appropriate codec for your CPU

cat /proc/cpuinfo

and look your cpu up to get an idea for codec


Download G.729 codec


copy link for your asterisk version


Go down to


module load and module unload is used in asterisk to load or unload codecs

If you want to use a specific codec for extensions or SIP Carrier

vi /etc/asterisk/sip.conf

edit allow=ulaw to allow=g729


add the allow=ulaw as a failback incase carrier doesn’t support G729

Included with Asterisk

Voicemail setup (voicemail.conf)

vi /etc/asterisk/voicemail.conf


  • Scroll down to bottom of file

Should see example imapvm same sequence sort of

    • Create new name in example:



101 => 123456,John Doe,

102 => 123456,Jane Doe,

What it means:

101 => 123456,John Doe, ** 101 is exten 123456 is password, name, email

  • What we just did was create extension 101 and 102 with password 123456 and name and email for voicemail, we will add this context to sip.conf and enable voicemail

Outbound calling (extensions.conf)

Edit /etc/asterisk/extensions.conf

You’ll create your dialplan here to making outbound calls with your SIP CARRIER

voipms has a sample sip.conf and extensions.conf you can use and replace with your sub_account username, here is what outbound looks like:


exten => _1NXXNXXXXXX,1,Dial(SIP/${EXTEN}@voipms)

exten => _1NXXNXXXXXX,n,Hangup()

exten => _NXXNXXXXXX,1,Dial(SIP/1${EXTEN}@voipms)

exten => _NXXNXXXXXX,n,Hangup()

exten => _011.,1,Dial(SIP/${EXTEN}@voipms)

exten => _011.,n,Hangup()

exten => _00.,1,Dial(SIP/${EXTEN}@voipms)

exten => _00.,n,Hangup()

Important to know that you need this also in your dialplan:


; Make sure to include inbound prior to outbound because the _NXXNXXXXXX handler will match the incoming call and create a loop

include => voipms-inbound

include => voipms-outbound

Creating a SIP Carrier and adding it (sip.conf/extensions.conf)

You will need to find a SIP provider and signup, I used and dumped $25 into it for testing..


It has support for Asterisk

It will give you the sample configuration for Asterisk sip.conf

edit /etc/asterisk/sip.conf

find the line marked [general]

under there insert your registration tag you got from the sample and replace with needed information:

register =>

Go to bottom need to insert the SIP CARRIER information do that before EXTENSIONS line




context=mycontext ;(one of our multiple servers, you can choose the one closer to your location)

secret=PASSWORD.. ;your password


username=220450_USERNAME ;(Replace with your 6 digit Main SIP Account User ID or Sub Account )



fromuser=220450_USERNAME;(Replace with your 6 digit Main SIP Account User ID or Sub Account username)





edit /etc/asterisk/extensions.conf



; Make sure to include inbound prior to outbound because the _NXXNXXXXXX handler will match the incoming call and create a loop

include => voipms-inbound

include => voipms-outbound


exten => _1NXXNXXXXXX,1,Dial(SIP/${EXTEN}@voipms)

exten => _1NXXNXXXXXX,n,Hangup()

exten => _NXXNXXXXXX,1,Dial(SIP/1${EXTEN}@voipms)

exten => _NXXNXXXXXX,n,Hangup()

exten => _011.,1,Dial(SIP/${EXTEN}@voipms)

exten => _011.,n,Hangup()

exten => _00.,1,Dial(SIP/${EXTEN}@voipms)

exten => _00.,n,Hangup()

; inbound context example for your DID numbers, do not add the number 1 in front


exten => 7863643011,1,Answer() ;your DID

edit /etc/asterisk/sip.conf

go to our extensions we setup 101 and 102 need to replace context=internal to context=mycontext

go to asterisk -rvvv


sip show peers

sip show registry

Echo Test call with SIP Carrier (extensions.conf)

You can dial 4443 from your SIP device to start the echo test

Need to make changes for this to work you will see some errors

[Aug 30 14:59:40] NOTICE[2099][C-00000005]: chan_sip.c:25503 handle_request_invite: Call from ‘101’ ( to extension ‘4443’ rejected because extension not found in context ‘mycontext’.

edit /etc/asterisk/extensions.conf

add the following

exten => 4443,1,Answer

exten => 4443,n,NoOp(Echo-Test-4443)

exten => 4443,n,Dial(4443@voipms)

open asterisk -rvvv


dial again, get new error

then open /etc/asterisk/extensions.conf

edit the following

Aug 30 15:02:10] WARNING[2223][C-00000006]: app_dial.c:2330 dial_exec_full: Dial argument takes format (technology/resource)

== Spawn extension (mycontext, 4443, 3) exited non-zero on ‘SIP/101-00000006’

exten => 4443,n,Dial(4443@voipms) ** change to exten => 4443,n,Dial(SIP/4443@voipms) **

asterisk -rvvv


dial and it’s a success!