No matching endpoint found for incoming call

Hello everyone,
I’m migrating to a Asterisk 16 on a different machine and using PJSIP instead of SIP. I have a problem when configuring the line on the VoIP gateways. I managed to create their extensions in the pjsip.conf, but on an incoming call, Asterisk says:

[May  2 15:26:35] NOTICE[100172]: res_pjsip/pjsip_distributor.c:676 log_failed_request: Request 'INVITE' from '<sip:33578974XX@172.16.1.222>' failed for '172.16.1.222:5060' (callid: 35e7c625e8645442) - No matching endpoint found
[May  2 15:26:35] NOTICE[100172]: res_pjsip/pjsip_distributor.c:676 log_failed_request: Request 'INVITE' from '<sip:33578974XX@172.16.1.222>' failed for '172.16.1.222:5060' (callid: 35e7c625e8645442) - No matching endpoint found
[May  2 15:26:35] NOTICE[100172]: res_pjsip/pjsip_distributor.c:676 log_failed_request: Request 'INVITE' from '<sip:33578974XX@172.16.1.222>' failed for '172.16.1.222:5060' (callid: 35e7c625e8645442) - Failed to authenticate

Here is my pjsip.conf file:

[transport-udp-nat]
type = transport
protocol = udp
bind = 0.0.0.0
;external_media_address = 188.218.155.110
;external_signaling_address = 188.218.155.110
;local_net = 172.16.0.0/255.255.0.0
;local_net = 192.168.255.0/255.255.255.0

;================================ TISCALI TRUNK =====

[tiscali-trunk]
type = registration
retry_interval = 20
max_retries = 10
contact_user = 003901158494XX
expiration = 120
client_uri = sip:003901158494XX@ims.tiscali.net
server_uri = sip:ims.tiscali.net
transport = transport-udp-nat
outbound_auth = tiscali-trunk-auth

[tiscali-trunk-auth]
type = auth
username = 0115849XXX
password = 2017111532XXX

[tiscali-endpoint]
type = endpoint
context = incoming
dtmf_mode = rfc4733
disallow = all
allow = alaw, ulaw
rtp_symmetric = yes
force_rport = yes
rewrite_contact = yes
rtp_timeout = 20
outbound_proxy = 94.32.130.112
direct_media = yes
trust_id_inbound = yes
from_user = 00390115849XXX
from_domain = ims.tiscali.net
language = it
allow_subscribe = yes
;auth = tiscali-trunk-auth
outbound_auth = tiscali-auth
aors = tiscali-aor

[tiscali-auth]
type = auth
password = 201711153XXXX
username = 0039011584XXXX

[tiscali-aor]
type = aor
contact = sip:00390115849XXX@ims.tiscali.net:5061
default_expiration = 180

[tiscali-identify]
type = identify
endpoint = tiscali-endpoint
match = ims.tiscali.net

;================================ MESSAGENET TRUNK ==

[messagenet-trunk]
type = registration
server_uri = sip:sip.messagenet.it:5061
client_uri = sip:5406371XXX@sip.messagenet.it:5061
;outbound_proxy = sip:192.168.1.6\;lr
retry_interval = 20
max_retries = 10
expiration = 120
contact_user = 01119115XXX
line = yes
endpoint = messagenet-endpoint
transport = transport-udp-nat
outbound_auth = messagenet-trunk-auth

[messagenet-trunk-auth]
type = auth
username = 5406371XXX
password = hKASXXXX
realm = sip.messagenet.it

[messagenet-endpoint]
type=endpoint
context = incoming
disallow = all
allow = alaw, ulaw
direct_media = no
rtp_symmetric = yes
force_rport = yes
from_user = 5406371XXX
from_domain = sip.messagenet.it
outbound_auth = messagenet-auth
aors = messagenet-aor
;outbound_proxy = sip:192.168.1.6\;lr

[messagenet-auth]
type = auth
username = 5406371XXX
password = hKASXXXXX
realm = sip.messagenet.it

[messagenet-aor]
type = aor
contact = sip:5406371XXX@sip.messagenet.it:5061
;outbound_proxy = sip:192.168.1.6\;lr
qualify_frequency = 60

[messagenet-identify]
type=identify
endpoint = messagenet-endpoint
match = sip.messagenet.it

;================================ ENDPOINT TEMPLATES ==
; Our primary endpoint template for internal desk phones.

[endpoint-internal](!)
type = endpoint
context = int
;subscribecontext = incoming
;host = dynamic
disallow = all
allow = !all,g722,ulaw,alaw
direct_media = no
trust_id_outbound = yes
device_state_busy_at = 1
rtp_symmetric = yes
force_rport = yes
rewrite_contact = yes
rtp_timeout = 20
language = it
allow_subscribe = yes
dtmf_mode = rfc4733

[auth-userpass](!)
type = auth
auth_type = userpass

[aor-single-reg](!)
type = aor
max_contacts = 1

[endpoint-10x]
type = endpoint
context = incoming
dtmf_mode = rfc4733
disallow = all
allow = alaw
allow = ulaw
rtp_symmetric = yes
force_rport = yes
rewrite_contact = yes
rtp_timeout = 20
direct_media = no
language = it
allow_subscribe = yes

;================================ ENDPOINT DEFINITIONS ==

[200](endpoint-internal)
auth = auth200
aors = 200
callerid = <200>

