Set up Asterisk Server on Ubuntu VM in VirtualBox to test Linphone : Part 2

We continue from the Set up Asterisk Server on Ubuntu VM in VirtualBox to test Linphone : Part 1, and will show how to configure Asterisk and Linphone as SIP client on two devices to call each other over WiFi.


Step 1: Establish IP connection between the SIP client (Linphone) and the Asterisk server

First let’s put the ubuntu virtual machine on the same IP subnet as your mobile device. Assume that your mobile device running Linphone is on wifi at home. The simplest way to establish IP connection between the virtual machine and your mobile device is to put the virtual machine to be on the same subnet.

To do so, assume the machine the VirtualBox is running on is already on the same WiFi network as your phone. To check, you can check the IP address of your phone and then check that of your VirtualBox host. The first three octets of both IP addresses should match. For example, my iPhone’s IP is 192.168.1.103 and my macbook air hosting VirtualBox has IP of 192.168.1.105. The first three octets are “192.168.1″. To test, you can “ping” your phone from your host machine. Say from my macbook air, to ping my phone, I would run the following command from a terminal

ping 192.168.1.103

If ping is successful, then you are all set to go.

Next, change the virtual interface to be of type “Bridged Adapter”. 

Then at the ubuntu commandline, type

sudo shutdown now -r

to restart the VM (virtual machine)

After the virtual machine came back up, type “ifconfig” to verify that its network interface is in the same subnet network as your phone. See here if you don’t already know how to check the IP.

Then test pinging the phone from the VM

ping 192.168.1.105 (use your phone’s IP here)

Step 2: Update the sip.conf and extention.conf

Next we will add two SIP clients and create a dial plan for them.

sudo vi /etc/asterisk/sip.conf

Add the following text at the end of sip.conf to create two SIP clients:

[6003]
type=friend
secret=test100
host=dynamic
context=my-phone
[6004]
type=friend
secret=test100
host=dynamic
context=my-phone

And also create a dialplan with include both 6003 and 6004. Open /etc/asterisk/extensions.conf and add the following text at the end:

[my-phone]
exten=>6003,1,Dial(SIP/6003)
exten=>6004,1,Dial(SIP/6004)

Then restart Asterisk by connecting to asterisk server then reload.

sudo asterisk -rvvvvv
ubuntu*CLI>reload

Let iphone be of account 6003(password test100), and iphone simulator be of account 6004 (password test100).Below is what SIP settings look like on my iPhone.

After my phone connects to the Asterisk server, it shows “Registered” at the upper lefthand corner.

After connecting the other SIP client(6004) to asterisk, you can try calling 6004 from 6003. To call 6004, just type 6004 and press the phone button.

You should hear the phone ringing and the screen would look as followed:

You can download the finished sip.conf and extensions.conf

25 thoughts on “Set up Asterisk Server on Ubuntu VM in VirtualBox to test Linphone : Part 2

  1. Hi,
    The two mobile phones have successfully registered.

    While calling I am facing this error:

    NOTICE[1165][C-0000000e]: chan_sip.c:25772 handle_request_invite: Call from ‘6004’ (xxx.xxx.xxx.xxx:5060) to extension ‘sip/6003’ rejected because extension not found in context ‘public’.

    Can you please help me…

    • Hi vijay, please make sure 6003 and 6004 are in “my-phone” context and that “my-phone” context info is added to extensions.conf

      • Hi Jessica Chiang,

        In this Path: /etc/asterisk/extensions.conf I added these 3 lines.

        [my-phone]
        exten=>6003,1,Dial(SIP/6003)
        exten=>6004,1,Dial(SIP/6004)

        I reload the Asterisk Server. And in mobile accounts are registered, while making calling 6004 from 6003 it showing user not found.

          • Hi Vijay, unfortunately I was not able to reproduce your problem. Are you still having the same problem?

          • The problem is that instead of contex is context:
            [6003]
            type=friend
            secret=test100
            host=dynamic
            context=my-phone
            [6004]
            type=friend
            secret=test100
            host=dynamic
            context=my-phone

        • Hey vijay glad that SIP is working out for you. To configure IAX, you would need to enable the IAX module. I will update the blog sometime this week to add that as part 3

          • Hey vijay, I have to correct myself. Linphone currently only supports SIP and not IAX. You could configure two asterisk servers to communicate to each other over IAX, but I doubt that’s what you want.

  2. Hi Jessica,
    Yes, Linphone supports only SIP.
    I am trying both Linphone and Zoiper. Zoiper suppors IAX so for that I need to enable IAX protocol.

  3. hi Jessica : ) how about accessing the phones behind NATs (i.e. without public IP) ? i’ve read that Linphone somehow deals with this issue, making use of STUN, but i don’t know how. maybe you have any idea or may suggest some article to read?

  4. Hi Jessica,
    I have problem when connect to Asterisk server with Linphone, it shows “Register failed”? Can I fix it?
    Sorry but you can explains for me about domain in Settings?
    What is that?
    Thank you.

    • Hi Long,
      If it says register failed, then it’s likely the following
      1) Linphone can’t reach the asterisk server via IP
      – Asterisk not running
      – Asterisk not accepting IP of the Linphone (Are your asterisk server and Linphone on the same machine? Say Linphone is simulated?)
      – Linphone can’t ping the host that the asterisk server runs on
      2) Authentication failed
      – check the password

      Also, does your asterisk server show any error message? To increase the debug level, log on to asterisk cli, and enter “set verbose 11”

  5. Hi Jessica,
    Everytime I try to use linphone to call it says “Forbidden”. What can I do to solve this problem?

Leave a Reply

Your email address will not be published.