Can't register from external LAN

Hi,
I’m working on a project where I need to access an Asterisk server behind a NAT from softphones and from WebRTC clients (which may be behind different NATs too).
As far as I know, I would only need to open and forward the SIP ports 5060 and 5061, and add the stun/turn servers to both: /etc/asterisk/rtp.conf, and to the softphones/SIP JS clients.
That should be pretty simple, but I’m stuck on the first step. The ports are opened on my NAT router and forwarded to the Asterisk server, where I receive the registration requests. However, the requests fail and the only message I get from Asterisk is:

Request 'REGISTER' from '<sip:user1@192.168.0.12>' failed for '88.28.12.202:49094 (callid: FVNVTNdEQo) - Failed to authenticate

I have searched on the net for various solutions but none of them works. This is my current pjsip.conf file in case it helps. 213.37.134.165 is my NATs’ IP address.

[transport-udp]
type=transport
protocol=udp
bind=0.0.0.0
external_signaling_address=213.37.134.165
external_signaling_port=5060

[transport-ws]
type=transport
protocol=ws
bind=0.0.0.0

[user1]
type=endpoint
context=from-internal
disallow=all
allow=ulaw,alaw,opus,vp8,h264
auth=user1
aors=user1

[user1]
type=auth
auth_type=userpass
password=user1
username=user1

[user1]
type=aor
max_contacts=1
remove_existing=true

[web_client]
type=aor
max_contacts=1
remove_existing=5

[web_client]
type=auth
auth_type=userpass
username=web_client
password=web_client

[web_client]
type=endpoint
aors=web_client
auth=web_client
webrtc=yes
context=from-internal
disallow=all
allow=opus,ulaw,alaw,vp8,h264

Does somebody knows why this is failing?
Thanks a lot.

The stun server needs to be added to the client configuration.

Please provide pjsip set logger on output for the call. Also please provide the complete error message, to make sure that the call isn’t going to chan_sip.

At first sight, this looks like a bad password.

Ok, so when should be the stun server added to Asterisk?

The request is going to pjsip, as I have already tested it locally, adn the password is right. Here it is the complete log after enabling pjsip logs:

Connected to Asterisk 19.3.0 currently running on freepbx (pid = 2325)
<--- Received SIP request (598 bytes) from UDP:88.28.14.195:57900 --->
REGISTER sip:192.168.0.12:5060 SIP/2.0
Via: SIP/2.0/UDP 88.28.14.195:57900;branch=z9hG4bK.9OEKi1xSt
From: <sip:user1@192.168.0.12>;tag=RItLYqwj~
To: sip:user1@192.168.0.12
CSeq: 20 REGISTER
Call-ID: n9JyU89n0w
Max-Forwards: 70
Supported: replaces, outbound, gruu
Accept: application/sdp
Accept: text/plain
Accept: application/vnd.gsma.rcs-ft-http+xml
Contact: <sip:user1@88.28.14.195:57900;transport=udp>;+sip.instance="<urn:uuid:8c4da795-70b4-00f6-8d0a-6646c064c2c1>"
Expires: 3600
User-Agent: LinphoneAndroid/4.6.10 (Pixel 6) LinphoneSDK/5.1.42 (tags/5.1.42^0)
Content-Length: 0


<--- Received SIP request (598 bytes) from UDP:88.28.14.195:57900 --->
REGISTER sip:192.168.0.12:5060 SIP/2.0
Via: SIP/2.0/UDP 88.28.14.195:57900;branch=z9hG4bK.9OEKi1xSt
From: <sip:user1@192.168.0.12>;tag=RItLYqwj~
To: sip:user1@192.168.0.12
CSeq: 20 REGISTER
Call-ID: n9JyU89n0w
Max-Forwards: 70
Supported: replaces, outbound, gruu
Accept: application/sdp
Accept: text/plain
Accept: application/vnd.gsma.rcs-ft-http+xml
Contact: <sip:user1@88.28.14.195:57900;transport=udp>;+sip.instance="<urn:uuid:8c4da795-70b4-00f6-8d0a-6646c064c2c1>"
Expires: 3600
User-Agent: LinphoneAndroid/4.6.10 (Pixel 6) LinphoneSDK/5.1.42 (tags/5.1.42^0)
Content-Length: 0


<--- Transmitting SIP response (457 bytes) to UDP:88.28.14.195:57900 --->
SIP/2.0 401 Unauthorized
Via: SIP/2.0/UDP 88.28.14.195:57900;rport=57900;received=88.28.14.195;branch=z9hG4bK.9OEKi1xSt
Call-ID: n9JyU89n0w
From: <sip:user1@192.168.0.12>;tag=RItLYqwj~
To: <sip:user1@192.168.0.12>;tag=z9hG4bK.9OEKi1xSt
CSeq: 20 REGISTER
WWW-Authenticate: Digest realm="asterisk",nonce="1655731131/3f05e65f6e47da3b3c45ba11cd6ca9e2",opaque="418dfe591cd65d21",algorithm=md5,qop="auth"
Server: Asterisk PBX 19.3.0
Content-Length:  0


<--- Transmitting SIP response (457 bytes) to UDP:88.28.14.195:57900 --->
SIP/2.0 401 Unauthorized
Via: SIP/2.0/UDP 88.28.14.195:57900;rport=57900;received=88.28.14.195;branch=z9hG4bK.9OEKi1xSt
Call-ID: n9JyU89n0w
From: <sip:user1@192.168.0.12>;tag=RItLYqwj~
To: <sip:user1@192.168.0.12>;tag=z9hG4bK.9OEKi1xSt
CSeq: 20 REGISTER
WWW-Authenticate: Digest realm="asterisk",nonce="1655731131/3f05e65f6e47da3b3c45ba11cd6ca9e2",opaque="5dae560c142b8670",algorithm=md5,qop="auth"
Server: Asterisk PBX 19.3.0
Content-Length:  0


<--- Received SIP request (876 bytes) from UDP:88.28.14.195:57900 --->
REGISTER sip:192.168.0.12:5060 SIP/2.0
Via: SIP/2.0/UDP 88.28.14.195:57900;branch=z9hG4bK.aEeSMfqBO
From: <sip:user1@192.168.0.12>;tag=RItLYqwj~
To: sip:user1@192.168.0.12
CSeq: 21 REGISTER
Call-ID: n9JyU89n0w
Max-Forwards: 70
Supported: replaces, outbound, gruu
Accept: application/sdp
Accept: text/plain
Accept: application/vnd.gsma.rcs-ft-http+xml
Contact: <sip:user1@88.28.14.195:57900;transport=udp>;+sip.instance="<urn:uuid:8c4da795-70b4-00f6-8d0a-6646c064c2c1>"
Expires: 3600
User-Agent: LinphoneAndroid/4.6.10 (Pixel 6) LinphoneSDK/5.1.42 (tags/5.1.42^0)
Authorization: Digest realm="asterisk", nonce="1655731131/3f05e65f6e47da3b3c45ba11cd6ca9e2", algorithm=md5, opaque="418dfe591cd65d21", username="user1",  uri="sip:192.168.0.12:5060", response="9cc18493e77df407b5a638c15d6cfd44", cnonce="oAGIH2U8rhqKcGNs", nc=00000001, qop=auth
Content-Length: 0


