Extension to extension calling between 2 FreePBX systems

Here I’m going to show how to setup extension to extension calling between 2 FreePBX systems using an IAX2 trunk.

There are 2 steps to this. First we need to create an IAX2 trunk on each system. Each trunk will configure the inbound and outbound user/connection. Then we will set up an outbound route on each system to tell FreePBX what calls to pass over the trunk. We will need extensions in different number ranges at each site for this to work.

Here are the details of the systems –

PBX1
IP Address : 1.1.1.1
Extension Range : 3000 – 3999

PBX2
IP Address : 2.2.2.2
Extension Range : 4000 – 4999

SETTING UP THE TRUNKS

First we create an IAX2 trunk on PBX1 with the following details –

Trunk setup PBX1

We are calling the the trunk pbxlink and creating a local user called ‘pbx1’ for the other system to connect to. We are connecting to the remote system with a user called ‘pbx2’

And we set up a similar IAX2 trunk on PBX2 –

PBX2 trunk config

Here we are also calling the the trunk pbxlink and creating a local user called ‘pbx2’ for the other system to connect to. We are connecting to the remote system with a user called ‘pbx1’

The context for incoming calls is set to ‘from-internal’. This means any call coming across the link will be treated as though it was called from an internal extension. You have to be very careful setting a trunk context to ‘from-internal’. If you did it for a normal inbound trunk you could allow unauthorised users to make outgoing calls from your system!

SETTING UP THE OUTBOUND ROUTES

Now we need to tell FreePBX what calls to send across the link. Don’t forget we are going to send calls for extensions 3XXX to PBX1 and calls for extensios 4XXX to PBX2.

Here is the Outbound Route on PBX1 –

PBX1 Outbound Route

That will send any 4 digit number starting with a 4 to PBX2, where the call will be treated as though it was dialled from a local extension.

Now the Outbound Route on PBX2 –

PBX2 Outbound Route

And finally on PBX2 we tell FreePBX to send any 4 digit number that starts with a 3 to PBX1.

Important!! If you have multiple Outbound Routes make sure this one is listed above any others that match general numbers dialled (or you’ll end up with the call matching the general Outbound Route, rather than your site to site one)

Now we should be able to make extension to extension calls between the 2 systems!

9 thoughts on “Extension to extension calling between 2 FreePBX systems

  1. John

    I have tried this on a Elastix PBX and a AsteriskNOW server and it does not work. After making a call and waiting for around 20 seconds, i am told that all lines are busy.

  2. ishaque

    I have an Asterisk Server A configured with Public IP (203.80.XX.XX) and another Asterisk Server B configured with private or dynamic IP(192.168.XX.XX).
    How can I configure IAX2 trunking between two servers to receive and sending calls

  3. matt Post author

    Public/Private IPs wouldn’t make any difference to the setup. But your systems do need to be setup for NAT if one/both of them will be using private IPs. For example with Asterisk settings externip and localnet.

  4. Christian

    Thanks for the excellent guides on your site:) Miles better than anything else I’ve found.

    I’m configuring a setup for two sites which need to be able to dial both locally and inter-pbx. It’s all within the same network using a VPN tunnel between the sites. We have limited bandwidth on one site and thus want to try and keep traffic to a minimum while still retaining quality.
    I have configured IAX2 trunks as per your other guide, but must I configure extensions as IAX2 devices as well, or can SIP extensions use the IAX2 trunk? The issue is that we all use soft-phones on MacOSX and it seems there’s limited support for IAX2 in fx. Jitsi.
    So can SIP extensions use the IAX2 trunks?

  5. Matt Newcombe Post author

    You are fine to use SIP extensions. Asterisk will do the SIP to IAX conversion to go across the trunk.

  6. marco

    Hi Matt,
    very good post! I’d like to know how to configure PBXs to allow outbound calls toward provider, i’ll explain better:

    I have two PBXs, and SIP trunk (let’s name this SIPTrunk1) between them to allow on-net intersite calls, and it’s working fine. Now, let’s say PBX1 has a SIP trunk toward SIP provider (let’s name this SIPTrunk2), i can make outbound calls from an extension that is registered toward PBX1. How can i get this for extensions registered toward PBX2?
    For users registered to PBX2 i want outbound calls traversing SIPTrunk1 first.

    REGARDS
    marco

  7. IZy

    Marco good question. I am having the same issue here.
    Hi Matt,
    very good post! I’d like to know how to configure PBXs to allow outbound calls toward provider, i’ll explain better:

    I have two PBXs, and SIP trunk (let’s name this SIPTrunk1) between them to allow on-net intersite calls, and it’s working fine. Now, let’s say PBX1 has a SIP trunk toward SIP provider (let’s name this SIPTrunk2), i can make outbound calls from an extension that is registered toward PBX1. How can i get this for extensions registered toward PBX2?
    For users registered to PBX2 i want outbound calls traversing SIPTrunk1 first.

    REGARDS
    marco

  8. John Carr

    I have a cloud hosted PBX and to reach it I cannot go directly to it’s IP address, I have to go to (example IP) http://2.2.2.2/h26NBCMWdyk Can I specify an address like that for the host inth epeer details of the trunk settings? So far no luck, but it may be because of firewall. I want to rule this out first.

Comments are closed.