[auth200](auth-userpass)
password = sip200
username = 200

[200](aor-single-reg)
mailboxes = 200@example

;========================================================

[201](endpoint-internal)
auth = auth201
aors = 201
callerid = <201>

[auth201](auth-userpass)
password = sip201
username = 201

[201](aor-single-reg)
mailboxes = 201@example

;========================================================

[202](endpoint-internal)
auth = auth202
aors = 202
callerid = <202>

[auth202](auth-userpass)
password = sip202
username = 202

[202](aor-single-reg)
mailboxes = 202@example

;========================================================

[203](endpoint-internal)
auth = auth203
aors = 203
callerid = <203>

[auth203](auth-userpass)
password = sip203
username = 203

[203](aor-single-reg)
mailboxes = 203@example


;========================================================

[204](endpoint-internal)
auth = auth204
aors = 204
callerid = <204>

[auth204](auth-userpass)
password = sip204
username = 204

[204](aor-single-reg)
mailboxes = 204@example

;========================================================

[205](endpoint-internal)
auth = auth205
aors = 205
callerid = <205>

[auth205](auth-userpass)
password = sip205
username = 205

[205](aor-single-reg)
mailboxes = 205@example

;========================================================

[206](endpoint-internal)
auth = auth206
aors = 206
callerid = <206>

[auth206](auth-userpass)
password = sip206
username = 206

[206](aor-single-reg)
mailboxes = 206@example

;========================================================

[207](endpoint-internal)
auth = auth207
aors = 207
callerid = <207>

[auth207](auth-userpass)
password = sip207
username = 207

[207](aor-single-reg)
mailboxes = 207@example

;========================================================

[208](endpoint-internal)
auth = auth208
aors = 208
callerid = <208>

[auth208](auth-userpass)
password = sip208
username = 208

[208](aor-single-reg)
mailboxes = 208@example

;========================================================

[209](endpoint-internal)
auth = auth209
aors = 209
callerid = <209>

[auth209](auth-userpass)
password = sip209
username = 209

[209](aor-single-reg)
mailboxes = 209@example

;========================================================

[210](endpoint-internal)
auth = auth210
aors = 210
callerid = <210>

[auth210](auth-userpass)
password = sip210
username = 210

[210](aor-single-reg)
mailboxes = 210@example

;=================================================== FAX ==

[801]
type = aor
max_contacts = 1
default_expiration = 180

[801]
type = auth
username = 801
password = 801

[801]
type = endpoint
context = fax
dtmf_mode = rfc4733
disallow = all
allow = alaw
allow = ulaw
rtp_symmetric = yes
force_rport = yes
rewrite_contact = yes
rtp_timeout = 20
language = it
allow_subscribe = yes
auth = 801
outbound_auth = 801
aors = 801

;========================================================

[10001](endpoint-10x)
auth = 10001
outbound_auth = 10001
aors = 10001

[10001]
type = aor
max_contacts = 1
default_expiration = 180

[10001]
type = auth
username = 10001
password = 10001

;========================================================

[10002](endpoint-10x)
auth = 10002
outbound_auth = 10002
aors = 10002

[10002]
type = aor
max_contacts = 1
default_expiration = 180

[10002]
type = auth
username = 10002
password = 10002

;========================================================

[10003](endpoint-10x)
auth = 10003
outbound_auth = 10003
aors = 10003

[10003]
type = aor
max_contacts = 1
default_expiration = 180

[10003]
type = auth
username = 10003
password = 10003

;========================================================

[10004](endpoint-10x)
auth = 10004
outbound_auth = 10004
aors = 10004

[10004]
type = aor
max_contacts = 1
default_expiration = 180

[10004]
type = auth
username = 10004
password = 10004

;========================================================

[10005](endpoint-10x)
auth = 10005
outbound_auth = 10005
aors = 10005

[10005]
type = aor
max_contacts = 1
default_expiration = 180

[10005]
type = auth
username = 10005
password = 10005

;========================================================

[10008](endpoint-10x)
auth = 10008
outbound_auth = 10008
aors = 10008

[10008]
type = aor
max_contacts = 1
default_expiration = 180

[10008]
type = auth
username = 10008
password = 10008

;========================================================

Do you have a SIP trace of a failed call?

How are you expecting calls from it to match an endpoint? It doesn’t look like you can match based on username since I think that’s callerid in it, so you’d need to match based on IP address which is not configured I believe.

pjsip.conf doesn’t contain extension, only endpoints.

There are no A or SRV records associated with this domain name, so there are no addresses to match.

172.16.1.222 is a local use IP address, so it is not possible to reverse resolve it to work out to whom it belongs.

@jcolp @david551
I’m sorry, I’ll try to explain more the situation. Tiscali and Messagenet are VoIP providers, configured correctly (even though Tiscali does not work for a problem on their end they’re now solving). I can receive the calls from the Messagenet trunk just fine.
Now I’m trying to configure the other line we have, which is converted to VoIP by 2 VoIP gateways (Patton). I converted the old working sip.conf to the new pjsip.conf I included, both manually and then with the use of the built-in script, but the line carried by the patton is not working as intended now. Reading jcolp’s answer, this might be because I would need to include a [identify] section for this provider, which was not into the sip.conf. But since the VoIP packets are coming from the Pattons, should I match based on the Pattons IP? What would be a basic example of configurations?
I thought of adding to pjsip.conf something like:

[patton 4120]
type=identify
endpoint= (???)
match=172.16.1.235

[patton 4114]
type=identify
endpoint= (???)
match=172.16.1.222

Is this correct? What should I put to “endpoint”, then? Do I really need to create an endpoint for the pattons aswell ?

Every call uses an endpoint and one is required. It depends on the configuration to use.

Thanks, I understand what you’re trying to tell me. What I’m not getting is how can I specify what endpoint to use when a call is received on the line converted to VoIP by the Patton gateways.
This is the SIP configuration of one Patton:

immagine_2022-05-02_171218447

In my old sip.conf I had these extensions:

[10004]
type=peer
context=vodafone
host=dynamic
secret=10004
insecure=port,invite
canreinvite=no
disallow=all
allow=alaw
allow=ulaw
allowexternaldomains=yes
allowguest=yes
qualify=yes

[10005]
type=peer
context=vodafone
host=dynamic
secret=10005
insecure=port,invite
canreinvite=no
disallow=all
allow=alaw
allow=ulaw
allowexternaldomains=yes
allowguest=yes
qualify=yes

And similar endpoints were configured for the other Patton; everything worked fine.

Now in the new machine, trying to migrate this to pjsip.conf, I did this:

[endpoint-10x]
type = endpoint
dtmf_mode = rfc4733
disallow = all
allow = alaw
allow = ulaw
rtp_symmetric = yes
force_rport = yes
rewrite_contact = yes
rtp_timeout = 20
direct_media = no
language = it
allow_subscribe = yes


[10004](endpoint-10x)
auth = 10004
outbound_auth = 10004
aors = 10004
context=vodafone

[10004]
type = aor
max_contacts = 1
default_expiration = 180

[10004]
type = auth
username = 10004
password = 10004

;========================================================

[10005](endpoint-10x)
auth = 10005
outbound_auth = 10005
aors = 10005
context=vodafone

[10005]
type = aor
max_contacts = 1
default_expiration = 180

[10005]
type = auth
username = 10005
password = 10005

Didn’t I migrate sip.conf correctly?

Probably, but I can’t see what you are trying to do.

Sorry, I don’t understand what you didn’t understand :stuck_out_tongue:

What aren’t you getting? I’ll try to explain myself better.

Your numbers in your log do not seem to match the numbers in your configuration. One can guess what could be what, or it could be because your numbers simply do not match. You could post a complete SIP trace, i.e. with pjsip set logger on.

There are multiple errors in your chan_sip configuration, so the translator may well have been confused, but if you also have allowguest=yes in the general section, where it is actually valid, you may be handling the Pattons as anonymous callers.

The endpoints in your identify sections should be 10004 and 10005.

I guess the Pattons are only using From user as their ID in the register and then using the caller ID, and that is why the default user/password match wasn’t matching.

Are the Pattons actually registering - you might have got away without that with allowguest in general. I can’t see any options to register in your screenshot. If they don’t have to register, and you know their addresses, it is better not to use dynamic hosts.

Thanks @david551 ,
I can post the pjsip.conf that is the result of the translation and the pjsip.conf that I made up from scratch. I did not have the occasion to test the translated one, I only used to correct some things in the one I created myself.

PJSIP_translated.conf :

;--
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
Non mapped elements start
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

[general]
port = 5060

[base]
limitonpeers = yes

[0115849478]
port = 5061

[messagenet]
auth = md5

[10001]
insecure = port,invite

[10002]
insecure = port,invite

[10003]
insecure = port,invite

[10004]
insecure = port,invite

[10005]
insecure = port,invite

[10008]
insecure = port,invite

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
Non mapped elements end
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
--;


[transport-udp]
type = transport
protocol = udp
bind = 0.0.0.0
external_media_address = 188.218.155.110
external_signaling_address = 188.218.155.110
local_net = 172.16.0.0/255.255.0.0
local_net = 192.168.255.0/255.255.255.0

[reg_sip.messagenet.it]
type = registration
retry_interval = 20
max_retries = 10
contact_user = 01119115XXX
expiration = 120
transport = transport-udp
outbound_auth = auth_reg_sip.messagenet.it
client_uri = sip:5406371XXX@sip.messagenet.it:5061
server_uri = sip:sip.messagenet.it:5061

[auth_reg_sip.messagenet.it]
type = auth
password = hKASXuM4
username = 5406371555

[reg_ims.tiscali.net]
type = registration
retry_interval = 20
max_retries = 10
contact_user = 00390115849XXX
expiration = 120
transport = transport-udp
outbound_auth = auth_reg_ims.tiscali.net
client_uri = sip:00390115849XXX@ims.tiscali.net
server_uri = sip:ims.tiscali.net

[auth_reg_ims.tiscali.net]
type = auth
password = 2017111532XXX
username = 00390115849XXX

[0115849XXX]   ; this is Tiscali.
type = aor
contact = sip:00390115849478@ims.tiscali.net:5061
default_expiration = 180

[0115849XXX]
type = identify
endpoint = 0115849XXX
match = ims.tiscali.net

[0115849XXX]
type = auth
username = 0115849XXX
password = 2017111532XXX

