B Establishment of the VoIP link


Asterisk IP PBX

We had implemented as explained before, a working server running Asterisk 13.2.0 over Ubuntu Server 14.04.2. In order to connect to the asterisk server we can choose one of the following procedures:

  • 1.Link through the router

Any component in the local LAN generated by the mikrotik server (by Ethernet or WiFi) may be able to connect to the asterisk server by ssh.
For example with a computer running linux we can just type the following:

shh 

The credentials for our case are the following:

Server IP: 192.168.88.242: This address can be changed in the DCHP server of the mikrotik router. 
A local static address can be configured, while we discourage it
Client: kasat
Password: gogolgogol

In order to get root privileges during the session we can add "sudo" to the command that we want to run, or type the following command:

sudo -i

Which will grant to kasat root privileges during all the ssh session.

  • 2.Direct configuration

The server can be configured directly with a screen and a keyboard connected to the Intel NUC.

While the asterisk server will run at system start-up, an asterisk terminal may be open with the following command:

Asterisk -rvvvvvv

This will open an asterisk terminal, where it may be configured or restarted, and we may be able to see logs in real time from it.

Configuration of the internal calls

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 calls

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.