Bind Extension to Outbound Trunk

Running the beta of asterisknow 1.5 with all bundled modules updated for freePBX 2.5.1
3 x pstn trunks g0-g2
2 x SIP trunks
2 x pstn extensions
2 x Hard IP extensions
6 x Soft IP extensions
Tenants have 1 of the pstn extensions Dahdi/5 (6007)
My Home Business has the other Dahdi/4
pstn trunk 1 has dialling prefix 9
pstn trunk 2 has dialling prefix 8
pstn trunk 3 has dialling prefix 7
Sip trunk 1 has dialling prefix 6
Sip trunk 2 has dialling prefix 5
I have been trying to force extension 6007 for the tenants through pstn trunk 3 and restrict them to free calling area only (no number beginning with a “0”)
Loaded latest version of custom contexts and setup a custom context “from-tenants”.
I set ENTIRE Basic Internal Dialplan to “allow” and
I set ALL OUTBOUND ROUTES to “allow rules” and
outrt-003-7 to “allow” priority 53(outrt-003-7 was a name produced by the system based on my outbound route) All others set to “deny” and all other priorities set to 50.
My only dial rule for the from-tenants custom context is 7|Z.
As with everyone else the context appears not to display after a submit and reload when selected for the extension. I manually changed Context as opposed to selecting under custom contexts dropdown to “from-tenants” just in case.
Assuming it has saved I tested its operation by dialing my mobile from extension 6007 using a 9 to prefix the number to ensure it couldn’t dial out on that trunk.

Verbose output from Asterisk as follows

