Basic Asterisk Configuration

After installing Asterisk we should need to configure it for actual working. If you don’t know how to install Asterisk, you can learn it here. With this basic Asterisk configuration, you will get an idea about how the Asterisk configuration takes place.

In this article we’re assuming asterisk is already been installed on your system. The scope of this article is to configure Asterisk to host local calls basically. After following steps of this article you will be able to:

  • Make calls locally
  • Access mail boxes

so lets get started…

To configure Asterisk we need to edit some configuration files in Asterisk’s directory i.e./etc/asterisk

The files which we will edit are:

  • /etc/asterisk/sip.conf
  • /etc/asterisk/extensions.conf
  • /etc/asterisk/voicemail.conf

Making a Backup

Before editing any files mentioned above, always make a backup of original files, because these files sometimes contain very important information to refer in case you need.

To make backup files, you can either make copies of original files with cp command and edit the original ones. or you can simply rename the files with mv command and create new files with the same names, I mostly prefer second method…

Method 1

Type the following commands one by one to make backup copy files by:

sudo cp /etc/asterisk/sip.conf /etc/asterisk/sip.conf.bk
sudo cp /etc/asterisk/extensions.conf /etc/asterisk/extensions.conf.bk
sudo cp /etc/asterisk/voicemail.conf /etc/asterisk/voicemail.conf.bk

And then edit the original files in upcoming steps.

Method 2

Type the following commands to rename original files to backup files by:

sudo mv /etc/asterisk/sip.conf /etc/asterisk/sip.conf.bk
sudo mv /etc/asterisk/extensions.conf /etc/asterisk/extensions.conf.bk
sudo mv /etc/asterisk/voicemail.conf /etc/asterisk/voicemail.conf.bk

And then create new empty files with the same names sip.conf, extensions.conf and voicemail.conf

Configure “sip.conf”

Open the sip.conf file by any preferred editor (gedit, nano etc), we are using gedit

sudo gedit /etc/asterisk/sip.conf

And update the following content into it

[general]
context=internal
allowguest=no
allowoverlap=no
bindport=5060
bindaddr=0.0.0.0
srvlookup=no
disallow=all
allow=ulaw
alwaysauthreject=yes
canreinvite=no
nat=yes
session-timers=refuse
localnet=192.168.1.0/255.255.255.0

[301]
type=friend
host=dynamic
secret=p@ss301
context=internal

[302]
type=friend
host=dynamic
secret=p@ss302
context=internal

Here, use your own localnet details in file, in my case its 192.168.1.0/255.255.255.0

The [301] and [302] are the extension numbers which I have declared, use your own extension numbers here.

The “secret” is a password allotted to its defined extension, you can use your preferred ones.

Now save the file by pressing Ctrl+s, and close the file.

Configure “extensions.conf”

Open the extensions.conf file by:

sudo gedit /etc/asterisk/extensions.conf

And update the following content into it

[internal]
exten => 301,1,Answer()
exten => 301,2,Dial(SIP/301,60)
exten => 301,3,Playback(vm-nobodyavail)
exten => 301,4,VoiceMail(301@main)
exten => 301,5,Hangup()

exten => 302,1,Answer()
exten => 302,2,Dial(SIP/302,60)
exten => 302,3,Playback(vm-nobodyavail)
exten => 302,4,VoiceMail(302@main)
exten => 302,5,Hangup()

exten => 401,1,VoicemailMain(301@main)
exten => 401,2,Hangup()
exten => 402,1,VoicemailMain(302@main)
exten => 402,2,Hangup()

Now save the file by pressing Ctrl+s, and close the file.

Configure “voicemail.conf”

Open the voicemail.conf file by:

sudo gedit /etc/asterisk/voicemail.conf

update the following:

[main]
301 => p@ss301
302 => p@ss302

Save the file and exit

Restart Asterisk

After editing configuration files, you must need to restart/reload Asterisk to apply the changes. Use any of the following method to restart Asterisk:

sudo service asterisk restart

OR

sudo /etc/init.d/asterisk restart

OR

sudo asterisk -rx reload

That’s it…the basic configuration of Asterisk is completed now

Conclusion

We learned how to install and configure Asterisk for basic operations like voicemail and local calling. You can make internal calls by directly dialing extension numbers like 301, 302 etc. To make a call we need an IP based phone like Soft-Phone and IP-phones. IP based hardware phones are little bit costly to afford for a small businesses. Software based phones or sometimes called as Soft-Phones are good to start with. To install and use Soft-Phones, you can see our tutorials on it.

Well, after all this basic configuration, we cannot call to external numbers. To do so, you need to subscribe to any VoIP vendor providing services in your region. To configure Asterisk for real outbound VoIP calling, check our tutorial on Advanced Asterisk Configuration.