(aka: anon caller ID, anonymous CID, blocked caller, blocked CID, private caller, private CID, *67, #31#, *81)
My situation:
-
I seek to have per-call CIDblocking effected on outbound calls, de/activatable via CLASS codes (aka STAR-codes)
-
so, if I dial a number straight up, it AUTOMATICALLY places the ‘*67’-style CID-block on this outbound call
-
alternatively, if I want to PROVIDE my CID to my destination, then I prefix the dialed num with *67 (or even *31#)
-
while I’m there: if I dial a 7-digit phnum then automatically prefix my AreaCode to the phnum (replace ‘NPA’ with your local areacode in DialPatterns below)
Problem observation wrt CIDhide:
-
In FreePBX, if one sets the HideCallerID flag
(via EditTrunk/Tab=General/HideCallerID)
this seems to just set the CID to be:
“hidden” <>
but… this conflicts with VoIP.ms’ requirement that the
proper CID be provided to VoIP.ms at time of call placement
(i.e. the proper number gets placed between <> chars) -
In response, in order to effect CIDblocking (aka *67-dialing) one must:
- populate CID field with sufficient info
(esp phnum) to keep VoIP.ms happy, and
- at a ‘low-level’ set the ‘withhold-CID’ flag for the call
Below sol’n tested as working with Bell Canada (Wireless) as term carrier, and ‘Private Caller’ (or maybe it was ‘Private Number’) came up as both CIDnumber and CIDname, using FreePBX v15.0.17.24, with Asterisk v16.11.1.
================================================================================================
The TL;DR sol’n:
- Using sub-accounts on VoIP.ms create one each of a subaccount for
CIDshow and CIDhide calls; set each as DeviceType=Asterisk & CIDnumber=IuseSystemCapable...
- using DialPatterns on OutboundRoutes we route calls to one or the
other of a Trunk designated for CIDshow, or CIDhide, calls
- each of the two Trunks attaches to a subaccount: CIDshow or CIDhide
- we set the CID on the CIDshow Trunk to be: "real_name" <my_10_digit_phnum>
- we set the CID on the CIDhide Trunk to be: "private" <my_10_digit_phnum>
- in /etc/asterisk/extensions_override_freepbx.conf we add:
[macro-dialout-trunk-predial-hook]
exten => s,3,ExecIf($[ "${CALLERID(name)}" = "private" ]?Set(HASH(__SIPHEADERS,Privacy)=id))
exten => s,5,MacroExit()
================================================================================================
More verbosely…
What happens below is that with an outbound route dedicated
(by way of using DialPattern matching) to CIDhide calls, we’ll
send the calls out via a Trunk dedicated to CIDhide calls.
This trunk has its CID setup with a ‘triggering’ name
(“private”), which gets matched in code that is hooked into the
predial context, and where the ‘withhold-CID’ flag then gets
activated.
=============
Step 1:
On VoIP.ms, for each of the two subaccounts (CIDhide and CIDshow):
Device type: Asterisk, IP PBX, Gateway or VoIP Switch
CallerID Number: I use a system capable of passing its own CallerID
(Strictly speaking one does not need separate sub-accounts but
it helps with call segregation [accounting] at VoIP.ms' end.)
=============
Step 2:
========================================================
Prepare FreePBX Route & Trunk for CIDshow...
========================================================
- In FreePBX, create a trunk for CIDshow calls,
named VoIP.ms####_CIDshow; populate PJSIP settings
- In FreePBX, create an OutboundRoute for CIDshow calls,
named ####_CIDshow_*67; populate DialPatterns as follows:
===============================================================
PREPEND PREFIX MatchPattern CallerID
===============================================================
*31# 1nXXnXXXXXX
*31# n11
*31# nXXnXXXXXX
NPA *31# nXXXXXX
*67 1nXXnXXXXXX
*67 n11
*67 nXXnXXXXXX
NPA *67 nXXXXXX
===============================================================
RouteSettings/TrunkSequenceForMatchedRoutes: VoIP.ms####_CIDshow
===============================================================
- In FreePBX, for trunk named VoIP.ms####_CIDshow - make sure it's working with the O/B route
========================================================
Prepare FreePBX Route & Trunk for CIDhide...
========================================================
- In FreePBX, create a trunk for CIDhide calls, named VoIP.ms####_CIDhide; populate PJSIP settings
- In FreePBX, create an OutboundRoute for CIDhide calls, named ####_CIDhide_*67; populate as follows:
===============================================================
PREPEND PREFIX MatchPattern CallerID
===============================================================
1nXXnXXXXXX
n11
nXXnXXXXXX
NPA nXXXXXX
===============================================================
RouteSettings/TrunkSequenceForMatchedRoutes: VoIP.ms####_CIDhide
===============================================================
- In FreePBX, for trunk named VoIP.ms####_CIDhide - make sure it's outdialing with the O/B route
==================================================================
In FreePBX, for the CIDhide Trunk:
-----------------------------------
{tab=General}
Hide CallerID=No
Outbound CallerID="private" <your_10_digit_phnum>
CID Options=Force Trunk CID
==================================================================
=============
Step 3:
Into this file:
/etc/asterisk/extensions_override_freepbx.conf
we'll insert the secret sauce:
[macro-dialout-trunk-predial-hook]
exten => s,1,NoOp(***** EnforceCIDblock-BEGIN [SuperVerbose] ***** EXTEN=${EXTEN} CIDnum=${CALLERID(number)} CIDname=${CALLERID(name)})
exten => s,2,ExecIf($[ "${CALLERID(name)}" = "private" ]?NoOp(***** EnforceCIDblock-CIDname [Verbose] Maybe matched - check for 0/1 before NoOp <-------)
exten => s,3,ExecIf($[ "${CALLERID(name)}" = "private" ]?Set(HASH(__SIPHEADERS,Privacy)=id))
exten => s,4,NoOp(***** EnforceCIDblock-END [SuperVerbose] ***** )
exten => s,5,MacroExit()
=============
Step 4:
Activate changes in Asterisk by way of:
asterisk -rx 'dialplan reload'
=============
Step 5:
- reset logfile
e.g.: cat /var/log/asterisk/full >> /var/log/asterisk/full-`date +"%Y%m%d"`
printf "" > /var/log/asterisk/full
- test as desired
- locate activity in logging via:
grep -iE --color=always "Verbose\]" /var/log/asterisk/full
- profit!