ps:...the way to do the ANI is to use the "a" argument.
exten => _NXXNXXXXXX,n,Set(CALLERID
Main Topics
Browse All TopicsI'm building an Asterisk-based VoIP system, and require to ensure that all outbound calls have CallerID (known as CLI here in the UK) information associated with them.
I'm testing this system by using Zoiper on my PC to make calls to my standard mobile phone, and vice versa.
I'm encountering a very strange issue with CallerID. If I set a CallerID in the softphone, regardless of what it's set to (even the word "gibberish"), when the call leaves the Asterisk box, it has my test VoIP number's proper CLI set as specified in extensions.conf, and this appears on my mobile.
But if I clear the CallerID field in Zoiper, then when the call leaves the Asterisk box no CLI is set, the call on my mobile comes up as from "Unknown" and I've verified with the upstream telephone provider who's taking the trunk from Asterisk that no CLI is appearing on those calls.
I'm using IAX to test, but we expect the system to also accept SIP when it's complete.
My IAX user:
[01133326209]
type=friend
host=dynamic
secret=********
context=01133326209
The "to mobiles" (07) outbound part of the user's entry in extensions.conf, from their [01133326209] context:
exten => _07.,1,Set(CALLERID(number
exten => _07.,2,Set(CALLERID(ANI)=0
exten => _07.,n,Dial(SIP/toSwitchCo
When I tail the logs, I can see the Set command being carried out. Nevertheless the call arrives at destination with "unknown" as its CLI.
[2009-04-01 18:40:11] VERBOSE[2652] logger.c: [2009-04-01 18:40:11] -- Accepting AUTHENTICATED call from xxx.xxx.121.65:
> requested format = gsm,
> requested prefs = (),
> actual format = gsm,
> host prefs = (),
> priority = mine
[2009-04-01 18:40:11] DEBUG[9932] pbx.c: Launching 'Set'
[2009-04-01 18:40:11] VERBOSE[9932] logger.c: [2009-04-01 18:40:11] -- Executing [07xxxxxx503@01133326209:1
[2009-04-01 18:40:11] DEBUG[9932] pbx.c: Launching 'Set'
[2009-04-01 18:40:11] VERBOSE[9932] logger.c: [2009-04-01 18:40:11] -- Executing [07xxxxxx503@01133326209:2
[2009-04-01 18:40:11] DEBUG[9932] pbx.c: Launching 'Dial'
[2009-04-01 18:40:11] VERBOSE[9932] logger.c: [2009-04-01 18:40:11] -- Executing [07xxxxxx503@01133326209:3
So this far it all appears to be working correctly, the number and ANI are aparently set - but the upstream doesn't see them, and they don't appear at the destination.
The next few lines in the log show:
[2009-04-01 18:40:11] DEBUG[9932] chan_sip.c: Asked to create a SIP channel with formats: 0x2 (gsm)
[2009-04-01 18:40:11] DEBUG[9932] chan_sip.c: Allocating new SIP dialog for (No Call-ID) - INVITE (With RTP)
Does the "No Call-ID" entry indicate that the CLI has been lost by this point?
Is there a reliable way of forcing the CallerID, regardless of whether the connecting softphone has anything set or not?
Edit: I've searched extensively for information on this problem, studied the O'Reilly book on Asterisk, and read the info on setting CallerID on voip-info, but nothing I've tried so far has solved this problem.
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
We've already tried all the various ways of setting the CallerID, with and without name, all in one line vs seperate lines - nothing works, the result is always that if the softphone has anything at all in the callerid field, then Asterisk correctly sets the callerid as defined in extensions.conf, however if the softphone has no callerid set, then Asterisk seems to completely ignore the callerid settings, even though we can see the lines being processed in the log.
We've also tried setting the callerid in iax.conf, however the effect of that was that regardless of whether anything was set in the softphone, no callerid was set by Asterisk.
None of this behaviour is documented anywhere, hence wondering if anyone else has seen similar problems, or if there's some kind of deep-level problem with either our Asterisk install, or the machine it's running on.
The non-comment bits of zapata.conf look like this:
[trunkgroups]
[channels]
context=default
switchtype=national
signalling=fxo_ls
usecallerid=yes
hidecallerid=no
callwaiting=yes
usecallingpres=yes
callwaitingcallerid=yes
threewaycalling=yes
transfer=yes
canpark=yes
cancallforward=yes
callreturn=yes
echocancel=yes
echocancelwhenbridged=yes
rxgain=0.0
txgain=0.0
group=1
callgroup=1
pickupgroup=1
immediate=no
Yes, we're going out via a SIP trunk, and can both make and receive calls between the voip system and standard mobile phones.
Here's the Asterisk log for a call made with "gibberish" in the CallerID field of Zoiper, this call arrived at my mobile phone with the correct 01133326209 CLI shown::
[2009-04-08 17:06:34] DEBUG[2647] frame.c: Could not find preferred codec - Returning zero codec
[2009-04-08 17:06:34] DEBUG[2647] chan_iax2.c: We don't do requested format gsm, falling back to peer capability 1550
[2009-04-08 17:06:34] VERBOSE[2647] logger.c: [2009-04-08 17:06:34] -- Accepting AUTHENTICATED call from 83.136.121.65:
> requested format = gsm,
> requested prefs = (),
> actual format = gsm,
> host prefs = (),
> priority = mine
[2009-04-08 17:06:34] DEBUG[24625] pbx.c: Launching 'Set'
[2009-04-08 17:06:34] VERBOSE[24625] logger.c: [2009-04-08 17:06:34] -- Executing [07xxxxxx503@01133326209:1
[2009-04-08 17:06:34] DEBUG[24625] pbx.c: Launching 'Set'
[2009-04-08 17:06:34] VERBOSE[24625] logger.c: [2009-04-08 17:06:34] -- Executing [07xxxxxx503@01133326209:2
[2009-04-08 17:06:34] DEBUG[24625] pbx.c: Launching 'Dial'
[2009-04-08 17:06:34] VERBOSE[24625] logger.c: [2009-04-08 17:06:34] -- Executing [07xxxxxx503@01133326209:3
[2009-04-08 17:06:34] DEBUG[24625] chan_sip.c: Asked to create a SIP channel with formats: 0x2 (gsm)
[2009-04-08 17:06:34] DEBUG[24625] chan_sip.c: Allocating new SIP dialog for (No Call-ID) - INVITE (With RTP)
[2009-04-08 17:06:34] DEBUG[24625] chan_sip.c: Setting NAT on RTP to Off
[2009-04-08 17:06:34] DEBUG[24625] chan_sip.c: *** Our native formats are 0x3f0008 (alaw|jpeg|png|h261|h263|h
[2009-04-08 17:06:34] DEBUG[24625] chan_sip.c: *** Joint capabilities are 0x0 (nothing)
[2009-04-08 17:06:34] DEBUG[24625] chan_sip.c: *** Our capabilities are 0x3f1fff (g723|gsm|ulaw|alaw|g726|a
[2009-04-08 17:06:34] DEBUG[24625] chan_sip.c: *** AST_CODEC_CHOOSE formats are 0x8 (alaw)
[2009-04-08 17:06:34] DEBUG[24625] chan_sip.c: *** Our preferred formats from the incoming channel are 0x2 (gsm)
[2009-04-08 17:06:34] DEBUG[24625] chan_sip.c: This channel will not be able to handle video.
[2009-04-08 17:06:34] DEBUG[24625] rtp.c: Channel 'IAX2/01133326209-6339' has no RTP, not doing anything
[2009-04-08 17:06:34] DEBUG[24625] chan_sip.c: Outgoing Call for 447783967503
[2009-04-08 17:06:34] DEBUG[24625] chan_sip.c: Updating call counter for outgoing call
[2009-04-08 17:06:34] DEBUG[24625] chan_sip.c: Our T38 capability (0), joint T38 capability (0)
[2009-04-08 17:06:34] DEBUG[24625] chan_sip.c: ** Our capability: 0x3f08fe (gsm|ulaw|alaw|g726|adpcm|
[2009-04-08 17:06:34] DEBUG[24625] chan_sip.c: ** Our prefcodec: 0x2 (gsm)
[2009-04-08 17:06:34] DEBUG[24625] chan_sip.c: This call needs video offers, but there's no video support enabled!
[2009-04-08 17:06:34] DEBUG[24625] chan_sip.c: -- Done with adding codecs to SDP
[2009-04-08 17:06:34] DEBUG[24625] channel.c: Internal timing is disabled (option_internal_timing=0 chan->timingfd=-1)
[2009-04-08 17:06:34] DEBUG[24625] chan_sip.c: Done building SDP. Settling with this capability: 0x3f08fe (gsm|ulaw|alaw|g726|adpcm|
[2009-04-08 17:06:34] VERBOSE[24625] logger.c: [2009-04-08 17:06:34] -- Called toSwitchConnectVoIP/447783
[2009-04-08 17:06:34] DEBUG[24625] channel.c: Set channel SIP/toSwitchConnectVoIP-08
[2009-04-08 17:06:34] DEBUG[24625] channel.c: Set channel IAX2/01133326209-6339 to write format slin
[2009-04-08 17:06:34] DEBUG[24625] channel.c: Set channel IAX2/01133326209-6339 to read format slin
[2009-04-08 17:06:34] DEBUG[24625] channel.c: Set channel SIP/toSwitchConnectVoIP-08
And here's the log for a call made with the CallerID field of Zoiper blanked, this call arrived with no CallerID, the mobile showed "Private" and the people provding the trunk to the PSTN saw no CLI:
[2009-04-08 17:16:22] DEBUG[2645] frame.c: Could not find preferred codec - Returning zero codec
[2009-04-08 17:16:22] DEBUG[2645] chan_iax2.c: We don't do requested format gsm, falling back to peer capability 1550
[2009-04-08 17:16:22] VERBOSE[2645] logger.c: [2009-04-08 17:16:22] -- Accepting AUTHENTICATED call from 83.136.121.65:
> requested format = gsm,
> requested prefs = (),
> actual format = gsm,
> host prefs = (),
> priority = mine
[2009-04-08 17:16:22] DEBUG[24858] pbx.c: Launching 'Set'
[2009-04-08 17:16:22] VERBOSE[24858] logger.c: [2009-04-08 17:16:22] -- Executing [07xxxxxx503@01133326209:1
[2009-04-08 17:16:22] DEBUG[24858] pbx.c: Launching 'Set'
[2009-04-08 17:16:22] VERBOSE[24858] logger.c: [2009-04-08 17:16:22] -- Executing [07xxxxxx503@01133326209:2
[2009-04-08 17:16:22] DEBUG[24858] pbx.c: Launching 'Dial'
[2009-04-08 17:16:22] VERBOSE[24858] logger.c: [2009-04-08 17:16:22] -- Executing [07xxxxxx503@01133326209:3
[2009-04-08 17:16:22] DEBUG[24858] chan_sip.c: Asked to create a SIP channel with formats: 0x2 (gsm)
[2009-04-08 17:16:22] DEBUG[24858] chan_sip.c: Allocating new SIP dialog for (No Call-ID) - INVITE (With RTP)
[2009-04-08 17:16:22] DEBUG[24858] chan_sip.c: Setting NAT on RTP to Off
[2009-04-08 17:16:22] DEBUG[24858] chan_sip.c: *** Our native formats are 0x3f0008 (alaw|jpeg|png|h261|h263|h
[2009-04-08 17:16:22] DEBUG[24858] chan_sip.c: *** Joint capabilities are 0x0 (nothing)
[2009-04-08 17:16:22] DEBUG[24858] chan_sip.c: *** Our capabilities are 0x3f1fff (g723|gsm|ulaw|alaw|g726|a
[2009-04-08 17:16:22] DEBUG[24858] chan_sip.c: *** AST_CODEC_CHOOSE formats are 0x8 (alaw)
[2009-04-08 17:16:22] DEBUG[24858] chan_sip.c: *** Our preferred formats from the incoming channel are 0x2 (gsm)
[2009-04-08 17:16:22] DEBUG[24858] chan_sip.c: This channel will not be able to handle video.
[2009-04-08 17:16:22] DEBUG[24858] rtp.c: Channel 'IAX2/01133326209-11936' has no RTP, not doing anything
[2009-04-08 17:16:22] DEBUG[24858] chan_sip.c: Outgoing Call for 447xxxxxx503
[2009-04-08 17:16:22] DEBUG[24858] chan_sip.c: Updating call counter for outgoing call
[2009-04-08 17:16:22] DEBUG[24858] chan_sip.c: Our T38 capability (0), joint T38 capability (0)
[2009-04-08 17:16:22] DEBUG[24858] chan_sip.c: ** Our capability: 0x3f08fe (gsm|ulaw|alaw|g726|adpcm|
[2009-04-08 17:16:22] DEBUG[24858] chan_sip.c: ** Our prefcodec: 0x2 (gsm)
[2009-04-08 17:16:22] DEBUG[24858] chan_sip.c: This call needs video offers, but there's no video support enabled!
[2009-04-08 17:16:22] DEBUG[24858] chan_sip.c: -- Done with adding codecs to SDP
[2009-04-08 17:16:22] DEBUG[24858] channel.c: Internal timing is disabled (option_internal_timing=0 chan->timingfd=-1)
[2009-04-08 17:16:22] DEBUG[24858] chan_sip.c: Done building SDP. Settling with this capability: 0x3f08fe (gsm|ulaw|alaw|g726|adpcm|
[2009-04-08 17:16:22] VERBOSE[24858] logger.c: [2009-04-08 17:16:22] -- Called toSwitchConnectVoIP/447xxx
[2009-04-08 17:16:22] DEBUG[24858] channel.c: Set channel SIP/toSwitchConnectVoIP-08
[2009-04-08 17:16:22] DEBUG[24858] channel.c: Set channel IAX2/01133326209-11936 to write format slin
[2009-04-08 17:16:22] DEBUG[24858] channel.c: Set channel IAX2/01133326209-11936 to read format slin
[2009-04-08 17:16:22] DEBUG[24858] channel.c: Set channel SIP/toSwitchConnectVoIP-08
I'm wondering if the cellphone provider is blocking the name...
Setting the callerid in the dialplan should force it to use whatever is there..... so i'm leaning toward provider setup issue, or the cell phone provider is blocking the name portion. Have you tried calling a land line with the call id name set ?
I don't think it'd down to the cellphone people (O2 in this case), as when there is something in the Zoiper Callerid field, then the CLI comes through just fine.
Also, Switch Telecom (who are providing the trunk via which Asterisk connects to the outside world) are also saying that the calls which come through to my mobile with no CLI also have no CLI when they pass through Switch's network.
The really weird thing is how the presence or absense of data in the callerid field of the softphone appears to somehow control this behaviour.
Put *anything at all* in the number field in Zoiper, whether it's a phone numbr or just random text (as I've said, I've tested this by typing the word "gibberish" into that field), and then the extensions.conf settings work, and the correct CLI (not the nonsense in the Zoiper fields) is provided when the call goes out. But if the callerid number field in Zoiper is left blank, then even though Asterisk's log shows the "Set" commands being carried out, no CLI is set on the line, and both Switch and O2 see the calls with no CLI.
As the upstream trunk needs the CLIs to be able to accurately bill the calls, we absolutely have to get this working properly - it's driving me up the wall at the moment!
Version: Asterisk 1.4.19.2
Unfortunately we don't control all the phones that will be connecting, when the service launches end users will make calls and be billed for them, so it's absolutely vital that every caller's CLI is set by Asterisk.
(sorry, meant to post this last night, but evidently forgot to click submit!)
I'm at a loss on this one....it should "just work"...especially if it already works from the softphone.
I've never had to do this myself, but i'm pretty sure it is possible to run a sniffer such as wireshark to examine the SIP header for callerid information.
I would try that, so that you can verify if the server is actually sending the information, and whether or not the carrier just isn't recieving it for whatever reason...
Ok...I think this might be it....
Have you tried using the........ fromuser="yourcallername" <5555555555>
......in the peer entry ?
[your_provider]
type=peer
fromuser="Yourname" <5555555555>
canreinvite=no
insecure=very
host= xxx.xxx.xxx.xxx
disallow=all
allow=ulaw
qualify=yes
nat=no
http://www.voip-info.org/w
fromuser = <from_ID> : Specify user to put in "from" instead of $CALLERID(number) (overrides the callerid) when placing calls _to_ peer (another SIP proxy). Valid only for type=peer.
I wonder if adding sip headers could fix this.
I found this on the wiki.
Sip header manipulation examples
These examples may be beneficial when interfacing Asterisk with a Nortel SST or an Acme Packet SBC.
Sending RFC-3323 compliant privacy headers in sip calls
ftp://ftp.rfc-editor.org/i
exten => _9.,1,SIPAddHeader(P-Asser
exten => _9.,n,SIPAddHeader(Privacy
exten => _9.,n.SetCallerPres(prohib
exten => _9.,n,Set(CALLERID(num)=)
exten => _9.,n,Set(CALLERID(name)=A
exten => _9.,n,Dial(SIP/+${EXTEN:1}
exten => _9.,n,Hangup()
Sending RFC-3325 compliant privacy headers in sip calls
ftp://ftp.rfc-editor.org/i
exten => _9.,1,SIPAddHeader(P-Prefe
exten => _9.,n,SIPAddHeader(Privacy
exten => _9.,n.SetCallerPres(prohib
exten => _9.,n,Set(CALLERID(num)=)
exten => _9.,n,Set(CALLERID(name)=A
exten => _9.,n,Dial(SIP/+${EXTEN:1}
exten => _9.,n,Hangup()
I tried it like this:
exten => _07.,1,SIPAddHeader(P-Asse
exten => _07.,n,SIPAddHeader(Privac
exten => _07.,n,SetCallerPres(prohi
exten => _07.,n,Set(CALLERID(num)=0
exten => _07.,n,Set(CALLERID(name)=
exten => _07.,n,Dial(SIP/toSwitchCo
Still no joy - now the CallerID doesn't come through at all, regardless of what is in the CallerID box on the softphone.
We're going to try upgrading to 1.4.24.1 (from 1.4.19.2), and see if that changes anything.
More info:
This problem only appears to affect Zoiper softphones. One of our engineers has tried a variety of other softphones, and not encountered the same problem, so whatever is clearing the CallerID (and over-riding the setting of it in Asterisk) is specific to Zoiper. Anyone got any theories on this?
Update: The problem is with the server running Asterisk.
Having exhausted all possible configuration options, we installed Asterisk on a different system (SuSE based), duplicated the config exactly (bar the local IP in sip.conf) and repeated the tests. Asterisk performed correctly with the dial plan (extensions.conf) settings over-riding whatever was set in the softphone, or adding them if the softphone was cleared of CallerID.
The server in question will now be replaced by a SuSE-based system.
The configuration which displayed the problem was Asterisk 1.4.x running on CentOS.
Thanks to everyone for looking at the issue with us, it was a very bizarre and seemingly one-off fault.
Final update: Found the underlying cause. Asterisk on this system wasn't running as root. Switching it to run as root solved the problem.
Speculation / guesswork, but it appears to work something like this:
If the calling device sets a CallerID, then the variable space is initialised, and hence Asterisk can update it. But if the calling device didnt set the field at all (which is presumably what Zoiper does when no CallerID is set) then the field isnt initialised in the first place and hence theres nothing for Asterisk to set, and as its not root it doesnt have permission to create the variable space.
Business Accounts
Answer for Membership
by: xuserx2000Posted on 2009-04-07 at 10:55:55ID: 24090037
If you put the callerid in the iax.conf/sip.conf file..it will override whatever is in the softphone. If you hard code the callerid in the dialplan just before Dial()..it will override whatever is in the softphone and whatever is configured in sip.conf/iax.conf.
(name)=YOU RNAME) (num)=5555 555555) ${EXTEN},6 0)
(all)=YOUR NAME <5555555555>)
example...
exten => _NXXNXXXXXX,1,Set(CALLERID
exten => _NXXNXXXXXX,n,Set(CALLERID
exten => _NXXNXXXXXX,n,Dial(zap/r2/
You can also set it all in one line...
exten => _NXXNXXXXXX,1,Set(CALLERID