Multi tenant is Asterisk

Does Asterisk can handle call routing in a multi-tenant environment where different companies have the same extension numbers in one asterisk system?

Use a different dialplan context for each company, and do not use endpoint names which are the same as extension numbers (for SIP, preferably use uncorrelated ones, but, if security isn’t an issue, you could prefix the endpoints with a tenant ID).

Note that, whilst Asterisk can do this, FreePBX cannot.

Yes, if you use different contexts

Consider this example. If we have two company called A and B, then A company create agent as using extension number 5001. as same as company B create agent as 5001. Then, when it received the inbound call for, how to handle queue for 5001 extension ?

in the queue your users need to look like one of these

Local/5001@CompanyA
pjsip/5001_CompanyA

There is a Github PR aiming to improve Asterisk multi-tenancy capabilities.

Cool, looks like “tenantid” was merged a couple of weeks ago: channel: Add multi-tenant identifier. by bkford · Pull Request #741 · asterisk/asterisk · GitHub :+1: @bford and is part of the CHANNEL dialplan function:

exten => example,1,Set(CHANNEL(tenantid)=My tenant ID)

Or, easily set in pjsip.conf:

[my_endpoint]
type=endpoint
tenantid=My tenant ID

And then read as such:

exten => example,2,NoOp(${CHANNEL(tenantid)})

However, what OP is asking is slightly different than what was implemented – the word “tenant” can mean many things :slight_smile:

Per @david551 comment, which is one way to solve this:

…there is some more detail in the source that you may wish to review:

1 Like