Interoffice Trunking with Elastix & IAX Part1
Introduction
=========
As a business grows, it is necessary to open further offices, usually in separate locations, or due to geographic requirements, they need a warehouse or distribution center that is separate to the head office.
One of the issues that occurs is the isolation of the two or more offices, almost as though they are two separate businesses. This occurs due the geographic isolation, but also in many cases isolation as they are using separate systems. Even the necessity, when dialling the other office, to dial a full phone number, continues to enforce this isolation.
It is surprising, especially in an office culture, how a simple change of dialling other office extensions directly, makes a change to the mentality of how the other office(s) are perceived. Add a few other functions such as the receptionist console providing visibility of the other office extensions (and their visibility of yours), and even an internal Instant Messaging/Presence ability that works across the two offices, and the culture changes. Further add in the ability for any staff to call the person that they need direct, knowing that there is no cost for the call.
I have seen it on many occasions, and I have had discussions with company directors who will categorically state that it has had a huge impact on their business efficiency and co-operation between branches due to a more homogenous single business. They also know that calls between all their offices have no call costs, and even if they wish to, they could stretch it further to include video between the various offices, either in a single room at each site, or at key staff desktops.
This document is not going to cover how to implement instant messaging, or the receptionist console, or how to setup video as these are generally covered by other tutorials on this site. Like all good systems, it is best implemented one building block at a time, test, and then move to the next phase, unless you are very experienced in which case, you generally don’t require this tutorial .
So the purpose of this guide is to provide you with the step by step guide on how to connect two offices together utilising an Elastix system in both offices.
Planning
======
Connecting two offices or sites with Elastix is relatively simple, but like all good things a bit of planning ahead of implementation is a good investment. I have seen many mistakes made, not from not understanding the concepts, but actually becoming confused with setup details and not putting the basic building blocks in place first. Some do start with the basic building blocks, but part way through they make a leap feeling confident, making changes on the fly, and then it ends up not working.
So it is important to write out what you are trying to do, it will make it easier in the long run. Even printing the configs from this tutorial, making changes to the names to suit your setup, will keep you on the right track.
This planning also extends to making sure that each site is using a separate set of Extension numbers e.g. 200 range in Sydney and the 500 range in Melbourne. This simplifies your routing rules. If you are setting up the two Elastix systems for the first time, then this is worth considering the particular numbering separation to make it easy for both yourself and the business. It may not always possible, especially if the two systems are already in existence and already using a common extension numbering scheme, and this is covered quickly at the end of this tutorial.
The Scenario
===========
This is scenario and configurations are taken from a production system, so you know that they work.
The company has two offices one in Sydney and one in Melbourne. The office in Sydney has 60 staff and the one Melbourne has 20 staff
The two offices have a Virtual Private Network (VPN) between them which will generally be the case with most businesses that need to share or access data between their offices.
Elastix IP Address & IP Ranges used by each office
The Sydney office has a 192.168.0.0/255.255.255.0 ip address range
The Sydney Elastix system has an ip address of 192.168.0.100
The Melbourne office as a 192.168.1.0/255.255.255.0 ip address range
The Melbourne Elastix system has an ip address of 192.168.1.100
Extensions setup on Elastix at each Office
Sydney : Extensions 201 – 260
Melbourne : Extensions 501 – 521

IAX Trunk Setup
==============
On the Sydney Elastix system
Add an IAX Trunk
Leave all other options until you reach Trunk Name as default. I know it hurts to leave fields blank, resist the temptation until you have a working trunk, then come back and tweak these options. Enter all the details below listed under the Sydney Elastix System.
On the Melbourne Elastix System, Add an IAX Trunk, and enter the information listed under the Melbourne Elastix System
|
Sydney Elastix System |
Melbourne Elastix System |
|
Trunk Name : melbourne PEER DETAILS username=melbourne type=peer secret=yellow47 qualify=yes host=192.168.1.100 context=from-internal trunk=yes disallow=all allow=gsm
User Context : sydney
USER DETAILS type=user secret=yellow47 host=192.168.1.100 context=from-internal disallow=all allow=gsm
Registration {Blank} |
Trunk name : sydney PEER DETAILS username=sydney type=peer secret=yellow47 qualify=yes host=192.168.0.100 context=from-internal trunk=yes disallow=all allow=gsm
User Context : melbourne
USER DETAILS type=user secret=yellow47 host=192.168.0.100 context=from-internal disallow=all allow=gsm
Registration {Blank} |
You should now be able to access the Asterisk CLI and type the command iax2 show peers on the Sydney Elastix system and see the following

And similarly on the Melbourne system

