Unable to properly route inbound calls received on a SIP trunk

Hello

I am currently trialling a new service that enables you to connect SIM cards to a PBX.

However, I have serious issues in creating outbound rules to properly route calls originating from the SIMs to other destinations.

About my setup

I have two trunks. One is an IAX trunk to my ISP that provides the DDI numbers. This is working fine and I can route inbound/outbound calls from my extensions with no problem.

The second is a SIP trunk to the ISP that provides connectivity to the SIM cards. My ISP is using IP based authentication my trunk conf looks like

disallow=all
allow=alaw
type=peer
trustrpid=yes
canreinvite=no
insecure=port,invite
host=100.123.123.182
port=5060
qualify=1000
dtmfmode=rfc2833
context=from-internal

when a call to an outbound number originates from the SIM card, the provider sends me the following INVITE

INVITE sip:[email protected]:5060;transport=udp SIP/2.0’
Max-Forwards: 70’
Record-Route: sip:100.123.123.182;r2=on;lr=on;ftag=67DDB89F-52CFC4ED00012F56-A01AC700;ngcplb=yes
Record-Route: sip:10.123.123.182;r2=on;lr=on;ftag=67DDB89F-52CFC4ED00012F56-A01AC700;ngcplb=yes
Via: SIP/2.0/UDP 100.123.123.182;branch=z9hG4bK07b.1f3e686d165046cc6c4999ff65ce18cb.0’
Via: SIP/2.0/UDP 10.123.123.182:5080;branch=z9hG4bK5U33WaZP;rport=5080’
From: sip:[email protected];tag=67DDB89F-52CFC4ED00012F56-A01AC700’
To: sip:[email protected]
CSeq: 10 INVITE’
Call-ID: 646e336e-74b9-444f-89df-7d407ee5a06c1_b2b-1’
Allow: INVITE, ACK, CANCEL, BYE, INFO, OPTIONS’
Supported: timer’
Content-Type: application/sdp’
Content-Length: 226’
Contact: sip:[email protected]:5060;ngcpct=‘sip:10.123.123.182:5080’

So I need to somehow match the inbound id (ie. [email protected]) with an outbound route.

Any help or pointers would be much appreciated.

Thank you

Forgot to mention that calls originating from the SIM to local extensions on my FreepBX is also working fine.

My issue is trying to make the outbound calls to flow to external destinations.

sample sip debug output

— (15 headers 11 lines) —
Sending to 100.123.123.182:5060 (NAT)
Using INVITE request as basis request - f2326224-f311-494a-b09f-8b3d4c04b6392_b2b-1
Found peer for ‘b0014’ from 100.123.123.182:5060
== Using SIP RTP TOS bits 184
== Using SIP RTP CoS mark 5
Found RTP audio format 8
Found RTP audio format 101
Found audio description format PCMA for ID 8
Found audio description format telephone-event for ID 101
Capabilities: us - 0x8 (alaw), peer - audio=0x8 (alaw)/video=0x0 (nothing)/text=0x0 (nothing), combined - 0x8 (alaw)
Non-codec capabilities (dtmf): us - 0x1 (telephone-event|), peer - 0x1 (telephone-event|), combined - 0x1 (telephone-event|)
Peer audio RTP is at port 100.123.123.182:37352
Looking for 442071234567 in from-internal (domain 109.123.123.239)
list_route: hop: sip:100.123.123.182;r2=on;lr=on;ftag=71E9846D-52D006C200042610-87591700;ngcplb=yes
list_route: hop: sip:10.123.123.182;r2=on;lr=on;ftag=71E9846D-52D006C200042610-87591700;ngcplb=yes

<— Transmitting (NAT) to 100.123.123.182:5060 —>
SIP/2.0 100 Trying
Via: SIP/2.0/UDP 100.123.123.182;branch=z9hG4bK14ec.47b4536a815419bf3d66588ccf8ef62d.0;received=100.123.123.182;rport=5060
Via: SIP/2.0/UDP 10.123.123.182:5080;branch=z9hG4bKESW31aLY;rport=5080
Record-Route: sip:100.123.123.182;r2=on;lr=on;ftag=71E9846D-52D006C200042610-87591700;ngcplb=yes
Record-Route: sip:10.123.123.182;r2=on;lr=on;ftag=71E9846D-52D006C200042610-87591700;ngcplb=yes
From: sip:[email protected];tag=71E9846D-52D006C200042610-87591700
To: sip:[email protected]
Call-ID: f2326224-f311-494a-b09f-8b3d4c04b6392_b2b-1
CSeq: 10 INVITE
Server: FPBX-2.11.0rc1(1.8.20.1)
Allow: INVITE, ACK, CANCEL, OPTIONS, BYE, REFER, SUBSCRIBE, NOTIFY, INFO, PUBLISH
Supported: replaces, timer
Contact: sip:[email protected]:5060
Content-Length: 0

<------------>
– Executing [[email protected]:1] Macro(“SIP/simprovider_trnk-00000045”, “user-callerid,LIMIT,EXTERNAL,”) in new stack
– Executing [[email protected]:1] Set(“SIP/simprovider_trnk-00000045”, “TOUCH_MONITOR=1389364930.96”) in new stack
– Executing [[email protected]:2] Set(“SIP/simprovider_trnk-00000045”, “AMPUSER=b0014”) in new stack
– Executing [[email protected]:3] GotoIf(“SIP/simprovider_trnk-00000045”, “0?report”) in new stack
– Executing [[email protected]:4] ExecIf(“SIP/simprovider_trnk-00000045”, “1?Set(REALCALLERIDNUM=b0014)”) in new stack
– Executing [[email protected]:5] Set(“SIP/simprovider_trnk-00000045”, “AMPUSER=”) in new stack
– Executing [[email protected]:6] Set(“SIP/simprovider_trnk-00000045”, “AMPUSERCIDNAME=”) in new stack
– Executing [[email protected]:7] GotoIf(“SIP/simprovider_trnk-00000045”, “1?report”) in new stack
– Goto (macro-user-callerid,s,15)
– Executing [[email protected]:15] GotoIf(“SIP/simprovider_trnk-00000045”, “1?continue”) in new stack
– Goto (macro-user-callerid,s,28)
– Executing [[email protected]:28] Set(“SIP/simprovider_trnk-00000045”, “CALLERID(number)=b0014”) in new stack
– Executing [[email protected]:29] Set(“SIP/simprovider_trnk-00000045”, “CALLERID(name)=”) in new stack
– Executing [[email protected]:30] Set(“SIP/simprovider_trnk-00000045”, “CDR(cnum)=b0014”) in new stack
– Executing [[email protected]:31] Set(“SIP/simprovider_trnk-00000045”, “CDR(cnam)=”) in new stack
– Executing [[email protected]:32] Set(“SIP/simprovider_trnk-00000045”, “CHANNEL(language)=en”) in new stack
– Executing [[email protected]:2] NoCDR(“SIP/simprovider_trnk-00000045”, “”) in new stack
– Executing [[email protected]:3] Progress(“SIP/simprovider_trnk-00000045”, “”) in new stack
Audio is at 14542
Adding codec 0x8 (alaw) to SDP
Adding non-codec 0x1 (telephone-event) to SDP

your trunk is in the wrong context…needs to be from-trunk not from-internal

Does this provider have US SIM?