How to Make Call using Opensource Voip Linphone on Ubuntu

We have had an article on installing Asterisk 13 on Ubuntu, but we did not go trough actually connecting with softphone and making the call. The article have been only about server side setup. Now we are going to build upon this article and connect Linphone to Asterisk 13.

Prerequisites

  1. Two Ubuntu computers on the same network (or computer and a VM, in my case it will be two laptops)
  2. One of them has asterisk installed

Installing Linphone and configuring Asterisk

Installing linphone is easy, on both of your computers type

sudo apt install linphone

After this we need to setup Asterisk to accept new users. On Asterisk machine, type

cd /etc/asterisk/

Here we moved to the directory where all of the Asterisk configuration files are located. We need sip.conf, but before editing it we will back it up:

sudo cp sip.conf sip.conf.orig

If you look into the file, it is huge. Scrolling takes time, so we will need to prune it to exclude all the commented lines, white spaces and only leave the lines that count as configuration.

So we open the file with vi while we are inside /etc/asterisk/

sudo vi sip.conf

And in vi we type this to remove comments

:g/^\s*;/d

Then this to remove white spaces.

:g/^$/d

What remains is the actual configuration. In the end of that configuration we need to add two users like this:

[miki] type=friend
context=phones
allow=ulaw,alaw
secret=12345678
host=dynamic
[bobby] type=friend
context=phones
allow=ulaw,alaw
secret=87654321
host=dynamic

Next we enter the Asterisk with asterisk -rvvv command and in asterisk prompt we type

sip reload

And then to show peers

sip show peers

Connecting Linphone

On both computers, start linphone and enter the wizard to add users, with passwords that you put ins sip.conf

After this, we are not yet ready to call. We need to write a dial plan in extensions.conf. Lets first backup it and then make new empty file:

sudo mv extensions.conf extensions.conf.orig

sudo nano extensions.conf

In empty file we will paste the dial plan.

[phones]

exten => 100,1,NoOp(First Line)
same => n,NoOp(Second Line)
same => n,Dial(SIP/miki)
same => n,Hangup

exten => 200,1,NoOp(First Line)
same => n,NoOp(Second Line)
same => n,Dial(SIP/bobby)
same => n,Hangup

Lets explain what all this means

In [] we put context, which is in our case phones. We operate on extensions, 100 for miki and 200 for boby. For doing things inside dial plan, we use things called applications. That are those things, like NoOp, Dial, and Hangup. Lets first explain the first line.

Exten is for extension, followed by => and then we say which number of the extension we operate on. It is 100, followed by 1 for the number of the line. NoOp is application that we use for the first line. In the second line things look differently but it is basically the same. Instead of exten we write same, because we are operating on same extension, 100.

This means that number 100 does not need to be repeated in second line and we move to line number but here we have a twist also. Instead of writing 2 (which we could also do), we will write n meaning next. There is simple reason for this.   If we wrote 2 and then inserted another line between 1 and 2 with new application, we would need to change all line numbers. This way, if we write n, we do not need to do this.

When we move to second extension we are at the square one again. First line needs to be written in full, and while cards can be used for rest.

Making first call

After we have made a dialplan and saved it we are ready to call. Before we do that, lets first reload dialplan. That is mandatory step whenever we add new configuration.

asterisk -rvvv

After entering prompt

dialplan reload

Lets enter asterisk and look at our peers now

ThinkPad-X220T*CLI> sip show peers
Name/username Host Dyn Forcerport Comedia ACL Port Status Description
bobby/bobby 192.168.1.6 D Auto (No) No 5060 Unmonitored
miki/miki 192.168.1.5 D Auto (No) No 5060 Unmonitored

We have two peers connected, and we can make a call from one to another. Lets call bobby

== Using SIP RTP CoS mark 5
-- Executing [[email protected]:1] NoOp("SIP/miki-0000000a", "First Line") in new stack
-- Executing [[email protected]:2] NoOp("SIP/miki-0000000a", "Second Line") in new stack
-- Executing [[email protected]:3] Dial("SIP/miki-0000000a", "SIP/bobby") in new stack
== Using SIP RTP CoS mark 5
-- Called SIP/bobby
-- SIP/bobby-0000000b is ringing

As we can see, the calling works.

How to find more applications

To write more complex dial plans, you would need to use more applications. You can browse applications in Asterisk prompt in several ways. For example you want dial applications, you would type core show applications dial

ThinkPad-X220T*CLI> core show applications like dial
-= Matching Asterisk Applications =-
Dial: Attempt to connect to another device or endpoint and bridge the call.
RetryDial: Place a call, retrying on failure allowing an optional exit extension.
-= 2 Applications Matching =-

It gives us two applications, one we already used and one is new to us, RetryDial. So if you type

core show application RetryDial

(notice no s, just application followed by the name), you will get the lengthy help file for application you selected.

But suppose you don't like either of those two apps, you want something more. You can expand your search by adding more vague definition like this

core show applications describing dial

I got 41 app by this search.

Conclusion

So building on our previous Asterisk article, we have shown how to configure Asterisk for use with Linphone. We have made a dialplan and made first call over our Asterisk server. Also we have introduced how to find applications you need to write your desired dial plan. Thank you for reading, and have fun with telephone calling.

About Mihajlo Milenovic

Miki is a long time GNU/Linux user, Free Software advocate and a freelance system administrator from Serbia. Got introduced to GNU/Linux in year 2003 on old AMD Duron computer, and since than always eager to learn new stuff about this system. From 2016 writes for Linoxide to share his experiences with wider audience

Author Archive Page

Have anything to say?

Your email address will not be published. Required fields are marked *

All comments are subject to moderation.