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

29 Comments

  1. vijay

    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…

    • Jessica Chiang

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

      • Vijay

        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.

        • Vijay

          Hi Jessica Chiang,

          Still same problem with this.

          Please replay as soon as possible…

          • Jessica Chiang

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

          • paperback writer

            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

          • Jessica Chiang

            Thank you so much papu4000! I’ve corrected the error.

    • Jessica Chiang

      Hey Vijay
      I’ve updated this blog to include sip.conf and extensions.conf on my machine. Hope it’ll be helpful
      jc

      • Vijay

        Hi Jessica,

        Thanks, now calls are going.

        And I need to configure in IAX also in Asterisk Server.

        Please suggest me.

      • Vijay

        Hi Jessica,
        Thanks, Now calls are going fine.
        And how to configure IAX in Asterisk Server?
        Please suggest me…

        • Jessica Chiang

          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

          • jessica

            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. Vijay

    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. Faris

    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?

    • Jessica Chiang

      This is to set up asterisk server to test end-to-end voip call made via linphone

  4. Long Nguyen

    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.

    • Jessica Chiang

      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”

      • Abdullah

        Hi Jessica,
        My linphone app is giving io error. can you help me with this?

        • Jessica Chiang

          Hi Abdullah, please post your error and I will see what I can help with

  5. Francis

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

  6. DarReNz

    if you guys got a call rejected or forbidden, add the line “load=app_dial.so” in the file modules.conf

  7. carlos josé duarte casillas

    dude, thanks! BUT…

    you need to homologate the passwords between the ones on this page (“test100”) and the ones on the finished sip.conf (“ping”). this little mistake cost my newbie ass about 20 minutes of confusion-induced headache.

    still, this straightforward tutorial gave me the confidence to “get it done” in a deliciously offhand, essential and preliminary manner, on which i can totally build on and perfect.

    again, much thanks!

    ps: it seems like you also skipped the part about modules.conf!

Leave a Reply