Building a PRI gateway

Do to physical location limitations, I’m need to have all my PRI’s in one location and the PBX in a different location.

So I’m thinking of building a FreePBX box loaded with all my PRI cards and just create an IAX trunk between that box and the actual PBX.

I dialed one of my DNIS numbers, 8772200456 and got Alisson’s recording so the calls are making it into the gateway box.

I setup an inbound route for 8772200456 and set the destination to the IAX trunk.

Then I Dialed the number and the call made it into the the gateway, then to the PBX but then, the pbx tried calling that number out and then back into the gateway and so on and so forth.

I thought perhaps because I didn’t create an inbound route for it in the PBX so I made an inbound route for 8772200456 and sent it to the IVR. I dialed the gateway but go thrown into that loop again.

Any ideas what I may be doing wrong?

FreePBX Distro 14 on the gateway and Distro 13 on the PBX

Wrong context, you want “from-trunk” on the far end of the IAX trunk.

On the Gateway
Trunk Name: ToPBX

host=10.255.100.230
type=friend
trunk=yes
secret=notsecure
qualify=yes
insecure=port,invite
context=from-internal
auth=md5
requirecalltoken=no

On the PBX
FromGateway

host=10.255.102.228
type=friend
trunk=yes
secret=notsecure
qualify=yes
insecure=port,invite
context=from-trunk
auth=md5
requirecalltoken=no