– Starting simple switch on ‘DAHDI/5-1’
– Executing [[email protected]:1] Macro(“DAHDI/5-1”, “user-callerid|SKIPTTL|”) in new stack
– Executing [[email protected]:1] Set(“DAHDI/5-1”, “AMPUSER=4005”) in new stack
– Executing [[email protected]:2] GotoIf(“DAHDI/5-1”, “0?report”) in new stack
– Executing [[email protected]:3] ExecIf(“DAHDI/5-1”, “1|Set|REALCALLERIDNUM=4005”) in new stack
– Executing [[email protected]:4] Set(“DAHDI/5-1”, “AMPUSER=”) in new stack
– Executing [[email protected]:5] Set(“DAHDI/5-1”, “AMPUSERCIDNAME=”) in new stack
– Executing [[email protected]:6] GotoIf(“DAHDI/5-1”, “1?report”) in new stack
– Goto (macro-user-callerid,s,11)
– Executing [[email protected]:11] GotoIf(“DAHDI/5-1”, “1?continue”) in new stack
– Goto (macro-user-callerid,s,20)
– Executing [[email protected]:20] NoOp(“DAHDI/5-1”, “Using CallerID “Channel 5” <4005>”) in new stack
– Executing [[email protected]:2] Set(“DAHDI/5-1”, “_NODEST=”) in new stack
– Executing [[email protected]:3] Macro(“DAHDI/5-1”, “record-enable||OUT|”) in new stack
– Executing [[email protected]:1] GotoIf(“DAHDI/5-1”, “1?check”) in new stack
– Goto (macro-record-enable,s,4)
– Executing [[email protected]:4] AGI(“DAHDI/5-1”, “recordingcheck|20090115-124223|1231976534.2151”) in new stack
– Launched AGI Script /var/lib/asterisk/agi-bin/recordingcheck
recordingcheck|20090115-124223|1231976534.2151: No AMPUSER db entry for . Not recording
– AGI Script recordingcheck completed, returning 0
– Executing [[email protected]:5] MacroExit(“DAHDI/5-1”, “”) in new stack
– Executing [[email protected]:4] Macro(“DAHDI/5-1”, “dialout-trunk|1|021999999||”) in new stack
– Executing [[email protected]:1] Set(“DAHDI/5-1”, “DIAL_TRUNK=1”) in new stack
– Executing [[email protected]:2] GosubIf(“DAHDI/5-1”, “0?sub-pincheck|s|1”) in new stack
– Executing [[email protected]:3] GotoIf(“DAHDI/5-1”, “0?disabletrunk|1”) in new stack
– Executing [[email protected]:4] Set(“DAHDI/5-1”, “DIAL_NUMBER=021999999”) in new stack
– Executing [[email protected]:5] Set(“DAHDI/5-1”, “DIAL_TRUNK_OPTIONS=trw”) in new stack
– Executing [[email protected]:6] Set(“DAHDI/5-1”, “OUTBOUND_GROUP=OUT_1”) in new stack
– Executing [[email protected]:7] GotoIf(“DAHDI/5-1”, “1?nomax”) in new stack
– Goto (macro-dialout-trunk,s,9)
– Executing [[email protected]:9] GotoIf(“DAHDI/5-1”, “0?skipoutcid”) in new stack
– Executing [[email protected]:10] Set(“DAHDI/5-1”, “DIAL_TRUNK_OPTIONS=tw”) in new stack
– Executing [[email protected]:11] Macro(“DAHDI/5-1”, “outbound-callerid|1”) in new stack
– Executing [[email protected]:1] ExecIf(“DAHDI/5-1”, “0|SetCallerPres|”) in new stack
– Executing [[email protected]:2] ExecIf(“DAHDI/5-1”, “0|Set|REALCALLERIDNUM=4005”) in new stack
– Executing [[email protected]:3] GotoIf(“DAHDI/5-1”, “1?normcid”) in new stack
– Goto (macro-outbound-callerid,s,6)
– Executing [[email protected]:6] Set(“DAHDI/5-1”, “USEROUTCID=”) in new stack
– Executing [[email protected]:7] Set(“DAHDI/5-1”, “EMERGENCYCID=”) in new stack
– Executing [[email protected]:8] Set(“DAHDI/5-1”, “TRUNKOUTCID=“PRIMESOFT”<+6498208272>”) in new stack
– Executing [[email protected]:9] GotoIf(“DAHDI/5-1”, “1?trunkcid”) in new stack
– Goto (macro-outbound-callerid,s,12)
– Executing [[email protected]:12] ExecIf(“DAHDI/5-1”, “1|Set|CALLERID(all)=PRIMESOFT<+6498208272>”) in new stack
– Executing [[email protected]:13] GotoIf(“DAHDI/5-1”, “1?exit”) in new stack
– Goto (macro-outbound-callerid,s,11)
– Executing [[email protected]:11] MacroExit(“DAHDI/5-1”, “”) in new stack
– Executing [[email protected]:12] ExecIf(“DAHDI/5-1”, “0|AGI|fixlocalprefix”) in new stack
– Executing [[email protected]:13] Set(“DAHDI/5-1”, “OUTNUM=021999999”) in new stack
– Executing [[email protected]:14] Set(“DAHDI/5-1”, “custom=DAHDI/g0”) in new stack
– Executing [[email protected]:15] ExecIf(“DAHDI/5-1”, “0|Set|DIAL_TRUNK_OPTIONS=M(setmusic^)tw”) in new stack
– Executing [[email protected]:16] Macro(“DAHDI/5-1”, “dialout-trunk-predial-hook|”) in new stack
– Executing [[email protected]:1] MacroExit(“DAHDI/5-1”, “”) in new stack
– Executing [[email protected]:17] GotoIf(“DAHDI/5-1”, “0?bypass|1”) in new stack
– Executing [[email protected]:18] GotoIf(“DAHDI/5-1”, “0?customtrunk”) in new stack
– Executing [[email protected]:19] Dial(“DAHDI/5-1”, “DAHDI/g0/021999999|300|tw”) in new stack
– Called g0/021999999
– DAHDI/1-1 answered DAHDI/5-1
– Hungup ‘DAHDI/1-1’
== Spawn extension (macro-dialout-trunk, s, 19) exited non-zero on ‘DAHDI/5-1’ in macro ‘dialout-trunk’
== Spawn extension (macro-dialout-trunk, s, 19) exited non-zero on ‘DAHDI/5-1’
– Executing [[email protected]:1] Macro(“DAHDI/5-1”, “hangupcall|”) in new stack
– Executing [[email protected]:1] ResetCDR(“DAHDI/5-1”, “w”) in new stack
– Executing [[email protected]:2] NoCDR(“DAHDI/5-1”, “”) in new stack
– Executing [[email protected]:3] GotoIf(“DAHDI/5-1”, “1?skiprg”) in new stack
– Goto (macro-hangupcall,s,6)
– Executing [[email protected]:6] GotoIf(“DAHDI/5-1”, “1?skipblkvm”) in new stack
– Goto (macro-hangupcall,s,9)
– Executing [[email protected]:9] GotoIf(“DAHDI/5-1”, “1?theend”) in new stack
– Goto (macro-hangupcall,s,11)
– Executing [[email protected]:11] Hangup(“DAHDI/5-1”, “”) in new stack
== Spawn extension (macro-hangupcall, s, 11) exited non-zero on ‘DAHDI/5-1’ in macro ‘hangupcall’
== Spawn extension (macro-hangupcall, s, 11) exited non-zero on ‘DAHDI/5-1’
– Hungup ‘DAHDI/5-1’