[0115849XXX]
type = endpoint
context = incoming
dtmf_mode = rfc4733
disallow = all
allow = alaw
allow = ulaw
rtp_symmetric = yes
force_rport = yes
rewrite_contact = yes
rtp_timeout = 20
outbound_proxy = 94.32.130.112
direct_media = yes
trust_id_inbound = yes
from_user = 00390115849XXX
from_domain = ims.tiscali.net
language = it
allow_subscribe = yes
auth = 0115849XXX
outbound_auth = 0115849XXX
aors = 0115849XXX

[messagenet]
type = aor
contact = sip:5406371555@sip.messagenet.it:5061
default_expiration = 180

[messagenet]
type = identify
endpoint = messagenet
match = sip.messagenet.it

[messagenet]
type = auth
username = messagenet
password = hKASXuM4

[messagenet]
type = endpoint
context = voipin
dtmf_mode = rfc4733
disallow = all
allow = alaw
allow = ulaw
rtp_symmetric = yes
force_rport = yes
rewrite_contact = yes
rtp_timeout = 20
from_user = 5406371XXX
language = it
allow_subscribe = yes
auth = messagenet
outbound_auth = messagenet
aors = messagenet

[200]
type = aor
max_contacts = 1
default_expiration = 180

[200]
type = auth
username = 200
password = M4c0mXXX

[200]
type = endpoint
context = int
dtmf_mode = rfc4733
disallow = all
allow = alaw
allow = ulaw
rtp_symmetric = yes
force_rport = yes
rewrite_contact = yes
rtp_timeout = 20
language = it
allow_subscribe = yes
auth = 200
outbound_auth = 200
aors = 200

[201]
type = aor
max_contacts = 1
default_expiration = 180

[201]
type = auth
username = 201
password = 201

[201]
type = endpoint
context = int
dtmf_mode = rfc4733
disallow = all
allow = alaw
allow = ulaw
rtp_symmetric = yes
force_rport = yes
rewrite_contact = yes
rtp_timeout = 20
language = it
allow_subscribe = yes
auth = 201
outbound_auth = 201
aors = 201

[202]
type = aor
max_contacts = 1
default_expiration = 180

[202]
type = auth
username = 202
password = 202

[202]
type = endpoint
context = int
dtmf_mode = rfc4733
disallow = all
allow = alaw
allow = ulaw
rtp_symmetric = yes
force_rport = yes
rewrite_contact = yes
rtp_timeout = 20
language = it
allow_subscribe = yes
auth = 202
outbound_auth = 202
aors = 202

[203]
type = aor
max_contacts = 1
default_expiration = 180

[203]
type = auth
username = 203
password = 203

[203]
type = endpoint
context = int
dtmf_mode = rfc4733
disallow = all
allow = alaw
allow = ulaw
rtp_symmetric = yes
force_rport = yes
rewrite_contact = yes
rtp_timeout = 20
language = it
allow_subscribe = yes
auth = 203
outbound_auth = 203
aors = 203

[204]
type = aor
max_contacts = 1
default_expiration = 180

[204]
type = auth
username = 204
password = 204

[204]
type = endpoint
context = int
dtmf_mode = rfc4733
disallow = all
allow = alaw
allow = ulaw
rtp_symmetric = yes
force_rport = yes
rewrite_contact = yes
rtp_timeout = 20
language = it
allow_subscribe = yes
auth = 204
outbound_auth = 204
aors = 204

[205]
type = aor
max_contacts = 1
default_expiration = 180

[205]
type = auth
username = 205
password = 205

[205]
type = endpoint
context = int
dtmf_mode = rfc4733
disallow = all
allow = alaw
allow = ulaw
rtp_symmetric = yes
force_rport = yes
rewrite_contact = yes
rtp_timeout = 20
language = it
allow_subscribe = yes
auth = 205
outbound_auth = 205
aors = 205

[206]
type = aor
max_contacts = 1
default_expiration = 180

[206]
type = auth
username = 206
password = 206

[206]
type = endpoint
context = int
dtmf_mode = rfc4733
disallow = all
allow = alaw
allow = ulaw
rtp_symmetric = yes
force_rport = yes
rewrite_contact = yes
rtp_timeout = 20
language = it
allow_subscribe = yes
auth = 206
outbound_auth = 206
aors = 206

[207]
type = aor
max_contacts = 1
default_expiration = 180

[207]
type = auth
username = 207
password = 207

[207]
type = endpoint
context = int
dtmf_mode = rfc4733
disallow = all
allow = alaw
allow = ulaw
rtp_symmetric = yes
force_rport = yes
rewrite_contact = yes
rtp_timeout = 20
language = it
allow_subscribe = yes
auth = 207
outbound_auth = 207
aors = 207

[208]
type = aor
max_contacts = 1
default_expiration = 180

[208]
type = auth
username = 208
password = 208

[208]
type = endpoint
context = int
dtmf_mode = rfc4733
disallow = all
allow = alaw
allow = ulaw
rtp_symmetric = yes
force_rport = yes
rewrite_contact = yes
rtp_timeout = 20
language = it
allow_subscribe = yes
auth = 208
outbound_auth = 208
aors = 208

[209]
type = aor
max_contacts = 1
default_expiration = 180

[209]
type = auth
username = 209
password = 209

[209]
type = endpoint
context = int
dtmf_mode = rfc4733
disallow = all
allow = alaw
allow = ulaw
rtp_symmetric = yes
force_rport = yes
rewrite_contact = yes
rtp_timeout = 20
language = it
allow_subscribe = yes
auth = 209
outbound_auth = 209
aors = 209