-- Accepting call from '2147620020' to '8772200456' on channel 0/7, span 1
-- Executing [8772200456@from-digital:1] Set("DAHDI/i1/2147620020-1e", "__DIRECTION=INBOUND") in new stack
-- Executing [8772200456@from-digital:2] Gosub("DAHDI/i1/2147620020-1e", "sub-record-check,s,1(in,8772200456,dontcare)") in new stack
-- Executing [s@sub-record-check:1] GotoIf("DAHDI/i1/2147620020-1e", "0?initialized") in new stack
-- Executing [s@sub-record-check:2] Set("DAHDI/i1/2147620020-1e", "__REC_STATUS=INITIALIZED") in new stack
-- Executing [s@sub-record-check:3] Set("DAHDI/i1/2147620020-1e", "NOW=1502929888") in new stack
-- Executing [s@sub-record-check:4] Set("DAHDI/i1/2147620020-1e", "__DAY=17") in new stack
-- Executing [s@sub-record-check:5] Set("DAHDI/i1/2147620020-1e", "__MONTH=08") in new stack
-- Executing [s@sub-record-check:6] Set("DAHDI/i1/2147620020-1e", "__YEAR=2017") in new stack
-- Executing [s@sub-record-check:7] Set("DAHDI/i1/2147620020-1e", "__TIMESTR=20170817-003128") in new stack
-- Executing [s@sub-record-check:8] Set("DAHDI/i1/2147620020-1e", "__FROMEXTEN=unknown") in new stack
-- Executing [s@sub-record-check:9] Set("DAHDI/i1/2147620020-1e", "__MON_FMT=wav") in new stack
-- Executing [s@sub-record-check:10] NoOp("DAHDI/i1/2147620020-1e", "Recordings initialized") in new stack
-- Executing [s@sub-record-check:11] ExecIf("DAHDI/i1/2147620020-1e", "0?Set(ARG3=dontcare)") in new stack
-- Executing [s@sub-record-check:12] Set("DAHDI/i1/2147620020-1e", "REC_POLICY_MODE_SAVE=") in new stack
-- Executing [s@sub-record-check:13] ExecIf("DAHDI/i1/2147620020-1e", "0?Set(REC_STATUS=NO)") in new stack
-- Executing [s@sub-record-check:14] GotoIf("DAHDI/i1/2147620020-1e", "2?checkaction") in new stack
-- Goto (sub-record-check,s,17)
-- Executing [s@sub-record-check:17] GotoIf("DAHDI/i1/2147620020-1e", "1?sub-record-check,in,1") in new stack
-- Goto (sub-record-check,in,1)
-- Executing [in@sub-record-check:1] NoOp("DAHDI/i1/2147620020-1e", "Inbound Recording Check to 8772200456") in new stack
-- Executing [in@sub-record-check:2] Set("DAHDI/i1/2147620020-1e", "FROMEXTEN=unknown") in new stack
-- Executing [in@sub-record-check:3] ExecIf("DAHDI/i1/2147620020-1e", "10?Set(FROMEXTEN=2147620020)") in new stack
-- Executing [in@sub-record-check:4] Gosub("DAHDI/i1/2147620020-1e", "recordcheck,1(dontcare,in,8772200456)") in new stack
-- Executing [recordcheck@sub-record-check:1] NoOp("DAHDI/i1/2147620020-1e", "Starting recording check against dontcare") in new stack
-- Executing [recordcheck@sub-record-check:2] Goto("DAHDI/i1/2147620020-1e", "dontcare") in new stack
-- Goto (sub-record-check,recordcheck,3)
-- Executing [recordcheck@sub-record-check:3] Return("DAHDI/i1/2147620020-1e", "") in new stack
-- Executing [in@sub-record-check:5] Return("DAHDI/i1/2147620020-1e", "") in new stack
-- Executing [8772200456@from-digital:3] Gosub("DAHDI/i1/2147620020-1e", "app-blacklist-check,s,1()") in new stack
-- Executing [s@app-blacklist-check:1] GotoIf("DAHDI/i1/2147620020-1e", "0?blacklisted") in new stack
-- Executing [s@app-blacklist-check:2] Set("DAHDI/i1/2147620020-1e", "CALLED_BLACKLIST=1") in new stack
-- Executing [s@app-blacklist-check:3] Return("DAHDI/i1/2147620020-1e", "") in new stack
-- Executing [8772200456@from-digital:4] Set("DAHDI/i1/2147620020-1e", "__FROM_DID=8772200456") in new stack
-- Executing [8772200456@from-digital:5] Set("DAHDI/i1/2147620020-1e", "CDR(did)=8772200456") in new stack
-- Executing [8772200456@from-digital:6] ExecIf("DAHDI/i1/2147620020-1e", "1 ?Set(CALLERID(name)=2147620020)") in new stack
-- Executing [8772200456@from-digital:7] Set("DAHDI/i1/2147620020-1e", "__MOHCLASS=") in new stack
-- Executing [8772200456@from-digital:8] Set("DAHDI/i1/2147620020-1e", "__REVERSAL_REJECT=FALSE") in new stack
-- Executing [8772200456@from-digital:9] GotoIf("DAHDI/i1/2147620020-1e", "1?post-reverse-charge") in new stack
-- Goto (from-digital,8772200456,11)
-- Executing [8772200456@from-digital:11] NoOp("DAHDI/i1/2147620020-1e", "") in new stack
-- Executing [8772200456@from-digital:12] Set("DAHDI/i1/2147620020-1e", "__CALLINGNAMEPRES_SV=allowed") in new stack
-- Executing [8772200456@from-digital:13] Set("DAHDI/i1/2147620020-1e", "__CALLINGNUMPRES_SV=allowed") in new stack
-- Executing [8772200456@from-digital:14] Set("DAHDI/i1/2147620020-1e", "CALLERID(name-pres)=allowed_not_screened") in new stack
-- Executing [8772200456@from-digital:15] Set("DAHDI/i1/2147620020-1e", "CALLERID(num-pres)=allowed_not_screened") in new stack
-- Executing [8772200456@from-digital:16] NoOp("DAHDI/i1/2147620020-1e", "CallerID Entry Point") in new stack
-- Executing [8772200456@from-digital:17] Set("DAHDI/i1/2147620020-1e", "__CRM_DIRECTION=INBOUND") in new stack
-- Executing [8772200456@from-digital:18] Set("DAHDI/i1/2147620020-1e", "__CRM_SOURCE=2147620020") in new stack
-- Executing [8772200456@from-digital:19] Set("DAHDI/i1/2147620020-1e", "__CRM_LINKEDID=1502929888.56") in new stack
-- Executing [8772200456@from-digital:20] ExecIf("DAHDI/i1/2147620020-1e", "1?Set(CHANNEL(hangup_handler_push)=crm-hangup,s,1)") in new stack
-- Executing [8772200456@from-digital:21] Goto("DAHDI/i1/2147620020-1e", "ext-trunk,1,1") in new stack
-- Goto (ext-trunk,1,1)
-- Executing [1@ext-trunk:1] Set("DAHDI/i1/2147620020-1e", "TDIAL_STRING=IAX2/ToPBX") in new stack
-- Executing [1@ext-trunk:2] Set("DAHDI/i1/2147620020-1e", "DIAL_TRUNK=1") in new stack
-- Executing [1@ext-trunk:3] Goto("DAHDI/i1/2147620020-1e", "ext-trunk,tdial,1") in new stack
-- Goto (ext-trunk,tdial,1)
-- Executing [tdial@ext-trunk:1] Set("DAHDI/i1/2147620020-1e", "OUTBOUND_GROUP=OUT_1") in new stack
-- Executing [tdial@ext-trunk:2] GotoIf("DAHDI/i1/2147620020-1e", "1?nomax") in new stack
-- Goto (ext-trunk,tdial,4)
-- Executing [tdial@ext-trunk:4] ExecIf("DAHDI/i1/2147620020-1e", "1?Set(CALLERPRES(name-pres)=allowed)") in new stack
-- Executing [tdial@ext-trunk:5] ExecIf("DAHDI/i1/2147620020-1e", "1?Set(CALLERPRES(num-pres)=allowed)") in new stack
-- Executing [tdial@ext-trunk:6] Set("DAHDI/i1/2147620020-1e", "DIAL_NUMBER=8772200456") in new stack
-- Executing [tdial@ext-trunk:7] GosubIf("DAHDI/i1/2147620020-1e", "0?sub-flp-1,s,1()") in new stack
-- Executing [tdial@ext-trunk:8] Set("DAHDI/i1/2147620020-1e", "OUTNUM=8772200456") in new stack
-- Executing [tdial@ext-trunk:9] Set("DAHDI/i1/2147620020-1e", "DIAL_TRUNK_OPTIONS=T") in new stack
-- Executing [tdial@ext-trunk:10] Dial("DAHDI/i1/2147620020-1e", "IAX2/ToPBX/8772200456,300,T") in new stack
-- Called IAX2/ToPBX/8772200456
-- Call accepted by 10.255.100.230:4569 (format ulaw)
-- Format for call is (ulaw)
-- IAX2/ToPBX-28329 is proceeding passing it to DAHDI/i1/2147620020-1e
-- IAX2/ToPBX-28329 is making progress passing it to DAHDI/i1/2147620020-1e
-- Accepting call from '8887272325' to '8772200456' on channel 0/8, span 1
-- Executing [8772200456@from-digital:1] Set("DAHDI/i1/8887272325-1f", "__DIRECTION=INBOUND") in new stack
-- Executing [8772200456@from-digital:2] Gosub("DAHDI/i1/8887272325-1f", "sub-record-check,s,1(in,8772200456,dontcare)") in new stack
-- Executing [s@sub-record-check:1] GotoIf("DAHDI/i1/8887272325-1f", "0?initialized") in new stack
-- Executing [s@sub-record-check:2] Set("DAHDI/i1/8887272325-1f", "__REC_STATUS=INITIALIZED") in new stack
-- Executing [s@sub-record-check:3] Set("DAHDI/i1/8887272325-1f", "NOW=1502929890") in new stack
-- Executing [s@sub-record-check:4] Set("DAHDI/i1/8887272325-1f", "__DAY=17") in new stack
-- Executing [s@sub-record-check:5] Set("DAHDI/i1/8887272325-1f", "__MONTH=08") in new stack
-- Executing [s@sub-record-check:6] Set("DAHDI/i1/8887272325-1f", "__YEAR=2017") in new stack
-- Executing [s@sub-record-check:7] Set("DAHDI/i1/8887272325-1f", "__TIMESTR=20170817-003130") in new stack
-- Executing [s@sub-record-check:8] Set("DAHDI/i1/8887272325-1f", "__FROMEXTEN=unknown") in new stack
-- Executing [s@sub-record-check:9] Set("DAHDI/i1/8887272325-1f", "__MON_FMT=wav") in new stack
-- Executing [s@sub-record-check:10] NoOp("DAHDI/i1/8887272325-1f", "Recordings initialized") in new stack
-- Executing [s@sub-record-check:11] ExecIf("DAHDI/i1/8887272325-1f", "0?Set(ARG3=dontcare)") in new stack
-- Executing [s@sub-record-check:12] Set("DAHDI/i1/8887272325-1f", "REC_POLICY_MODE_SAVE=") in new stack
-- Executing [s@sub-record-check:13] ExecIf("DAHDI/i1/8887272325-1f", "0?Set(REC_STATUS=NO)") in new stack
-- Executing [s@sub-record-check:14] GotoIf("DAHDI/i1/8887272325-1f", "2?checkaction") in new stack
-- Goto (sub-record-check,s,17)
-- Executing [s@sub-record-check:17] GotoIf("DAHDI/i1/8887272325-1f", "1?sub-record-check,in,1") in new stack
-- Goto (sub-record-check,in,1)
-- Executing [in@sub-record-check:1] NoOp("DAHDI/i1/8887272325-1f", "Inbound Recording Check to 8772200456") in new stack
-- Executing [in@sub-record-check:2] Set("DAHDI/i1/8887272325-1f", "FROMEXTEN=unknown") in new stack
-- Executing [in@sub-record-check:3] ExecIf("DAHDI/i1/8887272325-1f", "10?Set(FROMEXTEN=8887272325)") in new stack
-- Executing [in@sub-record-check:4] Gosub("DAHDI/i1/8887272325-1f", "recordcheck,1(dontcare,in,8772200456)") in new stack
-- Executing [recordcheck@sub-record-check:1] NoOp("DAHDI/i1/8887272325-1f", "Starting recording check against dontcare") in new stack
-- Executing [recordcheck@sub-record-check:2] Goto("DAHDI/i1/8887272325-1f", "dontcare") in new stack
-- Goto (sub-record-check,recordcheck,3)
-- Executing [recordcheck@sub-record-check:3] Return("DAHDI/i1/8887272325-1f", "") in new stack
-- Executing [in@sub-record-check:5] Return("DAHDI/i1/8887272325-1f", "") in new stack
-- Executing [8772200456@from-digital:3] Gosub("DAHDI/i1/8887272325-1f", "app-blacklist-check,s,1()") in new stack
-- Executing [s@app-blacklist-check:1] GotoIf("DAHDI/i1/8887272325-1f", "0?blacklisted") in new stack
-- Executing [s@app-blacklist-check:2] Set("DAHDI/i1/8887272325-1f", "CALLED_BLACKLIST=1") in new stack
-- Executing [s@app-blacklist-check:3] Return("DAHDI/i1/8887272325-1f", "") in new stack
-- Executing [8772200456@from-digital:4] Set("DAHDI/i1/8887272325-1f", "__FROM_DID=8772200456") in new stack
-- Executing [8772200456@from-digital:5] Set("DAHDI/i1/8887272325-1f", "CDR(did)=8772200456") in new stack
-- Executing [8772200456@from-digital:6] ExecIf("DAHDI/i1/8887272325-1f", "1 ?Set(CALLERID(name)=8887272325)") in new stack
-- Executing [8772200456@from-digital:7] Set("DAHDI/i1/8887272325-1f", "__MOHCLASS=") in new stack
-- Executing [8772200456@from-digital:8] Set("DAHDI/i1/8887272325-1f", "__REVERSAL_REJECT=FALSE") in new stack
-- Executing [8772200456@from-digital:9] GotoIf("DAHDI/i1/8887272325-1f", "1?post-reverse-charge") in new stack
-- Goto (from-digital,8772200456,11)
-- Executing [8772200456@from-digital:11] NoOp("DAHDI/i1/8887272325-1f", "") in new stack
-- Executing [8772200456@from-digital:12] Set("DAHDI/i1/8887272325-1f", "__CALLINGNAMEPRES_SV=allowed_failed_screen") in new stack
-- Executing [8772200456@from-digital:13] Set("DAHDI/i1/8887272325-1f", "__CALLINGNUMPRES_SV=allowed_failed_screen") in new stack
-- Executing [8772200456@from-digital:14] Set("DAHDI/i1/8887272325-1f", "CALLERID(name-pres)=allowed_not_screened") in new stack
-- Executing [8772200456@from-digital:15] Set("DAHDI/i1/8887272325-1f", "CALLERID(num-pres)=allowed_not_screened") in new stack
-- Executing [8772200456@from-digital:16] NoOp("DAHDI/i1/8887272325-1f", "CallerID Entry Point") in new stack
-- Executing [8772200456@from-digital:17] Set("DAHDI/i1/8887272325-1f", "__CRM_DIRECTION=INBOUND") in new stack
-- Executing [8772200456@from-digital:18] Set("DAHDI/i1/8887272325-1f", "__CRM_SOURCE=8887272325") in new stack
-- Executing [8772200456@from-digital:19] Set("DAHDI/i1/8887272325-1f", "__CRM_LINKEDID=1502929890.58") in new stack
-- Executing [8772200456@from-digital:20] ExecIf("DAHDI/i1/8887272325-1f", "1?Set(CHANNEL(hangup_handler_push)=crm-hangup,s,1)") in new stack
-- Executing [8772200456@from-digital:21] Goto("DAHDI/i1/8887272325-1f", "ext-trunk,1,1") in new stack
-- Goto (ext-trunk,1,1)
-- Executing [1@ext-trunk:1] Set("DAHDI/i1/8887272325-1f", "TDIAL_STRING=IAX2/ToPBX") in new stack
-- Executing [1@ext-trunk:2] Set("DAHDI/i1/8887272325-1f", "DIAL_TRUNK=1") in new stack
-- Executing [1@ext-trunk:3] Goto("DAHDI/i1/8887272325-1f", "ext-trunk,tdial,1") in new stack
-- Goto (ext-trunk,tdial,1)
-- Executing [tdial@ext-trunk:1] Set("DAHDI/i1/8887272325-1f", "OUTBOUND_GROUP=OUT_1") in new stack
-- Executing [tdial@ext-trunk:2] GotoIf("DAHDI/i1/8887272325-1f", "1?nomax") in new stack
-- Goto (ext-trunk,tdial,4)
-- Executing [tdial@ext-trunk:4] ExecIf("DAHDI/i1/8887272325-1f", "1?Set(CALLERPRES(name-pres)=allowed_failed_screen)") in new stack
-- Executing [tdial@ext-trunk:5] ExecIf("DAHDI/i1/8887272325-1f", "1?Set(CALLERPRES(num-pres)=allowed_failed_screen)") in new stack
-- Executing [tdial@ext-trunk:6] Set("DAHDI/i1/8887272325-1f", "DIAL_NUMBER=8772200456") in new stack
-- Executing [tdial@ext-trunk:7] GosubIf("DAHDI/i1/8887272325-1f", "0?sub-flp-1,s,1()") in new stack
-- Executing [tdial@ext-trunk:8] Set("DAHDI/i1/8887272325-1f", "OUTNUM=8772200456") in new stack
-- Executing [tdial@ext-trunk:9] Set("DAHDI/i1/8887272325-1f", "DIAL_TRUNK_OPTIONS=T") in new stack
-- Executing [tdial@ext-trunk:10] Dial("DAHDI/i1/8887272325-1f", "IAX2/ToPBX/8772200456,300,T") in new stack
-- Called IAX2/ToPBX/8772200456
-- Call accepted by 10.255.100.230:4569 (format ulaw)
-- Format for call is (ulaw)
-- IAX2/ToPBX-20890 is proceeding passing it to DAHDI/i1/8887272325-1f
-- IAX2/ToPBX-20890 is making progress passing it to DAHDI/i1/8887272325-1f
-- Span 1: Channel 0/7 got hangup request, cause 31
-- Hungup 'IAX2/ToPBX-28329'

