Preventing Extensions calling certain extension

I am new to FreePBX and searched for a solution but everything I tried has failed.

I have 2 sets of extensions 2001-2002 and 3001-3012 as well as 100-110

I am trying to prevent the 300* from calling the 200* and vice versa.

in both /etc/asterisk/extensions_custom.conf and /etc/asterisk/extensions_override_freepbx.conf I have:
[from-group-a]
exten => _3XXX,1,Goto(app-blackhole,congestion,1)
exten => _[*0-9]!,1,Goto(from-internal,${EXTEN},1)
exten => h,1,Hangup()

[from-group-b]
exten => _2XXX,1,Goto(app-blackhole,congestion,1)
exten => _[*0-9]!,1,Goto(from-internal,${EXTEN},1)
exten => h,1,Hangup()

The reason I have it in both is I think the extensions_custom is commented out

How are you calling on those contexts that you created?

I added it to the extension context and it now works, I think

Well it needs to be called before [ext-local] which contains all the dialplan for the device/user extensions and how to handle calls to them. But you also just can’t have both in there and expect each device to know what it is. The phones that are part of group A should only have access to [from-group-a] and the same goes for Group B.

If a phone from Group B has access to both, then both apply. So if a phone in B was to call another phone in B, the [from-group-a] context could match and stop them from calling each other.

Again, you need to call on your context before [ext-local] is hit. You really don’t need two contexts for this. If you match on both the dialed extension and the device’s callerID you can make sure that only 2XXX phones can’t call to 3XXX phones and vice versa. Take a look at the same code below. That one context should handle it for it.

[from-groups]
exten => _2XXX/_3XXX,1,Goto(app-blackhole,congestion,1)
exten => _3XXX/_2XXX,1,Goto(app-blackhole,congestion,1)
exten => _[*0-9]!,1,Goto(from-internal,${EXTEN},1)
exten => h,1,Hangup()
1 Like

Thank you, that looks better

Hello @thecivvie,

First, remove all of your previous changes.
Then, add these lines to your extensions_custom.conf file:

[from-internal-custom]
exten => _2XXX/_3XXX,1,Hangup
exten => _3XXX/_2XXX,1,Hangup

Then reload the dialplan like this (from the Linux console):
rasterisk -x'dialplan reload'

Thank you,

Daniel Friedman
Trixton LTD.

2 Likes