Multiple Outbound Routes & Trunks

I have a system hat is working fine with only 1 trunk. I have just added a second trunk with a different CID. What is the easiest way to toggle dialing to one trunk or the other? Thank for your help!

Do you want to be able to pick which trunk you go out over? And if so, is there a programmatic way to pick i.e. one for Local and one for International? If you can discern, it’s easy to do in Dialplan - if it’s arbitrary, it’s probably easiest to just put a Prefix for one trunk and do that again in Dialplan.

You could use COS if you had a way to say extension 1 go here and extension 2 go here.

Greg, thanks for your reply. I want to be able to pick the outbound trunk since I call out for both businesses. Right now we first hit “9” to get an outside line. Can it be set up to simply hit another number to get the other trunk? Here is my local dial plan and my LD dial plan:
Prepend + Prefix | Matchpattern (nothing entered in the CID field or the Prepend filed)

Having to dial a 9 is very Old-School PBX’ish and is not really necessary anymore - FreePBX is WAY smart about dialplan decoding.

But yes, if you pick 8 for instance then Prefix: 8 and then NXXXXXX and Prefix 8 and 1NXXNXXXXXX and choose the other trunk.

We try to be nice to our users and minimize what they have to key and what they have to remember, so for instance we live in the 505 area code and use SIP trunks that always want 10 or 11 digits for local or long distance, so our patterns are as follows:

NXXXXXX - Local Call
505NXXXXXX - Local Call
1505NXXXXXX - Local Call - Pass the 1 if they dialed it - our carrier doesn’t care.
8XXNXXXXXX - Toll Free (A Pattern for each of the specific Toll-Free Prefixes)
18XXNXXXXXX - Toll Free (A Pattern for each of the specific Toll-Free Prefixes)
NXXNXXXXXX - Long Distance since if it wasn’t 505 it has to be LD
1NXXNXXXXXX - Again LD - pass the 1 if they dialed it.

This way no matter what they dial we either fix it up, or just pass it.

Thanks Greg. I have set up a local and LD outbound route with “8” in the prefix that points to the new trunks. However, the system does not accept the call. Is there some additional setup that I need to do in Freepbx to get this online?

FYI, when I dial “9” I get a dial tone. When I dial “8” I get three short beeps. If I keep entering numbers after the 8, it says the number cannot be completed as dialed. MY incoming calls are working fine for the new route so I think it is not an authentication issue.

What kind of phones are you using? SIP? FXS on DAHDI?

Dialing 9 and getting dialtone is suspicious - on a SIP phone you should get dialtone as soon as you pick up the handset - it is generated locally, not by the switch - FXS on DAHDI on the other hand is generated by the system.

I may have confused you. We are using Cisco 7960 phones. When you pick up the handset, you do immediately hear a dial tone. However, when you then dial “9”, the tome changes just slightly. This is how I know the system is ready for me to dial the actual phone number. When I dial “8” for a now call, I get the three beeps instead of the second dial tone. After the three beeps, it is silent. Thanks again for your help. I thinks there must be some additional setup that I need to do to get the “8” working for the additional outbound route.

That sounds to me like internal Dial-Plan on the phone is doing something before it hits the Asterisk for processing - in which case the PHONES Dial-Plan will need to be adjusted to allow passing the 8 as a prefix also - Sorry we did some Cicso installs (conversions with existing Cisco phones) a few years ago and they were such a pain (with SIP) that we swore them off.

Maybe someone else can jump in with Cisco knowledge and help?


Thanks again for you help and patience. I changed the access number from “8” to “7” and it works fine. There must be some asterisk conflict with using “8”. So I will just leave it at “7” and consider the matter resolved.

Sweet - Never argue with success!

From bash, to show all your dialplan restricted to numbers only:-

rasterisk -x ‘dialplan show’|grep -E “^ '[0-9]”|sort -n

rasterisk -x ‘dialplan show’|grep -E “^ '8”

would show any collisions on endpoints starting with 8

1 Like

@GSnover . a little warning here, I’m sure you didn’t mean it but your 8XXNXXXXX matches might be misinterpreted by some as they include several non toll-free area codes, some are in the Caribbean which has a history of in some cases, not being toll-free at all :wink: also three “Paid Toll-Free” 880,881 and 882 go figure that term out :smile: .

My bad - shouldn’t post incomplete code examples as later, someone going back might not get the whole thing.

My dialing examples are what are allowed outbound to be dialed from the phone, but here are my actual dial plans that we use:

  1. Drop - A route that matches all the Carribean Prefixes to a dummy SIP trunk that kills the calls into nowhere. I got them from Level(3) after a customer put one of my boxes on a Public IP and 11 hours and $4K of toll fraud later, we always put this route in first to kill outbound to any of these prefixes. In case anyone gets this post on a search, here they are:


Note also that we check for all three permutations of the above to not miss anything that might have been dialed so for instance we check for 876NXXXXXX, 1876NXXXXXX and +1866NXXXXXX - it would have just made the list too long.

  1. Emergency - 911 and 9911 stripping the first 9 so if someone panics and dials the extra 9 it is dropped
  2. Local - All my customers home bases are in the 505 so NXXXXXX and 505NXXXXXX and 1505NXXXXXX
  3. Toll Free - Matching all the 8XXNXXXXXX and 18XXNXXXXXX Toll Free prefixes - again the very first route would have already peeled off the bad exchanges.
  4. Long Distance - Here we match NXXNXXXXXX and 1NXXNXXXXXX since it didn’t match anything before.
  5. International - Turned off for 98% of my customers, but 011. with a PIN.

Thanks for the heads up - probably should have posted a better example.

Oh dear, won’t work for me as I have phone numbers in 805 and my spiritual adviser lives in the Yukon, just teasing, I have similar rules just separate the Canucks similarly because they are often better routed elsewise , just that you need all the 8[2-8]{2}NXXXXXX EXPLICITLY reformatted for Asterisk

Spiritual Advisor :wink: - Yeah, I could really use some advice most of the time.

hehe, she has been unavailable lately due to “unforseen circumstances”. You forgot 829 and 849.

Those were not on my list from Level(3) - Are they new?

No , I think that “St. Kitts & Nevis” and “Dominican Republic: Santo Domingo” have been around since the pirate days possibly since before the USA :wink:

Fixed in the above post - Dominican Republic - We should have a sticky post somewhere with an updated list for EVERYONE to use - and since Dialplan can import a CSV, maybe have them posted here somewhere in that format.


Should be available from NANPA I use

but to get the real skinny is they want you to pay hundreds of dollars for public domain records we pay them to administer. So google is a little cheaper

seems up to date.

And don’t confuse the St. Kittens with the Dominicans they are strictly different Orders and have different habits. I believe the Dominicans wear black and the St. Kittens of course wear calico.