Home » Systems » Ubuntu » Basic Asterisk configuration in Ubuntu

Basic Asterisk configuration in Ubuntu

This is a basic Asterisk configuration tutorial for Ubuntu.

I am assuming you have already installed Asterisk, if you haven’t check out my other tutorial found here for how to install Asterisk.

After completing this guide your Asterisk will be able to :

  • Host calls locally
  • Access mail boxes

We will be editing the following files:

  • sip.conf
  • extensions.conf
  • voicemail.conf

These files are located in:

  • /etc/asterisk

Making a backup of sip.conf

Type the following to move the original sip.conf

sudo mv /etc/asterisk/sip.conf /etc/asterisk/sip.conf.orig

Creating a new sip.conf and configuring it

Type the following to create a new sip.conf

sudo vi /etc/asterisk/sip.conf

[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

[7001]
type=friend
host=dynamic
secret=123
context=internal

[7002]
type=friend
host=dynamic
secret=456
context=internal

Image below for reference.

draalin-basic-asterisk-configuration-in-ubuntu-10

You can save this file by first pressing ESC then letting go.

Followed by holding Shift and : then letting go again.

Now type wq! followed by pressing enter.

Your file is now saved.

Making a backup of extensions.conf

Type the following to move the original extensions.conf

sudo mv /etc/asterisk/extensions.conf /etc/asterisk/extensions.conf.orig

Creating a new extensions.conf and configuring it

Type the following to create a new extensions.conf

sudo vi /etc/asterisk/extensions.conf

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

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

exten => 8001,1,VoicemailMain(7001@main)
exten => 8001,2,Hangup()

exten => 8002,1,VoicemailMain(7002@main)
exten => 8002,2,Hangup()

Image below for reference.

draalin-basic-asterisk-configuration-in-ubuntu-12

You can save this file by first pressing ESC then letting go.

Followed by holding Shift and : then letting go again.

Now type wq! followed by pressing enter.

Your file is now saved.

Making a backup of voicemail.conf

Type the following to move the original voicemail.conf

sudo mv /etc/asterisk/voicemail.conf /etc/asterisk/voicemail.conf.orig

Creating a new voicemail.conf and configuring it

Type the following to create a new voicemail.conf

sudo vi /etc/asterisk/voicemail.conf

[main]
7001 => 123

7002 => 456

Image below for reference.

draalin-basic-asterisk-configuration-in-ubuntu-14

You can save this file by first pressing ESC then letting go.

Followed by holding Shift and : then letting go again.

Now type wq! followed by pressing enter.

Your file is now saved.

Reloading Asterisk to apply the configuration

You can restart asterisk by any of the three following ways:

Method 1

sudo asterisk -rx reload

Method 3

sudo /etc/init.d/asterisk restart

Method 2

sudo asterisk -r

Followed by typing:

reload

Followed by typing:

exit

Final Thoughts

That’s it you have now completed the tutorial!

I have added a gallery below for extra support.

This slideshow requires JavaScript.

About Tyler Bailey

Tyler Bailey is a university student who owns and runs draalin.com. Follow me on
  • thekev

    thanks, i’m pretty new to asterisk in general but this helped.

  • roofer

    good setup for my house. gj

  • Pingback: Advanced Asterisk configuration in Ubuntu | draalin()

  • Jin

    I always get No such command `sudo mv/etc/asterisk/sip.conf/etc/asterisk/sip.conf.orig…what ´s wrong I am, please give me advice.

    • Amod

      It’s “mv /etc/asterisk/sip.conf /etc/asterisk/sip.conf.orig”, not “mv/etc/asterisk/sip.conf/etc/asterisk/sip.conf.orig”

  • Hamad Abbasi

    Could you please add soft phone setup on clients machine? That would be really helpful as well but overall you did a fantastic job.

    • http://tylerbailey.ca Tyler Bailey

      Hi Hamad, I might do that in the future!

      • Hamad Abbasi

        Hi Tyler, Thanks to you.. I got Asterisks working internal on my home network. I installed X-Lite soft phones to test and they are working.

        Now, is it possible that I can port forward 5060 and RTP ports on my router to connect from outside while I am traveling?

        • http://tylerbailey.ca Tyler Bailey

          Hi Hamad, you should be able to do it with port forwarding.

  • shashwa

    You need to fix this text

    “Now type wq! followed by pressing enter.

    Your file is now saved.”

    :wq! will abandon all changes!

  • Krunal Patel

    this configuration is not support for sipml5 web app? what are the additional configuration used to support webRTC

  • http://mitritsakis.gr Valerio Paris Mitritsakis

    Just to be on the safe side that this comment will not be misunderstood I would like to say thank you to the author for writing this article. It is a useful resource for someone trying to learn Asterisk.

    Now with the actual comment.

    The problem with all these howto guides is that they are actually simply recipes. You follow them and end up with a basic working system. They do not explain what you are actually doing and most importantly why. From what I am reading I can assume for the most part what the configuration files are doing. Assumption is however, as they say, the mother of all fuck ups.

    So while this posting is very helpful it would have been stellar if every bit of this config was explained to the reader.

  • Muhammad Umair

    Hi Tyler Bailey: Excellent Post. I have followed all the steps n successfully configured the asterisk in ubuntu 14.04. I have some queries regarding configuration of asterisk on internet. I have added you on google plus. Will ask you via PM. Thanks in advance.

  • syahmina syuhrah

    hi tyler i have install asterisk successfully.. but i encounter a few problem when configuring it.. hope you can help me..