<--- Received SIP request (876 bytes) from UDP:88.28.14.195:57900 --->
REGISTER sip:192.168.0.12:5060 SIP/2.0
Via: SIP/2.0/UDP 88.28.14.195:57900;branch=z9hG4bK.aEeSMfqBO
From: <sip:user1@192.168.0.12>;tag=RItLYqwj~
To: sip:user1@192.168.0.12
CSeq: 21 REGISTER
Call-ID: n9JyU89n0w
Max-Forwards: 70
Supported: replaces, outbound, gruu
Accept: application/sdp
Accept: text/plain
Accept: application/vnd.gsma.rcs-ft-http+xml
Contact: <sip:user1@88.28.14.195:57900;transport=udp>;+sip.instance="<urn:uuid:8c4da795-70b4-00f6-8d0a-6646c064c2c1>"
Expires: 3600
User-Agent: LinphoneAndroid/4.6.10 (Pixel 6) LinphoneSDK/5.1.42 (tags/5.1.42^0)
Authorization: Digest realm="asterisk", nonce="1655731131/3f05e65f6e47da3b3c45ba11cd6ca9e2", algorithm=md5, opaque="418dfe591cd65d21", username="user1",  uri="sip:192.168.0.12:5060", response="9cc18493e77df407b5a638c15d6cfd44", cnonce="oAGIH2U8rhqKcGNs", nc=00000001, qop=auth
Content-Length: 0


[2022-06-20 13:18:51] NOTICE[8546]: res_pjsip/pjsip_distributor.c:676 log_failed_request: Request 'REGISTER' from '<sip:user1@192.168.0.12>' failed for '88.28.14.195:57900' (callid: n9JyU89n0w) - Failed to authenticate
<--- Transmitting SIP response (457 bytes) to UDP:88.28.14.195:57900 --->
SIP/2.0 401 Unauthorized
Via: SIP/2.0/UDP 88.28.14.195:57900;rport=57900;received=88.28.14.195;branch=z9hG4bK.aEeSMfqBO
Call-ID: n9JyU89n0w
From: <sip:user1@192.168.0.12>;tag=RItLYqwj~
To: <sip:user1@192.168.0.12>;tag=z9hG4bK.aEeSMfqBO
CSeq: 21 REGISTER
WWW-Authenticate: Digest realm="asterisk",nonce="1655731131/3f05e65f6e47da3b3c45ba11cd6ca9e2",opaque="4f21f8ab4894df0c",algorithm=md5,qop="auth"
Server: Asterisk PBX 19.3.0
Content-Length:  0


[2022-06-20 13:18:51] NOTICE[8546]: res_pjsip/pjsip_distributor.c:676 log_failed_request: Request 'REGISTER' from '<sip:user1@192.168.0.12>' failed for '88.28.14.195:57900' (callid: n9JyU89n0w) - Failed to authenticate
<--- Transmitting SIP response (457 bytes) to UDP:88.28.14.195:57900 --->
SIP/2.0 401 Unauthorized
Via: SIP/2.0/UDP 88.28.14.195:57900;rport=57900;received=88.28.14.195;branch=z9hG4bK.aEeSMfqBO
Call-ID: n9JyU89n0w
From: <sip:user1@192.168.0.12>;tag=RItLYqwj~
To: <sip:user1@192.168.0.12>;tag=z9hG4bK.aEeSMfqBO
CSeq: 21 REGISTER
WWW-Authenticate: Digest realm="asterisk",nonce="1655731131/3f05e65f6e47da3b3c45ba11cd6ca9e2",opaque="380e11461c7c7c6c",algorithm=md5,qop="auth"
Server: Asterisk PBX 19.3.0
Content-Length:  0

In fact, in those logs you can see that pjsip is being used.

As a last resort, when Asterisk is behind NAT and there is no better way of finding Asterisk’s public address.

Linphone is providing a correct public address in its request, and Asterisk is asking it for its password. It is not providing the password.

Either the remote router failed to open a port forwarding rule for the response, or Linphone has no password to offer. In either case, the problem appears to be at the remote end.

Its really awkward because if I’m connected to my wifi network, it works perfectly even if I’m using the external IP address. However once I use the mobile network to avoid the NAT, I get these problems.
Thanks a lot for your suggestions, I’ll try them.

After some more testing, I don’t think this is related to the network or to the remote server. It looks like there is some kind of misconfiguration causing the issue.

If I try to connect using ZoiPer instead of Linphone, the register fails too, and I get this output when Zoiper is on the external network, which is pretty similar to the one I got with Linphone:

<--- Received SIP request (652 bytes) from UDP:88.28.14.195:57619 --->
REGISTER sip:192.168.0.12:5060;transport=UDP SIP/2.0
Via: SIP/2.0/UDP 88.28.14.195:57619;branch=z9hG4bK-524287-1---6ed65ac995848b2d
Max-Forwards: 70
Contact: <sip:user1@88.28.14.195:57619;transport=UDP;rinstance=bb40a387c4dc99a2>
To: <sip:user1@192.168.0.12:5060>
From: <sip:user1@192.168.0.12:5060>;tag=2accb778
Call-ID: zYclxmwdUeEYe7acyMesaQ..
CSeq: 1 REGISTER
Expires: 70
Allow: INVITE, ACK, CANCEL, BYE, NOTIFY, REFER, MESSAGE, OPTIONS, INFO, SUBSCRIBE
Supported: replaces, norefersub, extended-refer, timer, outbound, path, X-cisco-serviceuri
User-Agent: Zoiper v2.10.17.3-mod
Allow-Events: presence, kpml, talk
Content-Length: 0


<--- Received SIP request (652 bytes) from UDP:88.28.14.195:57619 --->
REGISTER sip:192.168.0.12:5060;transport=UDP SIP/2.0
Via: SIP/2.0/UDP 88.28.14.195:57619;branch=z9hG4bK-524287-1---6ed65ac995848b2d
Max-Forwards: 70
Contact: <sip:user1@88.28.14.195:57619;transport=UDP;rinstance=bb40a387c4dc99a2>
To: <sip:user1@192.168.0.12:5060>
From: <sip:user1@192.168.0.12:5060>;tag=2accb778
Call-ID: zYclxmwdUeEYe7acyMesaQ..
CSeq: 1 REGISTER
Expires: 70
Allow: INVITE, ACK, CANCEL, BYE, NOTIFY, REFER, MESSAGE, OPTIONS, INFO, SUBSCRIBE
Supported: replaces, norefersub, extended-refer, timer, outbound, path, X-cisco-serviceuri
User-Agent: Zoiper v2.10.17.3-mod
Allow-Events: presence, kpml, talk
Content-Length: 0