So what have we done in the configurations that we have completed so far?
The Peer Details on the Sydney Elastix system, we have setup under Trunk Name Melbourne the details which include how to contact the Melbourne System, what password to use, the context to use, the codec to use, and we have also told it to trunk the calls. You can omit the Trunk=yes if you want, but it needs to be removed from both sides. Trunk=yes reduces the overhead a little especially if you have a number of calls being handled by that trunk.
The User Details on the Sydney System, are basically the authentication information for the Melbourne system when it tries to make contact with the Sydney system. The Sydney system will match the authentication being provided by the Melbourne system with the information here. If it matches then it will let the call come through.
The reverse is the same on the Melbourne Elastix System
It is as simple as this, you have setup a trunk between two offices. Now we need to get the Elastix systems on both ends to use this trunk because as it stands now, other than a but of authentication traffic, it doesn’t do much else. That’s where the next part of this tutorial comes into play.On both systems, we need to setup an outbound route to tell it what to do when a caller in Sydney wants to call an extension in Melbourne.
So on the Sydney Elastix system, setup an outbound route called MelbourneExts

So, what we have completed here is an outbound route that tells the Sydney Elastix system, when a user calls any three digit extension that starts with a five(5) that it is to be directed to the IAX2/melbourne Trunk.
We have also ticked the Intra Company Route option which tells the system to preserve the CID information when transferring the call to the Melbourne system.
On the Melbourne System, setup basically a mirror image of the Sydney outbound route.

As you will note, the route name is called SydneyExts, again Intra Company Route is ticked, and the other main difference is that we are telling the Melbourne Elastix system to handle any Melbourne users that dial 2xx and redirect the call to the IAX2/sydney Trunk.
That is it. The best way to test it is to dial a Melbourne extension from the Sydney office. There is no other science needed, no magic potions. The main reason for failure for many is usually the failure of the IAX trunk. There are many configurations on websites, some that contain lines using the G729 codec only (which is common), but on freshly installed Elastix systems, you are generally not going to have the G729 codec loaded. My recommendation is leave the codec setting as GSM until you have completed basic testing.
What to do if the same extension numbers exist at both branches
================================================
For staff sanity, it is better to plan for a change on one of the branches so that the extensions are unique to each branch. However, if this is not possible, then you can implement a slightly different way of calling extensions in each office.
The IAX Trunk setup remains exactly the same, however the difference is in the outbound routing for each system.
Since the company wants to maintain their extensions as they are, this means as an example, Sydney has extensions 201 – 260 and Melbourne has extensions 201-220, after discussion with the business, we decided that to call and Melbourne extension from Sydney, they will place a 3 in front of an extension number. Likewise Melbourne to call Sydney extensions they would place a 2 in front of the three digit extension they wanted to call.
So if Melbourne wanted to call Sydney Ext 201 they would call 2201
If Sydney wanted to call Melbourne Ext 203 they would call 3203
So the only change to implement this is in the outbound route in the examples shown previously of the outbound routes. In the Sydney Elastix system, I change the outbound route Dial Pattern from 5xx to 3|2xx and on the Melbourne Elastix system, I change the outbound route Dial Pattern from 2xx to 2|2xx
So you can see it visually, the following is the change to the Sydney System

And the following diagram is the changes to the Melbourne system

In a nutshell, from the Sydney Elastix System, if we just dialled 201 hoping to reach Melbourne it will never happen. it will always ring the Sydney 201 extension. By adding the digit, e.g. 3201, Elastix will not see it as a local extension number and will look at the outbound routes for a match. Now as soon as it makes a match (which is the 3|2xx), it will strip off the 3 digit, and pass 201 down the IAX Trunk to Melbourne. The Elastix System in Melbourne will recognise that it has an extension 201 and will connect the call.
Tags: Asterisk, elastix to elastix, iax, iax trunks, inbound routes, routes, VOIP

