• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 2961
  • Last Modified:

Asterisk syntax for blocking caller id


  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
  • 5
  • 3
1 Solution
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.
jkocklerAuthor Commented:
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!
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.
Improve Your Query Performance Tuning

In this FREE six-day email course, you'll learn from Janis Griffin, Database Performance Evangelist. She'll teach 12 steps that you can use to optimize your queries as much as possible and see measurable results in your work. Get started today!

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.
jkocklerAuthor Commented:
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 !
jkocklerAuthor Commented:
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.
jkocklerAuthor Commented:

  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.  
jkocklerAuthor Commented:
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!
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: SQL Server Core 2016

This course will introduce you to SQL Server Core 2016, as well as teach you about SSMS, data tools, installation, server configuration, using Management Studio, and writing and executing queries.

  • 5
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now