2 trunk same provider 2 context

Hi all and thanks for support.
I’ve an asterisk box connected to a cloud VOIP provider. The provider give me un EXTENSION and i connect my asterisk at this extension.
All call that are routed to this extension are handled and run a PHPAgi script (webcall to a web portal).
All work good and mine config is this:

/etc/asterisk/sip_custom_post.conf

register => user:password@dominio.sotto.livello.com

[user]
type=friend
secret=password
username=user
host=dominio.sotto.livello.com
port=5060
dtmfmode=rfc2833
canreinvite=no
disallow=all
allow=ulaw
allow=alaw
allow=gsm
insecure=port,invite
fromdomain=dominio.sotto.livello.com
context=from-pippo

/etc/asterisk/extensions_custom.conf

[from-pippo]
exten => _.,1,AGI(pippo.php)
exten => _.,n,Wait(60)
exten => h,1,Hangup
exten => i,1,Hangup
exten => t,1,Hangup

All works fine and mine script was run correctly.
Now, i must connect a second EXTENSION to mine asterisk box and with this second extension i must run a different php script
I think to configure all like this:

/etc/asterisk/sip_custom_post.conf

register => user:password@dominio.sotto.livello.com
register => user1:password1@dominio.sotto.livello.com

[user]
type=friend
secret=password
username=user
host=dominio.sotto.livello.com
port=5060
dtmfmode=rfc2833
canreinvite=no
disallow=all
allow=ulaw
allow=alaw
allow=gsm
insecure=port,invite
fromdomain=dominio.sotto.livello.com
context=from-pippo

[user1]
type=friend
secret=password1
username=user1
host=dominio.sotto.livello.com
port=5060
dtmfmode=rfc2833
canreinvite=no
disallow=all
allow=ulaw
allow=alaw
allow=gsm
insecure=port,invite
fromdomain=dominio.sotto.livello.com
context=from-pluto

/etc/asterisk/extensions_custom.conf

[from-pippo]
exten => _.,1,AGI(pippo.php)
exten => _.,n,Wait(60)
exten => h,1,Hangup
exten => i,1,Hangup
exten => t,1,Hangup

[from-pluto]
exten => _.,1,AGI(pluto.php)
exten => _.,n,Wait(60)
exten => h,1,Hangup
exten => i,1,Hangup
exten => t,1,Hangup

If i configure like i say, the 2 extension are “registered” in my asterisk, all call are answered regurarly at one extension and at second extension, but all the call are handled with “from-pippo” context so all execute “pippo.php” script.

Any idea about what i make wrong?
Thanks.
Mauro.

Your system is handling all inbound call on the context define for peer [user], You can use the callbackextension to route the calls,

register => user:secret@host/callbackextension1

register => user1:secret@host/callbackextension2

also you need to modify the use _. for the proper extensions defined on the call back

1 Like

You need a single direct in dialling trunk from the ITSP. You are trying to use a micro office/consumer service for a more substantial business.

Unless the ITSP sets the From header user to be the extension, which is unlikely, although the only possible reason for using type=friend, rather than type=peer, Asterisk will only have the IP address to go on to identify on which registration it is being invoked.

If the ITSP will allow you to specify a user part in your registration contact address, you can, however, use your incoming dialplan to separate the two registrations, but it will be arbitrary which sip.conf entry is used to route it there.

Thanks ambiorixg12.
I will try what you suggest me.
Only a question: what you really say me when you say “also you need to modify the use _. for the proper extensions defined on the call back” … in wich way i must modify this parameter and why?
Thanks,
Mauro.

So it matches the callback. So that it distinguishes between calls for the two registrations, which will have different callbacks.

Also note that using _. will produce warnings, for good reasons, as it also matches s (which might not be a problem here), h, i, t, e etc.

1 Like

Hi ambiorixg12
I do some tests.
After this test i can say that my asterisk box not matter what i declare like “callbackextension” at the end of the register string.
With just one register string too

register => user:password@dominio.sotto.livello.com/pippo

All incoming calls not matter “pippo” like "callbackextension"
All incoming calls are handled like user@from-sip-external
The DID is handled ok, i think, because in log i can see "DID=user"
But i not can understand why “callbackextension” not works.
Thanks,
Mauro.

Asterisk has no concept of DID’s. This message is the result of third party code.

Although there are some language problems, if the incoming request URI does not contain the callbackextension, this is a limitation of your ITSP, and the best solution is to use a service intended for PBX use, rather multiple subscriptions to services for single phones.

Thanks david551
My box is freepbx, maybe for this i can see DID= that for FreePbx is the caller ID
For now i find a solution, i edit the default “from-sip-external” context.
I not like this edit, i prefere route all incoming call in my oen new context, but for now (and whenever i’ve another best solution) i procede like this:

My COMPLETE /etc/asterisk/sip_custom_post.conf (that in FreePbx is included in /etc/asterisk/sip.conf). Only 2 line:

register => user:password@dominio.sotto.livello.com/user
register => user1:password1@dominio.sotto.livello.com/user1

My complete /etc/asterisk/extensions_custom.conf (that in FreePbx is included in /etc/asterisk/extensions.conf):

[from-sip-external]
exten => user,1,AGI(user.php)
exten => user,n,Wait(60)
exten => user1,1,AGI(user1.php)
exten => user1,n,Wait(60)
exten => h,1,Hangup
exten => i,1,Hangup
exten => t,1,Hangup

In this way i can handle user and user1 and run different PHPAgi script.

If anyone know better solution and know why “callbackextension” in my FreePbx is not considered, are welcome.
Thanks,
Mauro.

I need to see the incoming INVITE for each of the 2 calls and based on that I can propose a solution