How to block the incoming number in Asterisk

Hi All,

Need quick help. I need to block the incoming call in Asterisk.
I am doing this but its not working. Can you help what i am missing here.

Tried This --> This Did not worked.

#database put blacklist 0405512345 “Block Test Number”

#database del blacklist 0405512345

Tried This --> As well but it did not worked as well

#database put blockcaller 0405512345 1

Updated database successfully

#database get blockcaller 0405512345
Value: 1

Please advice what i am missing.

Even I tried using the country code but this also did not fixed the problem.

#database put blacklist +61123456789 “Cell Number”

#database put blockcaller +61123456789 1

hi,

try to add this in your dialplan :

same => n,set(ANUMBER=${CALLERID(number)})
same => n,execif($[${ANUMBER:0:2}=44]?hangup(21):noop(caller_number_ok))

it will drop incoming call with Calling Number 44xxxxxxxx
but will not work with calling number +44xxxxx.

if you have a lot of blacklisted number, better using agi.

If this is the local number i want to block:-
04123456789

Please help me to write the exact syntax. Also do i need to make these changes in the extension.conf file.

same => n,set(ANUMBER=${CALLERID(number)})
same => n,execif($[${ANUMBER:0:2}=44]?hangup(21):noop(caller_number_ok))

Is this right

same => n,set(ANUMBER=${CALLERID(04123456789)})
same => n,execif($[${ANUMBER:0:2}=44]?hangup(21):noop(caller_number_ok))

no.

this is to block a specific calling_number :
same => n,execif($[${CALLERID(number)}=04123456789]?hangup(21):noop(caller_number_ok))

Yes, I just want o block one number.

Will this work ?

this is to block a specific calling_number :
same => n,execif($[${CALLERID(number)}=04123456789]?hangup(21):noop(caller_number_ok))

Where and which file should i make this change ?

put it in your incoming dialplan

Is it

etc/asterisk/extension.conf

dir
acl.conf cdr_custom.conf cli_aliases.conf extensions.conf.old manager.conf pjsip.conf res_pgsql.conf statsd.conf
adsi.conf cdr_manager.conf cli.conf extensions.lua meetme.conf pjsip_notify.conf res_pktccops.conf telcordia-1.adsi
agents.conf cdr_mysql.conf cli_permissions.conf extensions_minivm.conf meetme.conf.old pjsip_wizard.conf res_snmp.conf test_sorcery.conf
alarmreceiver.conf cdr_odbc.conf codecs.conf features.conf mgcp.conf queuerules.conf res_stun_monitor.conf udptl.conf
alsa.conf cdr_pgsql.conf confbridge.conf features.conf.old minivm.conf queues.conf rtp.conf unistim.conf
amd.conf cdr_sqlite3_custom.conf confbridge.conf.old festival.conf misdn.conf res_config_mysql.conf rtp.conf.old users.conf
app_mysql.conf cdr_syslog.conf config_test.conf followme.conf modules.conf res_config_sqlite3.conf say.conf voicemail.conf
app_skel.conf cdr_tds.conf console.conf func_odbc.conf motif.conf res_config_sqlite.conf sip.conf voicemail.conf.old
ari.conf cel.conf dbsep.conf hep.conf musiconhold.conf res_corosync.conf sip.conf.old vpb.conf
ast_debug_tools.conf cel_custom.conf dnsmgr.conf http.conf muted.conf res_curl.conf sip_notify.conf xmpp.conf
asterisk.adsi cel_odbc.conf dsp.conf iax.conf ooh323.conf res_fax.conf skinny.conf
asterisk.conf cel_pgsql.conf dundi.conf iaxprov.conf osp.conf res_ldap.conf sla.conf
calendar.conf cel_sqlite3_custom.conf enum.conf indications.conf oss.conf res_odbc.conf smdi.conf
ccss.conf cel_tds.conf extconfig.conf indications.conf.old phone.conf resolver_unbound.conf sorcery.conf
cdr_adaptive_odbc.conf chan_dahdi.conf extensions.ael logger.conf phoneprov.conf res_parking.conf ss7.timers
cdr.conf chan_mobile.conf extensions.conf logger.conf.old pjproject.conf res_parking.conf.old stasis.conf

which file should i make this change.

We can’t answer that without the complete contents of extension.conf, extensions.lua, and extensions.ael, and all the files included from them, as we have no idea how you have written your dialplan.

If you don’t know which file to modify, you are unlikely to know how to modify it without further (self) training, or paid for consultancy.

I completely agree with you David. I am going through the online Asterisk training.
As I need to fix this issue. Not sure how to proceed further on the same.

Thanks

Hi All,

These two commands can block this caller ? Incoming caller which i want to block is - 123456789

exten => s,1,GotoIf($["${CALLERID(num)}" = “123456789”]?block)
exten => s,n(block),Hangup()

They will only do that if there is code between them that does something for non-blocked callers. With just those two lines, the fallback priority and the branch target are both the next priority.

You should also google “ex-girlfriend logic”, as you can do this with

exten => s/123456789,n,Hangup()
exten => s,s,Noop
1 Like