I have an Asterisk 13.4.0 installed over Ubuntu 14.04.6 LTS.
This PBX has several internal peers as SIP-phones, as well as two external lines, configured as Asterisk being a client to the provider’s SIP server. Both are connected to the same SIP server. We will call them here 1111111 and 2222222.
There is a following problem. When we make outgoing call, the call is routed properly via the line we have chosen. But all incoming calls are coming from peer 1111111, regardless of what phone number was dialed from PSTN.
Below is a register commands in sip.conf:
register => 11111111111:pass1:1111111@voip.provider.xyz/11111111111
register => 22222222222:pass2:2222222@voip.provider.xyz/22222222222
and peers configuration in the same file:
[defaults](!)
disallow=all
directmedia=no
[external-lines](!,defaults)
type=friend
qualify=yes
host=voip.provider.xyz
fromdomain=voip.provider.xyz
port=5060
disallow=all
allow=alaw
nat=force_rport,comedia
insecure=port,invite
dtmfmode=rfc2833
; context=from-external
language=en
[out01](external-lines)
username=11111111111
secret=pass1
fromuser=11111111111
context=from-1111111
[out02](external-lines)
username=22222222222
secret=pass2
fromuser=22222222222
context=from-2222222
Here’s also what I have in extensions.conf:
[from-1111111]
exten => 11111111111,1,Answer()
... <IVR rules> ...
[from-2222222]
exten => 22222222222,1,Dial(SIP/102,40,m)
So, when calls are coming to 2222222, there’s the following error:
NOTICE[4675][C-00000001]: chan_sip.c:25620 handle_request_invite: Call from '11111111111' (Provider_IP:5060) to extension '22222222222' rejected because extension not found in context 'from-1111111'.
So, it always uses the line that is first mentioned as a peer in sip.conf (and routes this call to the corresponding context), but extension is always choosed properly (corresponding to the number being dialed from PSTN).
This problem can easily be solved by creating the common context from-external and modifying extensions.conf as follows:
[from-external]
exten => 11111111111,1,Answer()
... <IVR rules> ...
exten => 22222222222,1,Dial(SIP/102,40,m)
And, to be honest, it is now configured so. And it works (meaning that incoming calls are routed properly by extension number.
But some stuff should monitor the availability of the lines via BLF. So, in case we use common context, BLF shows line 1111111 for every incoming call regardless of what number was dialed from PSTN.
And no, this is not an issue of this exact provider, because I have three more lines from another provider on this PBX, and there’s the same issue: the first line of that three is being used for every incoming call.