From Trunk to Route


For example i have:
Trunks: trunk1, trunk2, trunk3
Inbound routes: route1, route2, route3

now I need to send all calls from trunk2 through route2.
how to do it?

Your question seems unusual. In a typical PBX, calls are routed based on the number called. For example, the main company number routes to an IVR, the boss’ personal number routes to his extension, the ‘customer service’ number routes to a queue. This is done by specifying the called number in the DID Number field of the Inbound Route. In some cases, it is necessary for the trunk configuration to specify a special context (occasionally a custom context) to supply the dialed number in proper format to the routing logic.

If you need a specific relation between trunks and routes, please explain the requirements. Are you using pjsip or chan_sip trunks? Are the trunks with the same provider or different providers? Do you have multiple numbers on a given trunk?

Trunk2 is chan_sip trunk from specific provider. I don’t know DID number.
and i need a simple task: send all calls from trunk2 via route2.

Trunks allow you to accept and send calls to specific host(s). As it was pointed out the “context” setting will send incoming calls to that context to be processed. So all calls that come in over trunk2 two will be processed and whatever the DID they were sent to will be matched in your inbound routes.

So you need to know the DIDs that you have with the provider and setup inbound routes for them.

If Trunk2 is a chan_sip trunk using registration, then by using the context from-trunk, whatever you have after the / in your register string can be used as the DID Number in your Inbound Route. It doesn’t have to be an actual phone number. If there is no / in your register string (it ends with a domain name or IP address), put e.g. /1234567 at the end of the string. You can then set DID Number in your Inbound Route to 1234567 and calls to Trunk2 will go to that route.

If you are not using registration or are using pjsip, please post details.

That’s not how trunks and routes work.

Trunks are the gateway into the PBX. They accept traffic from a specific server (or list of servers with PJ-SIP) and convert the incoming traffic into a “call”. This call should have identifying characteristics like an assigned Direct In Dial number.

Every call that comes into the server, regardless of the trunk it came in from, is sent to all of the inbound routes. These routes are matched against the identifying characteristics and the inbound route is chosen. This flexibility is deliberate and I don’t know of a way to “short circuit” that without a lot of custom context code.

So, having said that, the short answer to your question is “No, you can’t do that.”

Having said “No”, however, there are ways to “fake” the system into doing this. For example, you could set up a custom context that sets the DID for your trunk to a specific DID. Use that DID as the DID in the Inbound Route and you map the trunk to route. Note, however, that this is just faking the system out - it isn’t sending the call from Trunk B to Route B - It is accepting the call on Trunk B and dummying up your data so that the call “appears” to be doing what you want to do. There are other ways to simulate this relationship, but they all involve messing with the system in a way that will be basically unsupportable.

If you can give us a Use Case for what you are trying to actually do, we might be able to suggest something simpler.

1 Like

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