<--- Transmitting SIP response (505 bytes) to UDP:88.28.14.195:57619 --->
SIP/2.0 401 Unauthorized
Via: SIP/2.0/UDP 88.28.14.195:57619;rport=57619;received=88.28.14.195;branch=z9hG4bK-524287-1---6ed65ac995848b2d
Call-ID: zYclxmwdUeEYe7acyMesaQ..
From: <sip:user1@192.168.0.12>;tag=2accb778
To: <sip:user1@192.168.0.12>;tag=z9hG4bK-524287-1---6ed65ac995848b2d
CSeq: 1 REGISTER
WWW-Authenticate: Digest realm="asterisk",nonce="1655738079/0a5bc3a62055bfd8018556dcd113ccd4",opaque="74da5fb649b889a2",algorithm=md5,qop="auth"
Server: Asterisk PBX 19.3.0
Content-Length:  0


<--- Transmitting SIP response (505 bytes) to UDP:88.28.14.195:57619 --->
SIP/2.0 401 Unauthorized
Via: SIP/2.0/UDP 88.28.14.195:57619;rport=57619;received=88.28.14.195;branch=z9hG4bK-524287-1---6ed65ac995848b2d
Call-ID: zYclxmwdUeEYe7acyMesaQ..
From: <sip:user1@192.168.0.12>;tag=2accb778
To: <sip:user1@192.168.0.12>;tag=z9hG4bK-524287-1---6ed65ac995848b2d
CSeq: 1 REGISTER
WWW-Authenticate: Digest realm="asterisk",nonce="1655738079/0a5bc3a62055bfd8018556dcd113ccd4",opaque="106e3bca62af82c0",algorithm=md5,qop="auth"
Server: Asterisk PBX 19.3.0
Content-Length:  0


<--- Received SIP request (950 bytes) from UDP:88.28.14.195:57619 --->
REGISTER sip:192.168.0.12:5060;transport=UDP SIP/2.0
Via: SIP/2.0/UDP 88.28.14.195:57619;branch=z9hG4bK-524287-1---27a117f64b0e8a26
Max-Forwards: 70
Contact: <sip:user1@88.28.14.195:57619;transport=UDP;rinstance=bb40a387c4dc99a2>
To: <sip:user1@192.168.0.12:5060>
From: <sip:user1@192.168.0.12:5060>;tag=2accb778
Call-ID: zYclxmwdUeEYe7acyMesaQ..
CSeq: 2 REGISTER
Expires: 70
Allow: INVITE, ACK, CANCEL, BYE, NOTIFY, REFER, MESSAGE, OPTIONS, INFO, SUBSCRIBE
Supported: replaces, norefersub, extended-refer, timer, outbound, path, X-cisco-serviceuri
User-Agent: Zoiper v2.10.17.3-mod
Authorization: Digest username="user1",realm="asterisk",nonce="1655738079/0a5bc3a62055bfd8018556dcd113ccd4",uri="sip:192.168.0.12:5060;transport=UDP",response="20fcef6c8ab60e75301c2a1a6f24eb11",cnonce="7b53f90ce4c2d181464ae9a1b5cc7c37",nc=00000001,qop=auth,algorithm=md5,opaque="74da5fb649b889a2"
Allow-Events: presence, kpml, talk
Content-Length: 0


<--- Received SIP request (950 bytes) from UDP:88.28.14.195:57619 --->
REGISTER sip:192.168.0.12:5060;transport=UDP SIP/2.0
Via: SIP/2.0/UDP 88.28.14.195:57619;branch=z9hG4bK-524287-1---27a117f64b0e8a26
Max-Forwards: 70
Contact: <sip:user1@88.28.14.195:57619;transport=UDP;rinstance=bb40a387c4dc99a2>
To: <sip:user1@192.168.0.12:5060>
From: <sip:user1@192.168.0.12:5060>;tag=2accb778
Call-ID: zYclxmwdUeEYe7acyMesaQ..
CSeq: 2 REGISTER
Expires: 70
Allow: INVITE, ACK, CANCEL, BYE, NOTIFY, REFER, MESSAGE, OPTIONS, INFO, SUBSCRIBE
Supported: replaces, norefersub, extended-refer, timer, outbound, path, X-cisco-serviceuri
User-Agent: Zoiper v2.10.17.3-mod
Authorization: Digest username="user1",realm="asterisk",nonce="1655738079/0a5bc3a62055bfd8018556dcd113ccd4",uri="sip:192.168.0.12:5060;transport=UDP",response="20fcef6c8ab60e75301c2a1a6f24eb11",cnonce="7b53f90ce4c2d181464ae9a1b5cc7c37",nc=00000001,qop=auth,algorithm=md5,opaque="74da5fb649b889a2"
Allow-Events: presence, kpml, talk
Content-Length: 0


[2022-06-20 15:14:39] NOTICE[3283]: res_pjsip/pjsip_distributor.c:676 log_failed_request: Request 'REGISTER' from '<sip:user1@192.168.0.12>' failed for '88.28.14.195:57619' (callid: zYclxmwdUeEYe7acyMesaQ..) - Failed to authenticate
<--- Transmitting SIP response (505 bytes) to UDP:88.28.14.195:57619 --->
SIP/2.0 401 Unauthorized
Via: SIP/2.0/UDP 88.28.14.195:57619;rport=57619;received=88.28.14.195;branch=z9hG4bK-524287-1---27a117f64b0e8a26
Call-ID: zYclxmwdUeEYe7acyMesaQ..
From: <sip:user1@192.168.0.12>;tag=2accb778
To: <sip:user1@192.168.0.12>;tag=z9hG4bK-524287-1---27a117f64b0e8a26
CSeq: 2 REGISTER
WWW-Authenticate: Digest realm="asterisk",nonce="1655738079/0a5bc3a62055bfd8018556dcd113ccd4",opaque="01800c2a16dc6f7c",algorithm=md5,qop="auth"
Server: Asterisk PBX 19.3.0
Content-Length:  0


[2022-06-20 15:14:39] NOTICE[3283]: res_pjsip/pjsip_distributor.c:676 log_failed_request: Request 'REGISTER' from '<sip:user1@192.168.0.12>' failed for '88.28.14.195:57619' (callid: zYclxmwdUeEYe7acyMesaQ..) - Failed to authenticate
<--- Transmitting SIP response (505 bytes) to UDP:88.28.14.195:57619 --->
SIP/2.0 401 Unauthorized
Via: SIP/2.0/UDP 88.28.14.195:57619;rport=57619;received=88.28.14.195;branch=z9hG4bK-524287-1---27a117f64b0e8a26
Call-ID: zYclxmwdUeEYe7acyMesaQ..
From: <sip:user1@192.168.0.12>;tag=2accb778
To: <sip:user1@192.168.0.12>;tag=z9hG4bK-524287-1---27a117f64b0e8a26
CSeq: 2 REGISTER
WWW-Authenticate: Digest realm="asterisk",nonce="1655738079/0a5bc3a62055bfd8018556dcd113ccd4",opaque="589d22e13229cc51",algorithm=md5,qop="auth"
Server: Asterisk PBX 19.3.0
Content-Length:  0

