callerID broken when calling to another asterisk server via iax2 trunk

two days ago asterisk server started to add some numbers before callerid like:

22300-14587:663

where the real phone number is 663

the same “22300-14587:” added to callername before phone number

it happens when call goes to another asterisk server via iax2 trunk. intra-server calls works fine.

users are able to make a call but unable to call-back missed call because callerid 22300-14587:663 doesn’t exist

need help please. where to dig?

asterisk 21 freepbx 17

here’s log on receiving asterisk server:

-- Accepting UNAUTHENTICATED call from 10.20.0.57:10439:
--        > requested format = ulaw,
--        > requested prefs = (ulaw|alaw|gsm|h264|mpeg4|g729),
--        > actual format = ulaw,
--        > host prefs = (ulaw|alaw|gsm|h264|g729),
--        > priority = mine
-- Executing [190@from-internal:1] Gosub("IAX2/10.20.0.57:10439-16248", "macro-user-callerid,s,1(LIMIT,EXTERNAL)") in new stack
-- Executing [s@macro-user-callerid:1] Set("IAX2/10.20.0.57:10439-16248", "TOUCH_MONITOR=1790152341.230") in new stack
-- Executing [s@macro-user-callerid:2] Set("IAX2/10.20.0.57:10439-16248", "CHANCONTEXT=") in new stack
-- Executing [s@macro-user-callerid:3] Set("IAX2/10.20.0.57:10439-16248", "CHANCONTEXT=") in new stack
-- Executing [s@macro-user-callerid:4] Set("IAX2/10.20.0.57:10439-16248", "CHANEXTENCONTEXT=10.20.0.57:10439-16248") in new stack
-- Executing [s@macro-user-callerid:5] Set("IAX2/10.20.0.57:10439-16248", "CHANEXTEN=10.20.0.57:10439-16248") in new stack
-- Executing [s@macro-user-callerid:6] Set("IAX2/10.20.0.57:10439-16248", "CALLERID(number)=10439-16248:872") in new stack

instead of “10439-16248:872” in CALLERID(number) must be just “872”

on calling asrterisk server i don’t see “10439-16248” anywhere in logs…

i’ve tried:

CUT(CALLERID(number),:,2)

and instead “CALLERID(number)=24874-2135:872” i saw “CALLERID(number)=24874-2135:”

why not 872??? what i’ve done wrong???

The channel number appears to be included in there. Maybe paste the results of this into this thread and I’m sure that some experts on here could offer some insight how the caller ID is being constructed and defined. I believe that macros are deprecated with FreePBX v17, seeing I had to redefine things in my config files after migrating from v16 a few months ago.

asterisk -rx "dialplan show macro-user-callerid"

here it is:

Спойлер

