Asterisk func callerid





The allowed values for <item> are:

  • name: alphanumeric string
  • num or number: number at which caller prefers to be called back (digits only in the POTS/ISDN world)
  • all: a Caller*ID string with the number specified between angle-brackets, e.g. "Some User <123>"
  • ani: "automatic number identifaction" - billing number (digits only in the POTS/ISDN world)
  • dnid: dialed number (digits only in the POTS/ISDN world), don't confuse with DNIS
  • rdnis: redirected dialed number information service (digits only in the POTS/ISDN world)
  • pres: call presentation/screening (textual representation, 1.6)
  • ton: type of number (digits only, 1.6)


  • This function may be both read from and written to.
  • ton can be 0(unknown — i.e., includes dial prefixes), 1(international), 2(national), 4(subscriber)
  • number is deprecated and doesn't work in 1.6.
  • CALLERID(num) and CALLERID(name) control the parts of the SIP address before the @ in the 'From' header under normal conditions.
  • AASTRA CID BUG: Setting CID (under sip.conf) to something other than the default (asterisk) with spaces in it (ex: Unknown Caller) when no CID is available will cause asterisk to Dial the Aastra phone, but it will not "ring".(tested with 480i ct firmware

ISDN (Q.931) only permits ASCII characters (more precisely: the IA5 character set) as CallerID name, see also the FILTER function. If indeed you would like to present special characters on an IP phone's display you will most probably have to turn to UTF-8 enconding:

NAME=`echo $NAME | iconv -f ISO-8859-1 -t UTF-8`

Asterisk 1.8

Asterisk 1.8 has an expanded CALLERID function. <item> can be one of:
  • all
  • name
  • name-valid
  • name-charset
  • name-pres
  • num
  • num-valid
  • num-plan
  • num-pres
  • subaddr
  • subaddr-valid
  • subaddr-type
  • subaddr-odd
  • tag
  • ANI-all
  • ANI-name
  • ANI-name-valid
  • ANI-name-charset
  • ANI-name-pres
  • ANI-num
  • ANI-num-valid
  • ANI-num-plan
  • ANI-num-pres
  • ANI-tag
  • DNID
  • dnid-num-plan
  • dnid-subaddr
  • dnid-subaddr-valid
  • dnid-subaddr-type
  • dnid-subaddr-odd

and you can set these to one of:
  • allowed_not_screened
  • allowed_passed_screen
  • allowed_failed_screen
  • allowed
  • prohib_not_screened
  • prohib_passed_screen
  • prohib_failed_screen
  • prohib
  • unavailable

e.g. to hide your caller id, use: Set(CALLERID(num-pres)=prohib)

When using ISDN, some systems may reject certain information elements (IEs) of the SETUP message and respond with error 100. It is possible to suppress the unwanted elements of the SETUP message as follows:
SETUP IE Suppress Call
Display Set(CALLERID(name-valid)=no)
Calling Party Number Set(CALLERID(num-valid)=no)

Upgrading to Asterisk 1.4

The behavior of the "clid" field of the CDR has always been that it will
contain the callerid ANI if it is set, or the callerid number if ANI was not
set. When using the "callerid" option for various channel drivers, some
would set ANI and some would not. This has been cleared up so that all
channel drivers set ANI. If you would like to change the callerid number
on the channel from the dialplan and have that change also show up in the
CDR, then you *must* set CALLERID(ANI) as well as CALLERID(num).


; Retrieve the Caller*ID string and save it off for later use
exten => s,1,Set(CallerIDString=${CALLERID(all)})

; Set our Caller*ID before we dial out
exten => s,1,Set(CALLERID(name)=Asterisk PBX)

From Domain

If you are trying to change the part that is to the right of the @ sign, then you want fromdomain, in your sip.conf

Security advisory

Asterisk Project Security Advisory - AST-2011-001
Summary: Stack buffer overflow in SIP channel driver
Reported on January 11, 2011

The issue was fixed in Asterisk versions:


When forming an outgoing SIP request while in pedantic mode, a
stack buffer can be made to overflow if supplied with
carefully crafted caller ID information. This vulnerability
also affects the URIENCODE dialplan function and in some
versions of asterisk, the AGI dialplan application as well.
The ast_uri_encode function does not properly respect the size
of its output buffer and can write past the end of it when
encoding URIs.


The size of the output buffer passed to the ast_uri_encode
function is now properly respected.

In asterisk versions not containing the fix for this issue,
limiting strings originating from remote sources that will be
URI encoded to a length of 40 characters will protect against
this vulnerability.

exten => s,1,Set(CALLERID(num)=${CALLERID(num):0:40})
exten => s,n,Set(CALLERID(name)=${CALLERID(name):0:40})
exten => s,n,Dial(SIP/channel)

The CALLERID(num) and CALLERID(name) channel values, and any
strings passed to the URIENCODE dialplan function should be
limited in this manner.

How to add Caller ID Name before the Caller ID on inbound Trunks

For instructions on how to set the caller ID name to be prefixed before the Caller ID Number on your inbound trunks. This site provides detailed instruction and examples on how to add CID Name into your dial plan.

See also

Created by: Corydon76, Last modification: Fri 08 of Mar, 2013 (05:01 UTC) by kubarebo
Please update this page with new information, just login and click on the "Edit" or "Discussion" tab. Get a free login here: Register Thanks! - Find us on Google+