When I perform the exact same steps (even using the external IP address) but with Zoiper connected to my local network, the logs are the following one:

<--- Received SIP request (692 bytes) from UDP:213.37.134.165:46453 --->
REGISTER sip:213.37.134.165:5060;transport=UDP SIP/2.0
Via: SIP/2.0/UDP 192.168.0.15:46453;branch=z9hG4bK-524287-1---985df714a0dbd3f0;rport
Max-Forwards: 70
Contact: <sip:user1@192.168.0.15:46453;rinstance=cd3b15c04e866c21;transport=UDP>
To: <sip:user1@213.37.134.165:5060;transport=UDP>
From: <sip:user1@213.37.134.165:5060;transport=UDP>;tag=8f055e6f
Call-ID: iqIf0dyamCcfjFLDue1Hyw..
CSeq: 1 REGISTER
Expires: 70
Allow: INVITE, ACK, CANCEL, BYE, NOTIFY, REFER, MESSAGE, OPTIONS, INFO, SUBSCRIBE
Supported: replaces, norefersub, extended-refer, timer, outbound, path, X-cisco-serviceuri
User-Agent: Zoiper v2.10.17.3-mod
Allow-Events: presence, kpml, talk
Content-Length: 0


<--- Received SIP request (692 bytes) from UDP:213.37.134.165:46453 --->
REGISTER sip:213.37.134.165:5060;transport=UDP SIP/2.0
Via: SIP/2.0/UDP 192.168.0.15:46453;branch=z9hG4bK-524287-1---985df714a0dbd3f0;rport
Max-Forwards: 70
Contact: <sip:user1@192.168.0.15:46453;rinstance=cd3b15c04e866c21;transport=UDP>
To: <sip:user1@213.37.134.165:5060;transport=UDP>
From: <sip:user1@213.37.134.165:5060;transport=UDP>;tag=8f055e6f
Call-ID: iqIf0dyamCcfjFLDue1Hyw..
CSeq: 1 REGISTER
Expires: 70
Allow: INVITE, ACK, CANCEL, BYE, NOTIFY, REFER, MESSAGE, OPTIONS, INFO, SUBSCRIBE
Supported: replaces, norefersub, extended-refer, timer, outbound, path, X-cisco-serviceuri
User-Agent: Zoiper v2.10.17.3-mod
Allow-Events: presence, kpml, talk
Content-Length: 0


<--- Transmitting SIP response (511 bytes) to UDP:213.37.134.165:46453 --->
SIP/2.0 401 Unauthorized
Via: SIP/2.0/UDP 192.168.0.15:46453;rport=46453;received=213.37.134.165;branch=z9hG4bK-524287-1---985df714a0dbd3f0
Call-ID: iqIf0dyamCcfjFLDue1Hyw..
From: <sip:user1@213.37.134.165>;tag=8f055e6f
To: <sip:user1@213.37.134.165>;tag=z9hG4bK-524287-1---985df714a0dbd3f0
CSeq: 1 REGISTER
WWW-Authenticate: Digest realm="asterisk",nonce="1655738247/cf9c287044e6443e6f16ce231a881277",opaque="54def57052ca4248",algorithm=md5,qop="auth"
Server: Asterisk PBX 19.3.0
Content-Length:  0


<--- Received SIP request (992 bytes) from UDP:213.37.134.165:46453 --->
REGISTER sip:213.37.134.165:5060;transport=UDP SIP/2.0
Via: SIP/2.0/UDP 192.168.0.15:46453;branch=z9hG4bK-524287-1---0b2731eb701b5fc6;rport
Max-Forwards: 70
Contact: <sip:user1@192.168.0.15:46453;rinstance=cd3b15c04e866c21;transport=UDP>
To: <sip:user1@213.37.134.165:5060;transport=UDP>
From: <sip:user1@213.37.134.165:5060;transport=UDP>;tag=8f055e6f
Call-ID: iqIf0dyamCcfjFLDue1Hyw..
CSeq: 2 REGISTER
Expires: 70
Allow: INVITE, ACK, CANCEL, BYE, NOTIFY, REFER, MESSAGE, OPTIONS, INFO, SUBSCRIBE
Supported: replaces, norefersub, extended-refer, timer, outbound, path, X-cisco-serviceuri
User-Agent: Zoiper v2.10.17.3-mod
Authorization: Digest username="user1",realm="asterisk",nonce="1655738247/cf9c287044e6443e6f16ce231a881277",uri="sip:213.37.134.165:5060;transport=UDP",response="3cedd3face420553e0d4ff4549317d1a",cnonce="8e001e7fe1ad7ede74e4d7b911dbe462",nc=00000001,qop=auth,algorithm=md5,opaque="54def57052ca4248"
Allow-Events: presence, kpml, talk
Content-Length: 0


<--- Received SIP request (992 bytes) from UDP:213.37.134.165:46453 --->
REGISTER sip:213.37.134.165:5060;transport=UDP SIP/2.0
Via: SIP/2.0/UDP 192.168.0.15:46453;branch=z9hG4bK-524287-1---0b2731eb701b5fc6;rport
Max-Forwards: 70
Contact: <sip:user1@192.168.0.15:46453;rinstance=cd3b15c04e866c21;transport=UDP>
To: <sip:user1@213.37.134.165:5060;transport=UDP>
From: <sip:user1@213.37.134.165:5060;transport=UDP>;tag=8f055e6f
Call-ID: iqIf0dyamCcfjFLDue1Hyw..
CSeq: 2 REGISTER
Expires: 70
Allow: INVITE, ACK, CANCEL, BYE, NOTIFY, REFER, MESSAGE, OPTIONS, INFO, SUBSCRIBE
Supported: replaces, norefersub, extended-refer, timer, outbound, path, X-cisco-serviceuri
User-Agent: Zoiper v2.10.17.3-mod
Authorization: Digest username="user1",realm="asterisk",nonce="1655738247/cf9c287044e6443e6f16ce231a881277",uri="sip:213.37.134.165:5060;transport=UDP",response="3cedd3face420553e0d4ff4549317d1a",cnonce="8e001e7fe1ad7ede74e4d7b911dbe462",nc=00000001,qop=auth,algorithm=md5,opaque="54def57052ca4248"
Allow-Events: presence, kpml, talk
Content-Length: 0


<--- Transmitting SIP response (511 bytes) to UDP:213.37.134.165:46453 --->
SIP/2.0 401 Unauthorized
Via: SIP/2.0/UDP 192.168.0.15:46453;rport=46453;received=213.37.134.165;branch=z9hG4bK-524287-1---985df714a0dbd3f0
Call-ID: iqIf0dyamCcfjFLDue1Hyw..
From: <sip:user1@213.37.134.165>;tag=8f055e6f
To: <sip:user1@213.37.134.165>;tag=z9hG4bK-524287-1---985df714a0dbd3f0
CSeq: 1 REGISTER
WWW-Authenticate: Digest realm="asterisk",nonce="1655738247/cf9c287044e6443e6f16ce231a881277",opaque="3cf71c6b6a21fd15",algorithm=md5,qop="auth"
Server: Asterisk PBX 19.3.0
Content-Length:  0


    -- Added contact 'sip:user1@192.168.0.15:46453;transport=UDP;rinstance=cd3b15c04e866c21' to AOR 'user1' with expiration of 70 seconds
  == Endpoint user1 is now Reachable
