AOR error while using Asterisk with Kamailio

Hello,

I have a following configuration of my environment - Asterisk 13.7.0 with PJSIP 2.4.5 stack working together with Kamailio 4.3.4

What I trying to achieve is to be able to connect my endpoints through Kamailio with performing authorization only on Asterisk (so to make Kamailio pass through all the REGISTER packets). As for now I was able to correctly (as I assume) configure Kamailio, but on Asterisk I’m getting the following error:

WARNING[1485]: res_pjsip_registrar.c:678 registrar_on_rx_request: AOR '102' not found for endpoint 'kamailio'

My configuration looks as follows

[kamailio]
type=endpoint
transport=transport-udp
context=testing
aors=kamailio
[kamailio]
type=identify
endpoint=kamailio
match=128.142.196.184
[kamailio-mars]
type=aor
contact=sip:128.142.196.184:5060

[102]
type=endpoint
context=testing
disallow=all
allow=ulaw
transport=transport-udp
auth=auth102
aors=102
[auth102]
type=auth
auth_type=userpass
password=102
username=102
[102]
type=aor
max_contacts=1

And the REGISTER packet received by Asterisk is

REGISTER sip:128.142.194.41:5060 SIP/2.0
Via: SIP/2.0/UDP 128.142.196.184;branch=z9hG4bKde8f.43c0cb32000000000000000000000000.0
To: <sip:102@128.142.194.41>
From: <sip:102@128.142.194.41>;tag=533cb9e91f4b999cf76861cbb9ed54ed-180c
CSeq: 10 REGISTER
Call-ID: 6fa94a272a247611-8719@127.0.0.1
Max-Forwards: 70
Content-Length: 0
User-Agent: kamailio (4.3.4 (x86_64/linux))
Contact: <sip:102@128.142.196.184:5060>
Expires: 300

where 128.142.194.41 is Asterisk and 128.142.196.184 is Kamailio. From what I see, the real IP of the client does appear in the communication Asterisk-Kamailio.

AOR names in PJSIP have meaning, just like in normal SIP. A REGISTER is a message requesting a Contact to be added to a specific named AOR. In the above case it’s telling you “I want to add a contact to AOR 102”. Since you’ve got it matching the “kamailio” endpoint it only has access to the “kamailio” AOR. It therefore fails as there is no AOR “102” accessible to it. You would need to have the 102 endpoint matched, or give the kamailio endpoint access.

Well, from my understanding I can’t have endpoint 102 matched as the transmission is proxied (or can I)? In my environments endpoints don’t have a connectivity with Asterisk (iptables), only Kamailio is allowed. From the other side, is it possible to just slightly change my config to allow Kamailio access to every existing AOR?

PJSIP currently has two applicable modules for matching - Either by source IP address or using the user portion of the From header. If the User portion were that of the user, then it would match that specific endpoint and not a catch-all like when matching using IP address.

There’s no way to do a wildcard for the aors, you’d have to list each explicitly separating them using “,”