Suppress CID with call forwarding

I’ve tried multiple methods to forward calls placed to an internal extension to be forwarded to an external number - misc. destination, custom extension, custom ring group, UCP call forward, etc. - and all methods are passing the incoming CID through to the outbound trunk. The problem is that our trunks will only allow internally owned DIDs to be passed to the SIP trunk instead of a forwarded CID or any other falsified number in the header.

Is there a FreePBX setting that disables the passing of a forwarded CID to the outbound trunk? If so, I haven’t been able to find it. I have looked at at least 6 other posts in these forums about this, but they all refer to doing this the reverse way ie. they WANT to pass the forwarded CID.

I have the correct DID configured on both the outbound route and the trunk, and it is passed correctly on all endpoint-created outbound calls. But when the call is being forwarded using one method or another, it is ignoring this and overriding it with the CID of the forwarded call. I confirmed this by watching the call progress in the Asterisk console logging:
Calling CID - 3135984310
Inbound DID dialed - 3139786090
Forwarding to - 3135644444

       > agi://127.0.0.1/dialparties.agi: Extension 107 has call forward set to +13135644444
       > agi://127.0.0.1/dialparties.agi: Primary ext is CF so disabling mastermode if it was set
       > agi://127.0.0.1/dialparties.agi: extnum +13135644444# has:  cw: 0; hascfb: 0 [] hascfu: 0 []
       > agi://127.0.0.1/dialparties.agi: Built External dialstring component for +13135644444: Local/+13135644444@from-internal/n
    -- agi://127.0.0.1/dialparties.agi: Filtered ARG3: +13135644444
 -- Executing [s@macro-outbound-callerid:30] ExecIf("PJSIP/Twilio-0000fe9c", "1?Set(CALLERID(all)=<+13139786090>)") in new stack
    -- Executing [s@macro-outbound-callerid:31] ExecIf("PJSIP/Twilio-0000fe9c", "1?Set(CALLERID(all)=3135984310 3135984310 <3135984310>)") in new stack
    -- Executing [s@macro-outbound-callerid:32] ExecIf("PJSIP/Twilio-0000fe9c", "0?Set(CALLERID(all)=)") in new stack
    -- Executing [s@macro-outbound-callerid:33] ExecIf("PJSIP/Twilio-0000fe9c", "0?Set(CALLERID(all)=3135984310)") in new stack
    -- Executing [s@macro-outbound-callerid:34] ExecIf("PJSIP/Twilio-0000fe9c", "0?Set(CALLERID(all)=3135984310)") in new stack
    -- Executing [s@macro-outbound-callerid:35] Set("PJSIP/Twilio-0000fe9c", "TIOHIDE=no") in new stack
    -- Executing [s@macro-outbound-callerid:36] ExecIf("PJSIP/Twilio-0000fe9c", "0?Set(CALLERPRES(name-pres)=prohib_passed_screen)") in new stack
    -- Executing [s@macro-outbound-callerid:37] ExecIf("PJSIP/Twilio-0000fe9c", "0?Set(CALLERPRES(num-pres)=prohib_passed_screen)") in new stack
    -- Executing [s@macro-outbound-callerid:38] ExecIf("PJSIP/Twilio-0000fe9c", "0?Set(CALLERPRES(name-pres)=prohib_passed_screen)") in new stack
    -- Executing [s@macro-outbound-callerid:39] ExecIf("PJSIP/Twilio-0000fe9c", "0?Set(CALLERPRES(num-pres)=prohib_passed_screen)") in new stack
    -- Executing [s@macro-outbound-callerid:40] Set("PJSIP/Twilio-0000fe9c", "CDR(outbound_cnum)=3135984310") in new stack
    -- Executing [s@macro-outbound-callerid:41] Set("PJSIP/Twilio-0000fe9c", "CDR(outbound_cnam)=3135984310 3135984310") in new stack
    -- Executing [s@macro-dialout-trunk:14] GosubIf("PJSIP/Twilio-0000fe9c", "0?sub-flp-1,s,1()") in new stack
    -- Executing [s@macro-dialout-trunk:15] Set("PJSIP/Twilio-0000fe9c", "OUTNUM=+13135644444") in new stack
    -- Executing [s@macro-dialout-trunk:16] Set("PJSIP/Twilio-0000fe9c", "custom=PJSIP") in new stack
    -- Executing [s@macro-dialout-trunk:17] ExecIf("PJSIP/Twilio-0000fe9c", "0?Set(DIAL_TRUNK_OPTIONS=M(setmusic^default)T)") in new stack
    -- Executing [s@macro-dialout-trunk:18] ExecIf("PJSIP/Twilio-0000fe9c", "0?Set(DIAL_TRUNK_OPTIONS=TM(confirm))") in new stack
    -- Executing [s@macro-dialout-trunk:19] GotoIf("PJSIP/Twilio-0000fe9c", "1?gocall") in new stack
    -- Goto (macro-dialout-trunk,s,21)
    -- Executing [s@macro-dialout-trunk:21] Macro("PJSIP/Twilio-0000fe9c", "dialout-trunk-predial-hook,") in new stack
    -- Executing [s@macro-dialout-trunk-predial-hook:1] MacroExit("PJSIP/Twilio-0000fe9c", "") in new stack
    -- Executing [s@macro-dialout-trunk:22] GotoIf("PJSIP/Twilio-0000fe9c", "1?skipcrm") in new stack
    -- Goto (macro-dialout-trunk,s,28)
    -- Executing [s@macro-dialout-trunk:28] NoOp("PJSIP/Twilio-0000fe9c", "CRM Finished") in new stack
    -- Executing [s@macro-dialout-trunk:29] GotoIf("PJSIP/Twilio-0000fe9c", "0?bypass,1") in new stack
    -- Executing [s@macro-dialout-trunk:30] ExecIf("PJSIP/Twilio-0000fe9c", "0?Set(CONNECTEDLINE(num,i)=+13135644444)") in new stack
    -- Executing [s@macro-dialout-trunk:31] ExecIf("PJSIP/Twilio-0000fe9c", "0?Set(CONNECTEDLINE(name,i)=CID:3135984310)") in new stack
    -- Executing [s@macro-dialout-trunk:32] ExecIf("PJSIP/Twilio-0000fe9c", "0?Set(CONNECTEDLINE(name,i)=CID:(Hidden)3135984310)") in new stack
    -- Executing [s@macro-dialout-trunk:33] GotoIf("PJSIP/Twilio-0000fe9c", "0?customtrunk") in new stack
    -- Executing [s@macro-dialout-trunk:34] ExecIf("PJSIP/Twilio-0000fe9c", "1?Set(DIAL_TRUNK_OPTIONS=)") in new stack
    -- Executing [s@macro-dialout-trunk:35] Set("PJSIP/Twilio-0000fe9c", "HASH(__SIPHEADERS,Alert-Info)=unset") in new stack
    -- Executing [s@macro-dialout-trunk:36] Dial("PJSIP/Twilio-0000fe9c", "PJSIP/+13135644444@Twilio,300,b(func-apply-sipheaders^s^1,(1))U(sub-send-obroute-email^+13135644444^13135644444^1^129937404^3135984310 3135984310^3135984310)") in new stack
    -- PJSIP/Twilio-0000fe9d Internal Gosub(func-apply-sipheaders,s,1(1)) start
