Freepbx/Asterisk/CallCentric Caller ID being changed to unknown number

Hi

I have two DIDs feeding an asterisk pbx. whenever I call in on one of the ddi’s, the callerid is not set to the correct caller id that’s passed through to the phone, but a 617 number. (my area code is 386).

I see the call coming in from Callcentric with the correct CID so i know it isn’t their issue, but i cannot find where it’s getting changed in asterisk. It doesn’t even appear in the logs at all.

Any help would be appreciated

here is callcentrics reply: https://pastebin.com/TXdv68my

Here is a full call log captured from start to end of call (hangup): https://pastebin.com/aSLALPnw

I also notice this line about half way down too:

pbx_variables.c:708 pbx_substitute_variables_helper_full: Function CALLERID(number) result is ‘’

It appears that the Set(CALLERID(all)="MAXX . ") on line 49 of the log may be clobbering the caller ID.

Can you post the code in your from-sip-external-custom context? Also, a reference to the Callcentric site from which it was derived? There may be an easy fix.

Otherwise, rather than such custom dialplan code, consider an approach such as https://www.callcentric.com/support/device/asterisk/14 , where you just alias all their servers to one trunk.

Or, use a pjsip trunk instead, which seems to handle the Callcentric quirks automatically.

I have all the CC DDIs coming in on one trunk and then using 2 inbound rules to check against the DDI number. and that all works great. routing wise.

this was what I was following: dslreports dot com/forum/r31085468-CallCentric-Setup-with-FreePBX

because i couldn’t get that working in the link you posted. i’m thinking i basically have a mix of the two and i can probably dump what i have in extensions_custom.conf

here is the CC extensions_custom.conf:

[from-sip-external-custom]
exten => _.,1,NoOp(Received incoming SIP connection from unknown peer to ${EXTEN})
exten => _.,n,Set(DID=${IF($["${EXTEN:1:2}"=""]?s:${EXTEN})})
exten => _.,n,Goto(s,1)
; CallCentric Check
exten => s,1,GotoIf($["${DID}"="MYCCID"]?callcentric)
; Regular Check
exten => s,1,GotoIf($["${ALLOW_SIP_ANON}"="yes"]?checklang:noanonymous)
; CallCentric DID Code
exten => s,n(callcentric),Set(Var_FROM_DOMAIN=${CUT(CUT(SIP_HEADER(TO),@,2),>,1)})
exten => s,n,GotoIF($["${Var_FROM_DOMAIN}" = "callcentric.com"]?callcentric-next)
exten => s,n,GotoIF($["${Var_FROM_DOMAIN}" = "ss.callcentric.com"]?callcentric-next)
exten => s,n,GotoIF($["${Var_FROM_DOMAIN}" = "66.193.176.35"]?callcentric-next:checklang)
exten => s,n(callcentric-next),Set(Var_TO_DID=${CUT(CUT(SIP_HEADER(TO),@,1),:,2)})
exten => s,n,GotoIF($["${Var_TO_DID}" = ""]?checklang)
exten => s,n,Set(DID=${Var_TO_DID})
; Regular script continues
exten => s,n(checklang),GotoIf($["${SIPLANG}"=""]?checkcallerid)
exten => s,n(setlanguage),Set(CHANNEL(language)=${SIPLANG})
exten => s,n(checkcallerid),ExecIf($["${CALLERID(number):0:1}" = "1"]?Set(CALLERID(all)="${CALLERID(name)} "))
exten => s,n,Goto(from-trunk,${DID},1)
exten => s,n(noanonymous),Set(TIMEOUT(absolute)=15)
exten => s,n,Log(WARNING,"Rejecting unknown SIP connection from ${CHANNEL(recvip)}")
exten => s,n,Answer
exten => s,n,Wait(2)
exten => s,n,Playback(ss-noservice)
exten => s,n,Playtones(congestion)
exten => s,n,Congestion(5)
exten => h,1,Hangup
exten => i,1,Hangup
exten => t,1,Hangup

i’ve also managed to get CDR records working (mysql modules were missing). if I look at the CDR logs, it shows as unknown (although the CNAM is still sent), but in the beta call event logging, it shows up.

The dslreports forum butchered one line. It should read:
exten => s,n(checkcallerid),ExecIf($["${CALLERID(number):0:1}" = "1"]?Set(CALLERID(all)="${CALLERID(name)} <${CALLERID(number):1}>"))

Edit your extensions_custom.conf, restart Asterisk and you should be good to go.

Stewart, that should be all on one line correct?

Yes, all on one line.

ok so change this:

exten => s,n(checkcallerid),ExecIf($["${CALLERID(number):0:1}" = “1”]?Set(CALLERID(all)="${CALLERID(name)} "))

to this:

exten => s,n(checkcallerid),ExecIf($["${CALLERID(number):0:1}" = “1”]? Set(CALLERID(all)="${CALLERID(name)} <${CALLERID(number):1}>"))

Correct, the dslr forum interpreted the text within <> as an unknown HTML tag and deleted it for security reasons.

i changed that line and tried a call, now i get “the person you have reached is not available etc”

In the logs is this:

Where would this line be coming from?
[2018-09-27 18:33:55] WARNING[9581][C-00000003]: app_exec.c:268 execif_exec: Could not find application! ( Set)

LOG:

-- Executing [[email protected]:10] Set("SIP/callcentric17-00000002", "CHANNEL(language)=en") in new stack

