I've done something similar and like the other submitter, I used a database. Instead of using the built int DB functionality, I used cmd MySQL. This was so I could write a web page that interacts with the same DB AND my DBA could do cross DB selects between this "Directory" table and the MySQL CDR.
In my example, I setup a table with 4 fields. id
(auto_increment int), number
(the phone number), name
(The name of user), ban
(an int that defaults to 0). The example does 2 things, 1- it looks up name from the DB and sets that as the caller id (Since our POTS line doesn't communicate that) 2- It looks up to see if ban
is set to 1, and blocks the call.
exten => s,1,Answer
exten => s,n,NoOp("Caller ID IS: ${CALLERID(number)}")
exten => s,n,MYSQL(Connect connid HOST USER PASSWORD database)
exten => s,n,MYSQL(Query resultid ${connid} SELECT name,ban FROM directory WHERE number='${CALLERID(number)}')
exten => s,n,MYSQL(Fetch fetchid ${resultid} name ban)
exten => s,n,NoOp("We found: ${name} ${ban}")
exten => s,n,MYSQL(Clear ${resultid})
exten => s,n,MYSQL(Disconnect ${connid});
exten => s,n,Set(CALLERID(name)=${name})
exten => s,10,NoOp()
exten => s,n,GotoIf($["${ban}" = "1"]?wedontlikeyou,s,1)
exten => s,n,Goto(mainmenu,s,1)
After this you'd have your [mainmenu] and [wedontlikeyou]. The later is your ban, it could be a simple hangup, error message, what ever you want. My preference is Congestion() since that tends to make people think the phone number is out of service.
Best Answer
Your config is correct. Your carrier is likely preventing you from setting an arbitrary CID number; check with them.