For Deutsche Telekom you have to use different register strings for each phone number. So I have setup 10 trunks, each with a different register string. But now I want to set a custom context for one number, so i thought I could setup a custom context for this trunk. In the asterisk log I see that all incoming calls get the context of the first alphabet number. It it possible to influence which trunk is “seen” ?
The called number is 9876543210 and therefor the context should be from-trunk-sip-OUT_9876543210
-- Executing [[email protected]_0123456789:1] Set("SIP/OUT_0123456789-00000002", "GROUP()=OUT_10") in new stack
-- Executing [[email protected]_0123456789:2] Goto("SIP/OUT_0123456789-00000002", "from-trunk,9876543210,1") in new stack
-- Goto (from-trunk,9876543210,1)
Probably not possible with chan_sip. If you set up PJSIP trunks, you might get it working using the technique described here:
However, there is no need to change your trunks if all you need is to send to a specific DID to a custom context, you can do that in the GUI by creating a Custom Destination, and choosing that destination from the inbound route for the DID.
This is a long-time “issue” with Asterisk. The choice of inbound trunk is always done alphabetically.
Out of curiosity, is something not working the way you want it to? The normal model for Asterisk is to differentiate on the Inbound Route, not the trunk. Is there something that handling this as the Inbound Route (and not the trunk) is problematic?
Trunks are not determined by alphabetical order, just a top down order. You can order your peer configs anyway you want in sip.conf. As well “Inbound Routes” is not an Asterisk thing, it’s a FreePBX/common name thing.
How a trunk is matches is based on how that trunk is setup. If you have two trunks setup with type=PEER and they have the same host= setting, the FIRST one in the sip.conf that matches those TWO settings, wins. Now a Friend/User type will care about the username portion and want to match on that over IP.
Trunks do two things for Asterisk. 1) They determine if the source of the call/request is actually allowed to send to Asterisk. This is the PEER vs FRIEND/USER part. 2) They tell matches on that Trunk to send incoming calls to a specific context in the dialplan. This would be your “Inbound Routes” section.
Please do not confuse the FreePBX implementation of Asterisk for the “normal model” of Asterisk. Because the “normal model” of Asterisk is configure it how you want. Which would mean person A and B’s “model” will be different.