Asterisk failed to authenticate- inbound call

I don’t understand why this is happening.

[voipms]
type = registration
transport = simpletrans
outbound_auth = voipms
client_uri = sip:132688_test@toronto1.voip.ms:5060 ; (one of our multiple rvers, you can choose the one closer to your location)
server_uri = sip:toronto1.voip.ms:5060 ; (one of our multiple servers , you can choose the one closer to your location)

[voipms]
type = auth
auth_type = userpass
username = 132688_test ; (Replace with your 6 digit Main SIP Account User ID or Sub Account username, i.e. 123456 or 123456_sub)
password = mypw ; your password

[voipms]
type = aor
contact = sip:132688_test@toronto1.voip.ms ; (one of our multiple servers, you can choose the one closer to your location)

[voipms]
type = endpoint
transport = simpletrans
context = union-123
disallow = all
allow = ulaw
; allow=g729 ; uncomment if you support g729
from_user = 132688_test ; (Replace with your 6 digit Main S User ID or Sub Account username, i.e. 123456 or 123456_sub)
auth = voipms
outbound_auth = voipms
aors = voipms
; NAT parameters:
rtp_symmetric = yes
rewrite_contact = yes
send_rpid = yes
;direct_media = no

[voipms]
type = identify
endpoint = voipms
match = toronto1.voip.ms ; (one of our multiple servers, you can choose the one closer to your location)

[atu-107]
type = registration
transport = simpletrans
outbound_auth = atu-107
client_uri = sip:132688_atu-107@toronto1.voip.ms:5060 ; (one of our multiple rvers, you can choose the one closer to your location)
server_uri = sip:toronto1.voip.ms:5060 ; (one of our multiple servers , you can choose the one closer to your location)

[atu-107]
type = auth
auth_type = userpass
username = 132688_atu-107 ; (Replace with your 6 digit Main SIP Account User ID or Sub Account username, i.e. 123456 or 123456_sub)
password = mypw ; your password

[atu-107]
type = aor
contact = sip:132688_atu-107@toronto1.voip.ms ; (one of our multiple servers, you can choose the one closer to your location)

[atu-107]
type = endpoint
transport = simpletrans
context = atu-107
disallow = all
allow = ulaw
; allow=g729 ; uncomment if you support g729
from_user = 132688_atu-107 ; (Replace with your 6 digit Main S User ID or Sub Account username, i.e. 123456 or 123456_sub)
auth = atu-107
outbound_auth = atu-107
aors = atu-107
; NAT parameters:
rtp_symmetric = yes
rewrite_contact = yes
send_rpid = yes
;direct_media = no

[atu-107]
type = identify
endpoint = atu-107
match = toronto1.voip.ms ; (one of our multiple servers, you can choose the one closer to your location)

Can someone please help me. The first trunk works fine and I am able to place inbound calls. The second one shows an error on the cli whenever I try to place a call. I can’t for the life of me figure out why that’s the case, they both look the same to me.

This is the error: ] NOTICE[237926]: res_pjsip/pjsip_distributor.c:676 log_failed_request: Request ‘INVITE’ from ‘“BASIM JABBAR KH” sip:mynumber@158.85.70.148’ failed for ‘158.85.70.148:5060’ (callid: 1083aa2d0a667f6d04a5a00b652dbe03@158.85.70.148:5060) - Failed to authenticate

You have two identify for the same thing. One named “voipms” and one named “atu-107”. If matching based on source IP you can only have one.

Additionally it is unlikely they will authenticate to you, so you’d need to remove the “auth” option from the endpoint to stop authenticating inbound.

You could also try not using identify and instead using line support[1].

[1] The PJSIP Outbound Registration 'line' Option ⋆ Open Source Communications Software | Asterisk Official Site

Hello,

in that cause how am I to specify the endpoint? Also now I have another problem. I used core stop gracefully. When I restarted it it seems like it is a completely different instance of Asterisk. None of my registrations show anymore, they are all gone.

Check the console at startup to see if the configuration was invalid in some way. And if you use identify then you can only use a single endpoint for all traffic from an IP address. If using line support you specify the endpoint to use on the outbound registration.

Configuration was invalid? I’m not sure what you mean, it was working before all my registrations showed as registered. Now all of a sudden there is no registrations at all. My conf files and everything are still the same, so I’m not sure why this happened? Is there a way to go back to my original instance of asterisk. The CLI doesn’t remember my old commands either, it’s as if it is completely new.

