Asterisk pjsip can not register endpoint

Guys, please help me, I can not register my pjsip extension:

<--- SIP read from UDP:192.168.1.3:39681 --->
REGISTER sip:192.168.1.9:5060;transport=UDP SIP/2.0
Via: SIP/2.0/UDP 192.168.1.3:39681;branch=z9hG4bK-524287-1---6c7c9e51d91e7a9a;rport
Max-Forwards: 70
Contact: <sip:101@192.168.1.3:39681;rinstance=4768845210e4a444;transport=UDP>
To: <sip:101@192.168.1.9:5060;transport=UDP>
From: <sip:101@192.168.1.9:5060;transport=UDP>;tag=b6fc0802
Call-ID: dLyEjjMFY2z-j_HaePJkug..
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: Z 5.3.7 rv2.9.30
Allow-Events: presence, kpml, talk
Content-Length: 0

<------------->
--- (14 headers 0 lines) ---
Sending to 192.168.1.3:39681 (NAT)
Sending to 192.168.1.3:39681 (NAT)

<--- Transmitting (NAT) to 192.168.1.3:39681 --->
SIP/2.0 401 Unauthorized
Via: SIP/2.0/UDP 192.168.1.3:39681;branch=z9hG4bK-524287-1---6c7c9e51d91e7a9a;received=192.168.1.3;rport=39681
From: <sip:101@192.168.1.9:5060;transport=UDP>;tag=b6fc0802
To: <sip:101@192.168.1.9:5060;transport=UDP>;tag=as0c560803
Call-ID: dLyEjjMFY2z-j_HaePJkug..
CSeq: 1 REGISTER
Server: Asterisk PBX 16.8.0
Allow: INVITE, ACK, CANCEL, OPTIONS, BYE, REFER, SUBSCRIBE, NOTIFY, INFO, PUBLISH, MESSAGE
Supported: replaces, timer
WWW-Authenticate: Digest algorithm=MD5, realm="asterisk", nonce="07fd5099"
Content-Length: 0


<------------>
Scheduling destruction of SIP dialog 'dLyEjjMFY2z-j_HaePJkug..' in 32000 ms (Method: REGISTER)

<--- SIP read from UDP:192.168.1.3:39681 --->
REGISTER sip:192.168.1.9:5060;transport=UDP SIP/2.0
Via: SIP/2.0/UDP 192.168.1.3:39681;branch=z9hG4bK-524287-1---a3c359ac925b7132;rport
Max-Forwards: 70
Contact: <sip:101@192.168.1.3:39681;rinstance=4768845210e4a444;transport=UDP>
To: <sip:101@192.168.1.9:5060;transport=UDP>
From: <sip:101@192.168.1.9:5060;transport=UDP>;tag=b6fc0802
Call-ID: dLyEjjMFY2z-j_HaePJkug..
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: Z 5.3.7 rv2.9.30
Authorization: Digest username="101",realm="asterisk",nonce="07fd5099",uri="sip:192.168.1.9:5060;transport=UDP",response="fe1dc7376c8182317bcf6781b77a0552",algorithm=MD5
Allow-Events: presence, kpml, talk
Content-Length: 0

<------------->
--- (15 headers 0 lines) ---
Sending to 192.168.1.3:39681 (NAT)

<--- Transmitting (NAT) to 192.168.1.3:39681 --->
SIP/2.0 403 Forbidden
Via: SIP/2.0/UDP 192.168.1.3:39681;branch=z9hG4bK-524287-1---a3c359ac925b7132;received=192.168.1.3;rport=39681
From: <sip:101@192.168.1.9:5060;transport=UDP>;tag=b6fc0802
To: <sip:101@192.168.1.9:5060;transport=UDP>;tag=as0c560803
Call-ID: dLyEjjMFY2z-j_HaePJkug..
CSeq: 2 REGISTER
Server: Asterisk PBX 16.8.0
Allow: INVITE, ACK, CANCEL, OPTIONS, BYE, REFER, SUBSCRIBE, NOTIFY, INFO, PUBLISH, MESSAGE
Supported: replaces, timer
Content-Length: 0


<------------>
[Apr 13 09:04:21] NOTICE[58]: chan_sip.c:28959 handle_request_register: Registration from '<sip:101@192.168.1.9:5060;transport=UDP>' failed for '192.168.1.3:39681' - Wrong password

I attached image here:

Wrong password.

I’m not sure, but you might get the same sequence if the endpoint (not extension) isn’t recognized, which might be done to avoid telling an attacker which users are valid.

2 Likes

I am sure the name and password is correct, but dont know why the log say wrong password, here is my pjsip.conf:

