B Establishment of the VoIP link » History » Version 1

Version 1/13 - Next » - Current version
piat, charles ugo, 03/17/2015 12:18 PM


B Establishment of the VoIP link

Installation of Asterisk FPBX

Configuration of the internal call

The configuration of the asterisk for the 3 handsets is implemented in the files sip.conf and extensions.conf. We register the 3 handsets in the file sip.conf and we build the channels in the extensions.conf. We had the choice to configure asterisk through the web interface or directly in the configuration files. We had chosen the second options because the first one generates errors in the handset registering.

sip.conf

[general]
context=unauthenticated
allowguest=no
srvlookup=no
udpbindaddr=0.0.0.0
tcpenable=no

We have set the default context to "unauthenticated" to ensure that unauthenticated guest calls will enter the dialplan. It will be useful for external call since we don't always know the caller. We have set allowguest to "no" to exclusively allow phone call from registered device in our local network. We put the udpbindaddr field equal to 0.0.0.0 to be sure that the VoIP server listen to all interfaces (nevertheless we could have udpbindaddr=192.168.35.0/24). We wanted to cancel the more restrictions as possible.

In the same file we have created the template for our devices.

[office-phone](!)
type=friend
context=LocalSets
host=dynamic
nat=force_rport,comedia
dtmfmode=auto
disallow=all
allow=g722 
allow=ulaw 
allow=alaw

We have set the type to friend so that the channel driver will match on the username and the IP. Next we have register the context as "LocalSets", this is where, calls from the device will enter the dialplan (it is not a default value, it is chosen by the user. It will correspond to the name of the template in the extensions.conf). The host parameter defines the IP address of the far end for this channel; we define the value as dynamic so we let Asterisk know that the phones will tell him where they are on the network. The NAT filed meaning network address translation; it is needed when the remote device is behind a firewall. The rport parameter signal to the far end that it should respond to the source IP and port the request originated from and respectively the comedia parameter is used to instruct Asterisk to send media (RTP) to the address and port that the far-end media came from.

[1001](office-phone)
secret=1001 
[1003](office-phone)
secret=1002 
[1003](office-phone)
secret=1003

Here we have defined the device name and its secret's code for the 3 handsets.

extensions.conf

[LocalSets] 
exten => 1001,1,Dial(SIP/1001) 
exten => 1002,1,Dial(SIP/1002) 
exten => 1003,1,Dial(SIP/1003)

In the file extensions.conf we create a template call "LocalSets" corresponding to the value of the context field in the sip.conf. The field “exten” means when the number 1001 (for instance in the second code line) is dial, asterisk will call the SIP/1001. The number 1 between commas corresponds to the priority.

Configuration of the External call

In our configuration we differentiate the InComing call from the OutGoing call. Likewise the internal call, we implement the configuration in the sip.conf to register our line from our provider and the extensions.conf to manage the calls.

InComing Call

sip.conf

[general]
register => 0033XXXXXXXXX:password@sip.ovh.fr

We register our phone line with our phone number, our password and the domain provided from ovh.

[forfait-ovh]
type=peer
host=sip.ovh.fr
context=ovh-sip
defaultuser=0033XXXXXXXXX
fromuser=0033XXXXXXXXX
secret=password
directmedia=no
nat=force_rport,comedia
canreinvite=no
qualify=yes
dtmfmode=auto

Here we have save information corresponding to our line. The context field refers to the template in the dialplan. We retrieve almost the same filed than those presented in the internal call.

extensions.conf

[ovh-sip] ; nom du plan
exten => s,1,Ringing(1)
exten => s,2,Answer
exten => s,3,Dial(SIP/1001,30,tm) 
exten => s,4,Hangup(16) 

In the file extensions.conf we create a template call "ovh-sip" corresponding to the value of the context field in the sip.conf. In The field “exten” we replace the number dialed by "s" which means asterisk will answer to all incoming call and the device SIP/1001 will received all the external calls. Here we can see in more details the priority rules, first Ringing, Answering, Dial and Hang-up.

OutGoing Call

In this part, we will just modified the file extensions.conf.

extensions.conf

[external]
exten => _0.,1,Dial(SIP/${EXTEN}@forfait-ovh) 
[LocalSets]
include => external

In the LocalSets we have included the template external to authorize external call to the handsets. The template “external” calls on the section [forfait-ovh] to provide the outgoing call. Only calls begining by zero (the aim is to block the international call but can be remove depending of the situation) are allowed by our configuration.