Asterisk syntax for blocking caller id

Posted on 2009-04-11
Medium Priority
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
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 3
LVL 19

Accepted Solution

feptias earned 2000 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.
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

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

Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

Question has a verified solution.

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

So you think no one can listen in on your VOIP conversations, eh? Well... if you haven't setup Secure Real Time Transport (SRTP), your voice communications can be hacked into by just about anyone! First, let's talk about the intended audience for…
Almost all Internet protocol telephones have built-in switches at the back that allow you to connect your personal computer to one port and use the other port to connect your phone to to a Cisco switch.   Why we need to connect the PC to the pho…
NetCrunch network monitor is a highly extensive platform for network monitoring and alert generation. In this video you'll see a live demo of NetCrunch with most notable features explained in a walk-through manner. You'll also get to know the philos…
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…

777 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