[ Context ‘macro-user-callerid’ created by ‘pbx_config’ ]
‘en’ => 1. Playback(im-sorry&an-error-has-occurred&with&call-forwarding) [extensions_override_freepbx.conf:66]
2. Return() [extensions_override_freepbx.conf:67]
[hook_1] 3. Playback(beep&im-sorry&your&simul-call-limit-reached&goodbye) [extensions_override_freepbx.conf:68]
4. Return() [extensions_override_freepbx.conf:69]
[hook_2] 5. Playback(im-sorry&an-error-has-occurred) [extensions_override_freepbx.conf:70]
6. Return() [extensions_override_freepbx.conf:71]
‘h’ => 1. Gosub(macro-hangupcall,s,1()) [extensions_override_freepbx.conf:64]
‘ja’ => 1. Playback(im-sorry&call-forwarding&jp-no&an-error-has-occured) [extensions_override_freepbx.conf:73]
2. Return() [extensions_override_freepbx.conf:74]
[hook_1] 3. Playback(beep&im-sorry&simul-call-limit-reached) [extensions_override_freepbx.conf:75]
4. Return() [extensions_override_freepbx.conf:76]
[hook_2] 5. Playback(im-sorry&an-error-has-occured) [extensions_override_freepbx.conf:77]
6. Return() [extensions_override_freepbx.conf:78]
‘lang-playback’ => 1. GosubIf($[${DIALPLAN_EXISTS(macro-user-callerid,${CHANNEL(language)})}]?macro-user-callerid,${CHANNEL(language)},${ARG1}():macro-user-callerid,en,${ARG1}()) [extensions_override_freepbx.conf:3]
2. Return() [extensions_override_freepbx.conf:4]
‘s’ => 1. Set(TOUCH_MONITOR=${UNIQUEID}) [extensions_override_freepbx.conf:6]
2. Set(CHANCONTEXT=${CUT(CHANNEL,@,2)}) [extensions_override_freepbx.conf:7]
3. Set(CHANCONTEXT=${CUT(CHANCONTEXT,-,1)}) [extensions_override_freepbx.conf:8]
4. Set(CHANEXTENCONTEXT=${CUT(CHANNEL,/,2)}) [extensions_override_freepbx.conf:9]
5. Set(CHANEXTEN=${CUT(CHANEXTENCONTEXT,@,1)}) [extensions_override_freepbx.conf:10]
6. Set(CALLERID(number)=${IF($[“${CHANCONTEXT}” = “webcallback”]?${CHANEXTEN}:${CALLERID(number)})}) [extensions_override_freepbx.conf:11]
7. Set(AMPUSER=${IF($[“${AMPUSER}” = “”]?${CALLERID(number)}:${AMPUSER})}) [extensions_override_freepbx.conf:12]
8. Set(HOTDESCKCHAN=${CUT(CHANNEL,/,2)}) [extensions_override_freepbx.conf:13]
9. Set(HOTDESKEXTEN=${CUT(HOTDESCKCHAN,-,1)}) [extensions_override_freepbx.conf:14]
10. Set(HOTDESKCALL=0) [extensions_override_freepbx.conf:15]
11. ExecIf($[“${DB(EDEVICE/${HOTDESKEXTEN}/user)}”=“DummyUser”]?Set(HOTDESKCALL=1)) [extensions_override_freepbx.conf:16]
12. ExecIf($[${HOTDESKCALL}=1]?Set(CALLERID(name)=${DB(EDEVICE/${HOTDESKEXTEN}/location)})) [extensions_override_freepbx.conf:17]
13. GotoIf($[“${CUT(CHANNEL,@,2):5:5}”=“queue” | ${LEN(${AMPUSERCIDNAME})}]?report) [extensions_override_freepbx.conf:18]
14. ExecIf($[“${REALCALLERIDNUM:1:2}” = “”]?Set(REALCALLERIDNUM=${CALLERID(number)})) [extensions_override_freepbx.conf:19]
15. Set(AMPUSER=${DB(DEVICE/${REALCALLERIDNUM}/user)}) [extensions_override_freepbx.conf:20]
16. GotoIf($[“${AMPUSER}” = “none”]?limit) [extensions_override_freepbx.conf:21]
17. Set(AMPUSERCIDNAME=${DB(AMPUSER/${AMPUSER}/cidname)}) [extensions_override_freepbx.conf:22]
18. ExecIf($[“${ARG2}” != “EXTERNAL” & ${DB_EXISTS(AMPUSER/${AMPUSER}/cidnum)} & “${AMPUSER}” != “${DB(AMPUSER/${AMPUSER}/cidnum)}”]?Set(__CIDMASQUERADING=TRUE)) [extensions_override_freepbx.conf:23]
19. GotoIf($[“${AMPUSERCIDNAME:1:2}” = “”]?report) [extensions_override_freepbx.conf:24]
20. Set(AMPUSERCID=${IF($[“${ARG2}” != “EXTERNAL” & “${DB_EXISTS(AMPUSER/${AMPUSER}/cidnum)}” = “1”]?${DB_RESULT}:${AMPUSER})}) [extensions_override_freepbx.conf:25]
21. Set(__DIAL_OPTIONS=${IF($[“${DB_EXISTS(AMPUSER/${AMPUSER}/dialopts)}” = “1”]?${DB_RESULT}:${DIAL_OPTIONS})}) [extensions_override_freepbx.conf:26]
22. Set(CALLERID(all)=“${AMPUSERCIDNAME}” <${AMPUSERCID}>) [extensions_override_freepbx.conf:27]
23. ExecIf($[“${DB(DEVICE/${ARG2}/tech)}”=“custom”]?Set(CUSDIAL=${CUT(CUT(DB(DEVICE/${ARG2}/dial),/,2),@,1)})) [extensions_override_freepbx.conf:28]
24. ExecIf($[“${DB(DEVICE/${ARG2}/tech)}”=“custom” & “${DB(DEVICE/${CUSDIAL}/type)}” =“”]?Set(CALLERID(all)=${IF($[${LEN(${DB(AMPUSER/${ARG2}/outboundcid)})}]?${DB(AMPUSER/${ARG2}/outboundcid)}:${CALLERID(all)})})) [extensions_override_freepbx.conf:29]
25. GotoIf($[“${ARG1}”=“LIMIT” & ${LEN(${AMPUSER})} & ${DB_EXISTS(AMPUSER/${AMPUSER}/concurrency_limit)} & ${DB(AMPUSER/${AMPUSER}/concurrency_limit)}>0 & ${GROUP_COUNT(${AMPUSER}@concurrency_limit)}>=${DB(AMPUSER/${AMPUSER}/concurrency_limit)}]?limit) [extensions_override_freepbx.conf:30]
26. ExecIf($[“${ARG1}”=“LIMIT” & ${LEN(${AMPUSER})}]?Set(GROUP(concurrency_limit)=${AMPUSER})) [extensions_override_freepbx.conf:31]
[report] 27. Noop(Macro depricated!! To keep the same line numbers) [extensions_override_freepbx.conf:32]
28. Noop(Macro depricated !! To keep the same line numbers) [extensions_override_freepbx.conf:33]
[report2] 29. GotoIf($[ “${ARG1}” = “SKIPTTL” | “${ARG1}” = “LIMIT” ]?continue) [extensions_override_freepbx.conf:34]
[report3] 30. Set(__TTL=${IF($[“foo${TTL}” = “foo”]?64:$[ ${TTL} - 1 ])}) [extensions_override_freepbx.conf:35]
31. GotoIf($[ ${TTL} > 0 ]?continue) [extensions_override_freepbx.conf:36]
32. Wait(${RINGTIMER}) [extensions_override_freepbx.conf:37]
33. Answer() [extensions_override_freepbx.conf:38]
34. Wait(1) [extensions_override_freepbx.conf:39]
35. Gosub(macro-user-callerid,lang-playback,1(hook_0)) [extensions_override_freepbx.conf:40]
36. Gosub(macro-hangupcall,s,1()) [extensions_override_freepbx.conf:41]
[macroerror] 37. Noop(Macro Limit Reached. Aborting Call) [extensions_override_freepbx.conf:42]
38. Answer() [extensions_override_freepbx.conf:43]
39. Wait(1) [extensions_override_freepbx.conf:44]
40. Gosub(macro-user-callerid,lang-playback,1(hook_2)) [extensions_override_freepbx.conf:45]
41. Gosub(macro-hangupcall,s,1()) [extensions_override_freepbx.conf:46]
[limit] 42. Answer() [extensions_override_freepbx.conf:47]
43. Wait(1) [extensions_override_freepbx.conf:48]
44. Gosub(macro-user-callerid,lang-playback,1(hook_1)) [extensions_override_freepbx.conf:49]
45. Gosub(macro-hangupcall,s,1()) [extensions_override_freepbx.conf:50]
46. Congestion(20) [extensions_override_freepbx.conf:51]
[continue] 47. Set(CALLERID(number)=${CALLERID(number):0:40}) [extensions_override_freepbx.conf:52]
48. Set(CALLERID(name)=${CALLERID(name):0:80}) [extensions_override_freepbx.conf:53]
49. GotoIf($[“${CALLERID(name)}” = “”]?cnum) [extensions_override_freepbx.conf:54]
50. Set(__MCNUM=${CALLERID(num)}) [extensions_override_freepbx.conf:55]
51. Set(__MCNAME=${CALLERID(name)}) [extensions_override_freepbx.conf:56]
52. Set(__MCEXTEN=${AMPUSER}) [extensions_override_freepbx.conf:57]
53. Set(__MCORGCHAN=${CHANNEL}) [extensions_override_freepbx.conf:58]
54. Set(CDR(cnam)=${CALLERID(name)}) [extensions_override_freepbx.conf:59]
[cnum] 55. Set(CDR(cnum)=${CALLERID(num)}) [extensions_override_freepbx.conf:60]
[return] 56. Return() [extensions_override_freepbx.conf:61]
57. Set(CHANNEL(language)=${MASTER_CHANNEL(CHANNEL(language))}) [extensions_override_freepbx.conf:62]
Include => ‘macro-user-callerid-custom’ [pbx_config]