[210]
type = aor
max_contacts = 1
default_expiration = 180

[210]
type = auth
username = 210
password = 210

[210]
type = endpoint
context = int
dtmf_mode = rfc4733
disallow = all
allow = alaw
allow = ulaw
rtp_symmetric = yes
force_rport = yes
rewrite_contact = yes
rtp_timeout = 20
language = it
allow_subscribe = yes
auth = 210
outbound_auth = 210
aors = 210

[801]
type = aor
max_contacts = 1
default_expiration = 180

[801]
type = auth
username = 801
password = 801

[801]
type = endpoint
context = fax
dtmf_mode = rfc4733
disallow = all
allow = alaw
allow = ulaw
rtp_symmetric = yes
force_rport = yes
rewrite_contact = yes
rtp_timeout = 20
language = it
allow_subscribe = yes
auth = 801
outbound_auth = 801
aors = 801

[10001]
type = aor
max_contacts = 1
default_expiration = 180

[10001]
type = auth
username = 10001
password = 10001

[10001]
type = endpoint
context = incoming
dtmf_mode = rfc4733
disallow = all
allow = alaw
allow = ulaw
rtp_symmetric = yes
force_rport = yes
rewrite_contact = yes
rtp_timeout = 20
direct_media = no
language = it
allow_subscribe = yes
auth = 10001
outbound_auth = 10001
aors = 10001

[10002]
type = aor
max_contacts = 1
default_expiration = 180

[10002]
type = auth
username = 10002
password = 10002

[10002]
type = endpoint
context = incoming
dtmf_mode = rfc4733
disallow = all
allow = alaw
allow = ulaw
rtp_symmetric = yes
force_rport = yes
rewrite_contact = yes
rtp_timeout = 20
direct_media = no
language = it
allow_subscribe = yes
auth = 10002
outbound_auth = 10002
aors = 10002

[10003]
type = aor
max_contacts = 1
default_expiration = 180

[10003]
type = auth
username = 10003
password = 10003

[10003]
type = endpoint
context = gsm
dtmf_mode = rfc4733
disallow = all
allow = alaw
allow = ulaw
rtp_symmetric = yes
force_rport = yes
rewrite_contact = yes
rtp_timeout = 20
direct_media = no
language = it
allow_subscribe = yes
auth = 10003
outbound_auth = 10003
aors = 10003

[10004]
type = aor
max_contacts = 1
default_expiration = 180

[10004]
type = auth
username = 10004
password = 10004

[10004]
type = endpoint
context = vodafone
dtmf_mode = rfc4733
disallow = all
allow = alaw
allow = ulaw
rtp_symmetric = yes
force_rport = yes
rewrite_contact = yes
rtp_timeout = 20
direct_media = no
language = it
allow_subscribe = yes
auth = 10004
outbound_auth = 10004
aors = 10004

[10005]
type = aor
max_contacts = 1
default_expiration = 180

[10005]
type = auth
username = 10005
password = 10005

[10005]
type = endpoint
context = vodafone
dtmf_mode = rfc4733
disallow = all
allow = alaw
allow = ulaw
rtp_symmetric = yes
force_rport = yes
rewrite_contact = yes
rtp_timeout = 20
direct_media = no
language = it
allow_subscribe = yes
auth = 10005
outbound_auth = 10005
aors = 10005

[10008]
type = aor
max_contacts = 1
default_expiration = 180

[10008]
type = auth
username = 10008
password = 10008

[10008]
type = endpoint
context = incoming
dtmf_mode = rfc4733
disallow = all
allow = alaw
allow = ulaw
rtp_symmetric = yes
force_rport = yes
rewrite_contact = yes
rtp_timeout = 20
direct_media = no
language = it
allow_subscribe = yes
auth = 10008
outbound_auth = 10008
aors = 10008

pjsip_from_scratch_in_use_right_now.conf :

[transport-udp-nat]
type = transport
protocol = udp
bind = 0.0.0.0
;external_media_address = 188.218.155.110
;external_signaling_address = 188.218.155.110
;local_net = 172.16.0.0/255.255.0.0
;local_net = 192.168.255.0/255.255.255.0

;================================ TISCALI TRUNK =====

[tiscali-trunk]
type = registration
retry_interval = 20
max_retries = 10
contact_user = 00390115849XXX
expiration = 120
client_uri = sip:00390115849XXX@ims.tiscali.net
server_uri = sip:ims.tiscali.net
transport = transport-udp-nat
outbound_auth = tiscali-trunk-auth

[tiscali-trunk-auth]
type = auth
username = 0115849XXX
password = 2017111532XXX

[tiscali-endpoint]
type = endpoint
context = incoming
dtmf_mode = rfc4733
disallow = all
allow = alaw, ulaw
rtp_symmetric = yes
force_rport = yes
rewrite_contact = yes
rtp_timeout = 20
outbound_proxy = 94.32.130.112
direct_media = yes
trust_id_inbound = yes
from_user = 00390115849XXX
from_domain = ims.tiscali.net
language = it
allow_subscribe = yes
;auth = tiscali-trunk-auth
outbound_auth = tiscali-auth
aors = tiscali-aor