November 14th, 2009 at 4:39 pm
Very Nice Article, Looking forward to more of this…
November 15th, 2009 at 7:16 pm
Excellent article, I have a question, how I can create a Outboubd Route in order to do calls from City A to others places in City B ?
And how I can call from city B to others countries using a VoIP provider that I have in city A ?
November 15th, 2009 at 8:15 pm
More to come…have recently posted Skype for Elastix (Asterisk) as well
Thank you for your comments
November 15th, 2009 at 8:21 pm
With the exact same setup as described.
The only difference is to setup an outbound route on City B Elastix system matching the phone numbers that you want to go across to the City A Elastix system and this route set it to use the Interoffice Trunk. City A Elastix system will receive the call information and match it against its outbound routes and send it from itself (just like you were an extension on that Box).
Thank you for the comments and good question. If time permits, I may add a more detailed description of the process you mentioned as a new article or maybe chain it onto the existing one….
November 16th, 2009 at 10:09 am
[...] This post was mentioned on Twitter by elastix, matthew monteleone. matthew monteleone said: Interoffice trunking with elastix… good article .. http://bit.ly/2SEKgL [...]
November 16th, 2009 at 10:45 am
Very good article! The only thing I would mention is the option to not put the voip trunks over the vpn, but let them connect over the internet. This can reduce some latency for you if it’s a problem.
November 16th, 2009 at 11:57 am
Great Article i have done exactly the same but issue with me is caller ID on either side it shows only the trunk extension not the calling extension is there any trick for it to show the caller extension on either side? if so kindly post it.
November 16th, 2009 at 3:32 pm
Alonso Gordillo,
Have just published part 2 of the Interoffice Trunking which covers the question you have. Thanks for the suggestion
November 16th, 2009 at 3:41 pm
Kspare,
Fair point to raise as I did not cover that in the article. As you said, you can perform this trunking without the VPN (and naturally with no voice encryption). For some this may be necessary if their connection latency is already higher than average. However on the whole, we have used VPN’s for all interoffice connections and have experienced no additional noticeable latency, but we do use as a minimum quality Routers $AUS350+ or Cisco kit and we purely use IPSEC VPN’s. Many of the consumer routers, do not have a decent CPU to handle VPN’s without inducing further latency.
But as you said, if you have a lower end Router or no VPN capability, it does not stop anyone connecting their boxes using their external addresses.
November 16th, 2009 at 4:17 pm
[...] Thanks to a comment from Alonso Gordillo on Inter-Office Trunking using Elastix, I have decided that it warranted a second part describing how to use your new Inter-Office trunk to have calls routed through the other office’s Elastix PBX. If you havent already, first please read Interoffice Trunking with Elastix & IAX Part 1 [...]
November 19th, 2009 at 5:20 pm
,..] blogs.elastix.org is one another nice source of information on this subject,..]
December 1st, 2009 at 4:47 am
Dear Bob,
still waiting for my question to be answered please answer if you have time.
Great Article i have done exactly the same but issue with me is caller ID on either side it shows only the trunk extension not the calling extension is there any trick for it to show the caller extension on either side? if so kindly post it.
Thank you.
December 16th, 2009 at 12:41 am
Hi Bob,
I tried to use your configuration described here but ran into problems. In my situation, instead of a VPN, our network uses NAT on the routers ( a special external IP is assigned to be NAT’ed to the elastix servers. this way you connect to the elastix server’s public IP and the router NATs you to the internal (essentially a DMZ type thing). This is on all networks.
Could you help in showing what should be different, and what I should tweak in order to make it work? I get a “all circuits are busy” error when i try to place a call between locations.
best regards,
Sina
Sina
December 29th, 2009 at 12:09 pm
Hi,
I don’t know why you use peer detail and user details instead of only peer detail like that:
username=user_name
secret=the_secret
type=friend
qualify=yes
host=Remote_IP
context=from-internal
Regards
Franck
trunk=yes
disallow=all
allow=gsm
That work fine with this.
December 29th, 2009 at 12:10 pm
Hi,
I don’t know why you use peer detail and user details instead of only peer detail like that:
username=user_name
secret=the_secret
type=friend
qualify=yes
host=Remote_IP
context=from-internal
Regards
FrancK
That work fine with this.
January 3rd, 2010 at 1:26 pm
Hola…
Yesterday I built a new elastix box to replace a box that was having hardware issues. This box is in San Francisco and connects to a call center in Manila Philippines. It has an OpenVox PRI/T1 card in it that works great~! Truly plug it in, turn it on.
Well, everything went fine until I tried to build the IAX connections between the two boxes. I followed the instructions in this post exactly EXCEPT that I specified the g729 codec because that is what was specified in the elastix box I replaced.
After 12 hours of changing SIP settings, NAT settings, Inbound/outbound settings, network/firewall settings, I then changed the IAX setup to allow=ulaw instead of allow=g729 and then of course everything started working properly.
I am new to asterisk/elastix and it has allowed me to start a call center in the Philippines supporting customers in California very economically. BUT, it can really be a challenge sometimes.
January 6th, 2010 at 8:08 am
Bob Sir, please answer my question.
January 19th, 2010 at 4:55 pm
Bob, a quick optional add on.
To enable iax2 encryption on your channel add the following into each trunk (peer & user)
encryption=aes128
auth=md5
(see post http://www.elastix.org/component/option,com_fireboard/Itemid,55/func,view/catid,3/id,43952/lang,en/#44006)
January 26th, 2010 at 11:09 pm
Great article,
I’m a university student and i need to do a proyect about this but im having some issues, should i use the same config for SIP connections?, when i call from one server to the other it is telling me that all target are bussy what can i do about that.
Please help me thank you.