No matching endpoint found | Kamailio + Kubernetes + Asterisk

Hello everyone,

I’m facing an issue and I’m not sure where the problem lies.
I have a Kamailio server running on IP 192.168.1.75, acting as a media proxy. It redirects traffic to a machine at IP 192.168.1.190, which hosts a Kubernetes environment. Inside this Kubernetes cluster, Asterisk is running.
My pjsip.conf:

[telnyx]
type=aor
contact=sip:sip.telnyx.com:5060
max_contacts=10
; Address of Record for Telnyx endpoint

[telnyx]
type=endpoint
transport=transport-udp-nat
context=telnyx
disallow=all
allow=g722
allow=ulaw
allow=alaw
direct_media=no
aors=telnyx
outbound_auth=telnyx
; Configures the endpoint for incoming/outgoing calls and media handling

[telnyx]
type=identify
endpoint=telnyx
match=sip.telnyx.com
match=sip.telnyx.eu
; Maps incoming requests from Telnyx to the configured endpoint

And my SIP Invite looks like this:

2025/05/13 15:19:12.020596 192.76.120.10:5060 -> 192.168.1.75:5060
INVITE sip:+35122xx00xxx@192.168.1.75:5060 SIP/2.0
Record-Route: <sip:192.76.120.10;r2=on;lr;ftag=a2ajDUc15ZmNQ>
Record-Route: <sip:10.255.0.1;r2=on;lr;ftag=a2ajDUc15ZmNQ>
Via: SIP/2.0/UDP 192.76.120.10;branch=z9hG4bK8ee5.375d79ec169166dd9b6cac67f62f1075.0
v:SIP/2.0/UDP 10.239.90.224:6000;received=10.239.90.224;rport=6000;branch=z9hG4bKDUSy2ct78ctQH
Max-Forwards:48
f:"+351928024051"<sip:+3519xxxxxxxx@sip.telnyx.com>;tag=a2ajDUc15ZmNQ
t:<sip:+35122xx00xxx@192.168.1.75:5060>
i:50474890-fc7f-4e69-9e34-bca46e330d92
CSeq:99020983 INVITE
m:<sip:mod_sofia@10.239.90.224:6000>
Allow:INVITE,ACK,BYE,CANCEL,OPTIONS,MESSAGE,INFO,UPDATE,REFER,NOTIFY
k:timer,path
u:talk,hold,conference,refer
Privacy:none
c:application/sdp
Content-Disposition:session
l:205
P-Asserted-Identity:"+3519xxxxxxxx"<sip:+3519xxxxxxxx@sip.telnyx.eu;verstat=No-TN-Validation>

v=0
o=Telnyx 1747132273 1747132274 IN IP4 50.114.149.20
s=Telnyx
c=IN IP4 50.114.149.20
t=0 0
m=audio 17278 RTP/AVP 9
a=rtpmap:9 G722/8000
a=sendrecv
a=rtcp:17279 IN IP4 50.114.149.20
a=ptime:20

And I’m getting this error:

res_pjsip/pjsip_distributor.c:673 log_failed_request: Request ‘INVITE’ from ‘“+3519xxxxxxxx” sip:+3519xxxxxxxx@sip.telnyx.com’ failed for ‘10.244.9.0:37438’ (callid: 739d18ad-5327-40e4-bf4f-e9a55ce160e8) - No matching endpoint found

Not consistent with

in your log extract.

What does the first address represent?

The first ip is Kubernetes internal network.
The second one is a telnyx ip.

This instructs Asterisk to match incoming SIP traffic based on source IP addresses resolved from those hostnames. If there is a match, then use the “telnyx” endpoint.

That’s not what is happening though. The actual source IP address is:

Therefore it does not match, does not use the “telnyx” endpoint, and says no matching endpoint.

You have to decide on how incoming traffic should be matched - if based on a source IP address, then the identify needs to be changed accordingly.

Thank you Jcolp, do you think maybe match_header can be used as a solution to filter telnyx in invite message, for example in “From” and point to the endpoint?

It works on arbitrary headers, so theoretically yes. I don’t have a configuration for you though for it.

Something like this should work right? Dosn’t matter what I try it’s not working

match_header=From: <sip:.*@sip.telnyx.com>

[Solved]
In kamailio I check if the source is telnyx with this code and if true I add a custom header

route[DETECT_TELNYX] {
    if (is_present_hf("From")) {
        # Check if From header contains telnyx.com or telnyx.eu domains
        if ($fU =~ ".*@sip\.telnyx\.(com|eu).*" || $fd =~ ".*telnyx\.(com|eu).*") {
            xlog("L_INFO", "Detected Telnyx traffic from $fU@$fd\n");

            # Set Telnyx flag
            setflag(FLAG_TELNYX_CALL);

            # Add custom header for Asterisk to match on
            append_hf("X-Telnyx-Source: kamailio\r\n");
            append_hf("X-Original-From-Domain: $fd\r\n");

        }
    }
}

and in asterisk I use this to match with telnyx endpoint

[telnyx]
type=identify
endpoint=telnyx
match_header=X-Telnyx-Source: kamailio