This can be set up if you have an idea of how the Asterisk Dial plan works, and can craft your own short dial plans.
This is from memory, so I’m not guarenteeing the accuracy. In brief, you change the context in the extension to say enterprise_1, enterprse_2 etc
This will only allow extensions in the same context to call one another, this is not sufficient, because they cannot call anywhere else in the dial plan, such as VM, or *43
So the next step in extensions_custom.conf is to add a new context called:-
and underneath it, enter
include => from-internal
You will then be able to call everyone in your own context, and everywhere else in the from-internal context, such as VM, echo test, etc, but not extensions belonging to enterprise_2 or 3, as they are not included in the from internal context.
Next you need to deal with outbound calls - if they are all going out over the same trunk, then this will just work via outbound routes, and trunks, however, it is likely that you will want different enterprises to use different trunks for billing purposes.
One way of doing this is to put some more entries in the [enterprise_1] context. Personally, I would consider passing all external calls into something like A2Billing, so that I could bill each of the enterprises myself, using accountcode to authenticate. So add some entries like:-
exten => _X.,1,Answer
exten => _X.,n,DeadAGI(a2billing.php|1)
exten => _X.,n,Hangup
Alternatively, you could put in something like:-
exten => _00ZX, goto some existing trunk for international calls beginning with 00
Just add the external pattern matching you need and number manipulation you need to suit your carrier.
Therre is probably a more elegant manner of doing the outbound calling, but the above should work. I’ve not put this complete methodology into a production environment, so it may need some tweaking.