PRI pass through legacy EPABX

Hi Friends,

Distro: FreePBX 13 fresh ISO install, no customizations, Asterisk 13

I have configured a Sangoma Two port PRI Card and everything works fine.

Earlier, I have manually created extensions by editing core asterisk files two create trunks, route, even the Dahdi config etc.

I’m in a bit of a mess as I plan to achieve the same thing solely through the GUI.

Basically, I have PSTN(from provider) terminating on SPAN1 and a Legacy EPABX terminating on SPAN2.
This setup will allow the FreePBX to serve as a monitor with CDR, recording etc.

I have already managed to setup the PRI Card etc from the GUI (it was tough initially, lots of parameters to set) and I’v created to contexts and put each SPAN in a separate group.
Also, I’v created two corresponding TRUNKS but the problem I’m facing is how to manage the Routes. Also, there is an option of ascending or round-robin but if I prefer to map 1:1 , do I need to create each DID manually and map it?

If I’m creating a general Route or TRUNK, I need to put a DID, but I want the original numbers to go through without being changed.

Kindly give me a direction, much appreciated.
Never thought GUI would be so tough.


    `[default]   ; context for the asterisk sip extensions to dialout and reach the epabx extensions

; dialplan to dial the outside numbers (mobile or landline , prefix is 7 and number 10 digits)

exten => _7XXXXXX.,1,Dial(${TRUNKPRI}/${EXTEN:1},tTo)
exten => _7XXXXXX.,2,Hangup()

; dialplan to dial the epabx extensions - in my case epabx extensions is 3 digits (300 to 399)
exten => _3XX,1,Dial(${TRUNKPBX}/${EXTEN},TtoR)
exten => _3XX,2,Hangup()

[from-pstn] ; context to receive inbound calls from the provider ie:port1 of T1 card
; dialplan to route the inbound calls from provider
; I get sent last 3 digits from my DID like: the DID is 3003300 so I’m sent 300 , 301 …

exten => _XXX,1,Dial(SIP/${EXTEN}) ; rings asterisk sip extension which matches the 3 Digits.
exten => _XXX,2,Hangup()

exten => _XXX,1,Dial(${TRUNKPBX}/${EXTEN},TtoR)
exten => _XXX,2,Hangup()`

And a similar context for [from epbx]

There are a couple of things wrong with this sentence:

  1. You can’t put a DID on a trunk. All you can put on a trunk is a CID (yours) and if you leave it blank, it will use whatever CID your outbound route is configured for.
  2. DID is for incoming calls only. You set the Caller ID for the number on your outgoing calls, and you can do a LOT of things to make that happen.

You have inbound and outbound routes. These are the rulesets for your outbound (and inbound) calling. Each inbound DID will have a destination, including the “default” incoming route (no DID, no CID).

On inbound routes, the CID is the CID of the calling party, so you can manage different processing tracks based on who calls. For example, create an inbound route with a CID of your cell phone, and send that route to some random function.

You’re working too hard. Most of your problems are simply not understanding the subtly of how the parts work together.

Trunks are separate from inbound and outbound routes. Your extensions are separate from the inbound and outbound routes. The are all essentially independent, so getting wrapped around the axle about how to recreate the old way to do this isn’t helping.

Just think about what you want to happen.

  • What do you want the trunks to do (talk to an ITSP, another PBX, a PRI, etc.)? Set the trunk up to do that.
  • What do you want to happen with your inbound routes? Where do you want the different calls to go? Do you want to do it based in inbound DID (the number on your system) or the incoming CID (the number from their phone)?
  • What about your outbound routes? Do you want to manage the Caller ID at the extension, the route, or the trunk? You can control who can access specific outbound routes using the “CID” field (the 4th one) on the configuration lines.
  • Do you really want to keep the old-style “Dial 9 for an outside line” or do you want to make it so that the PBX knows where to send a call based on your configuration?

Your configuration can be SO MUCH MORE thanks to the application of GUI and all of the additional settings that each of the options provides. You don’t have to worry about which trunk is going to be used by a specific phone, because you can set up all sorts of classes of service based on outbound routing.

Relax and simplify. Like I said, I think you’re just trying to do it the hard way. Zen up a little bit and look at what the system does, and shoot for what you want done, not how you want to do it.

1 Like

Thank you for your prompt reply.

