9 To Select Outside Line

Assuming you have command line access on the machine, you can tail -f /var/log/asterisk/full and see what is happening. It’s lots and lots of information, sometimes way too much for me.

If you have no activity on the machine, make a call, and then grab the log and post it here someone might be able to help.

Without a lot of details on how your trunks are setup, your outbound routes are setup, etc, it’s tough to say.

You have two trunks? The reports -> asterisk info -> peers is showing they are both connected?

How many outbound routes do you have? Just the one? If you remove the outbound route, what happens when you dial a number from your internal extension?

The two trunks are connected to two extensions that we access through those extensions. We can get dial tones and dial out. Yes, the trunks show as connected. Following recommendations here, I now have only one outbound route with both trunks in it. I have not tried removing the one outbound route.

Ok. I’ve never had trunks attached to extensions, even when I used a FXO box. Just had the connection info setup in the trunk setup dialog boxes…

Have you reviewed the logs in /var/log/asterisk/full while a call is being made?

Are there other routes on the system?

Take it down to basics.

Define a trunk, name it "line1"
Define an outbound route that uses that trunk and make adjustments until you can place outbound calls without a 9 prefix.

Then define a new trunk, “line2” Change the assigned trunk in the (only) outbound route and make sure you can still place calls without changing the rest of the config.

Cool, now just add trunk line1 and line2 to the outbound route. That’s stage one.

Add a second outbound route, configure it to match on whatever you need to dial to reach the voicemail service, have that route use only the trunk that supports it. May be an idea to make that trunk the second on in the list for the main outbound route.

So, now you can dial any number and the system gives you whatever line is free, but if you dial for voicemail it’ll only use the voicemail line.

Then there’s inbound calls to deal with but that should be simple.

I’m already at stage one. I can get a dial tone and make outbound calls on both trunks. I just have to specifically select each trunk before doing so. I have buttons assigned on my phone to do this.

So I’m trying to get working what I am told is the more modern way of doing things: an outbound route containing both trunks. I should be able to dial at the PBX dial tone and the system will route the call to the next trunk not in use or play a busy signal (or whatever you configure).

But it’s weird. The system gives a ringing sound on the phone but nothing happens. Both trunks remain idle.

yeah that was kinda my point, you don’t have to specifically select a trunk; you program the system to do that for you by telling it /once/ in advance what it is you want it to do, otherwise what’s the point of a computerised pbx?

Instead of having a button that selects a trunk, then dialling the number for the voicemail, have a button that dials voicemail and it does the work for you.

Anyway, the stage one that I mentioned, you’re not there. If you have a trunk and an outbound route and can make calls, then adding the second /tested/ trunk to it won’t result in the symptoms you mention.

What is unclear to me (and maybe others that have participated in this thread) is how you have configured your ATAs, and what is the configuration of the buttons you mention on your phone that select the trunks? As we have already mentioned, there is really no concept of manually seizing a trunk in an Asterisk/FreePBX system, so I am very curious how you’ve configured your phone, FreePBX, and the ATAs to do this.

I was following this page in the wiki setting up my system:

Configuring An HT503

After setting up the trunk, you setup an extension (Step 1) that’s what I did. I have configured buttons to access that extension. It gives me a dial tone and I can dial out.

I guess I misspoke. I apologize. I am accessing the extension for the trunk and not the trunk directly.

billsimon: You’re mistaken. Asterisk and FreePBX can definitely manually seize a line when you’re using an FXO adapter like the Grandstream GWX-4104, and can present you with a dial-tone from that line. I do it all the time so that I can control my alarm system from my analog telephone line in my residence.

In order to accomplish this, you’ll need to master the following:

  1. OPTIONAL: You need to configure your telephone’s dial-plan to immediately send through any call that begins with a 9, or to do so after only a shorter delay. If you don’t do this, you’ll have to wait for the dial plan timeout after you dial 9 and before you hear the dial-tone from the line being pulled on the FXO device. Note that this also means that you generally don’t want ANY other feature codes or internal numbers to start with a 9.

  2. You need to configure the FXO device to handle 2-stage dialing. The GXW-410X devices have a setting that can accomplish this. The Obi 110 will automatically accommodate two-stage dialing whenever it receives a call with no number to be dialed.

  3. You need to configure a Trunk in FreePBX that connects to the FXO device and which pulls the line (or pulls from a group of lines) that you desire. Generally, if you want to pull a specific line on an FXO device, you do that by including port=xxxx line in your PEER details that matches the port assigned to the particular analog line on the FXO device.

  4. You need to configure an outbound route in FreePBX that will route calls that contain a “9” by itself to the trunk referenced in item #3.

