Block calls without answering

Is it possible to block incoming calls before they are answered based on cli?

I’m assuming I can put something in dialplan before the answer line which will look-up the cli against a database and disconnect the call before it is answered.

Is this the right way to do this?

Thanks

Depends on the detailed channel technology. There is no way of rejecting analogue line calls**, but most other technologies allow you to call hangup with the appropriate ISDN clearing cause. E.g. hangup(1) signals number unavailable. Your network operator may limit the ones you can actually use.

Even answering and immediately hanging up may not clear the call.

It will be a sip channel and will have a cli.

The issue is I must not answer the call or I will be charged for it. The numbers are individual and I cannot pattern match thus I am thinking of having a database to hold the hundreds of numbers I need to block and perform a lookup as they enter the dial plan.

I take it this can’t be done before the dial plan

It can only be done from the dial plan, but it can be done before the call is answered. (Note it is usually an error to explicitly answer incoming calls unless you are going to run some sort of IVR.)