Linking two Freepbx servers together with IAX2

I’ve followed countless tutorials to do this that each differ by a little bit but I can never dial an extension located on the remote server from the main server. I get “Your call cannot be completed as dialed…”. The servers see each other - are logged into each other. Stuff happens on the terminal on each side during the process (quoted below).

Settings on Main Server:

Trunk Name = pbxlink
Outbound CallerID = MyNumber
No dialed manipulation rules

Outgoing Settings
Trunk Name = pbxlink
PEER Details
host=remote_IP
username=from_main_server
secret=password
type=friend
qualify=yes
context=from-internal
requirecalltoken=no

Incoming Settings
USER Context = from_remote_server
USER Details
secret=password
type=user
context=from-internal

Outbound Route on Main Server
Dial pattern = 507 (Only the third field called “match pattern” in it has a value)
Trunk Sequence = 0 = pbxlink

Settings on Remote Server:

Trunk Name = pbxlink
Outbound CallerID = MyNumber
No dialed manipulation rules

Outgoing Settings
Trunk Name = pbxlink
PEER Details
host=main_IP
username=from_remote_server
secret=password
type=friend
qualify=yes
context=from-internal
requirecalltoken=no

Incoming Settings
USER Context = from_main_server
USER Details
secret=password
type=user
context=from-internal

So I dial 507 from the main IVR where that IVR has a manual entry for 507 which aims at “Trunks” -> "pbxlink (iax)

Here’s what I see on the main server:

== Using SIP RTP TOS bits 184
== Using SIP RTP CoS mark 5
– Executing [[email protected]:1] Set(“SIP/SHMOOZE-SIP-ACCOUNT#”, “__FROM_DID=MYMAINNUMBER”) in new stack
– Executing [[email protected]:2] Gosub(“SIP/SHMOOZE-SIP-ACCOUNT#”, “app-blacklist-check,s,1()”) in new stack
– Executing [[email protected]:1] GotoIf(“SIP/SHMOOZE-SIP-ACCOUNT#”, “0?blacklisted”) in new stack
– Executing [[email protected]:2] Set(“SIP/SHMOOZE-SIP-ACCOUNT#”, “CALLED_BLACKLIST=1”) in new stack
– Executing [[email protected]:3] Return(“SIP/SHMOOZE-SIP-ACCOUNT#”, “”) in new stack
– Executing [[email protected]:3] Set(“SIP/SHMOOZE-SIP-ACCOUNT#”, “CDR(did)=MYMAINNUMBER”) in new stack
– Executing [[email protected]:4] ExecIf(“SIP/SHMOOZE-SIP-ACCOUNT#”, “0 ?Set(CALLERID(name)=17076577711)”) in new stack
– Executing [[email protected]:5] Set(“SIP/SHMOOZE-SIP-ACCOUNT#”, “CHANNEL(musicclass)=default”) in new stack
– Executing [[email protected]:6] Set(“SIP/SHMOOZE-SIP-ACCOUNT#”, “__MOHCLASS=default”) in new stack
– Executing [[email protected]:7] Set(“SIP/SHMOOZE-SIP-ACCOUNT#”, “__CALLINGPRES_SV=allowed_not_screened”) in new stack
– Executing [[email protected]:8] Set(“SIP/SHMOOZE-SIP-ACCOUNT#”, “CALLERPRES()=allowed_not_screened”) in new stack
– Executing [[email protected]:9] Goto(“SIP/SHMOOZE-SIP-ACCOUNT#”, “ivr-1,s,1”) in new stack
– Goto (ivr-1,s,1)
– Executing [[email protected]:1] Set(“SIP/SHMOOZE-SIP-ACCOUNT#”, “INVALID_LOOPCOUNT=0”) in new stack
– Executing [[email protected]:2] Set(“SIP/SHMOOZE-SIP-ACCOUNT#”, “_IVR_CONTEXT_ivr-1=”) in new stack
– Executing [[email protected]:3] Set(“SIP/SHMOOZE-SIP-ACCOUNT#”, “_IVR_CONTEXT=ivr-1”) in new stack
– Executing [[email protected]:4] Set(“SIP/SHMOOZE-SIP-ACCOUNT#”, “__IVR_RETVM=”) in new stack
– Executing [[email protected]:5] GotoIf(“SIP/SHMOOZE-SIP-ACCOUNT#”, “0?skip”) in new stack
– Executing [[email protected]:6] Answer(“SIP/SHMOOZE-SIP-ACCOUNT#”, “”) in new stack
– Executing [[email protected]:7] Wait(“SIP/SHMOOZE-SIP-ACCOUNT#”, “1”) in new stack
> 0xb5c73200 – Probation passed - setting RTP source address to 67.231.0.102:21180
– Executing [[email protected]:8] Set(“SIP/SHMOOZE-SIP-ACCOUNT#”, “IVR_MSG=custom/IVR_Main_Menu_Carrie”) in new stack
– Executing [[email protected]:9] Set(“SIP/SHMOOZE-SIP-ACCOUNT#”, “TIMEOUT(digit)=3”) in new stack
– Digit timeout set to 3.000
– Executing [[email protected]:10] ExecIf(“SIP/SHMOOZE-SIP-ACCOUNT#”, “1?Background(custom/IVR_Main_Menu_Carrie)”) in new stack
– <SIP/SHMOOZE-SIP-ACCOUNT#> Playing ‘custom/IVR_Main_Menu_Carrie.slin’ (language ‘en’)
== CDR updated on SIP/SHMOOZE-SIP-ACCOUNT#
– Executing [[email protected]:1] Goto(“SIP/SHMOOZE-SIP-ACCOUNT#”, “ext-trunk,3,1”) in new stack
– Goto (ext-trunk,3,1)
– Executing [[email protected]:1] Set(“SIP/SHMOOZE-SIP-ACCOUNT#”, “TDIAL_STRING=IAX2/pbxlink”) in new stack
– Executing [[email protected]:2] Set(“SIP/SHMOOZE-SIP-ACCOUNT#”, “DIAL_TRUNK=3”) in new stack
– Executing [[email protected]:3] Goto(“SIP/SHMOOZE-SIP-ACCOUNT#”, “ext-trunk,tdial,1”) in new stack
– Goto (ext-trunk,tdial,1)
– Executing [[email protected]:1] Set(“SIP/SHMOOZE-SIP-ACCOUNT#”, “OUTBOUND_GROUP=OUT_3”) in new stack
– Executing [[email protected]:2] GotoIf(“SIP/SHMOOZE-SIP-ACCOUNT#”, “1?nomax”) in new stack
– Goto (ext-trunk,tdial,4)
– Executing [[email protected]:4] ExecIf(“SIP/SHMOOZE-SIP-ACCOUNT#”, “1?Set(CALLERPRES()=allowed_not_screened)”) in new stack
– Executing [[email protected]:5] Set(“SIP/SHMOOZE-SIP-ACCOUNT#”, “DIAL_NUMBER=MYMAINNUMBER”) in new stack
– Executing [[email protected]:6] GosubIf(“SIP/SHMOOZE-SIP-ACCOUNT#”, “0?sub-flp-3,s,1()”) in new stack
– Executing [[email protected]:7] Set(“SIP/SHMOOZE-SIP-ACCOUNT#”, “OUTNUM=MYMAINNUMBER”) in new stack
– Executing [[email protected]:8] Set(“SIP/SHMOOZE-SIP-ACCOUNT#”, “DIAL_TRUNK_OPTIONS=Tt”) in new stack
– Executing [[email protected]:9] Dial(“SIP/SHMOOZE-SIP-ACCOUNT#”, “IAX2/pbxlink/MYMAINNUMBER,300,Tt”) in new stack
– Called IAX2/pbxlink/MYMAINNUMBER
– Call accepted by REMOTE_IP (format ulaw)
– Format for call is (ulaw)
– IAX2/pbxlink-667 is making progress passing it to SIP/SHMOOZE-SIP-ACCOUNT#
– IAX2/pbxlink-667 is making progress passing it to SIP/SHMOOZE-SIP-ACCOUNT#
– Hungup ‘IAX2/pbxlink-667’
== Spawn extension (ext-trunk, tdial, 9) exited non-zero on ‘SIP/SHMOOZE-SIP-ACCOUNT#’

Here’s what I see on the remote server

– Accepting AUTHENTICATED call from MAIN_SERVER_IP:
> requested format = ulaw,
> requested prefs = (ulaw|alaw|gsm),
> actual format = ulaw,
> host prefs = (ulaw|alaw|gsm),
> priority = mine
– Executing [[email protected]:1] ResetCDR(“IAX2/from_main_server-1054”, “”) in new stack
– Executing [[email protected]:2] NoCDR(“IAX2/from_main_server-1054”, “”) in new stack
– Executing [[email protected]:3] Progress(“IAX2/from_main_server-1054”, “”) in new stack
– Executing [[email protected]:4] Wait(“IAX2/from_main_server-1054”, “1”) in new stack
– Executing [[email protected]:5] Progress(“IAX2/from_main_server-1054”, “”) in new stack
– Executing [[email protected]:6] Playback(“IAX2/from_main_server-1054”, “silence/1&cannot-complete-as-dialed&check-number-dial-again,noanswer”) in new stack
– <IAX2/from_main_server-1054> Playing ‘silence/1.ulaw’ (language ‘en’)
– <IAX2/from_main_server-1054> Playing ‘cannot-complete-as-dialed.ulaw’ (language ‘en’)
– <IAX2/from_main_server-1054> Playing ‘check-number-dial-again.ulaw’ (language ‘en’)
== Spawn extension (from-internal, MYMAINNUMBER, 6) exited non-zero on ‘IAX2/from_main_server-1054’
– Executing [[email protected]:1] Hangup(“IAX2/from_main_server-1054”, “”) in new stack
== Spawn extension (from-internal, h, 1) exited non-zero on ‘IAX2/from_main_server-1054’
– Hungup ‘IAX2/from_main_server-1054’

I don’t know what tutorials you followed but my guess is somewhere you are using MYMAINNUMBER where you should be using ${MYMAINNUMBER}

Well, the only place I see I have a number is in the “outbound CallerID” settings of the IAX trunk. If I try to put a ${ in front of it and a } behind it, I’m unable to submit the change as it is called invalid.

I said it was a guess, unless you have defined MYMAINNUMBER in your context [from-internal] it just won’t work, for you, “back to the drawing board” perhaps? :wink:

( perhaps ${MAINNUMBER} would, from somewhere in your post, you just need to understand the difference between ${VARIABLE}, which is “resolved” to what the series of characters that the varable VARIABLE contained, and VARIABLE which is just a string of letters )

Well I tried some more troubleshooting out. I made a new extension on the main side and used it to call through the IAX2 trunk to an extension on the other end. Worked fine. Same in reverse.

The problem is that an outside caller reaches the IVR on the main side. I want them to be able to dial an extension that may or may not be on the other side of the IAX trunk. If it’s not on the other side of that trunk, it works. If the caller elects to dial an extension that happens to be on the other side of the IAX trunk, it fails. That’s what’s been happening this whole time as that is how I was testing the IAX trunk until now.

If I dial an extension from the IVR that is on the other side of the trunk, I get

– Invalid extension ‘507’ in context ‘ivr-1’ on SIP/SHMOOZE-SIP-ACCOUNT#

Not sure why I’m in context “ivr-1” instead of “from-internal” or something…

Now that I’ve whittled down the problem, this looks like what’s going to do it for me: http://cohutta.com/Dundi_How_to.pdf

Will report back.

edit: This looks pretty tedious. Thinking there ought to be an easier way to do this. Going to post a specific question.

I am not sure how many extensions you have on the servers, so there might be so many that it is even more tedious than your example… but… I have created Misc Destinations for each extension on the other side of the IAX2 trunk, then adding the extension number assigned to the Misc Destination in the IVR… Works every time for me… but I only have 9 extensions on the other side of the IAX2 peer. :wink:

Try making these two "Trunk Name"s unique. So under Settings on Main Server, call it PBXTrunkLink. Leave the other one the same.

I noticed that there are other problems. I would put a link into my website that shows you how to do this but it is against the FreePBX forum rules. PM me.