[tiscali-auth]
type = auth
password = 201711153XXXX
username = 0039011584XXXX

[tiscali-aor]
type = aor
contact = sip:0039011584XXXX@ims.tiscali.net:5061
default_expiration = 180

[tiscali-identify]
type = identify
endpoint = tiscali-endpoint
match = ims.tiscali.net

;================================ MESSAGENET TRUNK ==

[messagenet-trunk]
type = registration
server_uri = sip:sip.messagenet.it:5061
client_uri = sip:540637XXXX@sip.messagenet.it:5061
;outbound_proxy = sip:192.168.1.6\;lr
retry_interval = 20
max_retries = 10
expiration = 120
contact_user = 0111911XXXX
line = yes
endpoint = messagenet-endpoint
transport = transport-udp-nat
outbound_auth = messagenet-trunk-auth

[messagenet-trunk-auth]
type = auth
username = 54063XXXXX
password = hKAXXXXX
realm = sip.messagenet.it

[messagenet-endpoint]
type=endpoint
context = incoming
disallow = all
allow = alaw, ulaw
direct_media = no
rtp_symmetric = yes
force_rport = yes
from_user = 540637XXXX
from_domain = sip.messagenet.it
outbound_auth = messagenet-auth
aors = messagenet-aor
;outbound_proxy = sip:192.168.1.6\;lr

[messagenet-auth]
type = auth
username = 54063XXXXX
password = hKAXXXXX
realm = sip.messagenet.it

[messagenet-aor]
type = aor
contact = sip:540637XXXX@sip.messagenet.it:5061
;outbound_proxy = sip:192.168.1.6\;lr
qualify_frequency = 60

[messagenet-identify]
type=identify
endpoint = messagenet-endpoint
match = sip.messagenet.it

;================================ ENDPOINT TEMPLATES ==
; Our primary endpoint template for internal desk phones.

[endpoint-internal](!)
type = endpoint
context = int
;subscribecontext = incoming
;host = dynamic
disallow = all
allow = !all,g722,ulaw,alaw
direct_media = no
trust_id_outbound = yes
device_state_busy_at = 1
rtp_symmetric = yes
force_rport = yes
rewrite_contact = yes
rtp_timeout = 20
language = it
allow_subscribe = yes
dtmf_mode = rfc4733

[auth-userpass](!)
type = auth
auth_type = userpass

[aor-single-reg](!)
type = aor
max_contacts = 1

[endpoint-10x]
type = endpoint
context = incoming
dtmf_mode = rfc4733
disallow = all
allow = alaw
allow = ulaw
rtp_symmetric = yes
force_rport = yes
rewrite_contact = yes
rtp_timeout = 20
direct_media = no
language = it
allow_subscribe = yes

;================================ ENDPOINT DEFINITIONS ==

[200](endpoint-internal)
auth = auth200
aors = 200
callerid = <200>

[auth200](auth-userpass)
password = sip200
username = 200

[200](aor-single-reg)
mailboxes = 200@example

;========================================================

[201](endpoint-internal)
auth = auth201
aors = 201
callerid = <201>

[auth201](auth-userpass)
password = sip201
username = 201

[201](aor-single-reg)
mailboxes = 201@example

;========================================================

[202](endpoint-internal)
auth = auth202
aors = 202
callerid = <202>

[auth202](auth-userpass)
password = sip202
username = 202

[202](aor-single-reg)
mailboxes = 202@example

;========================================================

[203](endpoint-internal)
auth = auth203
aors = 203
callerid = <203>

[auth203](auth-userpass)
password = sip203
username = 203

[203](aor-single-reg)
mailboxes = 203@example


;========================================================

[204](endpoint-internal)
auth = auth204
aors = 204
callerid = <204>

[auth204](auth-userpass)
password = sip204
username = 204

[204](aor-single-reg)
mailboxes = 204@example

;========================================================

[205](endpoint-internal)
auth = auth205
aors = 205
callerid = <205>

[auth205](auth-userpass)
password = sip205
username = 205

[205](aor-single-reg)
mailboxes = 205@example

;========================================================

[206](endpoint-internal)
auth = auth206
aors = 206
callerid = <206>

[auth206](auth-userpass)
password = sip206
username = 206

[206](aor-single-reg)
mailboxes = 206@example

;========================================================

[207](endpoint-internal)
auth = auth207
aors = 207
callerid = <207>

[auth207](auth-userpass)
password = sip207
username = 207

[207](aor-single-reg)
mailboxes = 207@example

;========================================================

[208](endpoint-internal)
auth = auth208
aors = 208
callerid = <208>

[auth208](auth-userpass)
password = sip208
username = 208

[208](aor-single-reg)
mailboxes = 208@example

;========================================================

[209](endpoint-internal)
auth = auth209
aors = 209
callerid = <209>

[auth209](auth-userpass)
password = sip209
username = 209

[209](aor-single-reg)
mailboxes = 209@example

;========================================================

[210](endpoint-internal)
auth = auth210
aors = 210
callerid = <210>

[auth210](auth-userpass)
password = sip210
username = 210

[210](aor-single-reg)
mailboxes = 210@example

;=================================================== FAX ==

[801]
type = aor
max_contacts = 1
default_expiration = 180

[801]
type = auth
username = 801
password = 801