-= 5 extensions (72 priorities) in 1 context. =-

Спойлер

Этот текст будет скрыт

my guess is that callerID constructed somewhere else…

and why CUT not working properly? :frowning:

Just spitballing this to be honest, but Google gemini suggested trying this.

${CUT(CALLERID(number),:,2)}

yes. i’ve done exactly so. but result…

  1. Set(CALLERID(number)=${IF($[“${CHANCONTEXT}” = “webcallback”]?${CHANEXTEN}:${CUT(CALLERID(number),:,2)})}) [extensions_override_freepbx.conf:11]

Executing [s@macro-user-callerid:6] Set(“IAX2/10.20.0.57:24874-6476”, “CALLERID(number)=24874-6476:”) in new stack

this way works fine:

exten => s,n,Set(CALLERID(number)=${IF($[“${CHANCONTEXT}” = “webcallback”]?${CHANEXTEN}:${CALLERID(number)})})
exten => s,n,Set(CALLERID(number)=${CUT(CALLERID(number),:,2)})

result: 872

and this way gives a crap:

exten => s,n,Set(CALLERID(number)=${IF($[“${CHANCONTEXT}” = “webcallback”]?${CHANEXTEN}:${CUT(CALLERID(number),:,2)})})

result: 24874-2135:

why?

