ISDN PRI Outbound Trunk and Least Cost Routing

Guys, We have FreePBX 2.7 running on PIAF 1.4

We have a TE205 - dual channel ISDN PRI card - we are in Australia.

We are in the process of migrating from an Asterisk 1.4 solution across to a new system based on FreePBX 2.7.

We make heavy use of Least Cost Routing on outbound calls.

This is transparent to our users. i.e. they just dial the area code/International code they want and based on the lead in digits we will decide which provider to send it to - here is the difficult part though - all of our calls are sent out the same ZAP interface (g0) (which has 30 available channels), simply by changing the leading digits (say 1456 to use Optus or 1472 to use Worldcom) we are then routed out through the appropriate carriers network at the local telco exchange (this is part of the telecommunications act in Australia that all telcos must allow this)

I can not see anyway to make this work with Outbound routes and Trunks in FreePbx.
We have a single outbound trunk only.



Create two outbound routes both pointing to g0,

or I don’t know if this is plausible but split your T1 in half and make two groups: g0 and g1, with separate outbound routes to each.

I can match the various Country/Area codes fine in an outbound route, but if these are pointing to the same Zap Channel/Group then where do i prepend the digits for the LCR ?

I don’t believe i can do it in the Trunk as all calls will then get the actual digits rather than just the ones for the actual country in question.

Splitting the Zap Group into individual channels would allow me to have upto 30 different destinations but i suspect that i would only be able to have 1 actual call outbound per channel at that point ?



  1. For each LCR route that was needed create a Custom Trunk - give this a meaningful name that will identify this easily for you

  2. In the Dial Rules place the code required by your LCR provider followed by the +. (e.g. 1466+.) - This will add the number 1466 in front of whatever other number is presented to the trunk

  3. In the Custom DialString enter Local/[email protected]
    It is important to have the XXXX as something meaningful that will immediately identify the Trunk as this will be referenced in your outbound routes.

  4. Create a Custom Context by the following

  • Go to the Tools menu on the left
  • Choose the Config Edit option
  • Edit the file extensions_custom.conf

Add the following before the [From-Internal-Custom] context

exten => _X.,1,Dial(Zap/g0/${EXTEN},120,tr)
exten => _X.,2,Hangup

  1. Save this file once finished

  2. Go to the Setup tab on the left menu

  3. Go to Outbound Routes

  4. Create a new outbound Route - place this as a higher priority than your default routes (i.e. further to the top of the list)

  5. In the outbound route Dial pattern place the identifier the country/area code/mobiles etc that you are interested in
    e.g. 000118613. would match any call from Australia to China Mobile phones

  6. In the Trunk Sequence - choose the Custom Trunk you created earlier

  7. Save your config and apply it

using the method we have employed we are not getting correct ISDN PRI call codes for line status returned. Therefore whenever we dial a number that is incorrect, turned off, engaged or the like we receive a message all circuits are unavailable.

It appears that the ISDN Callstatus is not being set correctly.

We are looking for a workaround