[801]
type = endpoint
context = fax
dtmf_mode = rfc4733
disallow = all
allow = alaw
allow = ulaw
rtp_symmetric = yes
force_rport = yes
rewrite_contact = yes
rtp_timeout = 20
language = it
allow_subscribe = yes
auth = 801
outbound_auth = 801
aors = 801

;========================================================

[10001](endpoint-10x)
auth = 10001
outbound_auth = 10001
aors = 10001

[10001]
type = aor
max_contacts = 1
default_expiration = 180

[10001]
type = auth
username = 10001
password = 10001

;========================================================

[10002](endpoint-10x)
auth = 10002
outbound_auth = 10002
aors = 10002

[10002]
type = aor
max_contacts = 1
default_expiration = 180

[10002]
type = auth
username = 10002
password = 10002

;========================================================

[10003](endpoint-10x)
auth = 10003
outbound_auth = 10003
aors = 10003

[10003]
type = aor
max_contacts = 1
default_expiration = 180

[10003]
type = auth
username = 10003
password = 10003

;========================================================

[10004](endpoint-10x)
auth = 10004
outbound_auth = 10004
aors = 10004

[10004]
type = aor
max_contacts = 1
default_expiration = 180

[10004]
type = auth
username = 10004
password = 10004

;========================================================

[10005](endpoint-10x)
auth = 10005
outbound_auth = 10005
aors = 10005

[10005]
type = aor
max_contacts = 1
default_expiration = 180

[10005]
type = auth
username = 10005
password = 10005

;========================================================

[10008](endpoint-10x)
auth = 10008
outbound_auth = 10008
aors = 10008

[10008]
type = aor
max_contacts = 1
default_expiration = 180

[10008]
type = auth
username = 10008
password = 10008

;========================================================

Regarding the Patton’s situation on the old and functioning PBX, running the command “sip show peers” shows that they’re actually registered. I would expect the same behaviour when migrating to the new PBX with PJSIP (can’t make another try right now as we need our lines up and running for a bit).
immagine_2022-05-03_144136407

The chan_sip configuration was broken, as you have insecure=port, but the only thing that distinguished 10004 and 10005 is the port! Chances are that they were both being treated as the first matching peer, for incoming calls.

This means any IP match needs to include the port in chan_pjsip.

There is a subtle difference between how the two drivers handle registrations. chan_sip automatically creates the equivalent of identify/match for the IP and port from the registration, so type=peer will work after registration. chan_pjsip does not, so if something registers, it expects it have a from user that matches the account name. If the Pattons actually put the caller ID there, that will cause problems. Looking at your original errors, it is providing 33578974XX, which isn’t 100004 or 100005, so I assume it is sending the caller ID.

Whilst you can match by IP and have registration, that is normally pointless, as the point of registration is to tell you the IP and port, when you only know the address of record URI.

chan_pjsip has various matching options, but the simplest is probably to try and configure everything for IP matching and forget registration. You can still authenticate. Registration isn’t intended as an authentication mechanism.

As I said before, a match on ims.tiscali.net is not going to work as there are no IP addresses associated with that domain. The match for them needs to be on the addresses, or address ranges, from which they actually originate calls.

Hello @david551 ,
That was a helpful comment. I understand now the difference you mentioned between PJSIP and SIP in terms of matching. Since I’m using PJSIP and I know the IP of the pattons, I decided to match by IP; the problem is that each patton registers with 2 endpoints on the PBX, and like you said the only thing that differentiates 10004 and 10005 is the port, but I don’t know how to get it.

I’ve now made a modification in the pjsip.conf file, in oder to do IP matching:

; (1000x endpoint definitions start)

[endpoint-10x]
dtmf_mode = rfc4733
disallow = all
allow = alaw
allow = ulaw
rtp_symmetric = yes
force_rport = yes
rewrite_contact = yes
rtp_timeout = 20
direct_media = no
language = it
allow_subscribe = yes


[10001](endpoint-10x)
auth = 10001
outbound_auth = 10001
aors = 10001
context = incoming

[10001]
type = aor
max_contacts = 1
default_expiration = 180

[10001]
type = auth
username = 10001
password = 10001

[10001]
type = identify
endpoint = 10001
match = 172.16.1.235  ; IP Patton01

;========================================================

[10002](endpoint-10x)
auth = 10002
outbound_auth = 10002
aors = 10002
context = incoming

[10002]
type = aor
max_contacts = 1
default_expiration = 180

[10002]
type = auth
username = 10002
password = 10002

[10002]
type = identify
endpoint = 10002
match = 172.16.1.235  ; IP Patton01

;========================================================

[10003](endpoint-10x)
auth = 10003
outbound_auth = 10003
aors = 10003
context = gsm

[10003]
type = aor
max_contacts = 1
default_expiration = 180

[10003]
type = auth
username = 10003
password = 10003

[10003]
type = identify
endpoint = 10003
;match = ip_patton  , no patton for this endpoint.

;========================================================

[10004](endpoint-10x)
auth = 10004
outbound_auth = 10004
aors = 10004
context = vodafone

[10004]
type = aor
max_contacts = 1
default_expiration = 180

[10004]
type = auth
username = 10004
password = 10004

[10004]
type = identify
endpoint = 10004
match = 172.16.1.222  ; IP Patton02

;========================================================

[10005](endpoint-10x)
auth = 10005
outbound_auth = 10005
aors = 10005
context = vodafone