Nowhere is the context “from-tenants” refered to so I’m assuming I have done something that is simple wrong.

Can anyone enlighten me as to what that might be.
Which .conf file to check if the context exists and which .conf file lists it as an include. I’m assuming extensions-???

Cheers

which version number of CustomContexts are you using. Depending on where you downloaded it from it will say the latest but possibly not be. It is always important to state the actual version number instead of “the latest” as somebody a year from might see this have the same problem and the statement of “the latest” does not help them figure things out.

The current latest version is 0.3.4

and the documentation and download for it is at http://www.freepbx.org/support/documentation/module-documentation/third-party-unsupported-modules/customcontexts

I am using 0.3.4
I would have suspected that the verbose asterisk output in a correctly configured system would refer to the custom context I had created (from-tenants) if it was working as designed.
Am I correct in this assumption?

dear all
i’m using FreePBX 2.5.1.0 and could this version support CustomContexts ?
if not which CustomContexts version complay with FreePBX version?

                                                         Best Regards,

Bassam, yes it is supported on 2.5.x

Hello I’m using the latest version of FreePBX. If I under “extensions” to “Custom Context” make choices. Is this why not save?

I always get this error
Warning: Invalid argument supplied for foreach() in /var/www/asterisk/admin/modules/customcontexts/functions.inc.php on line 494

mp_leo: Make sure you are using version 0.3.4 from here: http://mirror.freepbx.org/modules/release/contributed_modules/

okay i have use but i cant If I under “extensions” to “Custom Context” make choices. Is this why not save?

My goal is a “device” or “user” to a “route out” to bind.

mp_leo, I was having the same issue when I had the Usersets module also installed at the same time as customcontexts.

Have you installed any other custom freepbx modules?

We would also like to be able to create custom contexts for users and devices so that we can lock down the phone when a user isn’t logged on.

Hello,

I have an IAX2 Extension that I use for fax sending. However, it uses the dialplan to send wherever it can send depending on the pattern matching.

I want it to use only ONE trunk to do the send so we don’t have issues as that is the trunk that is for fax-sending.

Some help would be good please.

Use the caller ID route field in the outbound route. Put the extension number in. Make sure this route is in front of your “catch all” route.

Is that the only shortcut? I ask because we’re in Device & User mode and we have a first route that goes to a fake trunk to fail all calls unless logged in (log in changes callerid see) and I don’t want that to conflict with this new rule you speak of.

Are there not any other ways? Its hard to believe its not built in already eh.

I don’t know what you mean as “built in”?

As in its not already in the settings for each device and each user restrict to the following trunk"

Never seen a phone system in my life that you specify trunk routes per user. Users are members of route groups or indexes.

FreePBX also has a module called ‘custom contexts’ that lets you design all the security contexts you want.

Just because you haven’t seen one doesn’t mean there shouldn’t be one. :slight_smile:
Looking at CustomContexts now.

Opinions are like…you know the phrase.

It just logically doesn’t make sense. Permissions come later in the dialplan. You need to have the ability to do digit modification. You also need to be able to do more than just bind trunks. You want to do least cost routing, toll restriction, tenant isolation etc.

Does this make sense?

But I think it’s so simple and FreePBX has so much good stuff going on, that I think this would really be helpful where you don’t need to do all sorts of things to accomplish one small thing.

I’ve followed your first suggestion, restricting by callerID, and it seems to have done the job! Much appreciated, thanks a ton!