Incoming call not matching defined SIP Trunk (integration with Skype for Business)

Hello, I am trying to setup FreePBX as a PBX for Skype For Business. I´ve followed this tutorial (www-moh10ly-com/blog/VoIP/asterisk/freepbx-asterisk-now-with-skype-for-business-integration --please change - for . as this system doesn´t allow me to paste URL links). I can call from FreePBX to S4B client but not back. It doesn´t matter which extension (built-in, existing, non-existing) I am dialing from the S4B client, it keeps telling me, that dialed number is not existent. Further, in the log, I can see Rejecting unknown SIP connection from IP-ADDRESS -OF-S4B-BOX.

My extension on FreePBX are using pjsip, Trunk is sip. S4B is configured to contact FreePBX box on port TCP/5160

My conf:

pjsip.transports.conf:
[0.0.0.0-udp]
type=transport
protocol=udp
bind=0.0.0.0:5060
external_media_address=EXTERNAL_IP
external_signaling_address=EXTERNAL_IP
allow_reload=no
tos=cs3
cos=3
local_net=FREEPBX_AND_S4B_SUBNET

sip_general_additional.conf (portion):
tcpenable=yes
transport=tcp
context=from-sip-external
callerid=Unknown
tcpenable=yes
bindport=5160
jbenable=no
srvlookup=no
tlsenable=no
allowguest=yes
notifyhold=yes
canreinvite=no
tlsbindaddr=[::]:5161
ALLOW_SIP_ANON=no
local_net=FREEPBX_AND_S4B_SUBNET

Trunk PEER details:
[Skype4B]
host=IP-ADDRESS -OF-S4B-BOX
transport=tcp
port=5060
insecure=invite,port
type=friend
context=from-internal
promiscredir=yes
qualify=yes
canreinvite=yes

Inbound and outbound routes are set accordingly to Mohammed´s article. Nevertheless, any call from S4B to FreePBX is marked with from-sip-external context. It´s driving me crazy because I cannot see why the incoming route is not being used, and therefore these calls are handled as an unknown peer will dial them. I must admit, that I am a FreePBX/Asterisk newbie, but still, it doesn´t make any sense to me. Thanks for any help.

You need to show this happening with a debug

asterisk -rvvvvvvvvv
sip set debug on

make call to PBX from Skype.

Also keep in mind that the Inbound Routes are only hit AFTER the PBX accepts a call OVER a trunk. So if the PBX is getting a call that it can’t match an IP for on a trunk, you’re going to get what you’re getting.

So let’s see how this call is actually hitting the PBX because the one thing that you have happening that this tutorial doesn’t (it seems) is that the author had “Allow SIP Guests” which would ignore the “sip-external” filter/check and allow any calls to be accepted on the PBX. That’s not the only issue with that article, it’s poorly done and the idea of it “working” is probably based on the author’s PBX being totally setup insecurely and allowing anyone in the world to make calls to it.

Ok, so I´ve disabled SIP guest option, which leads to the refusal of the incoming calls from S4B. Part of the log matching the test call:

[2018-10-15 18:47:10] VERBOSE[99396] chan_sip.c:
<— SIP read from TCP:10.10.64.50:49385 —>
ACK sip:[email protected];user=phone SIP/2.0
FROM: "Gregorij"sip:[email protected];user=phone;tag=bc1d6a26fc;epid=6495D1B57C
TO: sip:[email protected];user=phone;tag=as32140fbd
CSEQ: 1412 ACK
CALL-ID: 4f9f3ed9-10f2-4fcf-ada7-bece6b3ba1ca
MAX-FORWARDS: 70
VIA: SIP/2.0/TCP 10.10.64.50:49385;branch=z9hG4bK298bdfce
CONTENT-LENGTH: 0

<------------->
[2018-10-15 18:47:10] VERBOSE[99396] chan_sip.c: — (8 headers 0 lines) —
[2018-10-15 18:47:10] VERBOSE[99396] chan_sip.c:
<— SIP read from TCP:10.10.64.50:49385 —>
INVITE sip:[email protected];user=phone SIP/2.0
FROM: "Gregorij"sip:[email protected];user=phone;epid=6495D1B57C;tag=4ff510102f
TO: sip:[email protected];user=phone
CSEQ: 1413 INVITE
CALL-ID: 4df05419-0a05-49f9-879c-a64ffa3797ba
MAX-FORWARDS: 70
VIA: SIP/2.0/TCP 10.10.64.50:49385;branch=z9hG4bK797127d
CONTACT: sip:s4bfe.domain.local:5060;transport=Tcp;maddr=10.10.64.50;ms-opaque=5dc2015e7cb15d48
CONTENT-LENGTH: 336
SUPPORTED: 100rel
USER-AGENT: RTCC/6.0.0.0 MediationServer
CONTENT-TYPE: application/sdp
ALLOW: ACK
Allow: CANCEL,BYE,INVITE,PRACK,UPDATE

