IAX2 Trunk

Hello All,

I have a question.

I have 2 servers connected via iax2 trunks. what I want to know is that, I have Dahdi trunk (old PSTN card) on server 1 and the other server does not have that. Is it possible that the users on server 2 (without Dahdi trunk) can dial out from the Dahdi trunk on server 1 ? while server 2 is already connected to server 1 via a trunk.

Please give me some guideline, I will implement it myself. Many thanks in advance.

That’s possible.
Just have an outbound route on server 2 that sends the digits for local and long distance calling out to server 1.

Thanks for the reply.

I am able to make iax2 trunk, and I am able to make calls between servers. But i am having issues with the Dial Plan.
What I have done is, I put a period . in the match pattern, in dial plan in both servers and the calls can now be connected to both servers. But the issue is, now the outbound calls from server 1 to POTS are also routed to the server 2. And I cannot also make calls from the server 2 to POTS.
Can you please guide me in the dial plan ?

Many thanks in advance

Don’t use the period, because you want to be more specific.
Have two outbound routes on server 1.
One for outbound through the pots lines (local and long distance numbers), one for calls to extensions on server 2.
On server 2 send 7 and 10 digit calls through the IAX trunk to server 1.
Check the help section under there on how to match certain patterns.

Many thanks for this reply, Im going to test this tonight and share the results :slight_smile:
lets hope that I am successful.


Partial success.

I am now able to make calls from server 1 to server 2, via iax2 trunk and from Server 1 to POTS.
But i am not able to make calls from server 2 to POTS.
I tried a lot to match the patterns but the call always comes to the Server 1.

Ill share my settings as I think that the problem lies in inbound settings:

I have made a simple IVR, which caters the main menu of the company. Created an inbound route which caters all the incoming calls. Do you think that I have to create another inbound route which matches a match pattern and then forwards the calls from server 2 to the POTS lines?
I am unable to match those patterns.
What I want is something like: 9XXXXXXXXXXX
The pattern will be dialed from the the server 2 extension and when it matches the inbound route of server 1, it forwards the call to the POTs trunk.
Am I right?

Moreover, I have found another issue, please someone help me on that.

When I dial from outside to the POTs and the call is received by the IVR and I select the operator or the ring group, if I disconnect the call, the ring group or extension keeps ringing infinitely. Why is that so? :frowning:

im using freePBX 2.11.0
and asterisk asterisk 11.25.0 0.el7.centos

Best Regards

You are mixing three different things into your post.
Your original question was about outbound calls first.
What do your outbound routes on server 2 look like?
Share your IAX2 settings.

Thank you for the reply.

Please check below my iax2 settings

Server 1

CID Options: Allow any CID

Out going settings
Trunk Name: pbx1
PEER Details:


Incoming Settings

USER Context: pbx2

USER Details:



Server 2

CID Options: Allow any CID

Outgoing Settings

Trunk Name: pbx2
PEER Dstails:

Incoming Settings

USER Context: pbx1
USER Details:



I highly appreciate your help. Many thanks… please do reply.

Change the context on server 1 to from-internal for the Iax trunk rather than from-trunk


You can leave the incoming settings blank, they are not needed. And yes, context must be from-internal.
Here is a good guide on connecting to servers over an IAX trunk:
If they are on the same network, leave out the encryption details and ignore the section on port forwarding.

Change the context at both sides and also for the hangup issue just enable busydetect in your chan_dahdi.conf file.

Many Thanks for the replies, I did all the required settings. It was difficult but i had to match the pattern and I was able to make the calls from server2 to server1’s POTs lines.
And the busy detect settings also helped.

Sorry for bothering, unfortunately i am not able to do a setting, I want that, when someone calls in to our pots line, gets an ivr, dials X to an extension (which is at server 2) I want that to be transferred to server 2 seamlessly without any extra typing or audio cues.

I have made a Custom Extension 2900 on server1, did a setting dial = IAX2/mytrunk/2900 but i am not able to get the call transferred. Actually im not able to understand this logic.

Can anyone please help me ?

May thanks in advance.

Ok, what i did was, in the custom extension, in dial section, i wrote
"IAX2/trunkname/500" where 500 is the extension on server 2.
After saving this, this setting disappeared and Im no longer able to see it.

When I call from pots line, and select 5 on the ivr, which is directed to extension 2900 on server 1, i get a busy tone few times and then the call disconnects.

what am i doing wrong :frowning:

I found a solution and it suits me :slight_smile:

I made a ring group on server 2 and put all the extensions where i want the call to land on server 2.
On server 1, I made another ring group and put the ring group number of server 2 followed by a # sign.

So when i press 5 on the IVR, it routes my call to the ring group on server 1 and routes it forward via iax2 trunk to server to on the ring group of my choice …