Multi-account VoIP providers

In some cases one would like to be able to connect multiple SIP/IAX accounts to the same upstream server. Each account may have differing creditials etc and this can (with asterisk at least) create some authentication issues. Fortunately there exists some “solutions”.

The common way to connect to a SIP/IAX server is to create a “friend”, something like:

[ulsvoip]
username=uls
type=friend
secret=veryverysecret
qualify=yes ; possibly make this a value like 200
host=voip.uls.co.za
trunk=yes
disallow=all
allow=g729
context=???

The problem here is that when asterisk receives an incoming call it first attempts to find a matching host, which if you have multiple accounts like above all of them will match and either the first or last (I forgot which one, last iirc) will be used, and the secret= option will be applied to them.

Ok, so the solution turns out to be quite simple, create a single host based user (ie, no authentication whatsoever), something like:

[ulsvoip]
type=user
host=voip.uls.co.za
trunk=yes
disallow=all
allow=g729
context=incoming

And then rely on the DID information to determine which account was actually dialed by the provider. So for example, I will do something like:

exten => 0873513298,1,Goto(incoming-uls,${EXTEN},1)
exten => 0873513299,1,Goto(incoming-jkroon,${EXTEN},1)

In the incoming context.

For the outbound this is actually quite simple, use the exact config you used for the individual accounts, just change type from friend to peer. Eg, the uls account above becomes:

[ulsvoip]
username=uls
type=peer
secret=veryverysecret
qualify=yes ; possibly make this a value like 200
host=voip.uls.co.za
trunk=yes
disallow=all
allow=g729

And create the alternative account in a similar fashion, and now you’re good to dial using Dial(IAX2/ulsvoip-uls/${EXTEN} and Dial(IAX/ulsvoip-jkroon/${EXTEN}).

The motivations for using multiple accounts are equally interesting, the one that makes most sense for me personally is the situation where you have multiple companies in the same building and each needs to foot it’s own telephone bill. I’ve got four on the same PBX at the moment.

Tags:

Leave a Reply

This blog is kept spam free by WP-SpamFree.