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