<html>
<head>
<base href="https://wiki.asterisk.org/wiki">
<link rel="stylesheet" href="/wiki/s/en/2172/18/9/_/styles/combined.css?spaceKey=AST&forWysiwyg=true" type="text/css">
</head>
<body style="background: white;" bgcolor="white" class="email-body">
<div id="pageContent">
<div id="notificationFormat">
<div class="wiki-content">
<div class="email">
<h2><a href="https://wiki.asterisk.org/wiki/display/AST/Named+ACLs">Named ACLs</a></h2>
<h4>Page <b>edited</b> by <a href="https://wiki.asterisk.org/wiki/display/~mjordan">Matt Jordan</a>
</h4>
<br/>
<h4>Changes (2)</h4>
<div id="page-diffs">
<table class="diff" cellpadding="0" cellspacing="0">
<tr><td class="diff-snipped" >...<br></td></tr>
<tr><td class="diff-unchanged" > <br>|| Option || Value || Description || <br></td></tr>
<tr><td class="diff-changed-lines" >| deny | IP address <span class="diff-changed-words"><span class="diff-added-chars"style="background-color: #dfd;">\</span>[/Mask<span class="diff-added-chars"style="background-color: #dfd;">\</span>]</span> || An IP address to deny, with an optional subnet mask to apply | <br></td></tr>
<tr><td class="diff-changed-lines" >| permit | IP address <span class="diff-changed-words"><span class="diff-added-chars"style="background-color: #dfd;">\</span>[/Mask<span class="diff-added-chars"style="background-color: #dfd;">\</span>]</span> || An IP address to allow, with an optional subnet mask to apply | <br></td></tr>
<tr><td class="diff-unchanged" > <br>h4. Examples <br></td></tr>
<tr><td class="diff-snipped" >...<br></td></tr>
</table>
</div> <h4>Full Content</h4>
<div class="notificationGreySide">
<h2><a name="NamedACLs-Overview"></a>Overview</h2>
<p>Named ACLs introduce a new way to define Access Control Lists (ACLs) in Asterisk. Unlike traditional ACLs defined in specific module configuration files, Named ACLs can be shared across multiple modules. Named ACLs can also be accessed via the Asterisk Realtime Architecture (ARA), allowing for run-time updates of ACL information that can be retrieved by multiple consumers of ACL information.</p>
<h2><a name="NamedACLs-Configuration"></a>Configuration</h2>
<h3><a name="NamedACLs-StaticConfiguration"></a>Static Configuration</h3>
<p>Named ACLs can be defined statically in <em>acl.conf</em>. Each context in <em>acl.conf</em> defines a specific Named ACL, where the name of the context is the name of the ACL. The syntax for each context follows the permit/deny nomenclature used in traditional ACLs defined in a consumer module's configuration file. </p>
<div class='table-wrap'>
<table class='confluenceTable'><tbody>
<tr>
<th class='confluenceTh'> Option </th>
<th class='confluenceTh'> Value </th>
<th class='confluenceTh'> Description </th>
</tr>
<tr>
<td class='confluenceTd'> deny </td>
<td class='confluenceTd'> IP address [/Mask] </td>
<th class='confluenceTh'> An IP address to deny, with an optional subnet mask to apply </th>
</tr>
<tr>
<td class='confluenceTd'> permit </td>
<td class='confluenceTd'> IP address [/Mask] </td>
<th class='confluenceTh'> An IP address to allow, with an optional subnet mask to apply </th>
</tr>
</tbody></table>
</div>
<h4><a name="NamedACLs-Examples"></a>Examples</h4>
<div class="preformatted panel" style="border-width: 1px;"><div class="preformattedContent panelContent">
<pre>; within acl.conf
[name_of_acl1]
deny=0.0.0.0/0.0.0.0
permit=127.0.0.1
</pre>
</div></div>
<p>Multiple rules can be specified in an ACL as well by chaining deny/permit specifiers.</p>
<div class="preformatted panel" style="border-width: 1px;"><div class="preformattedContent panelContent">
<pre>[name_of_acl2]
deny=10.24.0.0/255.255.0.0
deny=10.25.0.0/255.255.0.0
permit=10.24.11.0/255.255.255.0
permit=10.24.12.0/255.255.255.0
</pre>
</div></div>
<p>Named ACLs support common modifiers like templates and additions within configuration as well.</p>
<div class="preformatted panel" style="border-width: 1px;"><div class="preformattedContent panelContent">
<pre>[template_deny_all](!)
deny=0.0.0.0/0.0.0.0
[deny_all_whitelist_these](template_deny_all)
permit=10.24.20.1
permit=10.24.20.2
permit=10.24.20.3
</pre>
</div></div>
<h3><a name="NamedACLs-ARAConfiguration"></a>ARA Configuration</h3>
<p>The ARA supports Named ACLs using the '<b>acls</b>' keyword in <em>extconfig.conf</em>.</p>
<div class="preformatted panel" style="border-width: 1px;"><div class="preformattedHeader panelHeader" style="border-bottom-width: 1px;"><b>Example Configuration</b></div><div class="preformattedContent panelContent">
<pre>;in extconfig.conf
acls => odbc,asterisk,acltable
</pre>
</div></div>
<h4><a name="NamedACLs-Schema"></a>Schema</h4>
<div class='table-wrap'>
<table class='confluenceTable'><tbody>
<tr>
<th class='confluenceTh'> Column Name </th>
<th class='confluenceTh'> Type </th>
<th class='confluenceTh'> Description </th>
</tr>
<tr>
<td class='confluenceTd'> name </td>
<td class='confluenceTd'> varchar(80) </td>
<td class='confluenceTd'> Name of the ACL </td>
</tr>
<tr>
<td class='confluenceTd'> rule_order </td>
<td class='confluenceTd'> integer </td>
<td class='confluenceTd'> Order to apply the ACL rule. Rules are applied in ascending order. Rule numbers do not have to be sequential </td>
</tr>
<tr>
<td class='confluenceTd'> sense </td>
<td class='confluenceTd'> varchar(6) </td>
<td class='confluenceTd'> Either 'permit' or 'deny' </td>
</tr>
<tr>
<td class='confluenceTd'> rule </td>
<td class='confluenceTd'> varchar(95) </td>
<td class='confluenceTd'> The IP address/Mask pair to apply </td>
</tr>
</tbody></table>
</div>
<h4><a name="NamedACLs-Examples"></a>Examples</h4>
<h5><a name="NamedACLs-TableCreationScript%28PostgreSQL%29"></a>Table Creation Script (PostgreSQL)</h5>
<div class="preformatted panel" style="border-width: 1px;"><div class="preformattedContent panelContent">
<pre>CREATE TABLE acltable
(
"name" character varying(80) NOT NULL,
rule_order integer NOT NULL,
sense character varying(6) NOT NULL,
"rule" character varying(95) NOT NULL,
CONSTRAINT aclrulekey PRIMARY KEY (name, rule_order, rule, sense)
)
WITH (
OIDS=FALSE
);
ALTER TABLE acltable OWNER TO asterisk;
GRANT ALL ON TABLE acltable TO asterisk;
)
</pre>
</div></div>
<h5><a name="NamedACLs-TableCreationScript%28SQLite3%29"></a>Table Creation Script (SQLite3)</h5>
<div class="preformatted panel" style="border-width: 1px;"><div class="preformattedContent panelContent">
<pre>BEGIN TRANSACTION;
CREATE TABLE acltable (rule TEXT, sense TEXT, rule_order NUMERIC, name TEXT);
COMMIT;
</pre>
</div></div>
<div class='panelMacro'><table class='noteMacro'><colgroup><col width='24'><col></colgroup><tr><td valign='top'><img src="/wiki/images/icons/emoticons/warning.gif" width="16" height="16" align="absmiddle" alt="" border="0"></td><td>These are just scripts generated by pgadmin III and SQLite Database Browser. They might not necessarily apply for your own setup.</td></tr></table></div>
<div class='panelMacro'><table class='noteMacro'><colgroup><col width='24'><col></colgroup><tr><td valign='top'><img src="/wiki/images/icons/emoticons/warning.gif" width="16" height="16" align="absmiddle" alt="" border="0"></td><td>Since ACLs are grabbed by consumers at configuration, a realtime ACL won't automatically be up to date in statically defined consumers unless a reload is issued against the consumer. Realtime consumers (such as SIP/IAX2 peers) will similarly be up to date if and only if they have built the peer in question since the changes to the realtime ACL have taken place.</td></tr></table></div>
<h2><a name="NamedACLs-NamedACLConsumers"></a>Named ACL Consumers</h2>
<p>Named ACLs are supported by the following Asterisk components:</p>
<ul>
        <li>Manager (IPv4 and IPv6)</li>
        <li>chan_sip (IPv4 and IPv6)</li>
        <li>chan_iax2 (IPv4 only)</li>
