One of the most common issues that people come up against is that they’ve rolled out one FreePBX machine, and now they want another, somewhere else. And to make it just that little bit harder, they want to link them together. At first, this can be a bit daunting, but it’s not – when you know how.
One of the first things you need to know, is that there are two ‘entry points’ in the freePBX dialplan. They are ‘from-trunk’ and ‘from-internal’. When a call is sent into the ‘from-trunk’ context, it is routed through the ‘DID’ logic, and treated as if it’s an external call. A call sent into the ‘from-internal’ context is treated as if it was dialed from a normal SIP, IAX or Zap extension of your PABX.
Normally, when you’re linking two freePBX machines together, you want the users pretty much be unaware that there are two machines, so you need a dialplan set up so that calls are treated that way. This means you need to have a little bit of forward planning if you don’t want your outbound routes and trunk setup to be pretty messy. As an example, let’s set up a couple of pretend freePBX machine here:
freePBX Machine ‘office1’
- Has an outgoing IAX trunk to Faktortel, that is configured as 0|. — eg, they dial 0numbernumber to make an external call. (As a minor unpaid plug, I’ve had nothing but good from Faktortel. Very happy with them.)
- Has extensions in the range 300 to 350
freePBX Machine ‘office2’
- Has an outgoing IAX trunk to MyTel (Yes, both of these are Australian providers. I’m Australian. Handle it 8-)) that is configured as 9|.
- Has extensions in the range 600 to 620
The first thing you want to do is set up the IAX trunk between the two sites. Something like this would do it:
At office1
Trunk Name office2
PEER Detailsdeny=all
allow=g729&alaw
type=friend
host=office2
qualify=yes
context=from-internal
Those options mean, in order:
- Deny ALL audio codecs.
- Except for g729 and alaw – if you were in the US, you’d use ulaw
- Use this entry to send calls to, and receive calls from a device.
- Use this entry when sending or receiving calls from the host ‘office2’
- Regularily send a keep-alive packet that ensures that the other machine is up and is responding to IAX traffic
- When a call comes in from host ‘office2’, send it to the ‘from-internal’ context – eg, treat it as if it originated locally in this PABX.
Now set up exactly the same trunk on office2, but changing host=office2 to host=office1 (normally, you’d use IP addresses here, rather than hostnames, to avoid potential DNS errors)
Trunk Name: office1deny=all
allow=g729&alaw
type=friend
host=office1
qualify=yes
context=from-internal
That’s almost it. You now have the ‘pipe’ between the two sites set up. Now all you need to do is set up the routing, which is easily done.
Go into your outbound routing on office1, which you should remember has extensions in the range 300 to 350, and they want to be able to call extensions 600 to 620 at office2. Create an outbound route name called ‘tooffice2’ with the dial plan match of ‘6[012]X’ (which means a three digit number anything starting with 6, with the second digit being 0, 1 or 2, and any last digit), and the trunk set to be ‘office2’. Do the same thing on office2, but with the dial plan match set to be ‘3[0-5]X’, and the trunk set to office1.
That’s it! You’ve now linked the two offices together. Someone on office1 will pick up the phone, dial 600 and it’ll fire off out the ‘tooffice2’ trunk because of the match, and arrive in the ‘from-internal’ context of office2 so it’s treated as an internal call.
As a caveat, this post handily avoids the issue of sites having conflicting extensions. If that is an issue, you could, possibly, re-map them in your Trunk dialling rules by something like 3+4|XX – that matches a three digit number starting with four, takes off the leading four, and adds a three to the start – basically, replacing the 4 with a 3. That would let you call 312 at office2 by dialling 412 at office1). You can also do ‘smart’ stuff like having office2 fail over to office1 if their connection to MyTel goes down, by having office2’s outbound route (which is currently 9|. with the only trunk being MyTel) have ‘office1’ after the mytel trunk, and in the ‘office1’ trunk on office2 add a 0 if the call being sent to it is longer than 3 digits – eg, 0+XXXX.
Another caveat is that this was written from a Hotel room in Toowoomba. I’m currently away from the office for the rest of the week, and this post was done from memory. Hopefully if there’s any errors, someone will leave a comment and I’ll fix it!
Update: There’s been a comment below about dialling out through an interconnect, when you just want the freepbx machine to pass the calls through blindly. Whilst we will be making a ‘to-trunk’ destination, which you can use to plumb routes together, there’s a solution on the Trixbox Forums that explain how to do it.