Currently, the “context” is defined in individual Dahdi>Span 0 (what we used to assign as g0, g1…)
Say, I have context-pstn and context-epbx

If I create Two trunks, and map each to one SPAN,
Currently, I created two trunks, first with group 0 and second with group 1.
After apply config, second one changes back to Group 0.

How can I forward calls b/w them ?
So outbound for g0 will be inbound for g1 and vice-versa?

EDIT: After apply config, second one changes back to Group 0.
This happens when you edit a TRUNK, I think its a bug, basically when you edit a Dahdi the g0 will not show in dropdown if set before, and any of the other three will show so next time you save, that gets saved.

So after spending hours figuring that was happening, I now have the exten_additional.conf with OUT_1 variable as DAHDI/g0 and OUT_2=DAHDI/g1. Now my two Trunks are ready.
I’m trying to document as much as I can if someone else were to land here bcos I’ve not found anything close to this post on the web.

Dear Dave,

The legacy epbx makes outbound calls by pressing 0, then obtaining dial tone and dialing a 10 digit number.

I have tried setting the same in Dial plan, but I keep getting the following asterisk output:

Accepting call from ‘3355112212’ to ‘s’ on channel 0/31, span 3
– Executing [[email protected]:1] NoOp(“DAHDI/i3/3355112212-49”, “No DID or CID Match”) in new stack
– Executing [[email protected]:2] Answer(“DAHDI/i3/3355112212-49”, “”) in new stack

Is there a workaround for the press 0?
Iv even tried X.
The user while typing the first few digits of the outbound number gets “no route voice message”.


OK - this is what I was talking about.

In FreePBX, a few of the things you want to do are done differently.

For example, in your old system, you would dial “0”, which tells your old PBX to connect your handset to an outbound POTS line. When this line goes active, you get a dial-tone in the handset.

In FreePBX, this isn’t really how we handle calls. The difference is that we intelligently program the outbound routes to handle all of our calls, regardless of what the destination is. So, to emulate your old system, you’d have to just through a lot of programming hoops to basically “disable” the smart processing.

In your new system, people will dial a 10-digit number (no need to connect to a POTS line first). The outbound routes will then process the number, looking for conditional matches to connect the call seamlessly to an outbound trunk. There’s no reason to dial “0” or “9” anymore - the intelligence of the outbound route module now takes all of the parameters for your call into account and chooses the best-case outbound trunk.

Now, it is possible for you to dial “0” then the 10-digit number, but the system (combined with the dial plan in your phones) are just going to (largely) ignore your “0”. I say largely because the outbound route will actually remove the “0” from the dialed number and then process the call from there.

Now, suppose you want to have a single extension that always calls out on a specific POTS line. To do that, you set up the outbound POTS trunk as you would (CID, etc.) and then set up the outbound routes so that the only route that uses that specific trunk is one based on the Caller ID (the 4th field in the outbound route table) of the single extension.

The point here is that the trunk is independent of the outbound route. You can have zero or more outbound routes pointing to a trunk. The trunk doesn’t care. The processing for which route gets chosen isn’t in the trunk (even though there are some rudimentary editing and selection capabilities in the trunk). The outbound route sets up the call and (in a perfect world) preformats the outbound number so that whatever trunks gets the number can process the number and connect you to the outside world.

In addition to the “aloofness” of the trunk, you can have as many trunks associated with an outbound route as you want. This, in fact, is usually a pretty good idea. If your outbound route “hits” on the parameters for the call, you want to drop into at least one place that can make the call, and fall into a fall-back trunk (a SIP trunk or another DAHDI trunk, for example) so that your callers don’t end up getting “All Circuits Are Busy” instead of a dial tone.

Thanks for your detailed post.
I opened another thread, bit specific to the nature of problem.

What you is correct, although, the legacy EPABX will stay in place. So all the local extensions etc that are analog (intra-Co) etc will be handled through that as we don’t want to shift to rewiring and new phones immediately.

The legacy PBX is programmed such that 0+<10digit mobile> will send call out and earlier directly to PRI Line.
Now, that part is intercepted by FreePBX.

I still feel that the call is passed to s and “No match of DID or CID” indicates some problem like two stage dialing etc.
How can we get asterisk to wait for entire number to be punched in?

This is a more relevant topic to that issue and hope it helps someone else in the future so well documenting each problem is better. You many reply there