</ul>
<h3><a name="NamedACLs-Configuration"></a>Configuration</h3>
<p>A consumer of Named ACLs can be configured to use a named ACL using the <em>acl</em> option in their ACL access rules. This can be in addition to the ACL rules traditionally defined in those configuration files.</p>
<div class="preformatted panel" style="border-width: 1px;"><div class="preformattedHeader panelHeader" style="border-bottom-width: 1px;"><b>Example 1: referencing a Named ACL</b></div><div class="preformattedContent panelContent">
<pre>; within sip.conf
[peer1]
;stuff
;deny=0.0.0.0/0.0.0.0
;permit=127.0.0.1
acl=name_of_acl_1 ; an ACL included from acl.conf that matches peer1's commented out permits/denies
</pre>
</div></div>
<p>Multiple named ACLs can be referenced as well by specifying a comma delineated list of Named ACLs to apply.</p>
<div class="preformatted panel" style="border-width: 1px;"><div class="preformattedHeader panelHeader" style="border-bottom-width: 1px;"><b>Example 2: multiple Named ACL references</b></div><div class="preformattedContent panelContent">
<pre>; within sip.conf
[peer1]
;stuff
acl=named_acl_1,named_acl_2
</pre>
</div></div>
<p>Similarly, a SIP or IAX2 peer defined in ARA can include an '<em>acl</em>' column and list the Named ACLs to apply in that column.</p>
<div class='panelMacro'><table class='noteMacro'><colgroup><col width='24'><col></colgroup><tr><td valign='top'><img src="/wiki/images/icons/emoticons/warning.gif" width="16" height="16" align="absmiddle" alt="" border="0"></td><td><b>NOTE</b><br />Named ACLs can also be defined using multiple instances of the <em>acl</em> keyword. This is discouraged, however, as the order in which ACLs are applied can be less obvious then the comma delineated list format.
<div class="preformatted panel" style="border-width: 1px;"><div class="preformattedContent panelContent">
<pre>acl=named_acl_1
acl=named_acl_2
</pre>
</div></div></td></tr></table></div>
<h3><a name="NamedACLs-ACLRuleApplication"></a>ACL Rule Application</h3>
<p>Each module consumer of ACL information maintains, for each object that uses the information, a list of the defined ACL rule sets that apply to that object. When an address is evaluated for the particular object, the address is evaluated against each rule. For an address to pass the ACL rules, it must pass each ACL rule set that was defined for that object. Failure of any ACL rule set will result in a rejection of the address.</p>
<h2><a name="NamedACLs-ModuleReloads"></a>Module Reloads</h2>
<p>ACL information is static once a consumer module references that information. Hence, changes in ACL information in an ARA backend will not automatically update consumers of that information. In order for consumers to receive updated ACL information, the Named ACL component must be reloaded.</p>
<p>The Named ACL component supports module reloads, in the same way as other Asterisk components. When the Named ACL component is reloaded, it will issue a request to all consumers of Named ACLs. Those consumer modules will also be automatically reloaded.</p>
<div class='panelMacro'><table class='warningMacro'><colgroup><col width='24'><col></colgroup><tr><td valign='top'><img src="/wiki/images/icons/emoticons/forbidden.gif" width="16" height="16" align="absmiddle" alt="" border="0"></td><td><b>WARNING</b><br />This implies that reloading the Named ACL component will force a reload of manager, chan_sip, etc. Only reload the Named ACL component if you want all consumers of that information to be reloaded as well.</td></tr></table></div>
</div>
<div id="commentsSection" class="wiki-content pageSection">
<div style="float: right;" class="grey">
<a href="https://wiki.asterisk.org/wiki/users/removespacenotification.action?spaceKey=AST">Stop watching space</a>
<span style="padding: 0px 5px;">|</span>
<a href="https://wiki.asterisk.org/wiki/users/editmyemailsettings.action">Change email notification preferences</a>
</div>
<a href="https://wiki.asterisk.org/wiki/display/AST/Named+ACLs">View Online</a>
|
<a href="https://wiki.asterisk.org/wiki/pages/diffpagesbyversion.action?pageId=20189112&revisedVersion=4&originalVersion=3">View Changes</a>
|
<a href="https://wiki.asterisk.org/wiki/display/AST/Named+ACLs?showComments=true&showCommentArea=true#addcomment">Add Comment</a>
</div>
</div>
</div>
</div>
</div>
</body>
</html>