Asterisk: Blacklisting For Multiple Users – June 06, 2009

There are a number of tutorials for people trying to setup blacklisting for their Asterisk server, but they all seem to assume that there is only one user on the server, or at least all users want to share the same blacklist.

Since I host for multiple, unrelated people, they don't necessarily want to share the same blacklist, so I had to come up with a configuration that would work for all customers.

Here are the changes I made (for Asterisk 1.4)

Outgoing dialplan: (custom per user)

Incoming dialplan: (custom per user)

Macros:(shared among all users; I use /etc/asterisk/custom/extensions-default.conf, and have a #include "custom/extensions-*.conf" in the default extensions.conf)

You should replace "<customername>" with the name of the customer, so each customer uses a different database (note you could use the same name for certain customers, if some of them want to share the blacklist, but everyone does not).

Replace <context>, <extension> and <priority> with the appropriate values for where to jump to if a blacklisted number is found.  (I find this nicer than the n+100 syntax, particularly since I always use "n" everywhere, rather than actual hard-coded numbers (ah, remember the good old days of basic, where you always numbered your lines: 10, 20, 30, so there was room to add in code later?).

And that's it.  You can use "database show" from within the CLI to watch the entries as they are added.

If it isn't clear from the above code and comments:

*32 blacklists the number of the person who called most recently
*31 removes a number from the blacklist (you'll have voice prompts to prompt you to enter and confirm the entry)
*30 adds a number to the blacklist (same voice prompts as with *31)

The only downside of this method is that the *32 requires that there aren't lots of calls per user, so the lastcallerid value is still valid (e.g. if you were at a call center, where you had lots of incoming calls, and didn't have time to dial *32 before the next call came in, you'd have to never use *32, and use *30 and manually enter the number instead).


Questions? Have Anything to Add?
(your comments will be published on this site - click here for private questions)

Hi,
How can i increase delay between each digit when read and say digit from Database.It is too fast for customers to listen and write.

Please help me, i will appreciate your help.

Regards,
Haseeb.

Posted by haseeb on October 17, 2009, 8:23 am

I guess you could use the CUT function to get each digit, and say it one at a time, with a delay in between. Though, the customers don't need to write down anything, so perhaps you were just hoping for a link to your company...

Posted by jondaley on October 17, 2009, 3:04 pm

Can you please tell me where should I modify Outgoing and Incoming dialplan for each user that will use blacklist?
I'm not quite sure in which config I should look for that.
Thanks
Regards
S

Posted by Sebastian on February 4, 2010, 7:00 am

Unfortunately, it depends on how you have things setup. But, basically, you can put the outgoing section in whatever context each user uses for his outgoing context (each user has to have his own outgoing context - if you only have one context currently that everyone shares, you'll need to change that to have each user have his own and then include the shared context).

The incoming side should be easier, since they have to have separate contexts, so just paste in the incoming section at some point (probably towards the top) in the incoming context.

And I can't even tell you which file, since different people set it up differently.

I try to not modify any files in the /etc/asterisk directory, except to add an include line to /etc/asterisk/extensions.conf to include *-extensions.conf in /etc/asterisk/custom/ and include *-sip.conf in /etc/asterisk/sip.conf.

I couldn't figure out a good way to not modify the voicemail.conf nor the users.conf. I used to not modify the users.conf, but I changed that within the last couple months - I forget what the reason was at the moment.

Posted by jondaley on February 4, 2010, 8:06 am