{"id":549,"date":"2022-12-29T22:02:13","date_gmt":"2022-12-29T22:02:13","guid":{"rendered":"https:\/\/merserver.com\/?p=549"},"modified":"2022-12-29T22:02:13","modified_gmt":"2022-12-29T22:02:13","slug":"connecting-two-freepbx-machines-together","status":"publish","type":"post","link":"http:\/\/merserver.com\/index.php\/2022\/12\/29\/connecting-two-freepbx-machines-together\/","title":{"rendered":"Connecting two FreePBX machines together"},"content":{"rendered":"\n<p>One of the most common issues that people come up against is that they\u2019ve 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\u2019s not \u2013 when you know how.<\/p>\n\n\n\n<p>One of the first things you need to know, is that there are two \u2018entry points\u2019 in the freePBX dialplan. They are \u2018from-trunk\u2019 and \u2018from-internal\u2019. When a call is sent into the \u2018from-trunk\u2019 context, it is routed through the \u2018DID\u2019 logic, and treated as if it\u2019s an external call. A call sent into the \u2018from-internal\u2019 context is treated as if it was dialed from a normal SIP, IAX or Zap extension of your&nbsp;<a href=\"http:\/\/en.wikipedia.org\/wiki\/PABX\">PABX<\/a>.<br>Normally, when you\u2019re 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\u2019t want your outbound routes and trunk setup to be pretty messy. As an example, let\u2019s set up a couple of pretend freePBX machine here:<br><strong>freePBX Machine \u2018office1\u2019<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Has an outgoing IAX trunk to&nbsp;<a href=\"http:\/\/faktortel.com.au\/\">Faktortel<\/a>, that is configured as 0|. \u2014 eg, they dial 0numbernumber to make an external call. (As a minor unpaid plug, I\u2019ve had nothing but&nbsp;<strong>good<\/strong>&nbsp;from Faktortel. Very happy with them.)<\/li>\n\n\n\n<li>Has extensions in the range 300 to 350<\/li>\n<\/ul>\n\n\n\n<p><strong>freePBX Machine \u2018office2\u2019<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Has an outgoing IAX trunk to&nbsp;<a href=\"http:\/\/www.mytel.net.au\/\">MyTel<\/a>&nbsp;(Yes, both of these are Australian providers. I\u2019m Australian. Handle it 8-)) that is configured as 9|.<\/li>\n\n\n\n<li>Has extensions in the range 600 to 620<\/li>\n<\/ul>\n\n\n\n<p>The first thing you want to do is set up the IAX trunk between the two sites. Something like this would do it:<br><strong><em>At office1<\/em><\/strong><br><strong>Trunk Name<\/strong>&nbsp;<em>office2<\/em><br><strong>PEER Details<\/strong><br><code>deny=all<br>allow=g729&amp;alaw<br>type=friend<br>host=office2<br>qualify=yes<br>context=from-internal<br><\/code><br>Those options mean, in order:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Deny ALL audio codecs.<\/li>\n\n\n\n<li>Except for g729 and alaw \u2013 if you were in the US, you\u2019d use ulaw<\/li>\n\n\n\n<li>Use this entry to send calls to,&nbsp;<strong>and<\/strong>&nbsp;receive calls from a device.<\/li>\n\n\n\n<li>Use this entry when sending or receiving calls from the host \u2018office2\u2019<\/li>\n\n\n\n<li>Regularily send a keep-alive packet that ensures that the other machine is up and is responding to IAX traffic<\/li>\n\n\n\n<li>When a call comes in from host \u2018office2\u2019, send it to the \u2018from-internal\u2019 context \u2013 eg, treat it as if it originated locally in this PABX.<\/li>\n<\/ul>\n\n\n\n<p>Now set up exactly the same trunk on office2, but changing host=office2 to host=office1 (normally, you\u2019d use IP addresses here, rather than hostnames, to avoid potential DNS errors)<br><strong>Trunk Name:<\/strong>&nbsp;<em>office1<\/em><br><code>deny=all<br>allow=g729&amp;alaw<br>type=friend<br>host=office1<br>qualify=yes<br>context=from-internal<br><\/code><br>That\u2019s almost it. You now have the \u2018pipe\u2019 between the two sites set up. Now all you need to do is set up the routing, which is easily done.<br>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 \u2018tooffice2\u2019 with the dial plan match of \u20186[012]X\u2019 (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 \u2018office2\u2019. Do the same thing on office2, but with the dial plan match set to be \u20183[0-5]X\u2019, and the trunk set to office1.<br>That\u2019s it! You\u2019ve now linked the two offices together. Someone on office1 will pick up the phone, dial 600 and it\u2019ll fire off out the \u2018tooffice2\u2019 trunk because of the match, and arrive in the \u2018from-internal\u2019 context of office2 so it\u2019s treated as an internal call.<br>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 \u2013 that matches a three digit number starting with four, takes off the leading four, and adds a three to the start \u2013 basically, replacing the 4 with a 3. That would let you call 312 at office2 by dialling 412 at office1). You can also do \u2018smart\u2019 stuff like having office2 fail over to office1 if their connection to MyTel goes down, by having office2\u2019s outbound route (which is currently 9|. with the only trunk being MyTel) have \u2018office1\u2019 after the mytel trunk, and in the \u2018office1\u2019 trunk on office2 add a 0 if the call being sent to it is longer than 3 digits \u2013 eg, 0+XXXX.<br>Another caveat is that this was written from a Hotel room in Toowoomba. I\u2019m currently away from the office for the rest of the week, and this post was done from memory. Hopefully if there\u2019s any errors, someone will leave a comment and I\u2019ll fix it!<br>Update: There\u2019s 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 \u2018to-trunk\u2019 destination, which you can use to plumb routes together, there\u2019s a solution on the&nbsp;<a href=\"http:\/\/www.trixbox.org\/modules\/newbb\/viewtopic.php?topic_id=2270&amp;forum=2&amp;viewmode=flat&amp;order=ASC&amp;start=10\">Trixbox Forums<\/a>&nbsp;that explain how to do it.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>One of the most common issues that people come up against is that they\u2019ve 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\u2019s not \u2013 when you&#8230;<\/p>\n<p class=\"more-link-wrap\"><a href=\"http:\/\/merserver.com\/index.php\/2022\/12\/29\/connecting-two-freepbx-machines-together\/\" class=\"more-link\">Read More<span class=\"screen-reader-text\"> &ldquo;Connecting two FreePBX machines together&rdquo;<\/span> &raquo;<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[6],"tags":[],"class_list":["post-549","post","type-post","status-publish","format-standard","hentry","category-it"],"_links":{"self":[{"href":"http:\/\/merserver.com\/index.php\/wp-json\/wp\/v2\/posts\/549","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/merserver.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/merserver.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/merserver.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/merserver.com\/index.php\/wp-json\/wp\/v2\/comments?post=549"}],"version-history":[{"count":1,"href":"http:\/\/merserver.com\/index.php\/wp-json\/wp\/v2\/posts\/549\/revisions"}],"predecessor-version":[{"id":550,"href":"http:\/\/merserver.com\/index.php\/wp-json\/wp\/v2\/posts\/549\/revisions\/550"}],"wp:attachment":[{"href":"http:\/\/merserver.com\/index.php\/wp-json\/wp\/v2\/media?parent=549"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/merserver.com\/index.php\/wp-json\/wp\/v2\/categories?post=549"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/merserver.com\/index.php\/wp-json\/wp\/v2\/tags?post=549"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}