Calls placed in [from-trunk] not DID routing

Hi, all.
Bit of an asterisk n00b, so bear with me.
This may be a ‘by design’ issue.

Vanilla trixbox 2.3.0.2 install, with freePBX 2.3.0
No manual customisations, and only minimal GUI config.
3x SIP extensions 500,501,502 ( all can call each other ).
1x Motorolla Wildcard X100p cheapie FXO card, which auto-configured OK giving a ZAP trunk and a 9_outside route. Added anyDID/anyCID inbound route to extension 500, PSTN now correctly rings ext 500. All working OK so far.

Now, add IAX2trunk from remote site ( 2xx extensions ).
This all works ONLY if I place the calls from the trunk into [from-internal].
If I place them into [from-trunk], they all get caught by the default inbound route and ring extn500, regardless of the extn dialled.
This appears to be by-design.

Looking at the files, I can see what’s hapening ( I think. )

The incoming call from the trunk call takes the following path through the dial-plan if I drop it into the [from-internal] context:
[from-internal]
includes [from-internal-xfer]
includes [from-internal-additional]
includes [ext-local]
matches extension, and call is completed correctly.

However, if I drop it into [from-trunk], it does this:
[from-trunk]
includes [from-pstn]
includes several things:
[ext-did] --> contains inbound route and call is matched here.
[ext-did-catchall]
[from-did-direct]
includes [ext-local]

The call is being matched in [ext-did],and not dropping through to [from-did-direct], where it would work as it includes [ext-local]. Is the call got to [from-did-direct], it would work, I think.

Here’s the freePBX generated code in [ext-did] that’s trapping all trunk calls to all extensions:
[ext-did]
include => ext-did-custom
exten => fax,1,Goto(ext-fax,in_fax,1)
exten => s,1,Set(__FROM_DID=s)
exten => s,n,GotoIf($[ “${CALLERID(name)}” != “” ] ?cidok)
exten => s,n,Set(CALLERID(name)=${CALLERID(num)})
exten => s,n(cidok),Noop(CallerID is ${CALLERID(all)})
exten => s,n,Goto(from-did-direct,500,1)

I thought the ‘s’ extn was to match things line PSTN calls that did not specify an extension to call. Which it is doing, correctly. Why is also catching calls to nominated extensions and sending them to extn 500? Is this code meant to match everything, including all calls to specific extensions?

What is the best way to allow trunk calls to DID to my extensions?

I can think of a few possibilities.

  1. Create inbound routes for each extension. Ugly. Then I need to maintain my extensions in 2 places: Extensions, and Inbound Routes. Also, may not work, as I notice that the GUI re-orders the inbound routes so that anyCID/anyDID route always goes to the top of the file, and will probably be matched first.

  2. I could change the order of the #includes in [from-pstn] to put [from-did-direct] before [ext-did], so the call will be matched to my extensions before hitting this catch-all. This will probably break something else in freePBX.

  3. There’s a DID field in the Extensions page, which I’m not using. If I place the extension’s own number in here, might it help? I’ve not looked to see what this actually does in the dialplan.

I’ll do some experimenting later, but a pointer to the cleanest method would be appreciated.
But I’m a n00b, and there is probably a blindingly obvious thing I’m doing wrong…


Ron

I now understand the DID logic, and have this fixed up.
( It will also affect direct inbound SIP calls coming routed from-sip-external -> from-trunk. )

It all hinges on the sequence of events in [from-pstn].
Without an any/any route, the call falls through [ext-did], and hits [from-did-direct], where the call goes to the correct exten.
The existence of an any/any route creates the [ext-did-catchall] , so it never recahes [from-did-direct], but is directed to the specified default exten.

All that’s required to fix it up is to add a DID value in the extension GUI.
That adds a per-extension entry in [ext-did] which matches the extention dialled, and does a goto to [from-did-direct], thus jumping round the catchall.

Thanks.
Ron

Yes, it is by design to not allow calls directly to any extension (or feature code, etc).

If you are setting up a “trusted” trunk between two systems, the best way is probably to make a new context in extensions_custom.conf, and include whatever you want to be accessible (ext-local, probably, at the least). You could also include outbound routes, to allow PSTN calls from that system to be routed out your local PSTN lines.

This setup will probably be officially supported (where you can do it in the GUI) once we implement CustomContexts. There are other ideas on how to properly implement a branch office setup (with a master system, and then branch systems) so we’re not really planning on putting a ton of effort into trunking directly, in favour of doing it properly with true branch systems (eg, also supporting voicemail, directory, transparent trunk sharing, failure handling (eg, internet connection going down, so rerouting trunks over PSTN or at least allowing voicemail)…). CustomContexts is on the roadmap for the next major release (2.4 or 3.0), but branch systems will probably take a while longer.


Greg MacLellan - Core FreePBX Developer
http//freepbx.org - irc.freenode.net #freepbx

Ron,
the catch is that many people use that for a pstn did. If you want your short version did to work you run out of space. Maybe the right solution is just a check box that makes the extension number exposed to the outside, and remove [from-did-direct]. Then it would just add it to the did context.

Philippe Lindheimer - FreePBX Project Lead
http//freepbx.org - IRC #freepbx