asterisk

Few days back, I created an account at voipfone.co.uk for VOIP service. I chose Asterisk 11 as it is stable and comes with Ubuntu 14.04 LTS. The installation and configuration of voipfone service in Asterisk is relatively easy.

Install asterisk

apt-get install asterisk

All configuration files of asterisk are in /etc/asterisk directory. The important files to complete a basic configuration are sip.conf and extensions.conf

Open /etc/asterisk/sip.conf in a text editor like vi or nano, and add these lines to sip.conf. Lets assume the account id is 30158787, voipfone account password is 879854, asterisk server IP is 52.10.11.12. The server was behind a NAT, so I had to do configuration related to NAT in sip.conf.

[general]
context=fromvoipfone
allowoverlap=no
udpbindaddr=0.0.0.0;
tcpenable=yes
tcpbindaddr=0.0.0.0
transport=tcp
srvlookup=yes
register=> 30158787:879854@sip.voipfone.net
nat=force_rport,comedia
externip=52.10.11.12
localnet=172.31.0.0/255.255.0.0
canreinvite=no


[voipfone]
type=friend
secret=879854
username=30158787
fromuser=30158787
fromdomain=sip.voipfone.net
host=sip.voipfone.net
insecure=port,invite
dtmfmode=rfc2833
context=fromvoipfone

Lets add few users in to sip.conf as well. In order to add users, add the below lines in sip.conf.

[1001]
type=friend
host=dynamic
secret=D4V1teiWAcdSDBKE
context=fromvoipfone

[1002]
type=friend
host=dynamic
secret=j3Tama0fNRFmltBx
context=fromvoipfone

[1003]
type=friend
host=dynamic
secret=zaShm0FNEKZ8VSZV
context=fromvoipfone

Here, we can use three SIP phones. 1001 sip account account can be configured in one phone with password D4V1teiWAcdSDBKE. Likewise, sip account 1002 and password j3Tama0fNRFmltBx in second one etc. You can add any number of account as you like into sip.conf.

Add the below lines in /etc/asterisk/extensions.conf. As my requirement is to ring all three SIP phones at once, when an incoming call comes in, my configuration has to be like below.

[fromvoipfone]
exten => s,1,Answer()
exten => s,2,Dial(SIP/1000&SIP/1001&SIP/1002,60,tT)
exten => s,3,Hangup()

exten => _[0-9+]!,1,Dial(SIP/${EXTEN}@voipfone,60,tT)

Lets start asterisk.

/etc/init.d/asterisk start

In order to watch what is happening behind asterisk, lets connect to the running instance in verbose mode.

asterisk -rvvvvvvv

Configure and connect the sip phones. Try calling the allotted 056 number can you can see all phone ringing at once. If you do not have a sip phone, you can try zoiper soft phone. If you have enough credits in voipfone account, you can dial outgoing call too.