[2018-09-27 18:33:55] DEBUG[9581][C-00000003]: pbx_variables.c:708 pbx_substitute_variables_helper_full: Function CALLERID(number) result is ‘MYNUMBER’
[2018-09-27 18:33:55] DEBUG[9581][C-00000003]: pbx_variables.c:777 pbx_substitute_variables_helper_full: Expression result is ‘1’
[2018-09-27 18:33:55] DEBUG[9581][C-00000003]: pbx_variables.c:708 pbx_substitute_variables_helper_full: Function CALLERID(name) result is ‘XXXXX .’
[2018-09-27 18:33:55] DEBUG[9581][C-00000003]: pbx_variables.c:708 pbx_substitute_variables_helper_full: Function CALLERID(number) result is ‘MY NUMBER’
[2018-09-27 18:33:55] DEBUG[9581][C-00000003]: pbx.c:2914 pbx_extension_helper: Launching ‘ExecIf’
– Executing [[email protected]:11] ExecIf(“SIP/callcentric17-00000002”, “1? Set(CALLERID(all)=” . “)”) in new stack
[2018-09-27 18:33:55] WARNING[9581][C-00000003]: app_exec.c:268 execif_exec: Could not find application! ( Set)
[2018-09-27 18:33:55] DEBUG[9581][C-00000003]: pbx.c:4389 __ast_pbx_run: Spawn extension (from-sip-external-custom,s,11) exited non-zero on ‘SIP/callcentric17-00000002’
== Spawn extension (from-sip-external-custom, s, 11) exited non-zero on ‘SIP/callcentric17-00000002’
[2018-09-27 18:33:55] DEBUG[9581][C-00000003]: channel.c:2590 ast_softhangup_nolock: Soft-Hanging (0x10) up channel ‘SIP/callcentric17-00000002’
[2018-09-27 18:33:55] DEBUG[9581][C-00000003]: channel.c:2590 ast_softhangup_nolock: Soft-Hanging (0x80) up channel ‘SIP/callcentric17-00000002’
[2018-09-27 18:33:55] DEBUG[9581][C-00000003]: pbx.c:2914 pbx_extension_helper: Launching ‘Hangup’

ignore that, there was a space there that I didnt see.

It works… thanks i appreciate your help

Why in the world are you pointing incoming calls to from-sip-external?! That shouldn’t be used at all for this.

; from-sip-external
;
; This context is the default SIP context unless otherwise changed in the SIP
; Settings module or other sip configuration locations. This context is hit by
; either anonymous SIP calls or mis-configured SIP trunks when the incoming call
; can not be matched with a SIP section.
;  

That is not part of the original from-sip-external, not sure why there’s a comment that says “regular script continues” because what is below that comment is still modified code from FreePBX default generated.

More importantly, why are you setting ${CALLERID(all)} to just the NAME? The (all) CallerID is the FULL CALLERID ie “Name” <number;> So you have basically changed your Caller ID to “Name” <> and thus you are seeing EMPTY ${CALLERID(num)} results when that VAR is called further in the dialplan.

On top of all that, there’s a space at the end between the VAR and the " that shouldn’t be there.

This is basically sending the call WHERE IT SHOULD GO IN THE FIRST PLACE. Which is then re-doing all the CallerID and normal call flow process but this time when it does all the CallerID lookup/blacklist/etc like normal you have completely trashed your CallerID information.

EDIT: This line also BREAKS the unknown PEER check because it stops ALL CALLS from hitting the the No-Service/Congestion playbacks and stopping the call from moving forward in the PBX. So you’ve basically opened your PBX to accept ALL CALLS from ANY SOURCE.

Why is this being done at ALL? Don’t you have a VALID PEER from CallCentric on the system?!

As far as I can see this call flow is completely FUBAR’d and causing more problem than it solves.

Tom

I am new at Freepbx, and as was previously mentioned, I was following tutorials given on multiple sites. the “from-sip-external” context is the one given in those links that i have shown previously. if that’s not what thy’re for then please, enlighten me so that I can learn.

Your comments came off obnoxious and “angry” (for want of a better term), i’m sure that’s not what was meant by that, but please, if you can help me by showing me what should be in there and what shouldn’t and put it in terms that is easy to follow, then please do so.

This is why i turned tot he community forums here, because I’m not 100% certain on the way things are working here, this is why i’m learning. If that makes sense.

What context should I be using?

As far as this line here:
exten => s,n(checkcallerid),ExecIf($["${CALLERID(number):0:1}" = “1”]?Set(CALLERID(all)="${CALLERID(name)} "))

That’s what stuart said, and that’s fixed.

I appreciate all the help i can get, but please, i’m new to this so instead of just saying what’s wrong, please offer suggestions on what to do to fix is, because that doesn’t help me.

@cblackburn1099, OK you are new and that’s cool. However, the others who have replied to this thread aren’t and not once made notice of any of this or the fact you’re using a context that is for known bad calls. Or the fact that that line I pointed out made the bad calls context pointless as it broke what it does.

So let’s try this from the basic beginning. What happens when you set this trunk up normally and use the proper context “from-trunk” instead of “from-sip-external”? No extra code just a plain ole setup. Do you have CallerID issues then?

don’t know yet. right now it’s working. so the next step is to rebuild the system with what i’ve learned and what you’ve said etc

this is just running on a small centos VPS so easy to re-image. obvously i’m doing this on a “non production” server for obvious reasons LOL

You don’t need to re-do the server. Remove the code you added and point the context to “from-trunk” and test. That’s it.

1 Like

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