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!


Basic troubleshooting issues you might experience in Asterisk

— Executing [103@internal:1] Answer(“SIP/101-00000003”, “”) in new stack

— Executing [103@internal:2] NoOp(“SIP/101-00000003”, “Internal-phone-call”) in new stack

— Executing [103@internal:3] Dial(“SIP/101-00000003”, “SIP/103,12,r”) in new stack

  1. [Aug 30 11:43:24] WARNING[2128][C-00000002]: chan_sip.c:6071 create_addr: Purely numeric hostname (103), and not a peer–rejecting!
  2. [Aug 30 11:43:24] WARNING[2128][C-00000002]: app_dial.c:2437 dial_exec_full: Unable to create channel of type ‘SIP’ (cause 20 – Subscriber absent)

== Everyone is busy/congested at this time (1:0/0/1)

— Executing [103@internal:4] VoiceMail(“SIP/101-00000003”, “103@internal-vm”) in new stack

  1. [Aug 30 11:43:24] WARNING[2128][C-00000002]: app_voicemail.c:6321 leave_voicemail: No entry in voicemail config file for ‘103’

1 This error occurred because the extension/user was not defined in sip.conf

2 This error occurred because the phone does not exist in sip.conf

1 This error occurs because a voicemail is not defined in voicemail.conf
View mailbox users, voicemail show users ** lists users from /etc/asterisk/voicemail.conf with voicemail accounts**