v=0
o=- 48 1 IN IP4 10.10.64.50
s=session
c=IN IP4 10.10.64.50
b=CT:1000
t=0 0
m=audio 54772 RTP/AVP 97 101 13 0 8
c=IN IP4 10.10.64.50
a=rtcp:54773
a=label:Audio
a=sendrecv
a=rtpmap:97 RED/8000
a=rtpmap:101 telephone-event/8000
a=fmtp:101 0-16
a=rtpmap:13 CN/8000
a=rtpmap:0 PCMU/8000
a=rtpmap:8 PCMA/8000
a=ptime:20
<------------->
[2018-10-15 18:47:10] VERBOSE[99396] chan_sip.c: — (14 headers 18 lines) —
[2018-10-15 18:47:10] VERBOSE[99396] chan_sip.c: Sending to 10.10.64.50:49385 (no NAT)
[2018-10-15 18:47:10] VERBOSE[99396][C-0000002e] chan_sip.c: Sending to 10.10.64.50:49385 (no NAT)
[2018-10-15 18:47:10] VERBOSE[99396][C-0000002e] chan_sip.c: Using INVITE request as basis request - 4df05419-0a05-49f9-879c-a64ffa3797ba
[2018-10-15 18:47:10] VERBOSE[99396][C-0000002e] chan_sip.c: No matching peer for ‘010’ from ‘10.10.64.50:49385’
[2018-10-15 18:47:10] VERBOSE[99396][C-0000002e] chan_sip.c:
<— Reliably Transmitting (no NAT) to 10.10.64.50:49385 —>
SIP/2.0 401 Unauthorized
Via: SIP/2.0/TCP 10.10.64.50:49385;branch=z9hG4bK797127d;received=10.10.64.50
From: "Gregorij"sip:[email protected];user=phone;epid=6495D1B57C;tag=4ff510102f
To: sip:[email protected];user=phone;tag=as763d2604
Call-ID: 4df05419-0a05-49f9-879c-a64ffa3797ba
CSeq: 1413 INVITE
Server: FPBX-14.0.3.19(13.22.0)
Allow: INVITE, ACK, CANCEL, OPTIONS, BYE, REFER, SUBSCRIBE, NOTIFY, INFO, PUBLISH, MESSAGE
Supported: replaces, timer
WWW-Authenticate: Digest algorithm=MD5, realm=“asterisk”, nonce=“5b1365ed”
Content-Length: 0

<------------>
[2018-10-15 18:47:10] VERBOSE[99396][C-0000002e] chan_sip.c: Scheduling destruction of SIP dialog ‘4df05419-0a05-49f9-879c-a64ffa3797ba’ in 32000 ms (Method: INVITE)

I think that the important record here is: No matching peer for ‘010’ from ‘10.10.64.50:49385’. But why? The trunk is configured to use this IP - IP-ADDRESS-OF-S4B-BOX in my previous post is 10.10.64.50. No other IP is used by the S4B host. The extensions are configured that everything matching pattern 0XX are extensions on S4B and are routed there (outgoing calls are working well), all other (ie. 6599) are FreePBX local.

So then that is actually host=10.10.64.50? Because that was hidden when you showed the config. Because if yes, then I think the issue is with this being type=friend since that wants to look at the user/ip and in this case it wants 010 to be the user but the trunk would be user Skype4B. So what this is saying when it is rejecting is “I can’t find a peer that matches both 010 and 10.10.64.50”

Try setting type=peer and making a call

Yes, in the trunk config host=10.10.64.50. I´ve changed type=peer but still the same. Still No matching peer for ‘010’ from ‘10.10.64.50:50390’.

How are you defining the peers? Normally, this message means that the extension you are trying to reach through the SIP handler you are using (for the port in question) isn’t defined (you’ve got it in the Chan-SIP extensions, but not the PJ-SIP extensions and are handling it from PJ-SIP).

How are you defining the peers?

You mean peers as a trunk or peers as extensions. The first one I´ve already posted here in my first post. For the second one, the idea is to have pjsip extensions on FreePBX and also every three digits extensions, that begin with 0 (so the pattern 0XX), are handled by the Skype4B. So the current testing configuration:

PJSIP extensions on FreePBX: 100, 150
Custom IVR menu on FreePBX: 6599
Extensions handled by Skype4B (and no config, other than the routes, about them in FreePBX): 010, 011

Calls between pjsip extensions are working normally, calls from pjsip extensions to IVR menu are working normally. Calls between Skype4B extensions are handled by Skype4B (so no touch from FreePBX) and are working normally. Calls from pjsip extensions to Skype4B extensions are working normally. The trouble here are “only” calls from Skype4B extensions to anything defined on FreePBX (PJSIP, IVR or built-in).

To make you full picture here, when I get this done, I want to connect another trunk from the VoIP provider to be able to make regular calls in and out either from pjsip extension and from Skype4B. So that means, that if Skype4B extensions will dial any regular telephone number, the call will be handled by Skype4B trunk in FreePBX and then routed to the VoIP provider trunk and there to the outside world. The nice to have thing here is to have phone number range from VoIP provider, so if anyone will dial XXX XXX 100, then this call will automatically ring on the 100 pjsip extension, and if anyone will dial XXX XXX 010, then this call will automatically ring on the 010 Skype4B extensions (that means it will be received by FreePBX on VoIP trunk, then strip only to 010 and then handled by the Skype4B trunk and hand over to the Skype4B). But all of this is step two and now I am stuck at the step one.

Is this what you asked me for?

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.