If you really wanted to get fancy, you could even program the phone to hot dial the line selector (i.e., dial the 9 as soon as you pick up the phone). Of course, pretty soon, he’s going to start to wonder why all the other phones on his system don’t show that the line is “in use”…

Now I haven’t addressed the wisdom of proceeding in this fashion because there are times when you want to hear the dialtone from the analog POTS line directly. That’s why Grandstream and Obi both support 2-stage dialing.

But, generally speaking, IT IS better to just tell your PBX in which cases it should use a particular analog line and to let the FXO device do the dialing for you. If you want to do that, you just configure the device to 1-stage dialing, set-up a trunk to the device, and link the trunk to your outbound routes so that it only handles certain types of calls, i.e. calls that start with 9 and then are following by a full phone number, i.e.


Generally, the better approach is to have each phone have ONE registration with its own extension number, and then set-up an outbound route that automatically selects the appropriate line based upon the number you’re dialing (or the extension number you’re calling from). All of the line buttons on the phone will send and receive calls with that same extension number.

If you really want to be able to select which FXO line your calls go out on, use a feature code like this:

*81 - Line 1
*82 - Line 2
*83 - Line 3

Just create an outbound route with the appropriate prefix that routes only to the trunk that connects to that particular FXO.

However, if what you want is every phone to show the same “line” on the button that says “line 1” (which is sometimes called “Shared Lined Appearance”) you’re going to be sorely disappointed. On a PBX, every phone IS its location. The buttons that are labelled as “lines” don’t actually correspond to your phone lines. Rather, each phone has its own set of multiple lines, and they all have the same “number” (the extension number of the phone).

Thanks for the correction and information on why you might want to do this. For your alarm circuit, it seems particularly useful. For typical PSTN use, less so.

Oh, I agree. For the typical PSTN use, it would be silly to set it up that way.

It also seems that the OP was under the mistaken impression that the Line buttons on his phone are somehow correlated with the PSTN lines on his FXO device, even though they aren’t. I find this is a common misconception since that’s how small business legacy phone systems used to work…

My Grandstream GXP2130s have only 3 line buttons. But I realize now that my buttons are extensions and can be assigned to any of the flexible buttons. Still useful to leave them where they are.

The phone has settings for “line” and “shared line”. A bit unclear on the difference.

After figuring out some configuration problems on my system, I still have buttons configured to get a direct dial tone from my PSTN lines. Now they are connected directly to the trunks whereas previously I (incorrectly) had a couple of extensions configured. Those are gone and the proper outbound route dialing system is now working.

So I don’t know if we just have a language issue here. I can get a direct dial tone as opposed to a PBX dial tone. The PBX dialing is also available and working.

You could try.
Setup an outbound route with 50 as a prefix

then set the trunk to the HT.

Try dialing 50 and see if it drops you onto the LIVE line.

works fine with my internal dahdi card that is simular but the HT device may not play the game wanting to perhaps see a number before opening the line. if so just try a p(pause) or w(wait) but you cannot put those in outbound routes.

or you could do the same with 9 !
leave all the other manipulation stuff blank unless you need it just the prefix set as 9.


I guess I wasn’t clear. I no longer need to do the whole 9 thing. Outbound route dialing through via the PBX dialtone is now working. I have been chastised over on the Asterisk forum that dialing 9 is “old fashioned” thinking.

I think I had my trunks misconfigured but they’re working now.

Don’t give it a moments thought, I still use petrol in my car.

That is the wonderment of Asterisk, What works for you is the way to do it.

But if you are deploying into a place that has experience of dialing the 9 before the number then make sure you put in a catch for that in an outbound route.
that way you do not care if they dial “90207123456” or “0207123456”


Precisely! This is the crux of the entire discussion.

Set up the system so that, no matter what the human does, the automation does the right thing and it works for you.

This is also what I do, but instead of looking for the 9 I check for 1 (long distance calling). None of my suppliers (We are Pure VOIP) want it, and it makes dialing faster, so for those who can’t kick the dial 1 (or in your case 9) habit, things still work.