Exclude certain extensions from IVR

I need to exclude some extensions from the from-did-direct-ivr context as they shouldn’t be available from outside. How can I implement this?

create IVR options with the extension numbers as the IVR options, then point them somewhere else like back to the IVR, to an error message, etc.

That would be a local hell as we’ve got 100+ extensions. Are there any asterisk dialplan tricks so I could override and effectively disable needed extensions from from-did-direct-ivr-custom? Or maybe there is some easy opportunity for dirty patching php code.

How many extensions to you want allow vs how many do you want to block? You really didn’t provide enough info in your 1st post for anyone to help. Philippe gave the best answer based on the info you provided.

Screwing around as you say “dirty patching” is the best way I know if to kill a functioning FreePBX system. I manage a 200 phone system, and I wouldn’t hesitate to use Philippe’s solution if I wanted to block some extensions. I wouldn’t be able to do it all at one sitting, but it would get done.

You could, perhaps, use the inverse of Philippe’s suggestion. If you have relatively fewer numbers you want to allow, uncheck the block which allows dial through and enter IVR options which point to the extension. That is, ivr option 1234 points to extension 1234.


The ratio is about 10 blocked to 100 available. We have a dynamic system so using any static methods that require painful hand work will only bring mess.
I find patching extensions_additional from cron with reloading dialplan every N minutes a better idea, but still dirty as it’s rather workaround than solution.

Can you intentionally set the 10-to-be-blocked to meet some pattern distinct from the others – e.g. any 300-series (300-399). Subject to your other dial plan goings-on – it may then be reasonable to do a persistent _3XX intercept/redirect.


When freePBX generates an IVR for me, the top of the IVR dial plan context looks like this…

include => ivr-2-custom <-- this is already here by freePBX design.
exten => h,1,Hangup
exten => s,1,Set(MSG=…)
exten => s,…
exten => s,…

The include => ivr-2-custom may be useful to you…

[ivr-2-custom] <-- add your -custom the dial plan fragment in extensions-custom.conf
exten => _3XX,1,NoOp(Intercept & Dump the forbidden 300-399 series extensions)
exten => _3XX,n,Goto(ivr-2,h,1) <— FreePBX guru may have a better line then this!
exten => _3XX,n,Congestion(12) <— Plays busy for 12s & hangs up.

I’ve not done this with an IVR but I am doing similar with a different (i.e. non-IVR) context. Between the NoOp and the Goto (or Congestion) you can elect to play a msg or other “friendlier” actions then just dumping.

I’m a tadpole myself so I’m sure the real guru’s here may have a better version of the above. But this approach pivots on your ability to pattern match the forbidden extens (e.g. _3XX, or what ever yours are).


What kind of interception do you mean?

This is just what I was looking for, as I needed to exclude people inadvertently entering our intercom extensions from the IVR.

This is what I used to just let them know it’s invalid, and go back to the ivr beginning:
exten => _6XXX,1,NoOp
exten => _6XXX,n,Playback(invalid)
exten => _6XXX,n,Goto(ivr-4,s,begin)