Blocking phone numbers


I’ve done some research but have had no luck.

Is it possible to block numbers inbound and if so how?


Yes it is, just check the caller id in the dialplan; the function CALLERID(num) returns the caller number.


Marco Bruni

Put the number(s) into the asterisk database: (with asterisk running on the console do an ‘asterisk -r’ to connect to the console), then do the following command, replace number with the no. you want to block.

database put blacklist NUMBER some_name

database show (will show you your DB contents)

In your dialplan you will want something like below in your main inbound call context, this should be the first line, the rest of the asterisk commands after this Answer() etc etc I will assume you know:
exten => s,1,GotoIf(${DB_EXISTS(blacklist/${CALLERID(num)})}?blacklisted,s,1)

Then create a context called blacklisted:

exten => s,1,Answer
exten => s,2,Wait(1)
exten => s,3,Zapateller
exten => s,4,Zapateller
exten => s,5,Playback(ss-noservice)
exten => s,6,Hangup