Inbound call matching based on IP address AND user

There is Asterisk 20.4.0 with PJSIP 2.13.1 worked on Ubuntu 22.04 x64.
It is necessary to allow only single IP which hard/soft phone can be used for connection with appropriate PBX extension from:

I read that Asterisk with PJSIP now suports endpoint (extension) based ACLs.

I added deny/permit to necessary endpoints:

type = endpoint
deny =
permit =

type = endpoint
deny =
permit =

type = endpoint
deny =
permit =

And such IPs are not at global ACL section.

But softphone can not connect to:

[Apr 14 17:58:00] NOTICE[88846]: acl.c:784 ast_apply_acl_internal: SIP ACL: Rejecting '' due to a failure to pass ACL '(BASELINE)'
[Apr 14 17:58:00] WARNING[88846]: res_pjsip_acl.c:134 apply_acl: Incoming SIP message from did not pass ACL test

Also I tried to set such ACLs at acl.conf:

deny =
permit =

and put it to endpoint:

type = endpoint
acl = marketing_acl

But there is no success.

If such IPs is to put to global ACL section all works.
But global ACL can content of several IPs.
But I need single and exact (different) allowed IP for each necessary extension.

What is wrong or what is necessary to set up instead or additionally ?

Just asking out of interest, because I was struggling with something similar some weeks ago. And I am still not sure how I got it working.

Do you notice a difference if you use

permit =


Just tried.
No changes - no success.
Can you post part of your configuration ?

What Asterisk and PJSIP do you use ?

If you have a /32 address, you don’t need ACLs. Use identify_by=ip in the enpoint sectin and use contact, rather than max_contacts, in the type=aor section. Use a type=identify section with the IP.

It’s great to identify by ip, but i have trunk where several extensions connects to using the same IP and I need to use match_header.
But there is no user_id and ip at one header and I need either multiple match - by ip and header or restrict ip and match by header.

Anyway I need also user/pass, that is userpass AND ip.

Here is links:

This link I cannot open.

 * Endpoint IP Access Controls
   Added new configuration Endpoint options:
    "acl" - list of IP ACL section names in acl.conf
    "deny" - List of IP addresses to deny access from
    "permit" - List of IP addresses to permit access from
    "contact_acl" - List of Contact ACL section names in acl.conf
    "contact_deny" - List of Contact header addresses to deny
    "contact_permit" - List of Contact header addresses to permit

Anyway I don’ t understand why it doesn’ t work.

These are different, and you can have both.

I don’t know which link you cannot open. Both work for me, although the second one is not the definitive repository for Asterisk. The definitive link for the second would be:

If you are trying to use the ACL to resolve an ambiguity in other idnetifiers, I suspect that the ACL is only applied after the final selection has been made, so will reject the call, rather than looking for an alternative match that is consistent with the ACL.

Why ?

I need that either local client (hard or soft) or some remote trunk could place an incoming call to the PBX using appropriate extension only with authentication by user/pass AND ip.

But some extensions can be used wih the trubk with the same ip and port

So, what is the best way ?

I just tried on my asterisk 18.15.1 (PJPROJECT 2.12.1)


And it works as it should. But I can remember some weeks ago also getting this “due to a failure to pass ACL ‘(BASELINE)’” message and I was not sure why. I was a bit in a hurry and got it working then somehow after some conf editing and restarts. I then thought that it was maybe a typo in the first place.

Did you provide endpoint configuration part ?

I showed you my deny/permit lines of the endpoint configuration. I don’t think that any other part of my configuration is relevant here.

I asked because I tried the same but failed.
I upgraded to 20.6.0.
But nothing changed.
May be some global parameter is important.

I could get working endpoint based ACL but if there is no global ACL at all or there is no deny = and contact_deny =

Do you have global ACL section ?

There is Asterisk 20.6.0 with PJSIP 2.13.1 worked on Ubuntu 22.04 x64.

There are some trunks.
Some of them have the same IP and port but diffrent usernames/passwords.

I need that incoming (inbound)calls from such trunks to Asterisk could be received by Asterisk only after IP, port AND username matching.
For example, if a call comes from trunk with IP as anonymous or with username ‘trunk2’ Asterisk will not receive such call. but if a call comes from trunk with the same IP but with different username ‘abc22’ such call will be accepted and handled by Asterisk further…

What is the best and most right way to authorize these trunks with the same IP and port using IP AND username ?

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.