[10005]
type = aor
max_contacts = 1
default_expiration = 180

[10005]
type = auth
username = 10005
password = 10005

[10005]
type = identify
endpoint = 10005
match = 172.16.1.222  ; IP Patton02

Now, running a test, I get these errors:

[May  5 14:04:44] WARNING[4156]: res_pjsip_endpoint_identifier_ip.c:290 common_identify: Identify '10004' points to endpoint '10004' but endpoint could not be found
[May  5 14:04:44] NOTICE[4156]: res_pjsip/pjsip_distributor.c:676 log_failed_request: Request 'INVITE' from '<sip:33578974XX@172.16.1.222>' failed for '172.16.1.222:5060' (callid: c8e384e2ef3989ea) - No matching endpoint found

How is Asterisk not finding the endpoint? This is the output of the 'pjsip show ’ command:

 Endpoint:  200/200                                              Unavailable   0 of 1
     InAuth:  auth200/200
        Aor:  200                                                1

 Endpoint:  201/201                                              Not in use    0 of 1
     InAuth:  auth201/201
        Aor:  201                                                1
      Contact:  201/sip:201@172.16.0.96:5060;registering_a 19336d013c NonQual         nan

 Endpoint:  202/202                                              Unavailable   0 of 1
     InAuth:  auth202/202
        Aor:  202                                                1

 Endpoint:  203/203                                              Unavailable   0 of 1
     InAuth:  auth203/203
        Aor:  203                                                1

 Endpoint:  204/204                                              Unavailable   0 of 1
     InAuth:  auth204/204
        Aor:  204                                                1

 Endpoint:  205/205                                              Unavailable   0 of 1
     InAuth:  auth205/205
        Aor:  205                                                1

 Endpoint:  206/206                                              Unavailable   0 of 1
     InAuth:  auth206/206
        Aor:  206                                                1

 Endpoint:  207/207                                              Unavailable   0 of 1
     InAuth:  auth207/207
        Aor:  207                                                1

 Endpoint:  208/208                                              Unavailable   0 of 1
     InAuth:  auth208/208
        Aor:  208                                                1

 Endpoint:  209/209                                              Unavailable   0 of 1
     InAuth:  auth209/209
        Aor:  209                                                1

 Endpoint:  210/210                                              Unavailable   0 of 1
     InAuth:  auth210/210
        Aor:  210                                                1

 Endpoint:  801                                                  Unavailable   0 of inf
    OutAuth:  801/801
     InAuth:  801/801
        Aor:  801                                                1

 Endpoint:  messagenet-endpoint                                  Unavailable   0 of inf
    OutAuth:  messagenet-auth/5406371555
        Aor:  messagenet-aor                                     0
      Contact:  messagenet-aor/sip:5406371555@sip.messagen 84de84a03f Unavail         nan
   Identify:  messagenet-identify/messagenet-endpoint
        Match: 212.97.59.76/32

 Endpoint:  tiscali-endpoint                                     Not in use    0 of inf
    OutAuth:  tiscali-auth/00390115849478
        Aor:  tiscali-aor                                        0
      Contact:  tiscali-aor/sip:00390115849478@ims.tiscali 9a230d56aa NonQual         nan
   Identify:  tiscali-identify/tiscali-endpoint
        Match: 94.32.130.112/32

As you can see, I can’t see the 1000x endpoints listed…

you need to indicate that it is a template

[endpoint-10x](!)

You’re absolutely right, I just noticed it a minute before reading your comment! :sweat_smile:
Yes, I made the change and reloaded the cfg, but I’m still getting this in the CLI when testing:

[May  5 14:25:37] WARNING[4156]: res_pjsip_endpoint_identifier_ip.c:290 common_identify: Identify '10004' points to endpoint '10004' but endpoint could not be found
[May  5 14:25:37] NOTICE[4156]: res_pjsip/pjsip_distributor.c:676 log_failed_request: Request 'INVITE' from '<sip:33578974XX@172.16.1.222>' failed for '172.16.1.222:5060' (callid: 96cd2b2c7256c250) - No matching endpoint found
[May  5 14:25:37] NOTICE[4156]: res_pjsip/pjsip_distributor.c:676 log_failed_request: Request 'INVITE' from '<sip:33578974XX@172.16.1.222>' failed for '172.16.1.222:5060' (callid: 96cd2b2c7256c250) - Failed to authenticate
[May  5 14:25:37] WARNING[4156]: res_pjsip_endpoint_identifier_ip.c:290 common_identify: Identify '10004' points to endpoint '10004' but endpoint could not be found

And there still isn’t any of the 1000x endpoints in the output of “pjsip show endpoints”.

That’s not the problem, and I can’t actually see the problem.

The ! stops the section from going directly into the configuration, but you can use any section as a template.

To be more specific, this is a piece of the SIP configuration of one SIP identity of one of the pattons (Patton02), which authenticates to the PBX through the identitities 10004 and 10005:

Literally all I’m changing from the entire patton’s cfg is the remote IP of the machine, the PBX using chan_sip has IP .232 , while the new PBX I’m migrating to implements res_pjsip and it has IP .233 . Port is not explicitly specified for any SIP identity of any of the pattons…

I’d suggest setting an explicit local port number, that you can then use in the match and contact lines. (You could also do it with a remote port number and two transports in Asterisk.)