== Spawn extension (ext-trunk, tdial, 10) exited non-zero on ‘DAHDI/i1/2147620020-1e’
– DAHDI/i1/2147620020-1e Internal Gosub(crm-hangup,s,1) start
– Executing [s@crm-hangup:1] NoOp(“DAHDI/i1/2147620020-1e”, “Sending Hangup to CRM”) in new stack
– Executing [s@crm-hangup:2] NoOp(“DAHDI/i1/2147620020-1e”, “HANGUP CAUSE: 31”) in new stack
– Executing [s@crm-hangup:3] ExecIf(“DAHDI/i1/2147620020-1e”, “0?Set(__CRM_VOICEMAIL=)”) in new stack
– Executing [s@crm-hangup:4] NoOp(“DAHDI/i1/2147620020-1e”, “MASTER CHANNEL: 1502929888.56 = 1502929888.56”) in new stack
– Executing [s@crm-hangup:5] GotoIf(“DAHDI/i1/2147620020-1e”, “0?return”) in new stack
– Executing [s@crm-hangup:6] Set(“DAHDI/i1/2147620020-1e”, “__CRM_HANGUP=1”) in new stack
– Executing [s@crm-hangup:7] AGI(“DAHDI/i1/2147620020-1e”, “sangomacrm.agi”) in new stack
– Launched AGI Script /var/lib/asterisk/agi-bin/sangomacrm.agi
– <DAHDI/i1/2147620020-1e>AGI Script sangomacrm.agi completed, returning 0
– Executing [s@crm-hangup:8] Return(“DAHDI/i1/2147620020-1e”, “”) in new stack
== Spawn extension (ext-trunk, tdial, 10) exited non-zero on ‘DAHDI/i1/2147620020-1e’
– DAHDI/i1/2147620020-1e Internal Gosub(crm-hangup,s,1) complete GOSUB_RETVAL=
– Hungup ‘DAHDI/i1/2147620020-1e’
– Accepting call from ‘8887272325’ to ‘8772200456’ on channel 0/9, span 1
– Executing [8772200456@from-digital:1] Set(“DAHDI/i1/8887272325-20”, “__DIRECTION=INBOUND”) in new stack
– Executing [8772200456@from-digital:2] Gosub(“DAHDI/i1/8887272325-20”, “sub-record-check,s,1(in,8772200456,dontcare)”) in new stack
– Executing [s@sub-record-check:1] GotoIf(“DAHDI/i1/8887272325-20”, “0?initialized”) in new stack
– Executing [s@sub-record-check:2] Set(“DAHDI/i1/8887272325-20”, “__REC_STATUS=INITIALIZED”) in new stack
– Executing [s@sub-record-check:3] Set(“DAHDI/i1/8887272325-20”, “NOW=1502929894”) in new stack
– Executing [s@sub-record-check:4] Set(“DAHDI/i1/8887272325-20”, “__DAY=17”) in new stack
– Executing [s@sub-record-check:5] Set(“DAHDI/i1/8887272325-20”, “__MONTH=08”) in new stack
– Executing [s@sub-record-check:6] Set(“DAHDI/i1/8887272325-20”, “__YEAR=2017”) in new stack
– Executing [s@sub-record-check:7] Set(“DAHDI/i1/8887272325-20”, “__TIMESTR=20170817-003134”) in new stack
– Executing [s@sub-record-check:8] Set(“DAHDI/i1/8887272325-20”, “__FROMEXTEN=unknown”) in new stack
– Executing [s@sub-record-check:9] Set(“DAHDI/i1/8887272325-20”, “__MON_FMT=wav”) in new stack
– Executing [s@sub-record-check:10] NoOp(“DAHDI/i1/8887272325-20”, “Recordings initialized”) in new stack
– Executing [s@sub-record-check:11] ExecIf(“DAHDI/i1/8887272325-20”, “0?Set(ARG3=dontcare)”) in new stack
– Executing [s@sub-record-check:12] Set(“DAHDI/i1/8887272325-20”, “REC_POLICY_MODE_SAVE=”) in new stack
– Executing [s@sub-record-check:13] ExecIf(“DAHDI/i1/8887272325-20”, “0?Set(REC_STATUS=NO)”) in new stack
– Executing [s@sub-record-check:14] GotoIf(“DAHDI/i1/8887272325-20”, “2?checkaction”) in new stack
– Goto (sub-record-check,s,17)
– Executing [s@sub-record-check:17] GotoIf(“DAHDI/i1/8887272325-20”, “1?sub-record-check,in,1”) in new stack
– Goto (sub-record-check,in,1)
– Executing [in@sub-record-check:1] NoOp(“DAHDI/i1/8887272325-20”, “Inbound Recording Check to 8772200456”) in new stack
– Executing [in@sub-record-check:2] Set(“DAHDI/i1/8887272325-20”, “FROMEXTEN=unknown”) in new stack
– Executing [in@sub-record-check:3] ExecIf(“DAHDI/i1/8887272325-20”, “10?Set(FROMEXTEN=8887272325)”) in new stack
– Executing [in@sub-record-check:4] Gosub(“DAHDI/i1/8887272325-20”, “recordcheck,1(dontcare,in,8772200456)”) in new stack
– Executing [recordcheck@sub-record-check:1] NoOp(“DAHDI/i1/8887272325-20”, “Starting recording check against dontcare”) in new stack
– Executing [recordcheck@sub-record-check:2] Goto(“DAHDI/i1/8887272325-20”, “dontcare”) in new stack
– Goto (sub-record-check,recordcheck,3)
– Executing [recordcheck@sub-record-check:3] Return(“DAHDI/i1/8887272325-20”, “”) in new stack
– Executing [in@sub-record-check:5] Return(“DAHDI/i1/8887272325-20”, “”) in new stack
– Executing [8772200456@from-digital:3] Gosub(“DAHDI/i1/8887272325-20”, “app-blacklist-check,s,1()”) in new stack
– Executing [s@app-blacklist-check:1] GotoIf(“DAHDI/i1/8887272325-20”, “0?blacklisted”) in new stack
– Executing [s@app-blacklist-check:2] Set(“DAHDI/i1/8887272325-20”, “CALLED_BLACKLIST=1”) in new stack
– Executing [s@app-blacklist-check:3] Return(“DAHDI/i1/8887272325-20”, “”) in new stack
– Executing [8772200456@from-digital:4] Set(“DAHDI/i1/8887272325-20”, “__FROM_DID=8772200456”) in new stack
– Executing [8772200456@from-digital:5] Set(“DAHDI/i1/8887272325-20”, “CDR(did)=8772200456”) in new stack
– Executing [8772200456@from-digital:6] ExecIf(“DAHDI/i1/8887272325-20”, “1 ?Set(CALLERID(name)=8887272325)”) in new stack
– Executing [8772200456@from-digital:7] Set(“DAHDI/i1/8887272325-20”, “__MOHCLASS=”) in new stack
– Executing [8772200456@from-digital:8] Set(“DAHDI/i1/8887272325-20”, “__REVERSAL_REJECT=FALSE”) in new stack
– Executing [8772200456@from-digital:9] GotoIf(“DAHDI/i1/8887272325-20”, “1?post-reverse-charge”) in new stack
– Goto (from-digital,8772200456,11)
– Executing [8772200456@from-digital:11] NoOp(“DAHDI/i1/8887272325-20”, “”) in new stack
– Executing [8772200456@from-digital:12] Set(“DAHDI/i1/8887272325-20”, “__CALLINGNAMEPRES_SV=allowed”) in new stack
– Executing [8772200456@from-digital:13] Set(“DAHDI/i1/8887272325-20”, “__CALLINGNUMPRES_SV=allowed”) in new stack
– Executing [8772200456@from-digital:14] Set(“DAHDI/i1/8887272325-20”, “CALLERID(name-pres)=allowed_not_screened”) in new stack
– Executing [8772200456@from-digital:15] Set(“DAHDI/i1/8887272325-20”, “CALLERID(num-pres)=allowed_not_screened”) in new stack
– Executing [8772200456@from-digital:16] NoOp(“DAHDI/i1/8887272325-20”, “CallerID Entry Point”) in new stack
– Executing [8772200456@from-digital:17] Set(“DAHDI/i1/8887272325-20”, “__CRM_DIRECTION=INBOUND”) in new stack
– Executing [8772200456@from-digital:18] Set(“DAHDI/i1/8887272325-20”, “__CRM_SOURCE=8887272325”) in new stack
– Executing [8772200456@from-digital:19] Set(“DAHDI/i1/8887272325-20”, “__CRM_LINKEDID=1502929894.60”) in new stack
– Executing [8772200456@from-digital:20] ExecIf(“DAHDI/i1/8887272325-20”, “1?Set(CHANNEL(hangup_handler_push)=crm-hangup,s,1)”) in new stack
– Executing [8772200456@from-digital:21] Goto(“DAHDI/i1/8887272325-20”, “ext-trunk,1,1”) in new stack
– Goto (ext-trunk,1,1)
– Executing [1@ext-trunk:1] Set(“DAHDI/i1/8887272325-20”, “TDIAL_STRING=IAX2/ToPBX”) in new stack
– Executing [1@ext-trunk:2] Set(“DAHDI/i1/8887272325-20”, “DIAL_TRUNK=1”) in new stack
– Executing [1@ext-trunk:3] Goto(“DAHDI/i1/8887272325-20”, “ext-trunk,tdial,1”) in new stack
– Goto (ext-trunk,tdial,1)
– Executing [tdial@ext-trunk:1] Set(“DAHDI/i1/8887272325-20”, “OUTBOUND_GROUP=OUT_1”) in new stack
– Executing [tdial@ext-trunk:2] GotoIf(“DAHDI/i1/8887272325-20”, “1?nomax”) in new stack
– Goto (ext-trunk,tdial,4)
– Executing [tdial@ext-trunk:4] ExecIf(“DAHDI/i1/8887272325-20”, “1?Set(CALLERPRES(name-pres)=allowed)”) in new stack
– Executing [tdial@ext-trunk:5] ExecIf(“DAHDI/i1/8887272325-20”, “1?Set(CALLERPRES(num-pres)=allowed)”) in new stack
– Executing [tdial@ext-trunk:6] Set(“DAHDI/i1/8887272325-20”, “DIAL_NUMBER=8772200456”) in new stack
– Executing [tdial@ext-trunk:7] GosubIf(“DAHDI/i1/8887272325-20”, “0?sub-flp-1,s,1()”) in new stack
– Executing [tdial@ext-trunk:8] Set(“DAHDI/i1/8887272325-20”, “OUTNUM=8772200456”) in new stack
– Executing [tdial@ext-trunk:9] Set(“DAHDI/i1/8887272325-20”, “DIAL_TRUNK_OPTIONS=T”) in new stack
– Executing [tdial@ext-trunk:10] Dial(“DAHDI/i1/8887272325-20”, “IAX2/ToPBX/8772200456,300,T”) in new stack
– Called IAX2/ToPBX/8772200456
– Call accepted by 10.255.100.230:4569 (format ulaw)
– Format for call is (ulaw)
– Span 1: Channel 0/8 got hangup request, cause 16
– Hungup ‘IAX2/ToPBX-20890’
== Spawn extension (ext-trunk, tdial, 10) exited non-zero on ‘DAHDI/i1/8887272325-1f’
– DAHDI/i1/8887272325-1f Internal Gosub(crm-hangup,s,1) start
– Executing [s@crm-hangup:1] NoOp(“DAHDI/i1/8887272325-1f”, “Sending Hangup to CRM”) in new stack
– Executing [s@crm-hangup:2] NoOp(“DAHDI/i1/8887272325-1f”, “HANGUP CAUSE: 16”) in new stack
– Executing [s@crm-hangup:3] ExecIf(“DAHDI/i1/8887272325-1f”, “0?Set(__CRM_VOICEMAIL=)”) in new stack
– Executing [s@crm-hangup:4] NoOp(“DAHDI/i1/8887272325-1f”, “MASTER CHANNEL: 1502929890.58 = 1502929890.58”) in new stack
– Executing [s@crm-hangup:5] GotoIf(“DAHDI/i1/8887272325-1f”, “0?return”) in new stack
– Executing [s@crm-hangup:6] Set(“DAHDI/i1/8887272325-1f”, “__CRM_HANGUP=1”) in new stack
– Executing [s@crm-hangup:7] AGI(“DAHDI/i1/8887272325-1f”, “sangomacrm.agi”) in new stack
– Launched AGI Script /var/lib/asterisk/agi-bin/sangomacrm.agi
– <DAHDI/i1/8887272325-1f>AGI Script sangomacrm.agi completed, returning 0
– Executing [s@crm-hangup:8] Return(“DAHDI/i1/8887272325-1f”, “”) in new stack
== Spawn extension (ext-trunk, tdial, 10) exited non-zero on ‘DAHDI/i1/8887272325-1f’
– DAHDI/i1/8887272325-1f Internal Gosub(crm-hangup,s,1) complete GOSUB_RETVAL=
– Hungup ‘DAHDI/i1/8887272325-1f’
– Span 1: Channel 0/9 got hangup request, cause 16
– Hungup ‘IAX2/ToPBX-30600’
== Spawn extension (ext-trunk, tdial, 10) exited non-zero on ‘DAHDI/i1/8887272325-20’
– DAHDI/i1/8887272325-20 Internal Gosub(crm-hangup,s,1) start
– Executing [s@crm-hangup:1] NoOp(“DAHDI/i1/8887272325-20”, “Sending Hangup to CRM”) in new stack
– Executing [s@crm-hangup:2] NoOp(“DAHDI/i1/8887272325-20”, “HANGUP CAUSE: 16”) in new stack
– Executing [s@crm-hangup:3] ExecIf(“DAHDI/i1/8887272325-20”, “0?Set(__CRM_VOICEMAIL=)”) in new stack
– Executing [s@crm-hangup:4] NoOp(“DAHDI/i1/8887272325-20”, “MASTER CHANNEL: 1502929894.60 = 1502929894.60”) in new stack
– Executing [s@crm-hangup:5] GotoIf(“DAHDI/i1/8887272325-20”, “0?return”) in new stack
– Executing [s@crm-hangup:6] Set(“DAHDI/i1/8887272325-20”, “__CRM_HANGUP=1”) in new stack
– Executing [s@crm-hangup:7] AGI(“DAHDI/i1/8887272325-20”, “sangomacrm.agi”) in new stack
– Launched AGI Script /var/lib/asterisk/agi-bin/sangomacrm.agi
– <DAHDI/i1/8887272325-20>AGI Script sangomacrm.agi completed, returning 0
– Executing [s@crm-hangup:8] Return(“DAHDI/i1/8887272325-20”, “”) in new stack
== Spawn extension (ext-trunk, tdial, 10) exited non-zero on ‘DAHDI/i1/8887272325-20’
– DAHDI/i1/8887272325-20 Internal Gosub(crm-hangup,s,1) complete GOSUB_RETVAL=
– Hungup ‘DAHDI/i1/8887272325-20’

Thanks Lorne,
I tried setting the context of the gateway IAX trunk as from-internal and the context of the PBX IAX trunk to from-trunk but same results. I also tried setting both as from-trunk and same behavior each time.