CallerID Blocking

wardmundy

Nerd Uno
Joined
Oct 12, 2007
Messages
19,206
Reaction score
5,228
From a blog that is no longer available (before it disappears from Google's cache):

Code:
Asterisk Caller ID Blocking Recipe
25 Sep 2007 — eric
Here’s another quick little Asterisk recipe that I threw together. It’s a handy because it only takes about 10 minutes to setup and is infinitely useful to the sales types. Just a note, this was done with Asterisk 1.4.8.
 
I wanted to do a little in AEL just to get a feel for it. It is a little AEL and a little regular extensions.conf type stuff.
 
The basic way that this CallerID Blocking recipe works is to use the Asterisk DB. An entry with the family of CIDBlock and the key of the dialing users extension will have a value of 1 or 0. The user initially sets their preference to either enabled (1) or disabled (0). When the number gets dialed, the preference gets checked and then the CALLERID(name)/CALLERID(number) values are set accordingly. In order for the user to enable CID Blocking, they need to dial *81. It will stay enabled until they dial *82.
 
How do we accomplish this? Easy. The sounds come with the asterisk sounds package.
 
Open up your extensions.conf and add the following lines (to whichever context works for you):
 
; Enable CallerID Blocking for the dialing extension
exten => *81,1,Set(DB(CIDBlock/${CHANNEL:4:4})=1)
exten => *81,2,Playback(privacy-your-callerid-is)
exten => *81,3,Playback(enabled)
exten => *81,4,Hangup()
 
; Disable CallerID Blocking for the dialing extension
exten => *82,1,Set(DB(CIDBlock/${CHANNEL:4:4})=0)
exten => *82,2,Playback(privacy-your-callerid-is)
exten => *82,3,Playback(disabled)
exten => *82,4,Hangup()
The last modification that needs to happen is that you have to change the exten that dials out to check the DB and react accordingly. Here is a snippet of mine (with the numbers changed to protect the innocent):
 
; Outbound calling for 111.222.3456 (my phone number)
exten =>_1NXXNXXXXXX,1,Set(CIDBlock=${DB(CIDBlock/${CHANNEL:4:4})})
exten =>_1NXXNXXXXXX,2,Set(${IF($[${CIDBlock} = 1]?CALLERID(name)=Unavailable:CALLERID(name)=MyCompany)})
exten =>_1NXXNXXXXXX,3,Set(${IF($[${CIDBlock} = 1]?CALLERID(number)=0-1-999:CALLERID(number)=1112223456)})
exten =>_1NXXNXXXXXX,4,DIAL(SIP/provider/${EXTEN},60,tr)
exten =>_1NXXNXXXXXX,5,Hangup
That’s really all it takes to set it up. Quick and handy.
 
* Note: *81 & *82 are arbitrary number combinations. Adjust to what works for you.
 
If you’re feeling really frisky, I added this AEL extension to check the status of your CallerID Blocking on *83. For fun, I have also included my *67 script for those who need an idea of how its done. As with almost anything in Asterisk, there are many ways to do it, this is just how I chose to accomplish this.
 
// Extra's for sending things outbound
context outbound-extra {
  *83 => {
            Playback(privacy-your-callerid-is);
            Set(CIDBlock=${DB(CIDBlock/${CHANNEL:4:4})});
            if(${CIDBlock} == 1) {
                Playback(enabled);
            }
            else {
                Playback(disabled);
            }
            Hangup();
  };
 
  *67 => {
      // Remove the *67 from the number we are dialing
      Set(dialed_number=${EXTEN:3:11});
      Set(CALLERID(name)=Unavailable):
      Set(CALLERID(number)=0-1-999):
      DIAL(SIP/provider/${dialed_number},60,tr);
      Hangup();
  };
};

Code:
Lucky225 • 6 years ago
Or you could use something RFC-3323 compliant and not spoof some random BS number that's going to confuse cellphone callers(0-1-999, wtf?)
 
Sending RFC-3323 compliant privacy headers in sip calls
 
ftp://ftp.rfc-editor.org/in-no...
 
exten => _9.,1,SIPAddHeader(P-Asserted-Identity: )
exten => _9.,n,SIPAddHeader(Privacy: user\; header\; session)
exten => _9.,n.SetCallerPres(prohib_not_screened) ; this might not be needed --- needs further testing
exten => _9.,n,Set(CALLERID(num)=)
exten => _9.,n,Set(CALLERID(name)=Anonymous)
exten => _9.,n,Dial(SIP/+${EXTEN:1}@sipcarrier)
exten => _9.,n,Hangup()
 

Members online

Forum statistics

Threads
25,824
Messages
167,830
Members
19,249
Latest member
jetest
Get 3CX - Absolutely Free!

Link up your team and customers Phone System Live Chat Video Conferencing

Hosted or Self-managed. Up to 10 users free forever. No credit card. Try risk free.

3CX
A 3CX Account with that email already exists. You will be redirected to the Customer Portal to sign in or reset your password if you've forgotten it.
Top