<--- Transmitting SIP response (498 bytes) to UDP:213.37.134.165:46453 --->
SIP/2.0 200 OK
Via: SIP/2.0/UDP 192.168.0.15:46453;rport=46453;received=213.37.134.165;branch=z9hG4bK-524287-1---0b2731eb701b5fc6
Call-ID: iqIf0dyamCcfjFLDue1Hyw..
From: <sip:user1@213.37.134.165>;tag=8f055e6f
To: <sip:user1@213.37.134.165>;tag=z9hG4bK-524287-1---0b2731eb701b5fc6
CSeq: 2 REGISTER
Date: Mon, 20 Jun 2022 15:17:27 GMT
Contact: <sip:user1@192.168.0.15:46453;transport=UDP;rinstance=cd3b15c04e866c21>;expires=69
Expires: 70
Server: Asterisk PBX 19.3.0
Content-Length:  0


<--- Received SIP request (989 bytes) from UDP:213.37.134.165:46453 --->
REGISTER sip:213.37.134.165:5060;transport=UDP SIP/2.0
Via: SIP/2.0/UDP 192.168.0.15:46453;branch=z9hG4bK-524287-1---4b82a73d72ea2625;rport
Max-Forwards: 70
Contact: <sip:user1@192.168.0.15:46453;transport=UDP;rinstance=cd3b15c04e866c21>;expires=0
To: <sip:user1@213.37.134.165:5060;transport=UDP>
From: <sip:user1@213.37.134.165:5060;transport=UDP>;tag=8f055e6f
Call-ID: iqIf0dyamCcfjFLDue1Hyw..
CSeq: 3 REGISTER
Allow: INVITE, ACK, CANCEL, BYE, NOTIFY, REFER, MESSAGE, OPTIONS, INFO, SUBSCRIBE
Supported: replaces, norefersub, extended-refer, timer, outbound, path, X-cisco-serviceuri
User-Agent: Zoiper v2.10.17.3-mod
Authorization: Digest username="user1",realm="asterisk",nonce="1655738247/cf9c287044e6443e6f16ce231a881277",uri="sip:213.37.134.165:5060;transport=UDP",response="b519d5261416ef0933bd5d6c3cf3e2a5",cnonce="6db7834dee4994bdeed520453ad7a55e",nc=00000002,qop=auth,algorithm=md5,opaque="54def57052ca4248"
Allow-Events: presence, kpml, talk
Content-Length: 0


<--- Received SIP request (989 bytes) from UDP:213.37.134.165:46453 --->
REGISTER sip:213.37.134.165:5060;transport=UDP SIP/2.0
Via: SIP/2.0/UDP 192.168.0.15:46453;branch=z9hG4bK-524287-1---4b82a73d72ea2625;rport
Max-Forwards: 70
Contact: <sip:user1@192.168.0.15:46453;transport=UDP;rinstance=cd3b15c04e866c21>;expires=0
To: <sip:user1@213.37.134.165:5060;transport=UDP>
From: <sip:user1@213.37.134.165:5060;transport=UDP>;tag=8f055e6f
Call-ID: iqIf0dyamCcfjFLDue1Hyw..
CSeq: 3 REGISTER
Allow: INVITE, ACK, CANCEL, BYE, NOTIFY, REFER, MESSAGE, OPTIONS, INFO, SUBSCRIBE
Supported: replaces, norefersub, extended-refer, timer, outbound, path, X-cisco-serviceuri
User-Agent: Zoiper v2.10.17.3-mod
Authorization: Digest username="user1",realm="asterisk",nonce="1655738247/cf9c287044e6443e6f16ce231a881277",uri="sip:213.37.134.165:5060;transport=UDP",response="b519d5261416ef0933bd5d6c3cf3e2a5",cnonce="6db7834dee4994bdeed520453ad7a55e",nc=00000002,qop=auth,algorithm=md5,opaque="54def57052ca4248"
Allow-Events: presence, kpml, talk
Content-Length: 0


<--- Transmitting SIP response (498 bytes) to UDP:213.37.134.165:46453 --->
SIP/2.0 200 OK
Via: SIP/2.0/UDP 192.168.0.15:46453;rport=46453;received=213.37.134.165;branch=z9hG4bK-524287-1---0b2731eb701b5fc6
Call-ID: iqIf0dyamCcfjFLDue1Hyw..
From: <sip:user1@213.37.134.165>;tag=8f055e6f
To: <sip:user1@213.37.134.165>;tag=z9hG4bK-524287-1---0b2731eb701b5fc6
CSeq: 2 REGISTER
Date: Mon, 20 Jun 2022 15:17:27 GMT
Contact: <sip:user1@192.168.0.15:46453;transport=UDP;rinstance=cd3b15c04e866c21>;expires=69
Expires: 70
Server: Asterisk PBX 19.3.0
Content-Length:  0


    -- Removed contact 'sip:user1@192.168.0.15:46453;transport=UDP;rinstance=cd3b15c04e866c21' from AOR 'user1' due to request
<--- Transmitting SIP response (392 bytes) to UDP:213.37.134.165:46453 --->
SIP/2.0 200 OK
Via: SIP/2.0/UDP 192.168.0.15:46453;rport=46453;received=213.37.134.165;branch=z9hG4bK-524287-1---4b82a73d72ea2625
Call-ID: iqIf0dyamCcfjFLDue1Hyw..
From: <sip:user1@213.37.134.165>;tag=8f055e6f
To: <sip:user1@213.37.134.165>;tag=z9hG4bK-524287-1---4b82a73d72ea2625
CSeq: 3 REGISTER
Date: Mon, 20 Jun 2022 15:17:27 GMT
Server: Asterisk PBX 19.3.0
Content-Length:  0


  == Contact user1/sip:user1@192.168.0.15:46453;transport=UDP;rinstance=cd3b15c04e866c21 has been deleted
  == Endpoint user1 is now Unreachable
<--- Transmitting SIP response (392 bytes) to UDP:213.37.134.165:46453 --->
SIP/2.0 200 OK
Via: SIP/2.0/UDP 192.168.0.15:46453;rport=46453;received=213.37.134.165;branch=z9hG4bK-524287-1---4b82a73d72ea2625
Call-ID: iqIf0dyamCcfjFLDue1Hyw..
From: <sip:user1@213.37.134.165>;tag=8f055e6f
To: <sip:user1@213.37.134.165>;tag=z9hG4bK-524287-1---4b82a73d72ea2625
CSeq: 3 REGISTER
Date: Mon, 20 Jun 2022 15:17:27 GMT
Server: Asterisk PBX 19.3.0
Content-Length:  0

