Unable to hear audio from Asterisk server when calling from a Linphone as a registered user

Hi all,

I’m new to Asterisk and would appreciate some assistance. Do let me know if I must provide any other info and I’d be happy to do that.

My Setup: I’m using Virtualbox installed on my Mac. I have UbuntuVMs on the VirtualBox.

  1. Asterisk Server on UbuntuVM1
  2. Linphone on UbuntuVM2

Both VMs have Host Only adapter + NAT adapter enabled so that they can all access internet as well as ping each other (side note: Bridged adapter has trouble with connecting to WiFi on Mac and hence why I’m not using the bridged adapter instead).

Now, static IP addresses have been assigned to both VMs.

Asterisk Server - 192.168.56.103
Linphone on Ubuntu - 192.168.56.104

/etc/asterisk/extensions.conf
[public]
exten => 30,1,Answer()
exten => 30,n,Background(/var/lib/asterisk/sounds/ivr_promt_user)
;exten => 30,n,SayDigits(1234)
[phones]
exten => 30,1,Answer()
exten => 30,n,Background(/var/lib/asterisk/sounds/ivr_promt_user)
;exten => 30,n,SayDigits(1234)
/etc/asterisk/sip.conf
[general]
bindaddr=0.0.0.0
context=public
host=dynamic
type=friend
allow=ulaw,alaw
[steve]
bindaddr=0.0.0.0
type=friend
context=phones
allow=ulaw,alaw
secret=12345678
host=dynamic
[clive]
bindaddr=0.0.0.0
type=friend
context=phones
allow=ulaw,alaw
secret=87654321
host=dynamic

I started asterisk server (on first VM) using sudo asterisk -rvvvvv.

Then I started linphone on my second VM. Clicked on Options > Preferences > Wizard > “I have already a sip account and I just want to use it” > Enter Username: steve, Password: 12345678, Domain: 192.168.56.103 (this is the ip address of the VM that Asterisk is on).

Asterisk CLI says:
--Registered SIP 'steve' at 192.168.56.104:5060
   > Saved useragent "Linphone/3.9.1 (belle-sip/1.4.2)" for peer steve

Now, I try calling sip:30@192.168.56.103 and hear nothing on the linphone side (the call gets answered, there is silence and then the call hangs up).

Asterisk CLI says:
== Using SIP RTP CoS mark 5
     -- Executing [30@phones:1] Answer("SIP/steve-00000000", " ") in new stack
     -- Executing [30@phones:2] BackGround("SIP/seteve-00000000", "/var/lib/asterisk/sounds/ivr_promt_user") in new stack
      -- <SIP/steve-00000000> Playing 'var/lib/asterisk/sounds/ivr_promt_user.ulaw' (language 'en')
          > 0x7f037000d4f0 -- Probation passed - setting RTP source address to 192.168.56.104:7078
     -- Executing [30@phones:3] Hangup("SIP/steve-00000000", " ") in new stack
  == Spawn extension (phones, 30, 3) exited non-zero on 'SIP/steve-00000000'

Now, if I delete the user account from Linphone (Options > Preferences > Select sip:steve@192.168.56.103 from under Account section > click Remove),

Asterisk CLI says:
--Unregistered SIP 'steve'

Now, on Linphone, my default settings are as follows:

Your display name:
Your username: steve
Your resulting SIP address: ""sip:steve@10.0.3.15:5060 (note that 10.0.3.15 is the IP address for this VM because of the NAT adapter. This field is not editable)

Now if I call sip:30@192.168.56.103, it works - i.e. the call is answered, I hear the IVR message, and the call hangs up.

Asterisk CLI says:
== Using SIP RTP CoS mark 5
     -- Executing [30@phones:1] Answer("SIP/steve-00000001", " ") in new stack
     -- Executing [30@phones:2] BackGround("SIP/seteve-00000001", "/var/lib/asterisk/sounds/ivr_promt_user") in new stack
      -- <SIP/steve-00000001> Playing 'var/lib/asterisk/sounds/ivr_promt_user.ulaw' (language 'en')
          > 0x7f037000d4f0 -- Probation passed - setting RTP source address to 192.168.56.104:7078
     -- Executing [30@phones:3] Hangup("SIP/steve-00000001", " ") in new stack
  == Spawn extension (phones, 30, 3) exited non-zero on 'SIP/steve-00000001'

Would anybody help me understand this / overcome this problem?

You need to set the Nat settings(including localnet) on your peers in the sip.conf and in your devices.

The thing here is all about NAT since you have different IP addresses. Take a quick search on Google or better in the forum, there are a lot threads about this in the forum.

Thanks for your reply @navaismo. I will try and find instructions for setting this.

However, since the virtual machines are all on the same local network, why is it necessary to set NAT settings?

I think it is more likely to be a firewall issue.

Although not related to your problem, you should remove host and type from general (they may be allowed, but no-one would put them there), and bindarddr from the individual sections (will be totally ignored). Also change type=friend to type=peer (best practice, for nearly all cases).

@navaismo I added the following line under [steve] as well as under [clive] in the sip.conf file and the issue is fixed. I also updated it as per @david551 instructed.

/etc/asterisk/sip.conf
[general]
context=public
type=peer
allow=ulaw,alaw
[steve]
type=peer
nat = yes
context=phones
allow=ulaw,alaw
secret=12345678
host=dynamic
[clive]
type=peer
nat = yes
context=phones
allow=ulaw,alaw
secret=87654321
host=dynamic