Asterisk doesn’t have separate instances unless that’s something of your environment. I don’t know what you’ve done or what is happening for you.

I can no longer even connect to a simple endpoint I made myself with a soft phone. All I did was use “core stop gracefully” in the CLI. For some reason when I restarted it, everything is different. All my registrations don’t show, the connections don’t work. I am not sure what is causing any of this to happen.

Okay I solved this problem by killing some processes. I had more than one asterisk process running? I’m not sure what that was if not another instance. Thank you. I will look into using line support.

I have a question about line registration if you may. If I use line registration then where do I put match and the ip address of the voip provider?

You don’t. Line support eliminates the need for that, if the provider respects the SIP RFC. When an INVITE comes in it looks for the line information, if present it can match it to the outbound registration information and match it to the configured endpoint.

Is there anywhere I’d have to make changes other than my pjsip.conf file? Or just add those lines under the registration?

If your pjsip.conf is where they are being configured, then no. That would be the only place.

This does not seem to be working, it’s very possible I’m doing something incorrectly. Under registration I added:

line = yes
endpoint = voipms

That is the name of my endpoint, do I have to put it in between <>? The link you sent showed &lt and &gt there as well.

It goes in the outbound registration section, that’s it. If it’s not working then you’ll need to provide a packet trace including the SIP REGISTER and a call attempt. As stated in the blog post, it’s up to the provider to properly do things and if they don’t then it won’t work in which case all your calls can only be directed to a single endpoint.

When I try to place inbound calls with line registration it says, “no matching endpoint found” on the Asterisk CLI.

I spoke to my voip provider and they said that they follow SIP RFC. They also traced my call and said it was being rejected at Asterisk and they had not seen that happen before (weird, feel they may be being dishonest) Can you please let me know if there is something I’m doing wrong here?

[voipms]
type=registration
transport = simpletrans
outbound_auth = voipms
client_ uri: myaccounturi
server_uri: myprovideruri
line = yes
endpoint = voipms

As I previously stated, you’d need to provide a SIP trace including the SIP REGISTER and a call attempt. This can be done in the console using “pjsip set logger on”.

<--- Transmitting SIP response (526 bytes) to UDP:158.85.70.148:5060 --->
SIP/2.0 401 Unauthorized
Via: SIP/2.0/UDP 158.85.70.148:5060;rport=5060;received=158.85.70.148;branch=z9hG4bK21ea7d56
Call-ID: 7f004c78437f2e63018ea889352d700b@158.85.70.148:5060
From: "BASIM JABBAR KH" <sip:6478925277@158.85.70.148>;tag=as6f096254
To: <sip:6478127048@35.183.128.250>;tag=z9hG4bK21ea7d56
CSeq: 105 INVITE
WWW-Authenticate: Digest realm="asterisk",nonce="1617641771/10a47483544ec1de841b0cb77508cce4",opaque="765a607351ecf841",algorithm=md5,qop="auth"
Server: Asterisk PBX 16.16.2
Content-Length:  0


<--- Received SIP request (420 bytes) from UDP:158.85.70.148:5060 --->
ACK sip:6478127048@35.183.128.250 SIP/2.0
Via: SIP/2.0/UDP 158.85.70.148:5060;branch=z9hG4bK21ea7d56;rport
Max-Forwards: 70
From: "BASIM JABBAR KH" <sip:6478925277@158.85.70.148>;tag=as6f096254
To: <sip:6478127048@35.183.128.250>;tag=z9hG4bK21ea7d56
Contact: <sip:6478925277@158.85.70.148:5060>
Call-ID: 7f004c78437f2e63018ea889352d700b@158.85.70.148:5060
CSeq: 105 ACK
User-Agent: voip.ms
Content-Length: 0

This is what I got from the logger. Please let me know if there’s anything else you’d need, and thank you again.

That is incomplete. It does not show Asterisk sending the SIP REGISTER to register to voip.ms and it does not show the SIP INVITE from them for an incoming call.

