Asterisk syntax for blocking caller id

Posted on 2009-04-11
Last Modified: 2013-11-12

  In a scenario where I am setting the caller id for peers in my sip.conf file, is there a way to make asterisk not send the caller id information, if it receives *67 for example in the number dialed ?  To clarify, this scenario is if I am NOT using caller id settings on the actual peer device, but in Asterisk.  I would think there would be a way to setup a variable in the extensions.conf dial plan, to not send caller id if it sees something like *67 in the number.  

I am using Asterisk 1.4.23
Question by:jkockler
  • 5
  • 3
LVL 19

Accepted Solution

feptias earned 500 total points
ID: 24122715
exten => _*67X.,1,Set(CALLERID(num)="")
exten => _*67X.,2,Set(CALLERID(name)="Anon")
exten => _*67X.,3,Dial(SIP/${EXTEN:3}@sip_peer_name,45)

That should work if the dialed number is prefixed with *67 and you change "sip_peer_name" to whatever peer name you have defined in sip.conf for your outbound VoIP trunk. You can set the name and number to whatever you want. However, it is possible that your VoIP service provider will replace the blank number with the number that they have assigned to your account in which case you must ask them what method is available for withholding your caller ID.

Author Comment

ID: 24122924
Awesome, I will give it a shot. My voip provider is pretty laid back, so it should work.  I will let you know how I do.  thanks!
LVL 19

Expert Comment

ID: 24128478
This is really a comment on your more recent post about *67 on the Linksys SPA942. I haven't checked, but presume that *67 is a recognised prefix for "withhold caller ID". It must be that the Linksys is using this prefix to toggle a mode that effects all subsequent calls. There is probably another code that toggles it back again.

The Asterisk dial plan snippet that I posted in my earlier answer is telling Asterisk to recognise any call dialled with a *67 prefix as one where the Caller ID should be overwritten. The code does not have to be "*67". It could be anything, provided it is unique within the dial plan. So, perhaps you should choose a different prefix (one that the Linksys does not recognise) and modify the dial plan in Asterisk accordingly. Then only those calls with the new prefix will have Caller ID overwritten.

If this fixes the problem, I suggest you delete the other more recent question.
Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

LVL 19

Expert Comment

ID: 24128683
I've just looked at SPA941 Admin Guide. The Linksys phone recognises a wide range of star codes (Linksys refer to them as "Vertical Service Activation Codes". *67 is "Block CID on ALL outbound calls". *66 will unblock the CID. *81 is "Block CID on the next outbound call".

You need to be clear if you want the phone or the Asterisk server to block the CLI. You can use any prefix in front of the number, program the dialplan in Asterisk to detect it (as shown in my sample code above) and that will do the job on a "per call" basis. Alternatively, you can use the Linksys star codes such as *67, but these are not normally used as a prefix in front of a dialled number - they are just used on their own. They instruct the phone to do something, not the Asterisk server, so you would want Asterisk to ignore them if it receives them.

Author Comment

ID: 24129362
Thanks Fepitas.  Thanks for finding out what turns off the *67 from the phone.  I posted the other thread so I know how to do it both ways.  If I have asterisk doing it for a particular context, I will disable the feature on the phone, otherwise the phone does not send the *67 over to Asterisk.  The reason for wanting to do it both ways is, just in case one particular scenario, I absolutely have to have the commands executed from the phones.  I would always prefer to do it from the Asterisk side though because I believe it to be more powerful and flexible.  Thanks for all your help !

Author Comment

ID: 24129378
You should paste your explanation on turning off *67 on the phone to my other post, so you credit for answering both questions.  It was a legitimate need to know both ways so I see no reason for you not to get 1000 points.

Author Comment

ID: 24768238

  Sorry for the long lag on getting back to this one, as I just now got around to testing it.  

So far I am having an issue the Linksys spa942, not sending the *67 .. I have disabled block CID everywhere I can find it in the phone, and even changed the Block CID vertical service code.  No matter what I do, the phone sends only *67 to asterisk,  and drops off the rest of the number.  I can see it right on the display of the phone.  I push *6744444444, hit dial, and the phone drops to fast busy, and only shows *67 on the display as last number dialed.

Asterisk verbose shows that it rejected "*67" extension, so I know that is did not get the rest of the number.  

Author Comment

ID: 24769187
Well I was able to get it working, I had to actually modify the dial plan within the phone, at the bottom of the extension tab, to look like this


Then change the vertical service code in regional to something other than *67 ... I chose *99....

Then I used your dial plan from above, but slightly modified to be more specific, in cases where people forget to dial a 1, which then makes a case for having to add an entry for people who do dial a 1, and this is what it looks like.

exten => _*67NXXXXXXXXX,1,Set(CALLERID(num)="")
exten => _*67NXXXXXXXXX,n,Set(CALLERID(name)="Anon")
exten => _*67NXXXXXXXXX,n,Dial(SIP/1${EXTEN:3}@my_service_provider)

exten => _*671NXXXXXXXXX,1,Set(CALLERID(num)="")
exten => _*671NXXXXXXXXX,n,Set(CALLERID(name)="Anon")
exten => _*671NXXXXXXXXX,n,Dial(SIP/1${EXTEN:4}@my_service_provider)

And of course the "imaginary" voip local calls:

exten => _*67NXXXXXX,1,Set(CALLERID(num)="")
exten => _*67NXXXXXX,n,Set(CALLERID(name)="Anon")
exten => _*67NXXXXXX,n,Dial(SIP/1***${EXTEN:3}@my_service_provider)

where *** is the local area code for the caller.  Works like a charm!!!

Thanks Fepitas!

Featured Post

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Ever wanted to query Cisco Call Manager CDR records from MS SQL Server? Here's how! CUCM can be configured to upload a CDR file to a given FTP server every minute. This article will show you how to set this up, schedule the import of this data an…
There are no good configuration guides for HP-H3C router to LYNC on the web. :( Big statement, but we havent been able to find one yet. We did find the following document useful, but the information was not enough to use H3C router for use as a L…
This tutorial gives a high-level tour of the interface of Marketo (a marketing automation tool to help businesses track and engage prospective customers and drive them to purchase). You will see the main areas including Marketing Activities, Design …
Windows 10 is mostly good. However the one thing that annoys me is how many clicks you have to do to dial a VPN connection. You have to go to settings from the start menu, (2 clicks), Network and Internet (1 click), Click VPN (another click) then fi…

815 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now