How to BLOCK/anonymize the CallerID of incoming calls?


When someone is calling one of my DIDs and has requested to be anonymous, my provider is sending me the call mentioning the anonymity request via using the P-Asserted-Identity but also sends the actual number.

The problem is that the actual number gets passed on to whatever destination extension I have set. How can I prevent the calls that are meant to be anonymous from passing the number to the destination DIDs? Ideally the connected sip phones should see something like “anonymous” instead of the number in order to protect the anonymity of the caller.
I tried everything however I could not make it work. I am confused! :cry:

An example below is when I am calling from an external anonymous line:

From: sip:(myHIDDEN-TelephoneNumber)@x.x.x.x
Privacy: id

…where myHIDDEN-TelephoneNumber is the actual number of the external line and x.x.x.x the IP of my asterisk.
I am using Asterisk 11.14

Many thanks for any help!

Can someone please suggest what is required to do this?

Ideally there must be a mechanism that checks if the caller requested anonymity or not. If yes the call should be transferred with anonymous callerID to the destination extension in asterisk but the incoming actual ID received must be available in the CDRs only for the server administrator to see.

Set the caller ID from the dialplan.

david55 is correct that you will likely need to set this yourself in the dialplan by reading the SIP headers. The function you need is SIP_HEADER.

You may have to play around to find the correct information but something like this should be the way:

same => n,Set(check=${SIP_HEADER(P-Asserted-Identity)}
same => n,GotoIf($["${check}" != “”]?anon:dial
same => n(anon),Set(${CALLERID(name)}=“PRIVATE”)
same => n,Set(${CALLERID(num)}="")
same => n(dial),Dial…

Depending on your dialplan, the callerid may be PRIVATE or not.

Can someone please share some dialplan lines so I can start from somewhere?
I am not familiar at all with writing dial plans but with some help I might get somewhere.
I have used dialplans that change the incoming DID but this is entirely different as it needs to read sip headers.
Not a clue! :cry:

nikole: You’ve already been given more dialplan that you can reasonably expect for free.

aweinburger: I think the problem here is not having Asterisk 101, but if caller ID is being sent in P-Asserted-ID, setting “trustrpid” to yes should capture all the information in a way that can be accessed through various ${CALLERID(…)} options.