Howwise RSS
VoIP & Phone Systems6 min read

Asterisk No Matching Endpoint Found: Fix PJSIP Trunk Match

Short answer

Asterisk no matching endpoint found means an INVITE arrived but no PJSIP identifier (ip, username, anonymous) matched it. Add a type=identify section with the carrier's source IPs, or set identify_by, then verify with pjsip show identifies.

Key takeaways
  • The log line means identification failed, not authentication: the INVITE reached Asterisk but no endpoint was selected.
  • The default endpoint_identifier_order is ip,username,anonymous, and an IP match must use the packet's source address, not the Contact or From host.
  • A registering trunk does not authorize inbound INVITEs; it still needs an identify section or a matching username.
  • Verify with pjsip show identifies and pjsip set logger on before placing a test call.
  • Never fix this with an anonymous endpoint that routes into a live context, because that invites toll fraud.

What does "No matching endpoint found" actually mean?

The asterisk no matching endpoint found message is logged when an incoming SIP request arrives and none of the configured identifiers can map it to a PJSIP endpoint. The packet reached Asterisk, so the network path works. What failed is the lookup that decides which endpoint, and therefore which context and auth rules, apply.

Typical log forms are:

res_pjsip/pjsip_distributor.c: Request 'INVITE' from '<sip:5551234@203.0.113.10>' failed for '203.0.113.10:5060' (callid: abc123) - No matching endpoint found

NOTICE: Request from '"x" <sip:x@203.0.113.10>' failed for '203.0.113.10:5060' - No matching endpoint found

How does PJSIP map an incoming INVITE to an endpoint?

The order is set by endpoint_identifier_order in the [global] section of pjsip.conf. The default is ip,username,anonymous. Each name corresponds to a module that does the matching.

The first identifier that returns an endpoint wins. If none does, the request is challenged with 401 (or rejected), because there is no endpoint whose auth can be checked.

IdentifierModuleMatches onConfig
ipres_pjsip_endpoint_identifier_ipPacket source IP (or SRV/hostname resolved), plus header matchestype=identify
usernameres_pjsip_endpoint_identifier_userUser part of From header equal to endpoint name (and auth_username if enabled)identify_by on the endpoint
auth_usernameres_pjsip_endpoint_identifier_userUsername in the Authorization headeridentify_by=auth_username
anonymousres_pjsip_endpoint_identifier_anonymousEndpoint literally named anonymous[anonymous] type=endpoint
[global]
type=global
endpoint_identifier_order=ip,username,anonymous

Is it an identification problem, a credential problem, or a firewall block?

Treat these as three separate failures. Chasing passwords when the endpoint was never matched wastes hours.

If the INVITE never shows in pjsip set logger output at all, the problem is upstream: firewall, wrong port, wrong transport or routing. If it shows but the log says no matching endpoint, it is identification. If the endpoint is named in the log (for example 'Failed to authenticate' or 'Endpoint trunk: ... challenge'), it was matched and you are in credential territory.

Symptom in logCauseFix
INVITE visible, 'No matching endpoint found'No identify, username or anonymous matchAdd type=identify or identify_by
401 sent, then 'No matching endpoint' again with the same IPCarrier is IP-auth only and never answers the challengeAdd identify with the carrier IP
Endpoint named, 'Failed to authenticate'Wrong password or auth_usernameFix auth section
403 Forbidden after matchACL (acl/contact_acl), or endpoint matched but no valid context or allow listCheck pjsip show endpoint for acl and context
No INVITE in logger at allFirewall, wrong port, wrong transport or no transport boundCheck iptables, transport, sngrep or tcpdump
Match works for some calls onlyCarrier uses several source IPsList all IPs or CIDRs in match
Tip: Challenging an IP-authenticated carrier with 401 is a sign of misidentification: carriers that authenticate by IP will not reply with credentials, so the call just dies.

How do I write a working PJSIP identify section for an IP-authenticated trunk?

Match the source IP of the packets, not the host in the Contact or From header. Carriers often put a domain or a private address in headers while the packets come from an SBC pool. Get the real addresses from the carrier's portal or from a capture, for example: tcpdump -ni any port 5060 -c 50.

A complete example for a trunk without registration:

[carrier]
type=endpoint
transport=transport-udp
context=from-trunk
disallow=all
allow=ulaw,alaw
aors=carrier
outbound_auth=carrier-auth
direct_media=no
rtp_symmetric=yes
force_rport=yes
rewrite_contact=yes
dtmf_mode=rfc4733

[carrier]
type=aor
contact=sip:203.0.113.10:5060

[carrier-auth]
type=auth
auth_type=userpass
username=myuser
password=secret

[carrier]
type=identify
endpoint=carrier
match=203.0.113.10
match=198.51.100.0/24
match=sbc.carrier.example
Warning: A hostname in match is resolved when the config loads, so it may capture only some of the A records and goes stale when DNS changes. Prefer explicit IPs or CIDRs from the carrier.

Why does a registering trunk still fail inbound?

