IVR route to Ring Group on another PBX

Hi all,

I have two instances FreePBX v14.0.11 . PBX “A” and PBX “B” linked via a SIP trunk. I can make calls to extensions both directions from each PBX. So calling internally from PBX “A” to “B” and “B” to “A” works.

On PBX “A” I have an IVR with an option to call a ring group on PBX “B”. The option to call the ring group is configured as a misc destination and the appropriate route is configured.

When I select option “2” on my IVR for the ring group on PBX “B” I hear an announcement

“The number you have dialled is not in service, check the number and dial again.”

If I set the IVR option to an extension PBX “B” the call completes normally, it appears the issue is only with ring groups.

Debug output, I have sanatised the IP etc

PBX “A”:

-- Executing [s@ivr-1:1] Set("SIP/providerA-000000c2", "_IVR_CONTEXT_ivr-1=") in new stack
-- Executing [s@ivr-1:2] Set("SIP/providerA-000000c2", "_IVR_CONTEXT=ivr-1") in new stack
-- Executing [s@ivr-1:3] Set("SIP/providerA-000000c2", "__IVR_RETVM=") in new stack
-- Executing [s@ivr-1:4] GotoIf("SIP/providerA-000000c2", "0?skip") in new stack
-- Executing [s@ivr-1:5] Answer("SIP/providerA-000000c2", "") in new stack
-- Executing [s@ivr-1:6] Wait("SIP/providerA-000000c2", "1") in new stack
-- Executing [s@ivr-1:7] Set("SIP/providerA-000000c2", "IVR_MSG=custom/Maingreeting) in new stack
-- Executing [s@ivr-1:8] Set("SIP/providerA-000000c2", "TIMEOUT(digit)=3") in new stack
-- Digit timeout set to 3.000
-- Executing [s@ivr-1:9] ExecIf("SIP/providerA-000000c2", "1?Background(custom/Maingreeting)") in new stack
-- <SIP/providerA-000000c2> Playing 'custom/Maingreeting.slin' (language 'en')
-- Executing [2@ivr-1:1] Set("SIP/providerA-000000c2", "__ivrreturn=0") in new stack
-- Executing [2@ivr-1:2] Goto("SIP/providerA-000000c2", "ext-miscdests,2,1") in new stack
-- Goto (ext-miscdests,2,1)
-- Executing [2@ext-miscdests:1] NoOp("SIP/providerA-000000c2", "MiscDest: CustomerService") in new stack
-- Executing [2@ext-miscdests:2] Goto("SIP/providerA-000000c2", "from-internal,790,1") in new stack
-- Goto (from-internal,790,1)
-- Executing [790@from-internal:1] Macro("SIP/providerA-000000c2", "user-callerid,LIMIT,EXTERNAL,") in new stack
-- Executing [s@macro-user-callerid:1] Set("SIP/providerA-000000c2", "TOUCH_MONITOR=1560233961.1311") in new stack
-- Executing [s@macro-user-callerid:2] Set("SIP/providerA-000000c2", "AMPUSER=44862417600") in new stack
-- Executing [s@macro-user-callerid:3] GotoIf("SIP/providerA-000000c2", "0?report") in new stack
-- Executing [s@macro-user-callerid:4] ExecIf("SIP/providerA-000000c2", "1?Set(REALCALLERIDNUM=44862417600)") in new stack
-- Executing [s@macro-user-callerid:5] Set("SIP/providerA-000000c2", "AMPUSER=") in new stack
-- Executing [s@macro-user-callerid:6] GotoIf("SIP/providerA-000000c2", "0?limit") in new stack
-- Executing [s@macro-user-callerid:7] Set("SIP/providerA-000000c2", "AMPUSERCIDNAME=") in new stack
-- Executing [s@macro-user-callerid:8] ExecIf("SIP/providerA-000000c2", "0?Set(__CIDMASQUERADING=TRUE)") in new stack
-- Executing [s@macro-user-callerid:9] GotoIf("SIP/providerA-000000c2", "1?report") in new stack
-- Goto (macro-user-callerid,s,16)
-- Executing [s@macro-user-callerid:16] NoOp("SIP/providerA-000000c2", "Macro Depth is 1") in new stack
-- Executing [s@macro-user-callerid:17] GotoIf("SIP/providerA-000000c2", "1?report2:macroerror") in new stack
-- Goto (macro-user-callerid,s,18)
-- Executing [s@macro-user-callerid:18] GotoIf("SIP/providerA-000000c2", "1?continue") in new stack
-- Goto (macro-user-callerid,s,37)
-- Executing [s@macro-user-callerid:37] Set("SIP/providerA-000000c2", "CALLERID(number)=44862417600") in new stack
-- Executing [s@macro-user-callerid:38] Set("SIP/providerA-000000c2", "CALLERID(name)=44862417600") in new stack
-- Executing [s@macro-user-callerid:39] GotoIf("SIP/providerA-000000c2", "0?cnum") in new stack
-- Executing [s@macro-user-callerid:40] Set("SIP/providerA-000000c2", "CDR(cnam)=44862417600") in new stack
-- Executing [s@macro-user-callerid:41] Set("SIP/providerA-000000c2", "CDR(cnum)=44862417600") in new stack
-- Executing [s@macro-user-callerid:42] Set("SIP/providerA-000000c2", "CHANNEL(language)=en") in new stack
-- Executing [790@from-internal:2] Gosub("SIP/providerA-000000c2", "sub-record-check,s,1(out,790,dontcare)") in new stack
-- Executing [s@sub-record-check:1] GotoIf("SIP/providerA-000000c2", "12?initialized") in new stack
-- Goto (sub-record-check,s,10)
-- Executing [s@sub-record-check:10] NoOp("SIP/providerA-000000c2", "Recordings initialized") in new stack
-- Executing [s@sub-record-check:11] ExecIf("SIP/providerA-000000c2", "0?Set(ARG3=dontcare)") in new stack
-- Executing [s@sub-record-check:12] Set("SIP/providerA-000000c2", "REC_POLICY_MODE_SAVE=") in new stack
-- Executing [s@sub-record-check:13] ExecIf("SIP/providerA-000000c2", "0?Set(REC_STATUS=NO)") in new stack
-- Executing [s@sub-record-check:14] GotoIf("SIP/providerA-000000c2", "3?checkaction") in new stack
-- Goto (sub-record-check,s,17)
-- Executing [s@sub-record-check:17] GotoIf("SIP/providerA-000000c2", "1?sub-record-check,out,1") in new stack
-- Goto (sub-record-check,out,1)
-- Executing [out@sub-record-check:1] NoOp("SIP/providerA-000000c2", "Outbound Recording Check from 44862417600 to 790") in new stack
-- Executing [out@sub-record-check:2] Set("SIP/providerA-000000c2", "RECMODE=") in new stack
-- Executing [out@sub-record-check:3] ExecIf("SIP/providerA-000000c2", "1?Goto(routewins)") in new stack
-- Goto (sub-record-check,out,7)
-- Executing [out@sub-record-check:7] Gosub("SIP/providerA-000000c2", "recordcheck,1(dontcare,out,790)") in new stack
-- Executing [recordcheck@sub-record-check:1] NoOp("SIP/providerA-000000c2", "Starting recording check against dontcare") in new stack
-- Executing [recordcheck@sub-record-check:2] Goto("SIP/providerA-000000c2", "dontcare") in new stack
-- Goto (sub-record-check,recordcheck,3)
-- Executing [recordcheck@sub-record-check:3] Return("SIP/providerA-000000c2", "") in new stack
-- Executing [out@sub-record-check:8] Return("SIP/providerA-000000c2", "") in new stack
-- Executing [790@from-internal:3] ExecIf("SIP/providerA-000000c2", "0 ?Set(CDR(accountcode)=)") in new stack
-- Executing [790@from-internal:4] Set("SIP/providerA-000000c2", "INTRACOMPANYROUTE=YES") in new stack
-- Executing [790@from-internal:5] Set("SIP/providerA-000000c2", "MOHCLASS=default") in new stack
-- Executing [790@from-internal:6] Set("SIP/providerA-000000c2", "_NODEST=") in new stack
-- Executing [790@from-internal:7] Macro("SIP/providerA-000000c2", "dialout-trunk,7,790,,off") in new stack
-- Executing [s@macro-dialout-trunk:1] Set("SIP/providerA-000000c2", "DIAL_TRUNK=7") in new stack
-- Executing [s@macro-dialout-trunk:2] ExecIf("SIP/providerA-000000c2", "1?Set(DIAL_OPTIONS=tr)") in new stack
-- Executing [s@macro-dialout-trunk:3] GosubIf("SIP/providerA-000000c2", "0?sub-pincheck,s,1()") in new stack
-- Executing [s@macro-dialout-trunk:4] ExecIf("SIP/providerA-000000c2", "0?Set(CALLERID(num)=)") in new stack
-- Executing [s@macro-dialout-trunk:5] GotoIf("SIP/providerA-000000c2", "0?disabletrunk,1") in new stack
-- Executing [s@macro-dialout-trunk:6] Set("SIP/providerA-000000c2", "DIAL_NUMBER=790") in new stack
-- Executing [s@macro-dialout-trunk:7] Set("SIP/providerA-000000c2", "DIAL_TRUNK_OPTIONS=tr") in new stack
-- Executing [s@macro-dialout-trunk:8] Set("SIP/providerA-000000c2", "OUTBOUND_GROUP=OUT_7") in new stack
-- Executing [s@macro-dialout-trunk:9] Set("SIP/providerA-000000c2", "DIAL_TRUNK_OPTIONS=Tt") in new stack
-- Executing [s@macro-dialout-trunk:10] GotoIf("SIP/providerA-000000c2", "1?nomax") in new stack
-- Goto (macro-dialout-trunk,s,12)
-- Executing [s@macro-dialout-trunk:12] GotoIf("SIP/providerA-000000c2", "1?skipoutcid") in new stack
-- Goto (macro-dialout-trunk,s,14)
-- Executing [s@macro-dialout-trunk:14] GosubIf("SIP/providerA-000000c2", "0?sub-flp-7,s,1()") in new stack
-- Executing [s@macro-dialout-trunk:15] Set("SIP/providerA-000000c2", "OUTNUM=790") in new stack
-- Executing [s@macro-dialout-trunk:16] Set("SIP/providerA-000000c2", "custom=SIP/MLTBELSIP") in new stack
-- Executing [s@macro-dialout-trunk:17] ExecIf("SIP/providerA-000000c2", "0?Set(DIAL_TRUNK_OPTIONS=M(setmusic^default)Tt)") in new stack
-- Executing [s@macro-dialout-trunk:18] ExecIf("SIP/providerA-000000c2", "0?Set(DIAL_TRUNK_OPTIONS=TtM(confirm))") in new stack
-- Executing [s@macro-dialout-trunk:19] Macro("SIP/providerA-000000c2", "dialout-trunk-predial-hook,") in new stack
-- Executing [s@macro-dialout-trunk-predial-hook:1] MacroExit("SIP/providerA-000000c2", "") in new stack
-- Executing [s@macro-dialout-trunk:20] GotoIf("SIP/providerA-000000c2", "0?bypass,1") in new stack
-- Executing [s@macro-dialout-trunk:21] ExecIf("SIP/providerA-000000c2", "0?Set(CONNECTEDLINE(num,i)=790)") in new stack
-- Executing [s@macro-dialout-trunk:22] ExecIf("SIP/providerA-000000c2", "0?Set(CONNECTEDLINE(name,i)=CID:44862417600)") in new stack
-- Executing [s@macro-dialout-trunk:23] ExecIf("SIP/providerA-000000c2", "0?Set(CONNECTEDLINE(name,i)=CID:(Hidden)44862417600)") in new stack
-- Executing [s@macro-dialout-trunk:24] GotoIf("SIP/providerA-000000c2", "0?customtrunk") in new stack
-- Executing [s@macro-dialout-trunk:25] Dial("SIP/providerA-000000c2", "SIP/MLTBELSIP/790,300,Ttb(func-apply-sipheaders^s^1,(7))") in new stack

== Using SIP RTP TOS bits 184
== Using SIP RTP CoS mark 5
– SIP/MLTBELSIP-000000c3 Internal Gosub(func-apply-sipheaders,s,1(7)) start
– Executing [s@func-apply-sipheaders:1] NoOp(“SIP/MLTBELSIP-000000c3”, “Applying SIP Headers to channel SIP/MLTBELSIP-000000c3”) in new stack
– Executing [s@func-apply-sipheaders:2] Set(“SIP/MLTBELSIP-000000c3”, “TECH=SIP”) in new stack
– Executing [s@func-apply-sipheaders:3] Set(“SIP/MLTBELSIP-000000c3”, “SIPHEADERKEYS=”) in new stack
– Executing [s@func-apply-sipheaders:4] While(“SIP/MLTBELSIP-000000c3”, “0”) in new stack
– Jumping to priority 9
– Executing [s@func-apply-sipheaders:10] Return(“SIP/MLTBELSIP-000000c3”, “”) in new stack
== Spawn extension (from-trunk-sip-MLTBELSIP, 790, 1) exited non-zero on ‘SIP/MLTBELSIP-000000c3’
– SIP/MLTBELSIP-000000c3 Internal Gosub(func-apply-sipheaders,s,1(7)) complete GOSUB_RETVAL=
– Called SIP/MLTBELSIP/790
– SIP/MLTBELSIP-000000c3 answered SIP/providerA-000000c2
– Channel SIP/MLTBELSIP-000000c3 joined ‘simple_bridge’ basic-bridge <950a5477-b487-4bf9-9e2b-5b1eb3e5e01b>
– Channel SIP/providerA-000000c2 joined ‘simple_bridge’ basic-bridge <950a5477-b487-4bf9-9e2b-5b1eb3e5e01b>
[2019-06-11 06:19:30] WARNING[56366][C-00000056]: chan_iax2.c:1240 jb_warning_output: Resyncing the jb. last_delay 0, this delay -206425481, threshold 1000, new offset 206425481
– Remote UNIX connection
– Remote UNIX connection disconnected
– Channel SIP/MLTBELSIP-000000c3 left ‘simple_bridge’ basic-bridge <950a5477-b487-4bf9-9e2b-5b1eb3e5e01b>
– Channel SIP/providerA-000000c2 left ‘simple_bridge’ basic-bridge <950a5477-b487-4bf9-9e2b-5b1eb3e5e01b>
== Spawn extension (macro-dialout-trunk, s, 25) exited non-zero on ‘SIP/providerA-000000c2’ in macro ‘dialout-trunk’
== Spawn extension (from-internal, 790, 7) exited non-zero on ‘SIP/providerA-000000c2’
– Executing [h@from-internal:1] Macro(“SIP/providerA-000000c2”, “hangupcall”) in new stack
– Executing [s@macro-hangupcall:1] GotoIf(“SIP/providerA-000000c2”, “1?theend”) in new stack
– Goto (macro-hangupcall,s,3)
– Executing [s@macro-hangupcall:3] ExecIf(“SIP/providerA-000000c2”, “0?Set(CDR(recordingfile)=)”) in new stack
– Executing [s@macro-hangupcall:4] NoOp(“SIP/providerA-000000c2”, "SIP/MLTBELSIP-000000c3 montior file= ") in new stack
– Executing [s@macro-hangupcall:5] GotoIf(“SIP/providerA-000000c2”, “1?skipagi”) in new stack
– Goto (macro-hangupcall,s,7)
– Executing [s@macro-hangupcall:7] Hangup(“SIP/providerA-000000c2”, “”) in new stack
== Spawn extension (macro-hangupcall, s, 7) exited non-zero on ‘SIP/providerA-000000c2’ in macro ‘hangupcall’
== Spawn extension (from-internal, h, 1) exited non-zero on ‘SIP/providerA-000000c2’

PBX “B”:

== Using SIP RTP TOS bits 184
== Using SIP RTP CoS mark 5
> 0x7fc1005a09c0 – Strict RTP learning after remote address set to: 10.10.10.10:17798
– Executing [790@from-trunk:1] Set(“SIP/branchpbx-00000080”, “__FROM_DID=790”) in new stack
– Executing [790@from-trunk:2] NoOp(“SIP/branchpbx-00000080”, “Received an unknown call with DID set to 790”) in new stack
– Executing [790@from-trunk:3] Goto(“SIP/branchpbx-00000080”, “s,a2”) in new stack
– Goto (from-trunk,s,2)
– Executing [s@from-trunk:2] Answer(“SIP/branchpbx-00000080”, “”) in new stack
> 0x7fc1005a09c0 – Strict RTP switching to RTP target address 10.10.10.10:17798 as source
– Executing [s@from-trunk:3] Log(“SIP/branchpbx-00000080”, “WARNING,Friendly Scanner from 10.10.10.10”) in new stack
[2019-06-11 06:15:30] WARNING[38636][C-0000004a]: Ext. s:3 @ from-trunk: Friendly Scanner from 10.10.10.10
– Executing [s@from-trunk:4] Wait(“SIP/branchpbx-00000080”, “2”) in new stack
– Executing [s@from-trunk:5] Playback(“SIP/branchpbx-00000080”, “ss-noservice”) in new stack
– <SIP/branchpbx-00000080> Playing ‘ss-noservice.ulaw’ (language ‘en’)
> 0x7fc1005a09c0 – Strict RTP learning complete - Locking on source address 10.10.10.10:17798
– Executing [s@from-trunk:6] SayAlpha(“SIP/branchpbx-00000080”, “790”) in new stack
– <SIP/branchpbx-00000080> Playing ‘digits/7.ulaw’ (language ‘en’)
– <SIP/branchpbx-00000080> Playing ‘digits/9.ulaw’ (language ‘en’)
== Spawn extension (from-trunk, s, 6) exited non-zero on ‘SIP/branchpbx-00000080’
– Executing [h@from-trunk:1] Macro(“SIP/branchpbx-00000080”, “hangupcall,”) in new stack
– Executing [s@macro-hangupcall:1] GotoIf(“SIP/branchpbx-00000080”, “1?theend”) in new stack
– Goto (macro-hangupcall,s,3)
– Executing [s@macro-hangupcall:3] ExecIf(“SIP/branchpbx-00000080”, “0?Set(CDR(recordingfile)=)”) in new stack
– Executing [s@macro-hangupcall:4] NoOp(“SIP/branchpbx-00000080”, " montior file= ") in new stack
– Executing [s@macro-hangupcall:5] GotoIf(“SIP/branchpbx-00000080”, “1?skipagi”) in new stack
– Goto (macro-hangupcall,s,7)
– Executing [s@macro-hangupcall:7] Hangup(“SIP/branchpbx-00000080”, “”) in new stack
== Spawn extension (macro-hangupcall, s, 7) exited non-zero on ‘SIP/branchpbx-00000080’ in macro ‘hangupcall’
== Spawn extension (from-trunk, h, 1) exited non-zero on ‘SIP/branchpbx-00000080’

This has to be set as a ring group in PBX A. The extensions in PBX B would need to be added as the actual ring group (not bouncing between groups like A1 to B1 etc) for the actual setting in PBX A. PBX B needs no additional settings for this to work.

Thanks DieselKrypto for the suggestion.

I setup a new ring group in PBX “A” and configured the routes for the ring group members located on PBX “B” . When I call the new ring group on PBX “A” via the IVR I get the following:

The ring group members are 713 and 702 on PBX “B”. The extension state is coming back as ExtensionState 4 (Unavailable) - even though I can dial 713 and 702 from PBX “A”

– Executing [s@macro-dial:4] ExecIf("SIP/providerA-000000cc", "0?Set(ALERT_INFO=)") in new stack

– Executing [s@macro-dial:5] ExecIf("SIP/providerA-000000cc", "0?Set(CHANNEL(musicclass)=)") in new stack

– Executing [s@macro-dial:6] AGI("SIP/providerA-000000cc", "dialparties.agi") in new stack

– Launched AGI Script /var/lib/asterisk/agi-bin/dialparties.agi

dialparties.agi: Starting New Dialparties.agi

dialparties.agi: Caller ID name is ‘44862417600’ number is ‘44862417600’

dialparties.agi: CW Ignore is:

dialparties.agi: CF Ignore is:

dialparties.agi: CW IN_USE/BUSY is: 1

> dialparties.agi: USE_CONFIRMATION: ‘FALSE’

> dialparties.agi: RINGGROUP_INDEX: ‘’

dialparties.agi: Methodology of ring is ‘ringall’

– dialparties.agi: Added extension 713 to extension map

– dialparties.agi: Added extension 702 to extension map

– dialparties.agi: Extension 713 cf is disabled

– dialparties.agi: Extension 702 cf is disabled

– dialparties.agi: Extension 713 do not disturb is disabled

– dialparties.agi: Extension 702 do not disturb is disabled

> dialparties.agi: extnum 713 has: cw: 0; hascfb: 0 [] hascfu: 0 []

dialparties.agi: EXTENSION_STATE: 4 (UNKNOWN)

dialparties.agi: Extension 713 has ExtensionState: 4

– dialparties.agi: Checking CW and CFB status for extension 713

dialparties.agi: Extension 713 is not available to be called

> dialparties.agi: extnum 702 has: cw: 0; hascfb: 0 [] hascfu: 0 []

dialparties.agi: EXTENSION_STATE: 4 (UNKNOWN)

dialparties.agi: Extension 702 has ExtensionState: 4

– dialparties.agi: Checking CW and CFB status for extension 702

dialparties.agi: Extension 702 is not available to be called

– dialparties.agi: Filtered ARG3:

> dialparties.agi: NODEST: 601 adding M(auto-blkvm) to dialopts: TtrM(auto-blkvm)

> dialparties.agi: NODEST: 601 blkvm enabled macro already in dialopts: TtrM(auto-blkvm)

dialparties.agi: Setting default NOANSWER DIALSTATUS since no extensions available

dialparties.agi: RVOL_MODE ‘’

dialparties.agi: RVOL is:

dialparties.agi: RVOLPARENT is:

– <SIP/providerA-000000cc>AGI Script dialparties.agi completed, returning 0

Try appending the extension number with a ‘#’, so ‘790#’ (without quotes), see if that works.

Also, check out this guide.

https://wiki.freepbx.org/pages/viewpage.action?pageId=4161588

The simplest fix is to use your original setup (with the ring group on PBX B) and change the context for the incoming trunk from PBX A to from-internal so 790 will be recognized and called. The from-trunk context allows only extension numbers.

Thank you for your support DieselKrypto and Stewart1,

Changing the trunk context to from-internal (was set to from-trunk) resolved the issue.

Appreciate your help here.

ONE WARNING!

Changing the trunk context to “from-internal” also means that anyone that has access to that context (say through an IVR with “direct dial” enabled) also has the opportunity to place calls from your system to the PSTN.

1 Like

Good catch cynjut, I will review this.

Yes, it’s certainly possible to inadvertently create a serious vulnerability. If the Outbound Route(s) on A that access the trunk in question allow only extensions or ring groups on B, you should be reasonably safe.

If you are still concerned, create a custom context that includes only the resources that PBX A is authorized to use.

Depending on your trunking providers, rates, etc., you might intentionally want to allow users on A to make some outgoing calls on B. In that case, set up the routes to disallow international or other expensive destinations.

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.