All incoming calls come from one peer

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 =>
register =>

and peers configuration in the same file:


; context=from-external



Here’s also what I have in extensions.conf:

exten => 11111111111,1,Answer()
... <IVR rules> ...

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:

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.

You should upgrade both asterisk and Ubuntu as well switching from sip -which is EOL- to pjsip – Daniel

As well as the advice from tootai to upgrade to something that’s supported
(both O/S and Asterisk in this case), an interim workaround would be simply to
use a single context for your incoming calls, and then use ${EXTEN} to
identify whether a call came in to 1111111 or 2222222.

As you’ve noticed, when you Register to the same external provider with more
than one sets of credentials, all calls come in to the context specified first.

So, just put all of your dialplan processing into that single context.

Next week, please upgrade everything.


Forgot to give the solution for pjsip

sends_line_with_registrations = yes

As I have written in the first message, I use single context. As you can see, I put it as a comment in sip.conf. I have divided it into two contexts just to find the intial problem.
My issue (with the single context) is that I cannot use BLF to monitor which line is used now, because line 1111111 is used for every incoming call.

I appreciate your advice regarding upgrade to PJSIP and to the actual versions of OS and PBX, but it is a big effort not to be done instantly. Sure, this will be sheduled and prepared to migrate seamlessly one day, but the discussed issue is smth that should be done rapidly.

The other problem you have here is that you are using a service intended for phones, not PBXes. That’s forcing you to have multiple accounts, which and forcing you to limit yourself to one active call on an account.

I’m not sure if your use of multiple directory numbers is because of the one call limit, in which case simply removing that restriction would remove the need to indicate when one of your allowed “lines” was in use, or whether you want true direct in dialling, in which case you need an account that supports multiple directory numbers, as well as multiple concurrent calls.

If you are stuck with both the obsolete channel driver and the unsuitable provider, I think custom hints existed in your obsolete Asterisk, and probably hangup handlers, so you might be able set a hangup handler, then use a custom hint to indicate which line. There will be some race conditions that need considering.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.