Outbound registration only tells the carrier where to send calls. It does not authorize inbound INVITEs from the carrier's IPs. Inbound requests are still run through the identifiers, so you need an identify section or a username match.

The username match fails when the carrier puts the dialed DID or another value in the From user, because the From user must equal the endpoint name. Use identify_by on the endpoint:

[carrier]
type=endpoint
identify_by=username,auth_username,ip
; or, if the carrier answers the challenge with its registered user:
; identify_by=auth_username
Tip: If the carrier shares IPs across customers or sends from changing addresses, match on a header instead: in the identify section use match_header=To: <sip:5551234@.*> or match_header=P-Called-Party-ID: .*. Header matching is available from Asterisk 13 onward, requires the identify type=identify with endpoint set, and takes a regex-style value on a single header per section, so it is only as unique as the header content.

How do I fix it in FreePBX and verify the match?

In FreePBX, do not edit generated files such as pjsip.endpoint.conf or pjsip.identify.conf. Set the carrier's IPs in the trunk's pjsip Settings > Match (Inbound) field (comma-separated IPs or CIDRs), or place custom sections in pjsip.identify_custom.conf. Then apply with fwconsole reload (or pjsip reload from the CLI for a quick check).

  1. Run pjsip show identifies and confirm your section lists the endpoint and every match address. Empty output means the section did not load.
  2. Run pjsip show endpoint carrier and confirm the context, transport, and allow list.
  3. Run pjsip set logger on, which is the supported way to enable PJSIP SIP message logging, and place a call. Read the INVITE's source IP, From, To and Request-URI.
  4. Run core set verbose 5 and watch for the channel being created in the expected context.
  5. Run dialplan show from-trunk to confirm that the context and DID pattern exist.
asterisk -rx "pjsip show identifies"
asterisk -rx "pjsip show endpoint carrier"
asterisk -rx "pjsip set logger on"
asterisk -rx "core set verbose 5"
sngrep port 5060

What other causes should I rule out, and how do I stay secure?

If the identify exists but calls still fail, check the carrier's actual source: failover or SBC pool IPs that differ from the documented ones, NAT or a proxy rewriting the source, the wrong transport (UDP vs TCP vs TLS) or port, or a typo in the endpoint name in the identify section. A different local port can also mean the transport is not bound where the carrier is sending.

Do not fix this by creating an anonymous endpoint that routes into a live context or by enabling allow_unauthenticated_calls. Open anonymous access invites toll fraud within hours of exposure.

Restrict the match to carrier IPs and keep any anonymous endpoint out of dialing contexts. At the firewall, explicitly allow every legitimate SIP source: each carrier, your internal phone subnet, and replies to Asterisk's own outbound requests.

# Allow replies to requests Asterisk sent itself (REGISTER, OPTIONS, outbound INVITEs)
iptables -A INPUT -m conntrack --ctstate ESTABLISHED,RELATED -j ACCEPT
# Carrier signaling
iptables -A INPUT -p udp -s 203.0.113.10 --dport 5060 -j ACCEPT
iptables -A INPUT -p udp -s 198.51.100.0/24 --dport 5060 -j ACCEPT
# Internal SIP phones (adjust to your LAN)
iptables -A INPUT -p udp -s 192.168.1.0/24 --dport 5060 -j ACCEPT
# Add an ACCEPT line for every other SIP provider or registrar you use
Warning: Do not finish this list with a blanket 'iptables -A INPUT -p udp --dport 5060 -j DROP'. It would also block internal SIP phones, other SIP providers, and the registrar's replies to Asterisk's outbound REGISTER requests when they are not covered by an earlier rule, which breaks registrations and calls that were working. Only add a default-deny after every legitimate source is listed and tested, keep console or out-of-band access in case you lock yourself out over SSH, and always allow RTP (default 10000-20000/udp) from the carrier.

Common questions

Why does pjsip show identifies return nothing?

No type=identify section loaded, usually because of a syntax error, a missing endpoint= value, or the config was not reloaded. Run pjsip reload and check the Asterisk log for parse errors. In FreePBX, confirm the Match (Inbound) field is saved and fwconsole reload was run.

Can I match multiple carrier IP addresses or a CIDR range?

Yes. Repeat match= lines or use a comma-separated list, and CIDR notation such as 198.51.100.0/24 is supported. Include every signaling IP the carrier lists, including failover ones.

Does match use the Contact or From header IP?

No. The IP identifier compares the packet's source address, so a private IP in Contact or a domain in From is irrelevant. Use match_header if you must identify by header content.

Why do I get 401 Unauthorized on an inbound INVITE from my carrier?

The call was not matched to an endpoint, so Asterisk challenges it as unknown. IP-authenticated carriers do not respond to the challenge, so the call fails; add an identify section for their IPs.

Do I need identify_by if I already have an identify section?

Not for IP matching, since the ip identifier is first in the default order. identify_by on the endpoint is for username-based matching, or to restrict which methods can identify that endpoint.

Related topics:asteriskpjsipsip trunkfreepbx