[102]
type=endpoint
aors=102
auth=102-auth
tos_audio=ef
tos_video=af41
cos_audio=5
cos_video=4
allow=ulaw,alaw,gsm,g726,g722
context=from-internal
callerid=102 <102>

dtmf_mode=rfc4733
direct_media=yes
outbound_auth=102-auth
mailboxes=102@device

mwi_subscribe_replaces_unsolicited=yes
aggregate_mwi=yes
use_avpf=no
rtcp_mux=no
max_audio_streams=1
max_video_streams=1
bundle=no
ice_support=no
media_use_received_transport=no
trust_id_inbound=yes
user_eq_phone=no
send_connected_line=yes
media_encryption=no
timers=yes
timers_min_se=90
media_encryption_optimistic=no
refer_blind_progress=yes
refer_blind_progress=yes
rtp_timeout=30
rtp_timeout_hold=300
send_pai=yes
rtp_symmetric=yes
rewrite_contact=yes
force_rport=yes
language=en
one_touch_recording=on
record_on_feature=apprecord
record_off_feature=apprecord

[103]
type=endpoint
aors=103
auth=103-auth
tos_audio=ef
tos_video=af41
cos_audio=5
cos_video=4
allow=ulaw,alaw,gsm,g726,g722
context=from-internal
callerid=103 <103>

dtmf_mode=rfc4733
direct_media=yes
outbound_auth=103-auth
aggregate_mwi=yes
use_avpf=no
rtcp_mux=no
max_audio_streams=1
max_video_streams=1
bundle=no
ice_support=no
media_use_received_transport=no
trust_id_inbound=yes
user_eq_phone=no
send_connected_line=yes
media_encryption=no
timers=yes
timers_min_se=90
media_encryption_optimistic=no
refer_blind_progress=yes
refer_blind_progress=yes
rtp_timeout=30
rtp_timeout_hold=300
send_pai=yes
rtp_symmetric=yes
rewrite_contact=yes
force_rport=yes
language=en
one_touch_recording=on
record_on_feature=apprecord
record_off_feature=apprecord

[101]
type=endpoint
aors=101
auth=101-auth
tos_audio=ef
tos_video=af41
cos_audio=5
cos_video=4
allow=ulaw,alaw,gsm,g726,g722
context=from-internal
callerid=101 <101>

dtmf_mode=rfc4733
direct_media=yes
outbound_auth=101-auth
mailboxes=101@device

mwi_subscribe_replaces_unsolicited=yes
aggregate_mwi=yes
use_avpf=no
rtcp_mux=no
max_audio_streams=1
max_video_streams=1
bundle=no
ice_support=no
media_use_received_transport=no
trust_id_inbound=yes
user_eq_phone=no
send_connected_line=yes
media_encryption=no
timers=yes
timers_min_se=90
media_encryption_optimistic=no
refer_blind_progress=yes
refer_blind_progress=yes
rtp_timeout=30
rtp_timeout_hold=300
send_pai=yes
rtp_symmetric=yes
rewrite_contact=yes
force_rport=yes
language=en
one_touch_recording=on
record_on_feature=apprecord
record_off_feature=apprecord

Here is netstat result:

Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name    
tcp        0      0 0.0.0.0:22              0.0.0.0:*               LISTEN      1580/sshd: /usr/sbi 
tcp        0      0 0.0.0.0:2000            0.0.0.0:*               LISTEN      602417/asterisk     
tcp        0      0 0.0.0.0:5060            0.0.0.0:*               LISTEN      602417/asterisk     
tcp        0      0 127.0.0.53:53           0.0.0.0:*               LISTEN      559189/systemd-reso 
tcp6       0      0 :::22                   :::*                    LISTEN      1580/sshd: /usr/sbi 
udp        0      0 0.0.0.0:4520            0.0.0.0:*                           602417/asterisk     
udp        0      0 0.0.0.0:4569            0.0.0.0:*                           602417/asterisk     
udp        0      0 0.0.0.0:5000            0.0.0.0:*                           602417/asterisk     
udp        0      0 0.0.0.0:5060            0.0.0.0:*                           602417/asterisk     
udp        0      0 0.0.0.0:47546           0.0.0.0:*                           602417/asterisk     
udp        0      0 127.0.0.53:53           0.0.0.0:*                           559189/systemd-reso 
udp        0      0 192.168.1.9:68          0.0.0.0:*                           559173/systemd-netw 
udp        0      0 0.0.0.0:2727            0.0.0.0:*                           602417/asterisk     
udp6       0      0 :::37650                :::*                                602417/asterisk  

Please help me

The output shows it being received by chan_sip, not chan_pjsip. You would need to confirm what ports are being used and if they are correct. If not correct then adjust. They each need unique ports. If chan_sip isn’t needed then it can be disabled by doing a noload in modules.conf for it.