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

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**

Installing and Configuring Asterisk CentOS 7

You will need a Linux OS to install Asterisk.



The above is version 7 32 or 64 depending on CPU and is a minimal install


  • Stuff to do once Linux OS is installed
  • vi /etc/sysconfig/network-scripts/ifcfg-eth0
  • Make sure onboot=yes change that from disabled
  • service network restart
  • ip addr show ( should show an ip address for eth0 )
  • yum -y update ( update the system without prompting )
  • shutdown -r now ( reboot system after updating to apply )
  • cd /usr/src
  • yum -y install wget ( install wget package to download files from the internet)
  • You can either wget Asterisk from up above or use CentOS repos to install Asterisk ( A word of caution is to make sure it is a LTS version or certified version of Asterisk)
  • yum method: yum -y install asterisk ( this will install asterisk with all dependencies )
  • It is also a good idea with CentOS to install the epel-release repo
  • yum -y install epel-release; yum repolist ( should install the epel-release and then list repos and should see epel)
  • If you download asterisk using wget
  • wget url-for-asterisk.tgz
  • tar zxfv name.of.file.tgz
  • cd name.of.folder
  • ** Have to install some custom files to run asterisk if you just run ./configure it’ll error out and complain**
  • yum -y install gcc gcc-c++ libxml2-devel sqlite-devel ncurses-devel
  • ./configure
  • make menuselect
  • make
  • make install
  • make samples ( install sample configuration files )
  • Have Asterisk start as a service
  • cd /usr/src/name-of-folder; cp contrib/init.d/rc.redhat.asterisk /etc/init.d/asterisk
  • vi /etc/init.d/asterisk ( locate AST_SBIN= ) replace that with AST_BIN=/usr/sbin/
  • service asterisk start ( if it complains about 64bit libraries do the following)
  • ┬áln -s /usr/lib/ /usr/lib64/ ( only if it complaines about 64bit .so file)
  • Disable selinux by vi /etc/selinux/config ( change SELINUX=enabled to SELINUX=disabled
  • shutdown -r now ( need to reboot otherwise selinux will enforce still )
  • chkconfig asterisk on ( enable to start on reboot ) or if chkconfig does not exist because of systemctl then use systemctl enable asterisk
  • systemctl status iptables or service iptables status ( if iptables is running need to disable )
  • systemctl disable iptables ( or firewalld ) service iptables stop systemctl stop iptables
  • chkconfig iptables off systemctl disable firewalld