Hi if you are reading this, probably you know what is asterisk and what it does, for others please read the extract from asterisk.org below.
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, 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 !
I have made this guide to beginners who just want to get asterisk server started and make calls between two voip phones ! . As I know when I started to learn asterisk it was difficult for me to understand things as Asterisk is really rich in its functionalities. if you start reading some books you might think it will take a two months to just get started !
OK lets begin !
1 - Get your OS ready !
As I want to make this simple I am focusing on just one OS Ubuntu 12.10 . If you don’t have Ubuntu please get any copy of Ubuntu from ubuntu.com . Installation of ubuntu is simple and you can find the instructions from the site itself.
2- Install Asterisk !
Installing Asterisk is really simple in Ubuntu open a terminal ( ctrl+alt+t ) and type the following.
sudo apt-get install asterisk
and press enter and then you will be asked for password after that you will get a confirmation, just confirm and installation will be finished soon (Around 10 mb download),
You will be asked to enter ITU-T telephone code: enter your country code (India 91) (This is not really important unless you are going to connect the asterisk to real telephones )
Now that was simple !
Note : if you are getting can not find package error, open a terminal and type the following
sudo apt-get update
then run
sudo apt-get install asterisk
3- Lets configure Asterisk !
Ok now that we have asterisk installed and running lets create some users for our server ! we are going to create two SIP users. This is configured under file /etc/asterisk/sip.conf.
Since there alot of details and comments in default sip.conf, we are not going to use it. we will start with a fresh file.
Move the default sip.conf to sip.conf.bkp for future references.
In terminal type
sudo mv /etc/asterisk/sip.conf /etc/asterisk/sip.conf.bkp
Now if you are on ubuntu desktop to edit a new sip.conf type the following command
sudo gedit /etc/asterisk/sip.conf
or if you are on server use your favourite editor (nano or sip) mine is nano.
sudo nano /etc/asterisk/sip.conf
Add the following lines to the file
[batman]
type=friend
host=dynamic
secret=bat123
context=users
[robin]
type=friend
host=dynamic
secret=rob321
context=users
What you have entered two users batman and robin, secret is the password for user. for other configuration lets leave it as it is and will look onto that later.
Now save the file and close the editor.
Now that we have two users we need to assign two numbers to this users. for this we need 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, you will understand that after you are familier with asterisk. Dialplan configuartions are in /etc/asterisk/extensions.conf file
Just like sip.conf, extensions.conf default have too much details that will be confusing for us at this point so lets move it a backup. open your terminal and type
sudo mv /etc/asterisk/extensions.conf /etc/asterisk/extensions.conf.bkp
Create a fresh extensions.conf file by issuing following command in terminal (use nano/vi for server users)
Now enter the following for configuring number for batman and robin
[users]
exten=>100,1,Dial(SIP/batman,20)
exten=>101,1,Dial(SIP/robin,20)
We have assigned number 100 for batman and 101 for robin ! You can learn more about this configuration later.
Now we need to make our connfigurations active. After editing configuration files we need to reload it from asterisk console to make it active.
type the following to get connected to asterisk console in terminal
sudo asterisk -r
Issue the following command to reload the sip conf.
sip reload
To reload diaplan issue following.
dialplan reload
Now our 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
batman (Unspecified) D N 0 Unmonitored
robin (Unspecified) D N 0 Unmonitored
4- Lets connect voip phone and make call !!
Now that all configurations are up and running lets connect two voip phones to our server, easiest way to test this is by creating a wifi netwrok using ubuntus network manager and connecting devices to this network. In that case your server IP will be 192.168.1.1 else you need to find ip of your system. (simple google for how to find my ip will get you result).
I used a softphone for ubuntu and sipdroid for android to test the setup using local wifi network.
Installing soft voip phone sipdroid is easy, you find it in play store.
Configuring sipdroid in android
click menu settings> sip account 1
Configure username as batman or robin give password we have given on sip conf and serverproxy as ip address of the asterisk server.
Click back and you will be connected to server.
You can verify connectivity by issuing sip show peers which will show the details something like below
rohith-Lenovo-G450*CLI> sip show peers
Name/username Host Dyn Forcerport ACL Port Status
batman/batman 192.168.1.143 D N 54891 Unmonitored
robin (Unspecified) D N 0 Unmonitored
Ok now for ubuntu I have installed sflsoftphone which seems actively developed
to install take a terminal and type
sudo apt-get install sflphone-gnome
Open sflphone-client from ubuntu dash and you will get a first time configuration screens like below