I don’t get why the first two register messages are responded with a 401 error but the following ones are successful.

Is it possible that some configuration is needed for this to work with devices outside the local network.
In case it’s important, I’m also using ARI and odbc for the realtime PJSIP database.

Thanks a lot again

Because the 401 says how to authenticate and provides the random challenge, and the client subsequently replies with:

Authorization: Digest username="user1",realm="asterisk",nonce="1655738079/0a5bc3a62055bfd8018556dcd113ccd4",uri="sip:192.168.0.12:5060;transport=UDP",response="20fcef6c8ab60e75301c2a1a6f24eb11",cnonce="7b53f90ce4c2d181464ae9a1b5cc7c37",nc=00000001,qop=auth,algorithm=md5,opaque="74da5fb649b889a2"

which is based on the password and the random challenge.

The ones that get the 401 don’t have such a header. You’d also get a 401 for an out of date random challenge (nonce). This is also a standard part of how SIP authentication works.

If the same device is responding to 401 in some cases, and not in others, it means the 401 is not reaching it, in the second category of cases, but it does have a password to use.

Ok, so our current hypothesis is that the 401 messages the server throws are not reaching the client (linphone/zoiper). However, by looking into the traces we can see that the client it is responding to the 401 messages, and in fact it includes the nonce of the message it’s responding to, for example.

I have completely disable my router firewall, I have tested with TCP transport, and I have also tried disabling SIP ALG on my router settings, but in that case Asterisk doesn’t event receive the messages.
What other ways could I try? I need to solve this problem.

I’m confused. I thought you said the broken configuration was the one with no 401s.

The broken configurations are the one on my second post and the first one on my fourth post. In both cases my phone (running Linphone/Zoiper) is outside my local network, it receives the initial 401s and then creates new messages which include the nonce and are also responded with 401 messages.
Here it is the latest example I posted

<--- Received SIP request (652 bytes) from UDP:88.28.14.195:57619 --->
REGISTER sip:192.168.0.12:5060;transport=UDP SIP/2.0
Via: SIP/2.0/UDP 88.28.14.195:57619;branch=z9hG4bK-524287-1---6ed65ac995848b2d
Max-Forwards: 70
Contact: <sip:user1@88.28.14.195:57619;transport=UDP;rinstance=bb40a387c4dc99a2>
To: <sip:user1@192.168.0.12:5060>
From: <sip:user1@192.168.0.12:5060>;tag=2accb778
Call-ID: zYclxmwdUeEYe7acyMesaQ..
CSeq: 1 REGISTER
Expires: 70
Allow: INVITE, ACK, CANCEL, BYE, NOTIFY, REFER, MESSAGE, OPTIONS, INFO, SUBSCRIBE
Supported: replaces, norefersub, extended-refer, timer, outbound, path, X-cisco-serviceuri
User-Agent: Zoiper v2.10.17.3-mod
Allow-Events: presence, kpml, talk
Content-Length: 0


<--- Received SIP request (652 bytes) from UDP:88.28.14.195:57619 --->
REGISTER sip:192.168.0.12:5060;transport=UDP SIP/2.0
Via: SIP/2.0/UDP 88.28.14.195:57619;branch=z9hG4bK-524287-1---6ed65ac995848b2d
Max-Forwards: 70
Contact: <sip:user1@88.28.14.195:57619;transport=UDP;rinstance=bb40a387c4dc99a2>
To: <sip:user1@192.168.0.12:5060>
From: <sip:user1@192.168.0.12:5060>;tag=2accb778
Call-ID: zYclxmwdUeEYe7acyMesaQ..
CSeq: 1 REGISTER
Expires: 70
Allow: INVITE, ACK, CANCEL, BYE, NOTIFY, REFER, MESSAGE, OPTIONS, INFO, SUBSCRIBE
Supported: replaces, norefersub, extended-refer, timer, outbound, path, X-cisco-serviceuri
User-Agent: Zoiper v2.10.17.3-mod
Allow-Events: presence, kpml, talk
Content-Length: 0


<--- Transmitting SIP response (505 bytes) to UDP:88.28.14.195:57619 --->
SIP/2.0 401 Unauthorized
Via: SIP/2.0/UDP 88.28.14.195:57619;rport=57619;received=88.28.14.195;branch=z9hG4bK-524287-1---6ed65ac995848b2d
Call-ID: zYclxmwdUeEYe7acyMesaQ..
From: <sip:user1@192.168.0.12>;tag=2accb778
To: <sip:user1@192.168.0.12>;tag=z9hG4bK-524287-1---6ed65ac995848b2d
CSeq: 1 REGISTER
WWW-Authenticate: Digest realm="asterisk",nonce="1655738079/0a5bc3a62055bfd8018556dcd113ccd4",opaque="74da5fb649b889a2",algorithm=md5,qop="auth"
Server: Asterisk PBX 19.3.0
Content-Length:  0


<--- Transmitting SIP response (505 bytes) to UDP:88.28.14.195:57619 --->
SIP/2.0 401 Unauthorized
Via: SIP/2.0/UDP 88.28.14.195:57619;rport=57619;received=88.28.14.195;branch=z9hG4bK-524287-1---6ed65ac995848b2d
Call-ID: zYclxmwdUeEYe7acyMesaQ..
From: <sip:user1@192.168.0.12>;tag=2accb778
To: <sip:user1@192.168.0.12>;tag=z9hG4bK-524287-1---6ed65ac995848b2d
CSeq: 1 REGISTER
WWW-Authenticate: Digest realm="asterisk",nonce="1655738079/0a5bc3a62055bfd8018556dcd113ccd4",opaque="106e3bca62af82c0",algorithm=md5,qop="auth"
Server: Asterisk PBX 19.3.0
Content-Length:  0


<--- Received SIP request (950 bytes) from UDP:88.28.14.195:57619 --->
REGISTER sip:192.168.0.12:5060;transport=UDP SIP/2.0
Via: SIP/2.0/UDP 88.28.14.195:57619;branch=z9hG4bK-524287-1---27a117f64b0e8a26
Max-Forwards: 70
Contact: <sip:user1@88.28.14.195:57619;transport=UDP;rinstance=bb40a387c4dc99a2>
To: <sip:user1@192.168.0.12:5060>
From: <sip:user1@192.168.0.12:5060>;tag=2accb778
Call-ID: zYclxmwdUeEYe7acyMesaQ..
CSeq: 2 REGISTER
Expires: 70
Allow: INVITE, ACK, CANCEL, BYE, NOTIFY, REFER, MESSAGE, OPTIONS, INFO, SUBSCRIBE
Supported: replaces, norefersub, extended-refer, timer, outbound, path, X-cisco-serviceuri
User-Agent: Zoiper v2.10.17.3-mod
Authorization: Digest username="user1",realm="asterisk",nonce="1655738079/0a5bc3a62055bfd8018556dcd113ccd4",uri="sip:192.168.0.12:5060;transport=UDP",response="20fcef6c8ab60e75301c2a1a6f24eb11",cnonce="7b53f90ce4c2d181464ae9a1b5cc7c37",nc=00000001,qop=auth,algorithm=md5,opaque="74da5fb649b889a2"
Allow-Events: presence, kpml, talk
Content-Length: 0