and if i set this on both asterisks - it failed totally. i receive “24874-2135:” in incoming callerid

and even if it on one of them - it breaks callerid in incoming calls. thus it’s not a workaround :frowning:

but i don’t see anything wrong with callerid on sendind server…

everywhere i see callerid it shows “889” without any prefixes

with one exception:

Executing [s@macro-dialout-trunk:25] ExecIf(“PJSIP/889-000001d2”, “1?Set(CONNECTEDLINE(name,i)=CID:889)”) in new stack

but it’s not callerid i guess…

The macro names are retained, but instead of using Macro(xxxxx,…), it uses Gosub(macro-xxxxx…, and a Return has to be at the end.

i’ve commented the line in /etc/asterisk/extensions_override_freepbx.conf:

;Set(CALLERID(number)=${IF($[“${CHANCONTEXT}” = “webcallback”]?${CHANEXTEN}:${CALLERID(number)})})

and now all things works fine. but! in file extensions_additional.conf this string still present…

and the question remains - what’s gone wrong with [macro-user-callerid] ???

Under Connectivity > Trunks in the admin portal what do the options look like for Caller ID in there for the IAX2 trunk?

like that:

Спойлер

How is the outbound route configured that points to the IAX2 trunk? See here for something similar → Issue with Caller ID on IAX Trunk Between Two FreePBX Systems.

out route:

Спойлер

and yes - it configured as an intra-company route

In the screen shot of your trunk configuration, I see that Outbound CallerID has cd-dz plugged into that field. Have you tried temporarily removing that value and testing it?

yes i’ve tried. nothing changes…