Asterisk installation and configuration in Linux Server to make Calls between two Voip phone

Asterisk is a free and open source framework for building communications applications and is sponsored by Digium.

Asterisk turns an ordinary computer into a communications server. Asterisk powers IP PBX systems, VoIP gateways, and conference servers and is used by small businesses, large businesses, call centers, carriers and governments worldwide.

Asterisk is one of the most famous Open source project that can be used in variety of interesting projects from simple voice voip server to complete home automation, private mobile service etc.

Asterisk is one of the best telephony solutions which is free to use. There are others such as “yate” that provide same type of solutions and even more custom ones. Due to the ease of implementation Asterisk has become more popular than anything else. Asterisk is very easy to use and lots of open source and closed source panels provide a GUI for it.

Installation of asterisk server:

Asterisk requires a system running with kernel 2.6 and the header files must be present to compile asterisk on our system. Asterisk is written in c; we require gcc with the supporting libs such as termcap, and openssl. Asterisk add-ons require the mysql header files so please install mysql lib, mysql client and the headers to compile asterisk-add-ons.

Download all files:

  1. Zaptel
  2. Libpri
  3. Asterisk
  4. asterisk-sounds
  5. asterisk-addones

Installation of asterisk:

Goto /usr/local/src by executing the below command

“cd /usr/local/src”

Now download the above mentioned files using “wget”.

wget  downloads.digium.com/pub/zaptel/zaptel-1.4.12.1.tar.gz

wget  downloads.asterisk.org/pub/telephony/libpri/libpri-1.4.9.tar.gz

wget  downloads.digium.com/pub/asterisk/releases/asterisk-1.4.20.tar.gz

wget  downloads.digium.com/pub/asterisk/releases/asterisk-sounds-1.2.1.tar.gz

wget  downloads.digium.com/pub/asterisk/releases/asterisk-addons-1.4.7.tar.gz

Now follow the below 31 steps for installing asterisk:

  1. tar -xzf zaptel-1.4.12.1.tar.gz
  2. tar -xzf libpri-1.4.9.tar.gz
  3. tar -xzf asterisk-1.4.20.tar.gz
  4. tar -xzf asterisk-sounds-1.2.1.tar.gz
  5. tar -xzf asterisk-addons-1.4.7.tar.gz
  6. cd zaptel-1.4.12.1
  7. ./configure
  8. make
  9. make install
  10. make config
  11. service zaptel start
  12. cd ..
  13. cd libpri-1.4.9
  14. make
  15. make install
  16. cd ..
  17. cd asterisk-1.4.20
  18. ./configure
  19. make
  20. make install
  21. make samples
  22. make config
  23. cd ..
  24. cd asterisk-sounds
  25. make install
  26. cd ..
  27. cd asterisk-addons-1.4.7
  28. ./configure
  29. make
  30. make install
  31. service asterisk start

Now we have installed a new asterisk server on our system.

Creating first sip extension:

Please add the following lines to sip.conf (/etc/asterisk/sip.conf)

Move the default sip.conf to sip.conf.bkp for future references.

In terminal type
mv /etc/asterisk/sip.conf /etc/asterisk/sip.conf.bak

Now to edit a new sip.conf type the following command:
/etc/asterisk/sip.conf

Add the following lines to the file:

[Actsupport]
type=support
host=web
secret=1q2w3e4r
context=users
[Amulya]
type=support
host=dynamic
secret=1qaz2wsx
context=users

We have entered two users Actsupport and Amulya, secret is the password for the above mentioned two users. Now save the file and exit.

Now we have two users and we need to assign two numbers for these two users. For this we’ve to edit dialplan configuration. Dialpan is the heart of asterisk, this is the most important file for configuration and asterisk works based on this configuration,  Dialplan configuartions are in /etc/asterisk/extensions.conf file. No extension can talk to each other unless we configure the dial plan.

Just like sip.conf, extensions.conf default have too much details that will be confusing for us at this point so lets move it as a backup. To do open your terminal and execute the below command.

# mv /etc/asterisk/extensions.conf /etc/asterisk/extensions.conf.bak

Create a new extensions.conf file by issuing the below command in terminal.

#vi /etc/asterisk/extensions.conf

Now enter the following for configuring extension for Actsupport and Amulya:

[users]
exten=>500,1,Dial(SIP/Actsupport,20)
exten=>501,1,Dial(SIP/Amulya,20)

Save it and exit.

We have assigned number 500 for Actsupport and 101 for Amulya.

Now we need to make our connfigurations active. After editing configuration files we need to reload it from asterisk console to make it activeType the below command to get connected to asterisk console in terminal.

#asterisk -r

Execute the following command to reload the sip conf:

sip reload

To reload dialplan issue following:

dialplan reload

Now the two users and two numbers are active, to see user status issue following command:

sip show peers

You will get the following message:

Name/username Host Dyn Forcerport ACL Port Status

Actsupport (Unspecified) D N 0 Unmonitored

Amulya (Unspecified) D N 0 Unmonitored

Thats it. Now connect voip phone and make call 🙂