<--- Received SIP request (950 bytes) from UDP:88.28.14.195:57619 --->
REGISTER sip:192.168.0.12:5060;transport=UDP SIP/2.0
Via: SIP/2.0/UDP 88.28.14.195:57619;branch=z9hG4bK-524287-1---27a117f64b0e8a26
Max-Forwards: 70
Contact: <sip:user1@88.28.14.195:57619;transport=UDP;rinstance=bb40a387c4dc99a2>
To: <sip:user1@192.168.0.12:5060>
From: <sip:user1@192.168.0.12:5060>;tag=2accb778
Call-ID: zYclxmwdUeEYe7acyMesaQ..
CSeq: 2 REGISTER
Expires: 70
Allow: INVITE, ACK, CANCEL, BYE, NOTIFY, REFER, MESSAGE, OPTIONS, INFO, SUBSCRIBE
Supported: replaces, norefersub, extended-refer, timer, outbound, path, X-cisco-serviceuri
User-Agent: Zoiper v2.10.17.3-mod
Authorization: Digest username="user1",realm="asterisk",nonce="1655738079/0a5bc3a62055bfd8018556dcd113ccd4",uri="sip:192.168.0.12:5060;transport=UDP",response="20fcef6c8ab60e75301c2a1a6f24eb11",cnonce="7b53f90ce4c2d181464ae9a1b5cc7c37",nc=00000001,qop=auth,algorithm=md5,opaque="74da5fb649b889a2"
Allow-Events: presence, kpml, talk
Content-Length: 0


[2022-06-20 15:14:39] NOTICE[3283]: res_pjsip/pjsip_distributor.c:676 log_failed_request: Request 'REGISTER' from '<sip:user1@192.168.0.12>' failed for '88.28.14.195:57619' (callid: zYclxmwdUeEYe7acyMesaQ..) - Failed to authenticate
<--- Transmitting SIP response (505 bytes) to UDP:88.28.14.195:57619 --->
SIP/2.0 401 Unauthorized
Via: SIP/2.0/UDP 88.28.14.195:57619;rport=57619;received=88.28.14.195;branch=z9hG4bK-524287-1---27a117f64b0e8a26
Call-ID: zYclxmwdUeEYe7acyMesaQ..
From: <sip:user1@192.168.0.12>;tag=2accb778
To: <sip:user1@192.168.0.12>;tag=z9hG4bK-524287-1---27a117f64b0e8a26
CSeq: 2 REGISTER
WWW-Authenticate: Digest realm="asterisk",nonce="1655738079/0a5bc3a62055bfd8018556dcd113ccd4",opaque="01800c2a16dc6f7c",algorithm=md5,qop="auth"
Server: Asterisk PBX 19.3.0
Content-Length:  0


[2022-06-20 15:14:39] NOTICE[3283]: res_pjsip/pjsip_distributor.c:676 log_failed_request: Request 'REGISTER' from '<sip:user1@192.168.0.12>' failed for '88.28.14.195:57619' (callid: zYclxmwdUeEYe7acyMesaQ..) - Failed to authenticate
<--- Transmitting SIP response (505 bytes) to UDP:88.28.14.195:57619 --->
SIP/2.0 401 Unauthorized
Via: SIP/2.0/UDP 88.28.14.195:57619;rport=57619;received=88.28.14.195;branch=z9hG4bK-524287-1---27a117f64b0e8a26
Call-ID: zYclxmwdUeEYe7acyMesaQ..
From: <sip:user1@192.168.0.12>;tag=2accb778
To: <sip:user1@192.168.0.12>;tag=z9hG4bK-524287-1---27a117f64b0e8a26
CSeq: 2 REGISTER
WWW-Authenticate: Digest realm="asterisk",nonce="1655738079/0a5bc3a62055bfd8018556dcd113ccd4",opaque="589d22e13229cc51",algorithm=md5,qop="auth"
Server: Asterisk PBX 19.3.0
Content-Length:  0

As you can see, Asterisk receives the messages with nonce from the softphone, so the router should be working properly.

can you try to also capture the sip traffic locally on the pc or roter where Zoiper/Linphone is running

Sure, I have repeated the same procedure but with the Zoiper logs enabled on my phone. The logs are a bit verbose and they include additional information, not just the SIP traces, but I think they could help so I’m not deleting them.
The logs I get on my Asterisk server are:

PJSIP Logging enabled
<--- Received SIP request (560 bytes) from UDP:88.28.18.129:13816 --->
REGISTER sip:192.168.0.25:5060;transport=UDP SIP/2.0
Via: SIP/2.0/UDP 88.28.18.129:13816;branch=z9hG4bK-524287-1---be4cc1af801e2797
Max-Forwards: 70
Contact: <sip:user1@88.28.18.129:13816;transport=UDP;rinstance=196e51ef47b31d66>
To: <sip:user1@192.168.0.25:5060>
From: <sip:user1@192.168.0.25:5060>;tag=db563107
Call-ID: iLiuWdMhVuAUvKSqXLMXew..
CSeq: 1 REGISTER
Expires: 60
Allow: INVITE, ACK, CANCEL, BYE, NOTIFY, REFER, MESSAGE, OPTIONS, INFO, SUBSCRIBE
User-Agent: Zoiper v2.10.17.3-mod
Allow-Events: presence, kpml, talk
Content-Length: 0


<--- Received SIP request (560 bytes) from UDP:88.28.18.129:13816 --->
REGISTER sip:192.168.0.25:5060;transport=UDP SIP/2.0
Via: SIP/2.0/UDP 88.28.18.129:13816;branch=z9hG4bK-524287-1---be4cc1af801e2797
Max-Forwards: 70
Contact: <sip:user1@88.28.18.129:13816;transport=UDP;rinstance=196e51ef47b31d66>
To: <sip:user1@192.168.0.25:5060>
From: <sip:user1@192.168.0.25:5060>;tag=db563107
Call-ID: iLiuWdMhVuAUvKSqXLMXew..
CSeq: 1 REGISTER
Expires: 60
Allow: INVITE, ACK, CANCEL, BYE, NOTIFY, REFER, MESSAGE, OPTIONS, INFO, SUBSCRIBE
User-Agent: Zoiper v2.10.17.3-mod
Allow-Events: presence, kpml, talk
Content-Length: 0


<--- Transmitting SIP response (505 bytes) to UDP:88.28.18.129:13816 --->
SIP/2.0 401 Unauthorized
Via: SIP/2.0/UDP 88.28.18.129:13816;rport=13816;received=88.28.18.129;branch=z9hG4bK-524287-1---be4cc1af801e2797
Call-ID: iLiuWdMhVuAUvKSqXLMXew..
From: <sip:user1@192.168.0.25>;tag=db563107
To: <sip:user1@192.168.0.25>;tag=z9hG4bK-524287-1---be4cc1af801e2797
CSeq: 1 REGISTER
WWW-Authenticate: Digest realm="asterisk",nonce="1655878471/f0550c5d9f952d938fa3effe3141fb72",opaque="0111218c1c5d17ce",algorithm=md5,qop="auth"
Server: Asterisk PBX 19.3.0
Content-Length:  0


