Same internal phone numbers in different contexts

Hello all.
I’m thinking about the situation, if it is possible - same internal phone numbers in different contexts ?

Let’s imagine that I have some server and offer integration of IP-telephony in small offices. The server has one IP address, one Asterisk.

One company wants to have 100, 101, 102, 10X internal phone numbers. And another company wants the same numbers.

I can describe in sip.conf something like:

[100]
...
context=company1
...

[101]
...
context=company1
...


[102]
...
context=company2
...

[103]
...
context=company2
...

Part of dialplan:

[company1]
exten => _XXX,1,MixMonitor(${UNIQUEID})
    same => n,Dial(SIP/${EXTEN},15,m(moh2))
    same => n,Hangup()

[company2]
exten => _XXX,1,MixMonitor(${UNIQUEID})
    same => n,Dial(SIP/${EXTEN},15,m(moh2))
    same => n,Hangup()

Later, in dialplan, phones from ‘company1’ can still call the phones from ‘company2’ context. But I want company1 to call company1 only, and company2 to call company2 only, despite the fact that both contexts have the same numeration.

I mean that when I dial from 101 phone (‘company1’ context) the phone number 103 (‘company2’ context), 103 phone rings. But I want to isolate them from each other.

Is it possible? I tried ‘Dial(SIP/${EXTEN}@company1)’ for company1, and ‘Dial(SIP/${EXTEN}@company2)’ for company2 respectively. But it doesn’t work.

So, if to be more straightforward, is it possible to specify the context in the ‘Dial’ application? I remember that I’ve saw somewhere something like ‘Dial(SIP/1234@contextname)’ but I cannot find anything like that in ‘core shoq application Dial’ and such a trick in my dialplan also doesn’t work.

This, as well as security, is why you should not confuse device names with extension numbers.

You should have a lookup table (can be extensions.conf itself) to map extensions to device resource names and the latter should, preferably, not be guessable.

For half and half, you could have:

sip.conf

[company-100]
context=company1

extensions.conf

[company1]
exten => _1XX!,1,Dial(SIP/company1-${EXTEN}
exten => _.,1,Dial(SIP/company2-${EXTEN:???)

david55, as usual, many thanks!