SIP Trunk : problem for inbound calls with multiple DIDs

Hi all,

I’m quite new with Asterisk and I’m experiencing troubles with my SIP Trunk.

Here’s my setup.

We have a CISCO CUCM 8.6 at work.

I’m setting up an asterisk VM with freepbx in order to make call from our cisco phones to my SIP provider (OVH).

So, I’ve setup a SIP trunk between the CUCM and Freepbx. Freepbx establishes the sip trunk to OVH.

The OVH sip trunk can handle 2 simultaneous calls and have a second number attached to it.

My trunk line username and primary line --> 003271**48
My second number DID attached to it --> 003271**42

Making calls through OVH works great with the two numbers.

But I can’t receive call on the second DID number (003271**42)

The error is :

chan_sip.c:25251 handle_request_invite: Call from ‘003271**48’ (91.121.129.23:5060) to extension ‘003271**42’ rejected because extension not found in context ‘custom-get-did-from-sip’

The custom-get-did-from-sip contains this workaround :

[custom-get-did-from-sip]
exten => s,1,Goto(from-trunk,${CUT(CUT(SIP_HEADER(To),@,1),:,2)},1)

But this only work for inbound call on the primary line.

If I remove this line and use the context “from-trunk” in the trunk peer config, call on primary line failed but works on secondary line.

I have setup two inbound routes for each DID and routed them to the CUCM.

Thank you for your help, I can provide sip trace if needed.