<--- Transmitting SIP request (588 bytes) to UDP:158.85.70.148:5060 --->
REGISTER sip:toronto1.voip.ms:5060 SIP/2.0
Via: SIP/2.0/UDP 172.31.29.184:5060;rport;branch=z9hG4bKPj99e4f9a4-c0f1-4384-8470-c837b0b75a69
From: <sip:132688_atu-107@toronto1.voip.ms>;tag=08cbef9e-a0e6-4f7c-8a5b-ad80bf01ce18
To: <sip:132688_atu-107@toronto1.voip.ms>
Call-ID: 42185a5c-8d52-4863-a7a5-bd42a034784a
CSeq: 61900 REGISTER
Contact: <sip:s@172.31.29.184:5060;line=demsozf>
Expires: 3600
Allow: OPTIONS, REGISTER, SUBSCRIBE, NOTIFY, PUBLISH, INVITE, ACK, BYE, CANCEL, UPDATE, PRACK, MESSAGE, REFER
Max-Forwards: 70
User-Agent: Asterisk PBX 16.16.2
Content-Length:  0



<--- Transmitting SIP response (526 bytes) to UDP:158.85.70.148:5060 --->
SIP/2.0 401 Unauthorized
Via: SIP/2.0/UDP 158.85.70.148:5060;rport=5060;received=158.85.70.148;branch=z9hG4bK24955411
Call-ID: 56f343800666386233985ad118db450b@158.85.70.148:5060
From: "BASIM JABBAR KH" <sip:6478925277@158.85.70.148>;tag=as252ef220
To: <sip:4379718586@35.183.128.250>;tag=z9hG4bK24955411
CSeq: 104 INVITE
WWW-Authenticate: Digest realm="asterisk",nonce="1617642314/ea127b035409ed367731a103e20fc4aa",opaque="6acbbead52971774",algorithm=md5,qop="auth"
Server: Asterisk PBX 16.16.2
Content-Length:  0


<--- Received SIP request (420 bytes) from UDP:158.85.70.148:5060 --->
ACK sip:4379718586@35.183.128.250 SIP/2.0
Via: SIP/2.0/UDP 158.85.70.148:5060;branch=z9hG4bK24955411;rport
Max-Forwards: 70
From: "BASIM JABBAR KH" <sip:6478925277@158.85.70.148>;tag=as252ef220
To: <sip:4379718586@35.183.128.250>;tag=z9hG4bK24955411
Contact: <sip:6478925277@158.85.70.148:5060>
Call-ID: 56f343800666386233985ad118db450b@158.85.70.148:5060
CSeq: 104 ACK
User-Agent: voip.ms
Content-Length: 0


<--- Received SIP request (1286 bytes) from UDP:158.85.70.148:5060 --->
INVITE sip:4379718586@35.183.128.250 SIP/2.0
Via: SIP/2.0/UDP 158.85.70.148:5060;branch=z9hG4bK12be1ad7;rport
Max-Forwards: 70
From: "BASIM JABBAR KH" <sip:6478925277@158.85.70.148>;tag=as252ef220
To: <sip:4379718586@35.183.128.250>
Contact: <sip:6478925277@158.85.70.148:5060>
Call-ID: 56f343800666386233985ad118db450b@158.85.70.148:5060
CSeq: 105 INVITE
User-Agent: voip.ms
Authorization: Digest username="132688_atu-107", realm="asterisk", algorithm=MD5, uri="sip:4379718586@35.183.128.250", nonce="1617642314/ea127b035409ed367731a103e20fc4aa", response="dcd52ae20bb5b0742d549d62a9641124", opaque="6acbbead52971774", qop=auth, cnonce="0917ff9e", nc=00000003
Date: Mon, 05 Apr 2021 17:05:14 GMT
Allow: INVITE, ACK, CANCEL, OPTIONS, BYE, REFER, SUBSCRIBE, NOTIFY, INFO, PUBLISH, MESSAGE
Supported: replaces, timer
X-Dest-User: 132688_atu-107
Remote-Party-ID: "BASIM JABBAR KH" <sip:6478925277@158.85.70.148>;party=calling;privacy=off;screen=no
Content-Type: application/sdp
Content-Length: 272

v=0
o=root 1092158552 1092158555 IN IP4 158.85.70.148
s=voip.ms
c=IN IP4 158.85.70.148
t=0 0
m=audio 19310 RTP/AVP 0 18 101
a=rtpmap:0 PCMU/8000
a=rtpmap:18 G729/8000
a=fmtp:18 annexb=no
a=rtpmap:101 telephone-event/8000
a=fmtp:101 0-16
a=ptime:20
a=sendrecv

Is this complete? Sorry for the hassle and my lack of knowledge, I am a programmer trying to set up a telephone system, hence my lack of knowledge.