Set(PJSIP_HEADER(remove,Alert-Info)=)") in new stack
[2022-04-28 16:23:32] ERROR[32334]: res_pjsip_header_funcs.c:547 remove_header: No headers had been previously added to this session.
    -- Executing [s@func-apply-sipheaders:9] ExecIf("PJSIP/Twilio-0000fe9d", "0?Set(sipheader=<http://127.0.0.1>;info=unset)") in new stack
    -- Executing [s@func-apply-sipheaders:10] ExecIf("PJSIP/Twilio-0000fe9d", "0?Set(sipheader=<http://127.0.0.1>unset)") in new stack
    -- Executing [s@func-apply-sipheaders:11] ExecIf("PJSIP/Twilio-0000fe9d", "0?SIPAddHeader(Alert-Info:unset)") in new stack
    -- Executing [s@func-apply-sipheaders:12] ExecIf("PJSIP/Twilio-0000fe9d", "0?Set(PJSIP_HEADER(add,Alert-Info)=unset)") in new stack
    -- Executing [s@func-apply-sipheaders:13] EndWhile("PJSIP/Twilio-0000fe9d", "") in new stack
    -- Executing [s@func-apply-sipheaders:5] While("PJSIP/Twilio-0000fe9d", "0") in new stack
    -- Executing [s@func-apply-sipheaders:14] Return("PJSIP/Twilio-0000fe9d", "") in new stack
  == Spawn extension (from-pstn-e164-us, 13135644444, 1) exited non-zero on 'PJSIP/Twilio-00000c9d'
    -- PJSIP/Twilio-00000c9d Internal Gosub(func-apply-sipheaders,s,1(1)) complete GOSUB_RETVAL=
    -- Called PJSIP/+13135644444@Twilio
    -- PJSIP/Twilio-00000c9d Internal Gosub(crm-hangup,s,1) start
    -- Executing [s@crm-hangup:1] NoOp("PJSIP/Twilio-0000fe9d", "Sending Hangup to CRM") in new stack
    -- Executing [s@crm-hangup:2] NoOp("PJSIP/Twilio-0000fe9d", "HANGUP CAUSE: 127") in new stack
    -- Executing [s@crm-hangup:3] ExecIf("PJSIP/Twilio-0000fe9d", "0?Set(__CRM_VOICEMAIL=)") in new stack
    -- Executing [s@crm-hangup:4] NoOp("PJSIP/Twilio-0000fe9d", "MASTER CHANNEL: 1651177412.3739 = 1651177404.3736") in new stack
    -- Executing [s@crm-hangup:5] GotoIf("PJSIP/Twilio-0000fe9d", "1?return") in new stack
    -- Goto (crm-hangup,s,8)
    -- Executing [s@crm-hangup:8] Return("PJSIP/Twilio-0000fe9d", "") in new stack
  == Spawn extension (from-pstn-e164-us, 13135644444, 1) exited non-zero on 'PJSIP/Twilio-00000c9d'
    -- PJSIP/Twilio-00000c9d Internal Gosub(crm-hangup,s,1) complete GOSUB_RETVAL=
  == Everyone is busy/congested at this time (1:0/0/1)
    -- Executing [s@macro-dialout-trunk:37] NoOp("PJSIP/Twilio-0000fe9c", "Dial failed for some reason with DIALSTATUS = CHANUNAVAIL and HANGUPCAUSE = 127") in new stack
    -- Executing [s@macro-dialout-trunk:38] GotoIf("PJSIP/Twilio-0000fe9c", "0?continue,1:s-CHANUNAVAIL,1") in new stack
    -- Goto (macro-dialout-trunk,s-CHANUNAVAIL,1)
    -- Executing [s-CHANUNAVAIL@macro-dialout-trunk:1] Set("PJSIP/Twilio-0000fe9c", "RC=127") in new stack
    -- Executing [s-CHANUNAVAIL@macro-dialout-trunk:2] Goto("PJSIP/Twilio-0000fe9c", "127,1") in new stack
    -- Goto (macro-dialout-trunk,127,1)
    -- Executing [127@macro-dialout-trunk:1] Goto("PJSIP/Twilio-0000fe9c", "continue,1") in new stack
    -- Goto (macro-dialout-trunk,continue,1)
    -- Executing [continue@macro-dialout-trunk:1] NoOp("PJSIP/Twilio-0000fe9c", "TRUNK Dial failed due to CHANUNAVAIL HANGUPCAUSE: 127 - failing through to other trunks") in new stack
    -- Executing [continue@macro-dialout-trunk:2] ExecIf("PJSIP/Twilio-0000fe9c", "0?Set(CALLERID(number)=)") in new stack
    -- Executing [13135644444@from-internal:12] Macro("PJSIP/Twilio-0000fe9c", "outisbusy,") in new stack
    -- Executing [s@macro-outisbusy:1] Progress("PJSIP/Twilio-0000fe9c", "") in new stack
    -- Executing [s@macro-outisbusy:2] GotoIf("PJSIP/Twilio-0000fe9c", "0?emergency,1") in new stack
    -- Executing [s@macro-outisbusy:3] GotoIf("PJSIP/Twilio-0000fe9c", "0?intracompany,1") in new stack
    -- Executing [s@macro-outisbusy:4] Playback("PJSIP/Twilio-0000fe9c", "all-circuits-busy-now&please-try-call-later, noanswer") in new stack
    -- <PJSIP/Twilio-0000fe9c> Playing 'all-circuits-busy-now.ulaw' (language 'en')
    

Use follow me on the extension and change the caller ID to Fixed CID Value. You can type in one of the numbers you own and it will be used as the caller ID.

1 Like

@adell4444 Thank you, I looked and looked and never saw that option! I just tested it and it works properly.

That being said, does anyone know if there is a global configuration for this somewhere within FreePBX? I eventually would prefer to transfer this task to be the responsibility of each user so that they can control call forwarding using their own numbers and on their own schedule through the UCP. I was under the impression that setting the Outbound CallerID field on the trunk was supposed to override everything, but clearly the forwarded CID supersedes this even on the trunk.

This should be doable at the trunk config:

Absolutely perfect! I missed this setting.

Thank you both for the assistance.

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