<--- Transmitting SIP response (505 bytes) to UDP:88.28.18.129:13816 --->
SIP/2.0 401 Unauthorized
Via: SIP/2.0/UDP 88.28.18.129:13816;rport=13816;received=88.28.18.129;branch=z9hG4bK-524287-1---be4cc1af801e2797
Call-ID: iLiuWdMhVuAUvKSqXLMXew..
From: <sip:user1@192.168.0.25>;tag=db563107
To: <sip:user1@192.168.0.25>;tag=z9hG4bK-524287-1---be4cc1af801e2797
CSeq: 1 REGISTER
WWW-Authenticate: Digest realm="asterisk",nonce="1655878471/f0550c5d9f952d938fa3effe3141fb72",opaque="1cd4c4e14fd1a97c",algorithm=md5,qop="auth"
Server: Asterisk PBX 19.3.0
Content-Length:  0


<--- Received SIP request (858 bytes) from UDP:88.28.18.129:13816 --->
REGISTER sip:192.168.0.25:5060;transport=UDP SIP/2.0
Via: SIP/2.0/UDP 88.28.18.129:13816;branch=z9hG4bK-524287-1---0e175c09b8a5691e
Max-Forwards: 70
Contact: <sip:user1@88.28.18.129:13816;transport=UDP;rinstance=196e51ef47b31d66>
To: <sip:user1@192.168.0.25:5060>
From: <sip:user1@192.168.0.25:5060>;tag=db563107
Call-ID: iLiuWdMhVuAUvKSqXLMXew..
CSeq: 2 REGISTER
Expires: 60
Allow: INVITE, ACK, CANCEL, BYE, NOTIFY, REFER, MESSAGE, OPTIONS, INFO, SUBSCRIBE
User-Agent: Zoiper v2.10.17.3-mod
Authorization: Digest username="user1",realm="asterisk",nonce="1655878471/f0550c5d9f952d938fa3effe3141fb72",uri="sip:192.168.0.25:5060;transport=UDP",response="d5f402bf094c820f12a96c802c7bb7e8",cnonce="473c5e75ec32c3289826e8673ca7cf2c",nc=00000001,qop=auth,algorithm=md5,opaque="0111218c1c5d17ce"
Allow-Events: presence, kpml, talk
Content-Length: 0


<--- Received SIP request (858 bytes) from UDP:88.28.18.129:13816 --->
REGISTER sip:192.168.0.25:5060;transport=UDP SIP/2.0
Via: SIP/2.0/UDP 88.28.18.129:13816;branch=z9hG4bK-524287-1---0e175c09b8a5691e
Max-Forwards: 70
Contact: <sip:user1@88.28.18.129:13816;transport=UDP;rinstance=196e51ef47b31d66>
To: <sip:user1@192.168.0.25:5060>
From: <sip:user1@192.168.0.25:5060>;tag=db563107
Call-ID: iLiuWdMhVuAUvKSqXLMXew..
CSeq: 2 REGISTER
Expires: 60
Allow: INVITE, ACK, CANCEL, BYE, NOTIFY, REFER, MESSAGE, OPTIONS, INFO, SUBSCRIBE
User-Agent: Zoiper v2.10.17.3-mod
Authorization: Digest username="user1",realm="asterisk",nonce="1655878471/f0550c5d9f952d938fa3effe3141fb72",uri="sip:192.168.0.25:5060;transport=UDP",response="d5f402bf094c820f12a96c802c7bb7e8",cnonce="473c5e75ec32c3289826e8673ca7cf2c",nc=00000001,qop=auth,algorithm=md5,opaque="0111218c1c5d17ce"
Allow-Events: presence, kpml, talk
Content-Length: 0


[2022-06-22 06:14:31] NOTICE[3612]: res_pjsip/pjsip_distributor.c:676 log_failed_request: Request 'REGISTER' from '<sip:user1@192.168.0.25>' failed for '88.28.18.129:13816' (callid: iLiuWdMhVuAUvKSqXLMXew..) - Failed to authenticate
<--- Transmitting SIP response (505 bytes) to UDP:88.28.18.129:13816 --->
SIP/2.0 401 Unauthorized
Via: SIP/2.0/UDP 88.28.18.129:13816;rport=13816;received=88.28.18.129;branch=z9hG4bK-524287-1---0e175c09b8a5691e
Call-ID: iLiuWdMhVuAUvKSqXLMXew..
From: <sip:user1@192.168.0.25>;tag=db563107
To: <sip:user1@192.168.0.25>;tag=z9hG4bK-524287-1---0e175c09b8a5691e
CSeq: 2 REGISTER
WWW-Authenticate: Digest realm="asterisk",nonce="1655878471/f0550c5d9f952d938fa3effe3141fb72",opaque="519756c000057b64",algorithm=md5,qop="auth"
Server: Asterisk PBX 19.3.0
Content-Length:  0


[2022-06-22 06:14:31] NOTICE[3612]: res_pjsip/pjsip_distributor.c:676 log_failed_request: Request 'REGISTER' from '<sip:user1@192.168.0.25>' failed for '88.28.18.129:13816' (callid: iLiuWdMhVuAUvKSqXLMXew..) - Failed to authenticate
<--- Transmitting SIP response (505 bytes) to UDP:88.28.18.129:13816 --->
SIP/2.0 401 Unauthorized
Via: SIP/2.0/UDP 88.28.18.129:13816;rport=13816;received=88.28.18.129;branch=z9hG4bK-524287-1---0e175c09b8a5691e
Call-ID: iLiuWdMhVuAUvKSqXLMXew..
From: <sip:user1@192.168.0.25>;tag=db563107
To: <sip:user1@192.168.0.25>;tag=z9hG4bK-524287-1---0e175c09b8a5691e
CSeq: 2 REGISTER
WWW-Authenticate: Digest realm="asterisk",nonce="1655878471/f0550c5d9f952d938fa3effe3141fb72",opaque="771a5f9578e81155",algorithm=md5,qop="auth"
Server: Asterisk PBX 19.3.0
Content-Length:  0

While on the zopier client, which is outside my local network, I have the following log (I need to upload a file as there is too much text)
logfile_20220622_081432.txt (67.4 KB)

Again, thanks a lot for your help, I really appreciate it!

Hi again,
I don’t know if this can be of any help in order to solve the problem, or maybe this is directly the solution, but after some tries, I have managed to get this working by setting Asterisk’s local IP address as the registrer/domain address, and then adding my NAT external address as a proxy on Zoiper configuration.

With this, I can receive and make calls fron inside and outside my network.

hmm
yes both the SIP from asterisk and the phone log look fine