<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://wiki.alpinelinux.org/w/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Kunkku</id>
	<title>Alpine Linux - User contributions [en]</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.alpinelinux.org/w/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Kunkku"/>
	<link rel="alternate" type="text/html" href="https://wiki.alpinelinux.org/wiki/Special:Contributions/Kunkku"/>
	<updated>2026-04-30T13:58:17Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.40.0</generator>
	<entry>
		<id>https://wiki.alpinelinux.org/w/index.php?title=Setting_up_Homer&amp;diff=14234</id>
		<title>Setting up Homer</title>
		<link rel="alternate" type="text/html" href="https://wiki.alpinelinux.org/w/index.php?title=Setting_up_Homer&amp;diff=14234"/>
		<updated>2017-12-19T16:10:40Z</updated>

		<summary type="html">&lt;p&gt;Kunkku: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This page describes how to set up [http://sipcapture.org/ HOMER] on&lt;br /&gt;
Alpine Linux.&lt;br /&gt;
&lt;br /&gt;
The packages are available in the community repository starting from&lt;br /&gt;
Alpine Linux 3.6. Make sure that this repository is enabled in&lt;br /&gt;
&amp;lt;code&amp;gt;/etc/apk/repositories&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
== Primary Node ==&lt;br /&gt;
&lt;br /&gt;
Install the required packages, set up the database, and enable&lt;br /&gt;
required services:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;apk add homer-api-doc homer-ui mariadb kamailio-mysql nginx php7-fpm&lt;br /&gt;
&lt;br /&gt;
rc-service mariadb setup&lt;br /&gt;
rc-update add mariadb&lt;br /&gt;
rc-service mariadb start&lt;br /&gt;
mysql_secure_installation&lt;br /&gt;
&lt;br /&gt;
homer_db_init&lt;br /&gt;
rc-update add crond&lt;br /&gt;
rc-service crond start&lt;br /&gt;
&lt;br /&gt;
cp /usr/share/doc/homer-api/examples/sipcapture/sipcapture.kamailio /etc/kamailio/kamailio.cfg&lt;br /&gt;
echo rc_need=mariadb &amp;gt; /etc/conf.d/kamailio&lt;br /&gt;
rc-update add kamailio&lt;br /&gt;
rc-service kamailio start&lt;br /&gt;
&lt;br /&gt;
cp /usr/share/doc/homer-api/examples/web/homer5.php-fpm /etc/php7/php-fpm.d/homer5.conf&lt;br /&gt;
rc-update add php-fpm7&lt;br /&gt;
rc-service php-fpm7 start&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Override the default nginx configuration with the HOMER template:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;: &amp;gt; /etc/nginx/conf.d/default.conf&lt;br /&gt;
cp /usr/share/doc/homer-api/examples/web/homer5.nginx /etc/nginx/conf.d/homer5.conf&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Make the following changes in&lt;br /&gt;
&amp;lt;code&amp;gt;/etc/nginx/conf.d/homer5.conf&amp;lt;/code&amp;gt;:&lt;br /&gt;
&lt;br /&gt;
{|&lt;br /&gt;
|root&lt;br /&gt;
|&amp;lt;code&amp;gt;/usr/share/webapps/homer&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
|server_name&lt;br /&gt;
|your server&#039;s host name&lt;br /&gt;
|-&lt;br /&gt;
|fastcgi_pass&lt;br /&gt;
|&amp;lt;code&amp;gt;127.0.0.1:9001&amp;lt;/code&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
If you are going to deploy database nodes in addition to this primary&lt;br /&gt;
node, change &amp;lt;code&amp;gt;SINGLE_NODE&amp;lt;/code&amp;gt; to &amp;lt;code&amp;gt;0&amp;lt;/code&amp;gt; in&lt;br /&gt;
&amp;lt;code&amp;gt;/etc/homer/configuration.php&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
Set &amp;lt;code&amp;gt;HOMER_TIMEZONE&amp;lt;/code&amp;gt; in&lt;br /&gt;
&amp;lt;code&amp;gt;/etc/homer/preferences.php&amp;lt;/code&amp;gt; according to your time zone.&lt;br /&gt;
&lt;br /&gt;
Enable the &amp;lt;code&amp;gt;nginx&amp;lt;/code&amp;gt; service:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;rc-update add nginx&lt;br /&gt;
rc-service nginx start&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If using a firewall, you have to allow users to access the nginx&lt;br /&gt;
server using HTTP. In addition, reception of the captured SIP traffic&lt;br /&gt;
must be allowed on UDP port 9060.&lt;br /&gt;
&lt;br /&gt;
=== LDAP Authentication ===&lt;br /&gt;
&lt;br /&gt;
If you intend to authenticate the HOMER users using LDAP, install the&lt;br /&gt;
LDAP authentication module:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;apk add homer-api-ldap&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In addition, you have to allow connections to the LDAP server if using&lt;br /&gt;
a firewall.&lt;br /&gt;
&lt;br /&gt;
==== Changes in /etc/homer/preferences.php ====&lt;br /&gt;
&lt;br /&gt;
Enable LDAP authentication:&lt;br /&gt;
&amp;lt;pre&amp;gt;define(&#039;AUTHENTICATION&#039;,&amp;quot;LDAP&amp;quot;);&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Uncomment the LDAP section and add/update parameters according to your&lt;br /&gt;
server configuration:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;define(&#039;LDAP_HOST&#039;,&amp;quot;localhost&amp;quot;);&lt;br /&gt;
define(&#039;LDAP_PORT&#039;,389);&lt;br /&gt;
define(&#039;LDAP_VERSION&#039;,3);&lt;br /&gt;
define(&#039;LDAP_BIND_USER&#039;,&amp;quot;cn=HOMER,ou=Apps,dc=example,dc=com&amp;quot;);&lt;br /&gt;
define(&#039;LDAP_BIND_PASSWORD&#039;,&amp;quot;secret&amp;quot;);&lt;br /&gt;
define(&#039;LDAP_BASEDN&#039;,&amp;quot;ou=Users,dc=example,dc=com&amp;quot;);&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Add one of the following lines, depending on whether the STARTTLS&lt;br /&gt;
mechanism shall be used to protect the LDAP connection:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;define(&#039;LDAP_ENCRYPTION&#039;,&amp;quot;none&amp;quot;);&lt;br /&gt;
define(&#039;LDAP_ENCRYPTION&#039;,&amp;quot;tls&amp;quot;);&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If TLS is used, you have to make sure that the relevant root&lt;br /&gt;
certificate is trusted. If using a self-signed root certificate, one&lt;br /&gt;
way to achieve this is to add the &amp;lt;code&amp;gt;TLS_CACERT&amp;lt;/code&amp;gt; parameter to&lt;br /&gt;
&amp;lt;code&amp;gt;/etc/openldap/ldap.conf&amp;lt;/code&amp;gt;, specifying the path to the&lt;br /&gt;
trusted CA certificate.&lt;br /&gt;
&lt;br /&gt;
Specify the users who should have admin rights:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;define(&#039;LDAP_ADMIN_USERS&#039;,&amp;quot;donald,mike&amp;quot;);&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Remove the parameters starting with &amp;lt;code&amp;gt;LDAP_GROUP_&amp;lt;/code&amp;gt; unless&lt;br /&gt;
you want to authorize users based on group membership.&lt;br /&gt;
&lt;br /&gt;
==== Nested Groups with Active Directory ====&lt;br /&gt;
&lt;br /&gt;
The default settings in &amp;lt;code&amp;gt;/etc/homer/preferences.php&amp;lt;/code&amp;gt; are&lt;br /&gt;
intended for LDAP schemas conforming to&lt;br /&gt;
[https://tools.ietf.org/rfc/rfc2307.txt RFC 2307]. Otherwise, you may&lt;br /&gt;
have to modify the parameters starting with&lt;br /&gt;
&amp;lt;code&amp;gt;LDAP_USERNAME_ATTRIBUTE_&amp;lt;/code&amp;gt;. The following example&lt;br /&gt;
demonstrates how to authenticate and authorize users against Microsoft&lt;br /&gt;
Windows Active Directory based on nested group membership:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;define(&#039;LDAP_USERNAME_ATTRIBUTE_OPEN&#039;,&amp;quot;(&amp;amp;(samaccountname=&amp;quot;);&lt;br /&gt;
define(&#039;LDAP_USERNAME_ATTRIBUTE_CLOSE&#039;,&amp;quot;)(memberof:1.2.840.113556.1.4.1941:=cn=HOMER,ou=Groups,dc=example,dc=com))&amp;quot;);&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Database Nodes ==&lt;br /&gt;
&lt;br /&gt;
To make your HOMER system more scalable, you may want to deploy&lt;br /&gt;
multiple database nodes. This sections instructs how to set up an&lt;br /&gt;
additional database node.&lt;br /&gt;
&lt;br /&gt;
Install the required packages on the new database node and enable the&lt;br /&gt;
database service:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;apk add homer-api-doc homer-db mariadb kamailio-mysql&lt;br /&gt;
&lt;br /&gt;
rc-service mariadb setup&lt;br /&gt;
rc-update add mariadb&lt;br /&gt;
rc-service mariadb start&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Set up the database. You may want to disable remote root logins to the&lt;br /&gt;
database.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;mysql_secure_installation&lt;br /&gt;
homer_db_init -r&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You may want to change the default password for the HOMER database&lt;br /&gt;
user. This can be done as follows:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt; mysql -e &amp;quot;SET PASSWORD FOR &#039;homer_user&#039; = PASSWORD(&#039;&amp;lt;password&amp;gt;&#039;);&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Enable the &amp;lt;code&amp;gt;crond&amp;lt;/code&amp;gt; service:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;rc-update add crond&lt;br /&gt;
rc-service crond start&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Override the Kamailio configuration with the HOMER template:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;cp /usr/share/doc/homer-api/examples/sipcapture/sipcapture.kamailio /etc/kamailio/kamailio.cfg&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Change the &amp;lt;code&amp;gt;capture_node&amp;lt;/code&amp;gt; parameter in&lt;br /&gt;
&amp;lt;code&amp;gt;/etc/kamailio/kamailio.cfg&amp;lt;/code&amp;gt; to a unique value. If you&lt;br /&gt;
changed the database user password, update the&lt;br /&gt;
&amp;lt;code&amp;gt;HOMER_DB_PASSWORD&amp;lt;/code&amp;gt; parameter accordingly.&lt;br /&gt;
&lt;br /&gt;
Enable the &amp;lt;code&amp;gt;kamailio&amp;lt;/code&amp;gt; service:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;echo rc_need=mariadb &amp;gt; /etc/conf.d/kamailio&lt;br /&gt;
rc-update add kamailio&lt;br /&gt;
rc-service kamailio start&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If using a firewall, you have to allow the reception of captured SIP&lt;br /&gt;
packets on UDP port 9060. In addition, you have to allow the primary&lt;br /&gt;
node to access the local database.&lt;br /&gt;
&lt;br /&gt;
Finally, you have to add the database node to the primary server&lt;br /&gt;
configuration via the web user interface. Log in as an admin&lt;br /&gt;
user. Click on &#039;&#039;Panels&#039;&#039;, &#039;&#039;System Admin&#039;&#039;, and then&lt;br /&gt;
&#039;&#039;Add Node&#039;&#039;. Use the following values:&lt;br /&gt;
&lt;br /&gt;
{|&lt;br /&gt;
|Node&lt;br /&gt;
|Value of &amp;lt;code&amp;gt;capture_node&amp;lt;/code&amp;gt; in &amp;lt;code&amp;gt;/etc/kamailio/kamailio.cfg&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
|Host&lt;br /&gt;
|Host name or IP address of the database node&lt;br /&gt;
|-&lt;br /&gt;
|Port&lt;br /&gt;
|&amp;lt;code&amp;gt;3306&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
|DB Name&lt;br /&gt;
|&amp;lt;code&amp;gt;homer_data&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
|DB Username&lt;br /&gt;
|&amp;lt;code&amp;gt;homer_user&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
|DB Password&lt;br /&gt;
|Database password, which is &amp;lt;code&amp;gt;homer_password&amp;lt;/code&amp;gt; unless you changed it&lt;br /&gt;
|-&lt;br /&gt;
|DB Tables&lt;br /&gt;
|&amp;lt;code&amp;gt;sip_capture&amp;lt;/code&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Capture Nodes ==&lt;br /&gt;
&lt;br /&gt;
To capture packets on a SIP server, install the HOMER CaptAgent:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;apk add captagent&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Configure the &amp;lt;code&amp;gt;capture-host&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;capture-port&amp;lt;/code&amp;gt;&lt;br /&gt;
parameters in &amp;lt;code&amp;gt;/etc/captagent/transport_hep.xml&amp;lt;/code&amp;gt;. The&lt;br /&gt;
capture host is the primary or an additional database node. The port&lt;br /&gt;
should be set to &amp;lt;code&amp;gt;9060&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
Enable the service:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;rc-update add captagent&lt;br /&gt;
rc-service captagent start&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If using a firewall, you have to allow sending the captured SIP&lt;br /&gt;
packets to UDP port 9060 of the specified capture host.&lt;br /&gt;
&lt;br /&gt;
== Retention Period of Captured Packets ==&lt;br /&gt;
&lt;br /&gt;
A cron job takes care of removing obsolete data from the capture host&lt;br /&gt;
databases. The retention period can be adjusted by modifying&lt;br /&gt;
&amp;lt;code&amp;gt;/etc/homer/rotation.ini&amp;lt;/code&amp;gt;.&lt;/div&gt;</summary>
		<author><name>Kunkku</name></author>
	</entry>
	<entry>
		<id>https://wiki.alpinelinux.org/w/index.php?title=Setting_up_Homer&amp;diff=13864</id>
		<title>Setting up Homer</title>
		<link rel="alternate" type="text/html" href="https://wiki.alpinelinux.org/w/index.php?title=Setting_up_Homer&amp;diff=13864"/>
		<updated>2017-09-19T08:38:28Z</updated>

		<summary type="html">&lt;p&gt;Kunkku: LDAP authentication&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Draft}}&lt;br /&gt;
&lt;br /&gt;
Rough notes for setting up [http://sipcapture.org Homer] on Alpine Linux from testing repository&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;apk add homer-api-doc homer-ui mariadb kamailio-mysql nginx php7-fpm&lt;br /&gt;
&lt;br /&gt;
rc-service mariadb setup&lt;br /&gt;
rc-update add mariadb&lt;br /&gt;
rc-service mariadb start&lt;br /&gt;
mysql_secure_installation&lt;br /&gt;
&lt;br /&gt;
homer_db_init&lt;br /&gt;
rc-update add crond&lt;br /&gt;
rc-service crond start&lt;br /&gt;
&lt;br /&gt;
cp /usr/share/doc/homer-api/examples/sipcapture/sipcapture.kamailio /etc/kamailio/kamailio.cfg&lt;br /&gt;
echo rc_need=mariadb &amp;gt; /etc/conf.d/kamailio&lt;br /&gt;
rc-update add kamailio&lt;br /&gt;
rc-service kamailio start&lt;br /&gt;
&lt;br /&gt;
cp /usr/share/doc/homer-api/examples/web/homer5.php-fpm /etc/php7/php-fpm.d/homer5.conf&lt;br /&gt;
rc-update add php-fpm7&lt;br /&gt;
rc-service php-fpm7 start&lt;br /&gt;
&lt;br /&gt;
: &amp;gt; /etc/nginx/conf.d/default.conf&lt;br /&gt;
cp /usr/share/doc/homer-api/examples/web/homer5.nginx /etc/nginx/conf.d/homer5.conf&lt;br /&gt;
edit &amp;quot;root&amp;quot; in /etc/nginx/conf.d/homer5.conf to &amp;quot;/usr/share/webapps/homer&amp;quot;&lt;br /&gt;
edit &amp;quot;server_name&amp;quot; in /etc/nginx/conf.d/homer5.conf&lt;br /&gt;
edit &amp;quot;fastcgi_pass&amp;quot; in /etc/nginx/conf.d/homer5.conf to &amp;quot;127.0.0.1:9001&amp;quot;&lt;br /&gt;
edit &amp;quot;SINGLE_NODE&amp;quot; in /etc/homer/configuration.php to &amp;quot;0&amp;quot; if using DB nodes&lt;br /&gt;
edit &amp;quot;HOMER_TIMEZONE&amp;quot; in /etc/homer/preferences.php&lt;br /&gt;
rc-update add nginx&lt;br /&gt;
rc-service nginx start&lt;br /&gt;
&lt;br /&gt;
configure DB nodes in web UI, default password is &amp;quot;homer_password&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== LDAP Authentication ==&lt;br /&gt;
&lt;br /&gt;
Install LDAP authentication module:&lt;br /&gt;
&amp;lt;pre&amp;gt;apk add homer-api-ldap&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Changes in /etc/homer/preferences.php ===&lt;br /&gt;
&lt;br /&gt;
Enable LDAP authentication:&lt;br /&gt;
&amp;lt;pre&amp;gt;define(&#039;AUTHENTICATION&#039;,&amp;quot;LDAP&amp;quot;);&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Uncomment the LDAP section and add/update parameters according to your server&lt;br /&gt;
configuration:&lt;br /&gt;
&amp;lt;pre&amp;gt;define(&#039;LDAP_HOST&#039;,&amp;quot;localhost&amp;quot;);&lt;br /&gt;
define(&#039;LDAP_PORT&#039;,389);&lt;br /&gt;
define(&#039;LDAP_VERSION&#039;,3);&lt;br /&gt;
define(&#039;LDAP_BIND_USER&#039;,&amp;quot;cn=HOMER,ou=Apps,dc=example,dc=com&amp;quot;);&lt;br /&gt;
define(&#039;LDAP_BIND_PASSWORD&#039;,&amp;quot;secret&amp;quot;);&lt;br /&gt;
define(&#039;LDAP_BASEDN&#039;,&amp;quot;ou=Users,dc=example,dc=com&amp;quot;);&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Add one of the following lines:&lt;br /&gt;
&amp;lt;pre&amp;gt;define(&#039;LDAP_ENCRYPTION&#039;,&amp;quot;none&amp;quot;);&lt;br /&gt;
define(&#039;LDAP_ENCRYPTION&#039;,&amp;quot;tls&amp;quot;);&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Remove the variables starting with LDAP_GROUP_ unless you want to authorize&lt;br /&gt;
users based on group membership.&lt;br /&gt;
&lt;br /&gt;
== Database Nodes ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;apk add homer-api-doc homer-db mariadb kamailio-mysql&lt;br /&gt;
&lt;br /&gt;
rc-service mariadb setup&lt;br /&gt;
rc-update add mariadb&lt;br /&gt;
rc-service mariadb start&lt;br /&gt;
mysql_secure_installation&lt;br /&gt;
&lt;br /&gt;
homer_db_init -r&lt;br /&gt;
rc-update add crond&lt;br /&gt;
rc-service crond start&lt;br /&gt;
&lt;br /&gt;
cp /usr/share/doc/homer-api/examples/sipcapture/sipcapture.kamailio /etc/kamailio/kamailio.cfg&lt;br /&gt;
edit &amp;quot;capture_node&amp;quot; in /etc/kamailio/kamailio.cfg&lt;br /&gt;
echo rc_need=mariadb &amp;gt; /etc/conf.d/kamailio&lt;br /&gt;
rc-update add kamailio&lt;br /&gt;
rc-service kamailio start&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Capture Nodes ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;apk add captagent&lt;br /&gt;
edit &amp;quot;capture-host&amp;quot; in /etc/captagent/transport_hep.xml&lt;br /&gt;
edit &amp;quot;capture-port&amp;quot; in /etc/captagent/transport_hep.xml to &amp;quot;9060&amp;quot;&lt;br /&gt;
rc-update add captagent&lt;br /&gt;
rc-service captagent start&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;/div&gt;</summary>
		<author><name>Kunkku</name></author>
	</entry>
	<entry>
		<id>https://wiki.alpinelinux.org/w/index.php?title=Setting_up_Homer&amp;diff=13755</id>
		<title>Setting up Homer</title>
		<link rel="alternate" type="text/html" href="https://wiki.alpinelinux.org/w/index.php?title=Setting_up_Homer&amp;diff=13755"/>
		<updated>2017-09-02T10:09:56Z</updated>

		<summary type="html">&lt;p&gt;Kunkku: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Draft}}&lt;br /&gt;
&lt;br /&gt;
Rough notes for setting up [http://sipcapture.org Homer] on Alpine Linux from testing repository&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;apk add homer-api-doc homer-ui mariadb kamailio-mysql nginx php7-fpm&lt;br /&gt;
&lt;br /&gt;
rc-service mariadb setup&lt;br /&gt;
rc-update add mariadb&lt;br /&gt;
rc-service mariadb start&lt;br /&gt;
mysql_secure_installation&lt;br /&gt;
&lt;br /&gt;
homer_db_init&lt;br /&gt;
rc-update add crond&lt;br /&gt;
rc-service crond start&lt;br /&gt;
&lt;br /&gt;
cp /usr/share/doc/homer-api/examples/sipcapture/sipcapture.kamailio /etc/kamailio/kamailio.cfg&lt;br /&gt;
echo rc_need=mariadb &amp;gt; /etc/conf.d/kamailio&lt;br /&gt;
rc-update add kamailio&lt;br /&gt;
rc-service kamailio start&lt;br /&gt;
&lt;br /&gt;
cp /usr/share/doc/homer-api/examples/web/homer5.php-fpm /etc/php7/php-fpm.d/homer5.conf&lt;br /&gt;
rc-update add php-fpm7&lt;br /&gt;
rc-service php-fpm7 start&lt;br /&gt;
&lt;br /&gt;
: &amp;gt; /etc/nginx/conf.d/default.conf&lt;br /&gt;
cp /usr/share/doc/homer-api/examples/web/homer5.nginx /etc/nginx/conf.d/homer5.conf&lt;br /&gt;
edit &amp;quot;root&amp;quot; in /etc/nginx/conf.d/homer5.conf to &amp;quot;/usr/share/webapps/homer&amp;quot;&lt;br /&gt;
edit &amp;quot;server_name&amp;quot; in /etc/nginx/conf.d/homer5.conf&lt;br /&gt;
edit &amp;quot;fastcgi_pass&amp;quot; in /etc/nginx/conf.d/homer5.conf to &amp;quot;127.0.0.1:9001&amp;quot;&lt;br /&gt;
edit &amp;quot;SINGLE_NODE&amp;quot; in /etc/homer/configuration.php to &amp;quot;0&amp;quot; if using DB nodes&lt;br /&gt;
edit &amp;quot;HOMER_TIMEZONE&amp;quot; in /etc/homer/preferences.php&lt;br /&gt;
rc-update add nginx&lt;br /&gt;
rc-service nginx start&lt;br /&gt;
&lt;br /&gt;
configure DB nodes in web UI, default password is &amp;quot;homer_password&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Database Nodes ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;apk add homer-api-doc homer-db mariadb kamailio-mysql&lt;br /&gt;
&lt;br /&gt;
rc-service mariadb setup&lt;br /&gt;
rc-update add mariadb&lt;br /&gt;
rc-service mariadb start&lt;br /&gt;
mysql_secure_installation&lt;br /&gt;
&lt;br /&gt;
homer_db_init -r&lt;br /&gt;
rc-update add crond&lt;br /&gt;
rc-service crond start&lt;br /&gt;
&lt;br /&gt;
cp /usr/share/doc/homer-api/examples/sipcapture/sipcapture.kamailio /etc/kamailio/kamailio.cfg&lt;br /&gt;
edit &amp;quot;capture_node&amp;quot; in /etc/kamailio/kamailio.cfg&lt;br /&gt;
echo rc_need=mariadb &amp;gt; /etc/conf.d/kamailio&lt;br /&gt;
rc-update add kamailio&lt;br /&gt;
rc-service kamailio start&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Capture Nodes ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;apk add captagent&lt;br /&gt;
edit &amp;quot;capture-host&amp;quot; in /etc/captagent/transport_hep.xml&lt;br /&gt;
edit &amp;quot;capture-port&amp;quot; in /etc/captagent/transport_hep.xml to &amp;quot;9060&amp;quot;&lt;br /&gt;
rc-update add captagent&lt;br /&gt;
rc-service captagent start&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;/div&gt;</summary>
		<author><name>Kunkku</name></author>
	</entry>
	<entry>
		<id>https://wiki.alpinelinux.org/w/index.php?title=Setting_up_Homer&amp;diff=13676</id>
		<title>Setting up Homer</title>
		<link rel="alternate" type="text/html" href="https://wiki.alpinelinux.org/w/index.php?title=Setting_up_Homer&amp;diff=13676"/>
		<updated>2017-07-06T12:16:18Z</updated>

		<summary type="html">&lt;p&gt;Kunkku: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Draft}}&lt;br /&gt;
&lt;br /&gt;
Rough notes for setting up [http://sipcapture.org Homer] on Alpine Linux from testing repository&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;apk add homer-api-doc homer-ui mariadb kamailio-mysql nginx php7-fpm&lt;br /&gt;
&lt;br /&gt;
rc-service mariadb setup&lt;br /&gt;
rc-update add mariadb&lt;br /&gt;
rc-service mariadb start&lt;br /&gt;
mysql_secure_installation&lt;br /&gt;
&lt;br /&gt;
homer_db_init&lt;br /&gt;
rc-update add crond&lt;br /&gt;
rc-service crond start&lt;br /&gt;
&lt;br /&gt;
cp /usr/share/doc/homer-api/examples/sipcapture/sipcapture.kamailio /etc/kamailio/kamailio.cfg&lt;br /&gt;
echo rc_need=mariadb &amp;gt; /etc/conf.d/kamailio&lt;br /&gt;
rc-update add kamailio&lt;br /&gt;
rc-service kamailio start&lt;br /&gt;
&lt;br /&gt;
cp /usr/share/doc/homer-api/examples/web/homer5.php-fpm /etc/php7/php-fpm.d/homer5.conf&lt;br /&gt;
rc-update add php-fpm7&lt;br /&gt;
rc-service php-fpm7 start&lt;br /&gt;
&lt;br /&gt;
rm /etc/nginx/conf.d/default.conf&lt;br /&gt;
cp /usr/share/doc/homer-api/examples/web/homer5.nginx /etc/nginx/conf.d/homer5.conf&lt;br /&gt;
edit &amp;quot;root&amp;quot; in /etc/nginx/conf.d/homer5.conf to &amp;quot;/usr/share/webapps/homer&amp;quot;&lt;br /&gt;
edit &amp;quot;server_name&amp;quot; in /etc/nginx/conf.d/homer5.conf&lt;br /&gt;
edit &amp;quot;fastcgi_pass&amp;quot; in /etc/nginx/conf.d/homer5.conf to &amp;quot;127.0.0.1:9001&amp;quot;&lt;br /&gt;
edit &amp;quot;SINGLE_NODE&amp;quot; in /etc/homer/configuration.php to &amp;quot;0&amp;quot; if using DB nodes&lt;br /&gt;
edit &amp;quot;HOMER_TIMEZONE&amp;quot; in /etc/homer/preferences.php&lt;br /&gt;
rc-update add nginx&lt;br /&gt;
rc-service nginx start&lt;br /&gt;
&lt;br /&gt;
configure DB nodes in web UI, default password is &amp;quot;homer_password&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Database Nodes ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;apk add homer-api-doc homer-db mariadb kamailio-mysql&lt;br /&gt;
&lt;br /&gt;
rc-service mariadb setup&lt;br /&gt;
rc-update add mariadb&lt;br /&gt;
rc-service mariadb start&lt;br /&gt;
mysql_secure_installation&lt;br /&gt;
&lt;br /&gt;
homer_db_init -r&lt;br /&gt;
rc-update add crond&lt;br /&gt;
rc-service crond start&lt;br /&gt;
&lt;br /&gt;
cp /usr/share/doc/homer-api/examples/sipcapture/sipcapture.kamailio /etc/kamailio/kamailio.cfg&lt;br /&gt;
edit &amp;quot;capture_node&amp;quot; in /etc/kamailio/kamailio.cfg&lt;br /&gt;
echo rc_need=mariadb &amp;gt; /etc/conf.d/kamailio&lt;br /&gt;
rc-update add kamailio&lt;br /&gt;
rc-service kamailio start&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Capture Nodes ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;apk add captagent&lt;br /&gt;
edit &amp;quot;capture-host&amp;quot; in /etc/captagent/transport_hep.xml&lt;br /&gt;
edit &amp;quot;capture-port&amp;quot; in /etc/captagent/transport_hep.xml to &amp;quot;9060&amp;quot;&lt;br /&gt;
rc-update add captagent&lt;br /&gt;
rc-service captagent start&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;/div&gt;</summary>
		<author><name>Kunkku</name></author>
	</entry>
	<entry>
		<id>https://wiki.alpinelinux.org/w/index.php?title=Setting_up_Homer&amp;diff=13144</id>
		<title>Setting up Homer</title>
		<link rel="alternate" type="text/html" href="https://wiki.alpinelinux.org/w/index.php?title=Setting_up_Homer&amp;diff=13144"/>
		<updated>2017-02-20T14:57:37Z</updated>

		<summary type="html">&lt;p&gt;Kunkku: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Draft}}&lt;br /&gt;
&lt;br /&gt;
Rough notes for setting up [http://sipcapture.org Homer] on Alpine Linux from testing repository&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;apk add homer-api-doc homer-ui mariadb kamailio-mysql nginx php5-fpm&lt;br /&gt;
&lt;br /&gt;
rc-service mariadb setup&lt;br /&gt;
rc-update add mariadb&lt;br /&gt;
rc-service mariadb start&lt;br /&gt;
mysql_secure_installation&lt;br /&gt;
&lt;br /&gt;
homer_db_init&lt;br /&gt;
rc-update add crond&lt;br /&gt;
rc-service crond start&lt;br /&gt;
&lt;br /&gt;
cp /usr/share/doc/homer-api/examples/sipcapture/sipcapture.kamailio /etc/kamailio/kamailio.cfg&lt;br /&gt;
echo rc_need=mariadb &amp;gt; /etc/conf.d/kamailio&lt;br /&gt;
rc-update add kamailio&lt;br /&gt;
rc-service kamailio start&lt;br /&gt;
&lt;br /&gt;
cp /usr/share/doc/homer-api/examples/web/homer5.php-fpm /etc/php5/fpm.d/homer5.conf&lt;br /&gt;
rc-update add php-fpm&lt;br /&gt;
rc-service php-fpm start&lt;br /&gt;
&lt;br /&gt;
rm /etc/nginx/conf.d/default.conf&lt;br /&gt;
cp /usr/share/doc/homer-api/examples/web/homer5.nginx /etc/nginx/conf.d/homer5.conf&lt;br /&gt;
edit &amp;quot;root&amp;quot; in /etc/nginx/conf.d/homer5.conf to &amp;quot;/usr/share/webapps/homer&amp;quot;&lt;br /&gt;
edit &amp;quot;server_name&amp;quot; in /etc/nginx/conf.d/homer5.conf&lt;br /&gt;
edit &amp;quot;fastcgi_pass&amp;quot; in /etc/nginx/conf.d/homer5.conf to &amp;quot;127.0.0.1:9001&amp;quot;&lt;br /&gt;
edit &amp;quot;SINGLE_NODE&amp;quot; in /etc/homer/configuration.php to &amp;quot;0&amp;quot; if using DB nodes&lt;br /&gt;
edit &amp;quot;HOMER_TIMEZONE&amp;quot; in /etc/homer/preferences.php&lt;br /&gt;
rc-update add nginx&lt;br /&gt;
rc-service nginx start&lt;br /&gt;
&lt;br /&gt;
configure DB nodes in web UI, default password is &amp;quot;homer_password&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Database Nodes ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;apk add homer-api-doc homer-db mariadb kamailio-mysql&lt;br /&gt;
&lt;br /&gt;
rc-service mariadb setup&lt;br /&gt;
rc-update add mariadb&lt;br /&gt;
rc-service mariadb start&lt;br /&gt;
mysql_secure_installation&lt;br /&gt;
&lt;br /&gt;
homer_db_init -r&lt;br /&gt;
rc-update add crond&lt;br /&gt;
rc-service crond start&lt;br /&gt;
&lt;br /&gt;
cp /usr/share/doc/homer-api/examples/sipcapture/sipcapture.kamailio /etc/kamailio/kamailio.cfg&lt;br /&gt;
edit &amp;quot;capture_node&amp;quot; in /etc/kamailio/kamailio.cfg&lt;br /&gt;
echo rc_need=mariadb &amp;gt; /etc/conf.d/kamailio&lt;br /&gt;
rc-update add kamailio&lt;br /&gt;
rc-service kamailio start&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Capture Nodes ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;apk add captagent&lt;br /&gt;
edit &amp;quot;capture-host&amp;quot; in /etc/captagent/transport_hep.xml&lt;br /&gt;
edit &amp;quot;capture-port&amp;quot; in /etc/captagent/transport_hep.xml to &amp;quot;9060&amp;quot;&lt;br /&gt;
rc-update add captagent&lt;br /&gt;
rc-service captagent start&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;/div&gt;</summary>
		<author><name>Kunkku</name></author>
	</entry>
	<entry>
		<id>https://wiki.alpinelinux.org/w/index.php?title=Setting_up_Homer&amp;diff=13138</id>
		<title>Setting up Homer</title>
		<link rel="alternate" type="text/html" href="https://wiki.alpinelinux.org/w/index.php?title=Setting_up_Homer&amp;diff=13138"/>
		<updated>2017-02-08T08:00:35Z</updated>

		<summary type="html">&lt;p&gt;Kunkku: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Draft}}&lt;br /&gt;
&lt;br /&gt;
Rough notes for setting up [http://sipcapture.org Homer] on Alpine Linux from testing repository&lt;br /&gt;
&lt;br /&gt;
{{Cmd|apk add homer-api-doc homer-ui mariadb mariadb-client kamailio-mysql nginx php5-fpm&lt;br /&gt;
&lt;br /&gt;
rc-service mariadb setup&lt;br /&gt;
rc-update add mariadb&lt;br /&gt;
rc-service mariadb start&lt;br /&gt;
mysql_secure_installation&lt;br /&gt;
&lt;br /&gt;
mysql &amp;lt; /usr/share/homer-api/sql/homer_databases.sql&lt;br /&gt;
mysql &amp;lt; /usr/share/homer-api/sql/homer_user.sql&lt;br /&gt;
mysql homer_data &amp;lt; /usr/share/homer-api/sql/schema_data.sql&lt;br /&gt;
mysql homer_configuration &amp;lt; /usr/share/homer-api/sql/schema_configuration.sql&lt;br /&gt;
mysql homer_statistic &amp;lt; /usr/share/homer-api/sql/schema_statistic.sql&lt;br /&gt;
homer_rotate&lt;br /&gt;
&lt;br /&gt;
cp /usr/share/doc/homer-api/examples/sipcapture/sipcapture.kamailio /etc/kamailio/kamailio.cfg &lt;br /&gt;
rc-update add kamailio&lt;br /&gt;
rc-service kamailio start&lt;br /&gt;
&lt;br /&gt;
cp /usr/share/doc/homer-api/examples/web/homer5.php-fpm /etc/php5/fpm.d/homer5.conf&lt;br /&gt;
rc-update add php-fpm&lt;br /&gt;
rc-service php-fpm start&lt;br /&gt;
&lt;br /&gt;
rm /etc/nginx/conf.d/default.conf&lt;br /&gt;
cp /usr/share/doc/homer-api/examples/web/homer5.nginx /etc/nginx/conf.d/homer5.conf&lt;br /&gt;
edit &amp;quot;root&amp;quot; in /etc/nginx/conf.d/homer5.conf to &amp;quot;/usr/share/webapps/homer&amp;quot;&lt;br /&gt;
edit &amp;quot;server_name&amp;quot; in /etc/nginx/conf.d/homer5.conf&lt;br /&gt;
edit &amp;quot;fastcgi_pass&amp;quot; in /etc/nginx/conf.d/homer5.conf to &amp;quot;127.0.0.1:9001&amp;quot;&lt;br /&gt;
edit &amp;quot;HOMER_TIMEZONE&amp;quot; in /etc/homer/preferences.php&lt;br /&gt;
rc-update add nginx&lt;br /&gt;
rc-service nginx start&lt;br /&gt;
}}&lt;/div&gt;</summary>
		<author><name>Kunkku</name></author>
	</entry>
	<entry>
		<id>https://wiki.alpinelinux.org/w/index.php?title=Alpine_Wall_User%27s_Guide&amp;diff=11535</id>
		<title>Alpine Wall User&#039;s Guide</title>
		<link rel="alternate" type="text/html" href="https://wiki.alpinelinux.org/w/index.php?title=Alpine_Wall_User%27s_Guide&amp;diff=11535"/>
		<updated>2015-12-24T11:01:16Z</updated>

		<summary type="html">&lt;p&gt;Kunkku: Replaced content with &amp;quot;The current Alpine Wall User&amp;#039;s Guide is available [http://git.alpinelinux.org/cgit/awall/about/ here].&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;The current Alpine Wall User&#039;s Guide is available [http://git.alpinelinux.org/cgit/awall/about/ here].&lt;/div&gt;</summary>
		<author><name>Kunkku</name></author>
	</entry>
	<entry>
		<id>https://wiki.alpinelinux.org/w/index.php?title=Alpine_Wall_User%27s_Guide&amp;diff=10168</id>
		<title>Alpine Wall User&#039;s Guide</title>
		<link rel="alternate" type="text/html" href="https://wiki.alpinelinux.org/w/index.php?title=Alpine_Wall_User%27s_Guide&amp;diff=10168"/>
		<updated>2014-09-29T10:47:29Z</updated>

		<summary type="html">&lt;p&gt;Kunkku: /* Filter Rules */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Configuration File Processing ==&lt;br /&gt;
&lt;br /&gt;
[[Alpine Wall]] (awall) reads its configuration from multiple&lt;br /&gt;
JSON-formatted files, called &#039;&#039;policy files&#039;&#039;. The files located in&lt;br /&gt;
directory &amp;lt;tt&amp;gt;/usr/share/awall/mandatory&amp;lt;/tt&amp;gt; are &#039;&#039;mandatory&#039;&#039;&lt;br /&gt;
policies shipped with APK packages. In addition, there can be&lt;br /&gt;
installation-specific mandatory policies in &amp;lt;tt&amp;gt;/etc/awall&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
The latter directory may also contain symbolic links to policy files&lt;br /&gt;
located in &amp;lt;tt&amp;gt;/usr/share/awall/optional&amp;lt;/tt&amp;gt; and&lt;br /&gt;
&amp;lt;tt&amp;gt;/etc/awall/optional&amp;lt;/tt&amp;gt;. These are &#039;&#039;optional&#039;&#039; policies, which&lt;br /&gt;
can be enabled on need basis. Such symbolic links are easily created&lt;br /&gt;
and destroyed using the &amp;lt;tt&amp;gt;awall enable&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;awall&lt;br /&gt;
disable&amp;lt;/tt&amp;gt; commands. &amp;lt;tt&amp;gt;awall list&amp;lt;/tt&amp;gt; shows which optional&lt;br /&gt;
policies are enabled and disabled. The command also prints the&lt;br /&gt;
description of the optional policy if defined in the file using a&lt;br /&gt;
top-level attribute named &#039;&#039;&#039;description&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Sometimes a policy file depends on other policy files. In this case,&lt;br /&gt;
the policy file must have a top-level attribute &#039;&#039;&#039;import&#039;&#039;&#039;, the&lt;br /&gt;
value of which is a list of policy names, which correspond to the file&lt;br /&gt;
names without the &amp;lt;tt&amp;gt;.json&amp;lt;/tt&amp;gt; suffix. The imported policies may be&lt;br /&gt;
either optional policies or &#039;&#039;private&#039;&#039; policies, located in&lt;br /&gt;
&amp;lt;tt&amp;gt;/usr/share/awall/private&amp;lt;/tt&amp;gt; or &amp;lt;tt&amp;gt;/etc/awall/private&amp;lt;/tt&amp;gt;. By&lt;br /&gt;
default, the policies listed there are processed before the importing&lt;br /&gt;
policy.&lt;br /&gt;
&lt;br /&gt;
The order of the generated iptables rules generally reflects the&lt;br /&gt;
processing order of their corresponding awall policies. The&lt;br /&gt;
processing order of policies can be adjusted by defining&lt;br /&gt;
top-level attributes &#039;&#039;&#039;after&#039;&#039;&#039; and &#039;&#039;&#039;before&#039;&#039;&#039; in policy&lt;br /&gt;
files. These attributes are lists of policies, after or before&lt;br /&gt;
which the declaring policy shall be processed. Putting a policy&lt;br /&gt;
name to either of these lists does not by itself import the&lt;br /&gt;
policy. The ordering directives are ignored with respect to those&lt;br /&gt;
policies that are not enabled by the user or imported by other&lt;br /&gt;
policies. If not defined, &#039;&#039;&#039;after&#039;&#039;&#039; is assumed to be equal to&lt;br /&gt;
the relative complement of the &#039;&#039;&#039;before&#039;&#039;&#039; definition in the&lt;br /&gt;
&#039;&#039;&#039;import&#039;&#039;&#039; definition of the policy.&lt;br /&gt;
&lt;br /&gt;
As the import directive does not require the path name to be&lt;br /&gt;
specified, awall expects policies to have unique names, even if&lt;br /&gt;
located in different directories. It is allowed to import optional&lt;br /&gt;
policies that are not explicitly enabled by the user. Such policies&lt;br /&gt;
show up with the &amp;lt;tt&amp;gt;required&amp;lt;/tt&amp;gt; status in the output of &amp;lt;tt&amp;gt;awall&lt;br /&gt;
list&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
== List Parameters ==&lt;br /&gt;
&lt;br /&gt;
Several awall parameters are defined as lists of values. In order to&lt;br /&gt;
facilitate manual editing of policy files, awall also accepts single&lt;br /&gt;
values in place of lists. Such values are semantically equivalent to&lt;br /&gt;
lists containing one element.&lt;br /&gt;
&lt;br /&gt;
== Variable Expansion ==&lt;br /&gt;
&lt;br /&gt;
Awall allows variable definitions in policy files. The top-level&lt;br /&gt;
attribute &#039;&#039;&#039;variable&#039;&#039;&#039; is a dictionary containing the&lt;br /&gt;
definitions. The value of a variable can be of any type (string,&lt;br /&gt;
integer, list, or dictionary).&lt;br /&gt;
&lt;br /&gt;
A variable is referenced in policy files by a string which equals the&lt;br /&gt;
variable name prepended with the &#039;&#039;&#039;$&#039;&#039;&#039; character. If the value of&lt;br /&gt;
the variable is a string, the reference can be embedded into a longer&lt;br /&gt;
string in order to substitute some part of that string (in shell&lt;br /&gt;
style). Variable references can be used when defining other variables,&lt;br /&gt;
as long as the definitions are not circular.&lt;br /&gt;
&lt;br /&gt;
Policy files can reference variables defined in other policy&lt;br /&gt;
files. Policy files can also override variables defined elsewhere by&lt;br /&gt;
redefining them. In this case, the new definition affects all policy&lt;br /&gt;
files, also those processed before the overriding policy. Awall&lt;br /&gt;
variables are in fact simple macros, since each variable remains&lt;br /&gt;
constant thoughout a single processing round. If multiple files define&lt;br /&gt;
the same variable, the definition in the file processed last takes&lt;br /&gt;
effect.&lt;br /&gt;
&lt;br /&gt;
If defined as an empty string, all non-embedded references to a&lt;br /&gt;
variable evaluate as if the attribute in question was not present in&lt;br /&gt;
the configuration. This is also the case when a string containing&lt;br /&gt;
embedded variable references finally evaluates to an empty string.&lt;br /&gt;
&lt;br /&gt;
== Configuration Objects ==&lt;br /&gt;
&lt;br /&gt;
Configuration objects can be divided into two main types.&lt;br /&gt;
&#039;&#039;Auxiliary objects&#039;&#039; model high-level concepts such as services and&lt;br /&gt;
zones. &#039;&#039;Rule objects&#039;&#039; translate into one or more iptables rules, and&lt;br /&gt;
are often defined with the help of some auxiliary objects.&lt;br /&gt;
&lt;br /&gt;
=== Services ===&lt;br /&gt;
&lt;br /&gt;
A &#039;&#039;service&#039;&#039; represents a set of network protocols. A top-level&lt;br /&gt;
attribute &#039;&#039;&#039;service&#039;&#039;&#039; is a dictionary that maps service names to&lt;br /&gt;
service definition objects, or lists thereof in more complex cases.&lt;br /&gt;
&lt;br /&gt;
A service definition object contains an attribute named&lt;br /&gt;
&#039;&#039;&#039;proto&#039;&#039;&#039;, which corresponds to the &amp;lt;tt&amp;gt;--protocol&amp;lt;/tt&amp;gt; option&lt;br /&gt;
of iptables. The protocol can be defined as a numerical value or&lt;br /&gt;
string as defined in &amp;lt;tt&amp;gt;/etc/protocols&amp;lt;/tt&amp;gt;. If the protocol is&lt;br /&gt;
&#039;&#039;&#039;tcp&#039;&#039;&#039; or &#039;&#039;&#039;udp&#039;&#039;&#039;, the scope of the service definition may&lt;br /&gt;
be constrained by defining an attribute named &#039;&#039;&#039;port&#039;&#039;&#039;, which&lt;br /&gt;
is a list of TCP or UDP port numbers or ranges thereof, separated&lt;br /&gt;
by the &#039;&#039;&#039;-&#039;&#039;&#039; character. If the protocol is &#039;&#039;&#039;icmp&#039;&#039;&#039; or&lt;br /&gt;
&#039;&#039;&#039;icmpv6&#039;&#039;&#039;, an analogous &#039;&#039;&#039;type&#039;&#039;&#039; attribute may be used. The&lt;br /&gt;
replies to ICMP messages have their own type codes, which may be&lt;br /&gt;
specified using the &#039;&#039;&#039;reply-type&#039;&#039;&#039; attribute.&lt;br /&gt;
&lt;br /&gt;
If the protocol is &#039;&#039;&#039;icmp&#039;&#039;&#039; or &#039;&#039;&#039;icmpv6&#039;&#039;&#039;, the scope of the&lt;br /&gt;
rule is also automatically limited to IPv4 or IPv6,&lt;br /&gt;
respectively. There are also other services which are specific to&lt;br /&gt;
IPv4 or IPv6. To constrain the scope of the service definition to&lt;br /&gt;
either protocol version, an optional &#039;&#039;&#039;family&#039;&#039;&#039; attribute can&lt;br /&gt;
be set to value &#039;&#039;&#039;inet&#039;&#039;&#039; or &#039;&#039;&#039;inet6&#039;&#039;&#039;, respectively.&lt;br /&gt;
&lt;br /&gt;
Some services require the server or client to open additional&lt;br /&gt;
connections to dynamically allocated ports or even different&lt;br /&gt;
hosts. &#039;&#039;Connection tracking helpers&#039;&#039; are used to make the firewall&lt;br /&gt;
aware of such additional connections. The &#039;&#039;&#039;ct-helper&#039;&#039;&#039; attribute is&lt;br /&gt;
used to associate such a helper to a service definition when&lt;br /&gt;
required by the service.&lt;br /&gt;
&lt;br /&gt;
All rule objects, except for policies, may have an attribute named&lt;br /&gt;
&#039;&#039;&#039;service&#039;&#039;&#039;, constraining the rule&#039;s scope to specific services&lt;br /&gt;
only. This attribute is a list of service names, referring to the keys&lt;br /&gt;
of the top-level service dictionary.&lt;br /&gt;
&lt;br /&gt;
=== Zones ===&lt;br /&gt;
&lt;br /&gt;
A &#039;&#039;zone&#039;&#039; represents a set of network hosts. A top-level attribute &lt;br /&gt;
&#039;&#039;&#039;zone&#039;&#039;&#039; is a dictionary that maps zone names to zone objects. A&lt;br /&gt;
zone object has an attribute named &#039;&#039;&#039;iface&#039;&#039;&#039;, &#039;&#039;&#039;addr&#039;&#039;&#039;, or&lt;br /&gt;
both. &#039;&#039;&#039;iface&#039;&#039;&#039; is a list of network interfaces and &#039;&#039;&#039;addr&#039;&#039;&#039; is a&lt;br /&gt;
list of IPv4/IPv6 host and network addresses (CIDR&lt;br /&gt;
notation). &#039;&#039;&#039;addr&#039;&#039;&#039; may also contain domain names, which are&lt;br /&gt;
expanded to IP addresses using DNS resolution. If not defined,&lt;br /&gt;
&#039;&#039;&#039;addr&#039;&#039;&#039; defaults to the entire address space and &#039;&#039;&#039;iface&#039;&#039;&#039; to all&lt;br /&gt;
interfaces. An empty zone can be defined by setting either &#039;&#039;&#039;addr&#039;&#039;&#039;&lt;br /&gt;
or &#039;&#039;&#039;iface&#039;&#039;&#039; to an empty list.&lt;br /&gt;
&lt;br /&gt;
Rule objects contain two attributes, &#039;&#039;&#039;in&#039;&#039;&#039; and &#039;&#039;&#039;out&#039;&#039;&#039;, which are&lt;br /&gt;
lists of zone names. These attributes control whether a packet matches&lt;br /&gt;
the rule or not. If a particular zone is referenced by the &#039;&#039;&#039;in&#039;&#039;&#039; &lt;br /&gt;
attribute, the rule applies to packets whose ingress interface and&lt;br /&gt;
source address are covered by the zone definition. Correspondingly, if&lt;br /&gt;
a zone is referenced by the &#039;&#039;&#039;out&#039;&#039;&#039; attribute, the rule applies to&lt;br /&gt;
packets whose egress interface and destination address are included in&lt;br /&gt;
the zone. If both &#039;&#039;&#039;in&#039;&#039;&#039; and &#039;&#039;&#039;out&#039;&#039;&#039; are defined, the packet must&lt;br /&gt;
fulfill both criteria in order to match the rule.&lt;br /&gt;
&lt;br /&gt;
The firewall host itself can be referred to using the special value&lt;br /&gt;
&#039;&#039;&#039;_fw&#039;&#039;&#039; as the zone name.&lt;br /&gt;
&lt;br /&gt;
By default, awall does not generate iptables rules with identical&lt;br /&gt;
ingress and egress interfaces. This behavior can be changed per zone&lt;br /&gt;
by setting the optional &#039;&#039;&#039;route-back&#039;&#039;&#039; attribute of the zone to&lt;br /&gt;
&#039;&#039;&#039;true&#039;&#039;&#039;. Note that this attribute can have an effect also in the&lt;br /&gt;
case where &#039;&#039;&#039;in&#039;&#039;&#039; and &#039;&#039;&#039;out&#039;&#039;&#039; attributes of a rule are not equal&lt;br /&gt;
but their definitions overlap. In this case, the &#039;&#039;&#039;route-back&#039;&#039;&#039;&lt;br /&gt;
attribute of the &#039;&#039;&#039;out&#039;&#039;&#039; zone determines the behavior.&lt;br /&gt;
&lt;br /&gt;
=== Limits ===&lt;br /&gt;
&lt;br /&gt;
A &#039;&#039;limit&#039;&#039; specifies the maximum rate for a flow of packets or new&lt;br /&gt;
connections. Unlike the other auxiliary objects, limits are not named&lt;br /&gt;
members of a top-level dictionary but are embedded into other objects.&lt;br /&gt;
&lt;br /&gt;
In its simplest form, a limit definition is an integer specifying the&lt;br /&gt;
maximum number of packets or connections per second. More complex&lt;br /&gt;
limits are defined as objects, where the &#039;&#039;&#039;count&#039;&#039;&#039; attribute define&lt;br /&gt;
the maximum during an interval defined by the &#039;&#039;&#039;interval&#039;&#039;&#039;&lt;br /&gt;
attribute. The unit of the &#039;&#039;&#039;interval&#039;&#039;&#039; attribute is second, and&lt;br /&gt;
the default value is 1.&lt;br /&gt;
&lt;br /&gt;
The maximum rate defined by a limit may be absolute or specific to&lt;br /&gt;
blocks of IP addresses or pairs thereof. The number of most&lt;br /&gt;
significant bits taken into account when mapping the source and&lt;br /&gt;
destination IP addresses to blocks can be specified with the&lt;br /&gt;
&#039;&#039;&#039;mask&#039;&#039;&#039; attribute. The &#039;&#039;&#039;mask&#039;&#039;&#039; attribute is an object with two&lt;br /&gt;
attributes defining the prefix lengths, named &#039;&#039;&#039;src&#039;&#039;&#039; and&lt;br /&gt;
&#039;&#039;&#039;dest&#039;&#039;&#039;. Alternatively, the &#039;&#039;&#039;mask&#039;&#039;&#039; object may have object&lt;br /&gt;
attributes named &#039;&#039;&#039;inet&#039;&#039;&#039; and &#039;&#039;&#039;inet6&#039;&#039;&#039; which contain address&lt;br /&gt;
family&amp;amp;ndash;specific prefix length pairs. If &#039;&#039;&#039;mask&#039;&#039;&#039; is defined as&lt;br /&gt;
an integer, it is interpreted as the source address prefix length.&lt;br /&gt;
&lt;br /&gt;
The default value for &#039;&#039;&#039;mask&#039;&#039;&#039; depends on the type of the enclosing&lt;br /&gt;
object. For [[#Filter Rules|filters]], the default behavior is to&lt;br /&gt;
apply the limit for each source address separately. For&lt;br /&gt;
[[#Logging Classes|logging classes]], the limit is considered absolute&lt;br /&gt;
by default.&lt;br /&gt;
&lt;br /&gt;
=== Logging Classes ===&lt;br /&gt;
&lt;br /&gt;
A &#039;&#039;logging class&#039;&#039; specifies how packets matching certain rules are&lt;br /&gt;
logged. A top-level attribute &#039;&#039;&#039;log&#039;&#039;&#039; is a dictionary that maps&lt;br /&gt;
logging class names to setting objects.&lt;br /&gt;
&lt;br /&gt;
A setting object may have an attribute named &#039;&#039;&#039;mode&#039;&#039;&#039;, which&lt;br /&gt;
specifies which logging facility to use. Allowed values are &#039;&#039;&#039;log&#039;&#039;&#039;,&lt;br /&gt;
&#039;&#039;&#039;nflog&#039;&#039;&#039;, and &#039;&#039;&#039;ulog&#039;&#039;&#039;. The default is &#039;&#039;&#039;log&#039;&#039;&#039;, i.e. in-kernel&lt;br /&gt;
logging.&lt;br /&gt;
&lt;br /&gt;
The following table shows the optional attributes valid for all&lt;br /&gt;
logging modes:&lt;br /&gt;
&lt;br /&gt;
{|&lt;br /&gt;
!Attribute!!Description&lt;br /&gt;
|-&lt;br /&gt;
|&#039;&#039;&#039;every&#039;&#039;&#039;&lt;br /&gt;
|Divide successive packets into groups, the size of which is specified by the value of this attribute, and log only the first packet of each group&lt;br /&gt;
|-&lt;br /&gt;
|&#039;&#039;&#039;limit&#039;&#039;&#039;&lt;br /&gt;
|Maximum number of packets to be logged defined as [[#Limits|limit]]&lt;br /&gt;
|-&lt;br /&gt;
|&#039;&#039;&#039;prefix&#039;&#039;&#039;&lt;br /&gt;
|String with which the log entries are prefixed&lt;br /&gt;
|-&lt;br /&gt;
|&#039;&#039;&#039;probability&#039;&#039;&#039;&lt;br /&gt;
|Probability for logging an individual packet (default: 1)&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
With the in-kernel log mode &#039;&#039;&#039;log&#039;&#039;&#039;, the level of logging may be&lt;br /&gt;
specified using the &#039;&#039;&#039;level&#039;&#039;&#039; attribute. Log modes &#039;&#039;&#039;nflog&#039;&#039;&#039; and&lt;br /&gt;
&#039;&#039;&#039;ulog&#039;&#039;&#039; are about copying the packets into user space, at least&lt;br /&gt;
partially. The following table shows the additional attributes valid&lt;br /&gt;
with these modes:&lt;br /&gt;
&lt;br /&gt;
{|&lt;br /&gt;
!Attribute!!Description&lt;br /&gt;
|-&lt;br /&gt;
|&#039;&#039;&#039;group&#039;&#039;&#039;&lt;br /&gt;
|Netlink group to be used&lt;br /&gt;
|-&lt;br /&gt;
|&#039;&#039;&#039;range&#039;&#039;&#039;&lt;br /&gt;
|Number of bytes to be copied&lt;br /&gt;
|-&lt;br /&gt;
|&#039;&#039;&#039;threshold&#039;&#039;&#039;&lt;br /&gt;
|Number of packets to queue inside the kernel before copying them&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
[[#Filter Rules|Filter]] and [[#Policy Rules|policy]] rules can have&lt;br /&gt;
an attribute named &#039;&#039;&#039;log&#039;&#039;&#039;. If it is a string, it is interpreted as&lt;br /&gt;
a reference to a logging class, and logging is performed according to&lt;br /&gt;
the definitions. If the value of the &#039;&#039;&#039;log&#039;&#039;&#039; attribute is &#039;&#039;&#039;true&#039;&#039;&#039;&lt;br /&gt;
(boolean), logging is done using default settings. If the value is&lt;br /&gt;
&#039;&#039;&#039;false&#039;&#039;&#039; (boolean), logging is disabled for the rule. If &#039;&#039;&#039;log&#039;&#039;&#039;&lt;br /&gt;
is not defined, logging is done using the default settings except for&lt;br /&gt;
accept rules, for which logging is omitted.&lt;br /&gt;
&lt;br /&gt;
Default logging settings can be set by defining a logging class named&lt;br /&gt;
&#039;&#039;&#039;_default&#039;&#039;&#039;. Normally, default logging uses the &#039;&#039;&#039;log&#039;&#039;&#039; mode with&lt;br /&gt;
packets limited to one per second.&lt;br /&gt;
&lt;br /&gt;
=== Rules ===&lt;br /&gt;
&lt;br /&gt;
There are several types of rule objects:&lt;br /&gt;
* Filter rules&lt;br /&gt;
* Policy rules&lt;br /&gt;
* Packet Logging rules&lt;br /&gt;
* NAT rules&lt;br /&gt;
* Packet Marking rules&lt;br /&gt;
* Transparent Proxy rules&lt;br /&gt;
* MSS Clamping rules&lt;br /&gt;
* Connection Tracking Bypass rules&lt;br /&gt;
&lt;br /&gt;
All rule objects can have the &#039;&#039;&#039;in&#039;&#039;&#039; and &#039;&#039;&#039;out&#039;&#039;&#039; attributes&lt;br /&gt;
referring to [[#Zones|zones]] as described in the previous section. In&lt;br /&gt;
addition, the scope of the rule can be further constrained with the&lt;br /&gt;
following attributes:&lt;br /&gt;
&lt;br /&gt;
{|&lt;br /&gt;
!Attribute!!Value format!!Effect&lt;br /&gt;
|-&lt;br /&gt;
|&#039;&#039;&#039;src&#039;&#039;&#039;&lt;br /&gt;
|Similar to &#039;&#039;&#039;addr&#039;&#039;&#039; attribute of [[#Zones|zone objects]]&lt;br /&gt;
|Packet&#039;s source address matches the value&lt;br /&gt;
|-&lt;br /&gt;
|&#039;&#039;&#039;dest&#039;&#039;&#039;&lt;br /&gt;
|Similar to &#039;&#039;&#039;addr&#039;&#039;&#039; attribute of [[#Zones|zone objects]]&lt;br /&gt;
|Packet&#039;s destination address matches the value&lt;br /&gt;
|-&lt;br /&gt;
|&#039;&#039;&#039;ipset&#039;&#039;&#039;&lt;br /&gt;
|Object containing two attributes: &#039;&#039;&#039;name&#039;&#039;&#039; referring to an [[#IP Sets|IP set]] and &#039;&#039;&#039;args&#039;&#039;&#039;, which is a list of strings &#039;&#039;&#039;in&#039;&#039;&#039; and &#039;&#039;&#039;out&#039;&#039;&#039;&lt;br /&gt;
|Packet matches the IP set referred here when the match arguments are taken from the source (&#039;&#039;&#039;in&#039;&#039;&#039;) and destination (&#039;&#039;&#039;out&#039;&#039;&#039;) address or port in the order specified by &#039;&#039;&#039;args&#039;&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
|&#039;&#039;&#039;ipsec&#039;&#039;&#039;&lt;br /&gt;
|&#039;&#039;&#039;in&#039;&#039;&#039; or &#039;&#039;&#039;out&#039;&#039;&#039;&lt;br /&gt;
|IPsec decapsulation perfomed on ingress (&#039;&#039;&#039;in&#039;&#039;&#039;) or encapsulation performed on egress (&#039;&#039;&#039;out&#039;&#039;&#039;)&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Rule objects are declared in type-specific top-level dictionaries in&lt;br /&gt;
awall policy files. If a packet matches multiple rules, the one&lt;br /&gt;
appearing earlier in the list takes precedence. If the matching rules&lt;br /&gt;
are defined in different policy files, the one that was processed&lt;br /&gt;
earlier takes precedence in the current implementation, but this may&lt;br /&gt;
change in future versions.&lt;br /&gt;
&lt;br /&gt;
==== Filter Rules ====&lt;br /&gt;
&lt;br /&gt;
Filter objects specify an action for packets fulfilling certain&lt;br /&gt;
criteria. The top-level attribute &#039;&#039;&#039;filter&#039;&#039;&#039; is a list of filter&lt;br /&gt;
objects.&lt;br /&gt;
&lt;br /&gt;
Filter objects must have an attribute named &#039;&#039;&#039;action&#039;&#039;&#039;, the value of&lt;br /&gt;
which can be one of the following:&lt;br /&gt;
&lt;br /&gt;
{|&lt;br /&gt;
!Value!!Action&lt;br /&gt;
|-&lt;br /&gt;
|&#039;&#039;&#039;accept&#039;&#039;&#039;&lt;br /&gt;
|Accept the packet (default)&lt;br /&gt;
|-&lt;br /&gt;
|&#039;&#039;&#039;reject&#039;&#039;&#039;&lt;br /&gt;
|Reject the packet with an ICMP error message&lt;br /&gt;
|-&lt;br /&gt;
|&#039;&#039;&#039;drop&#039;&#039;&#039;&lt;br /&gt;
|Silently drop the packet&lt;br /&gt;
|-&lt;br /&gt;
|&#039;&#039;&#039;tarpit&#039;&#039;&#039;&lt;br /&gt;
|Put incoming TCP connections into persist state and ignore attempts to close them. Silently drop non-TCP packets. (Connection tracking bypass is automatically enabled for the matching packets.)&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Filter objects, the action of which is &#039;&#039;&#039;accept&#039;&#039;&#039;, may also contain&lt;br /&gt;
limits for packet flow or new connections. These are specified with&lt;br /&gt;
the &#039;&#039;&#039;flow-limit&#039;&#039;&#039; and &#039;&#039;&#039;conn-limit&#039;&#039;&#039; attributes,&lt;br /&gt;
respectively. The values of these attributes are&lt;br /&gt;
[[#Limits|limit objects]]. The &#039;&#039;&#039;drop&#039;&#039;&#039; action is applied to the&lt;br /&gt;
packets exceeding the limit. Optionally, the limit object may have an&lt;br /&gt;
attribute named &#039;&#039;&#039;log&#039;&#039;&#039;. It defines how the dropped packets should&lt;br /&gt;
be logged and is semantically similar to the &#039;&#039;&#039;log&#039;&#039;&#039; attribute of&lt;br /&gt;
rule objects.&lt;br /&gt;
&lt;br /&gt;
Filter objects may have an attribute named &#039;&#039;&#039;dnat&#039;&#039;&#039;, the value&lt;br /&gt;
of which is an IPv4 address. If defined, this enables destination&lt;br /&gt;
NAT for all IPv4 packets matching the rule, such that the&lt;br /&gt;
specified address replaces the original destination address. If&lt;br /&gt;
also port translation is desired, the attribute may be defined as&lt;br /&gt;
an object consisting of attributes &#039;&#039;&#039;addr&#039;&#039;&#039; and &#039;&#039;&#039;port&#039;&#039;&#039;. The&lt;br /&gt;
format of the &#039;&#039;&#039;port&#039;&#039;&#039; attribute is similar to that of the&lt;br /&gt;
&#039;&#039;&#039;to-port&#039;&#039;&#039; attribute of [[#NAT Rules|NAT rules]]. This option&lt;br /&gt;
has no effect on IPv6 packets.&lt;br /&gt;
&lt;br /&gt;
Filter objects may have a boolean attribute named &#039;&#039;&#039;no-track&#039;&#039;&#039;. If&lt;br /&gt;
set to &#039;&#039;&#039;true&#039;&#039;&#039;, connection tracking is bypassed for the matching&lt;br /&gt;
packets. In addition, if &#039;&#039;&#039;action&#039;&#039;&#039; is set to &#039;&#039;&#039;accept&#039;&#039;&#039;, the&lt;br /&gt;
corresponding packets travelling to the reverse direction are also&lt;br /&gt;
allowed.&lt;br /&gt;
&lt;br /&gt;
If one or more connection tracking helpers are associated with the&lt;br /&gt;
services referred to by an accept rule, additional iptables rules are&lt;br /&gt;
generated for the related connections detected by the helpers. The&lt;br /&gt;
&#039;&#039;&#039;related&#039;&#039;&#039; attribute can be used to override the default rules&lt;br /&gt;
generated by awall. It is a list of basic rule objects, the packets&lt;br /&gt;
matching to which are accepted, provided that they are also detected&lt;br /&gt;
by at least one of the helpers.&lt;br /&gt;
&lt;br /&gt;
==== Policy Rules ====&lt;br /&gt;
&lt;br /&gt;
Policy objects describe the default action for packets that did not&lt;br /&gt;
match any filter. The top-level attribute &#039;&#039;&#039;policy&#039;&#039;&#039; is a list of&lt;br /&gt;
policy objects.&lt;br /&gt;
&lt;br /&gt;
Policy objects must have the &#039;&#039;&#039;action&#039;&#039;&#039; attribute defined. The&lt;br /&gt;
possible values and their semantics are the same as in&lt;br /&gt;
[[#Filter Rules|filter rules]].&lt;br /&gt;
&lt;br /&gt;
==== Packet Logging Rules ====&lt;br /&gt;
&lt;br /&gt;
Packet logging rules allow packets matching the specified criteria to&lt;br /&gt;
be logged before any filtering takes place. Such rules are contained&lt;br /&gt;
in the top-level list named &#039;&#039;&#039;packet-log&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Logging class may be specified using the &#039;&#039;&#039;log&#039;&#039;&#039;&lt;br /&gt;
attribute. Otherwise, default logging settings are used.&lt;br /&gt;
&lt;br /&gt;
==== NAT Rules ====&lt;br /&gt;
&lt;br /&gt;
NAT rules come in two flavors: &#039;&#039;source NAT rules&#039;&#039; and&lt;br /&gt;
&#039;&#039;destination NAT rules&#039;&#039;. These are contained in two top-level lists&lt;br /&gt;
named &#039;&#039;&#039;snat&#039;&#039;&#039; and &#039;&#039;&#039;dnat&#039;&#039;&#039;, respectively.&lt;br /&gt;
&lt;br /&gt;
Each NAT rule may have an attribute named &#039;&#039;&#039;to-addr&#039;&#039;&#039; that&lt;br /&gt;
specifies the IPv4 address range to which the original source or&lt;br /&gt;
destination address is mapped. The value can be a single IPv4 address&lt;br /&gt;
or a range specified by two addresses, separated with the &#039;&#039;&#039;-&#039;&#039;&#039;&lt;br /&gt;
character. If not defined, it defaults to the primary address of the&lt;br /&gt;
ingress interface in case of destination NAT, or that of the egress&lt;br /&gt;
interface in case of source NAT.&lt;br /&gt;
&lt;br /&gt;
Optionally, a NAT rule can specify the TCP and UDP port range to which&lt;br /&gt;
the original source or destination port is mapped. The attribute is&lt;br /&gt;
named &#039;&#039;&#039;to-port&#039;&#039;&#039;, and the value can be a single port number or a&lt;br /&gt;
range specified by two numbers, separated with the &#039;&#039;&#039;-&#039;&#039;&#039;&lt;br /&gt;
character. If &#039;&#039;&#039;to-port&#039;&#039;&#039; is not specified, the original port number&lt;br /&gt;
is kept intact.&lt;br /&gt;
&lt;br /&gt;
NAT rules, may have an &#039;&#039;&#039;action&#039;&#039;&#039; attribute set to value&lt;br /&gt;
&#039;&#039;&#039;include&#039;&#039;&#039; or &#039;&#039;&#039;exclude&#039;&#039;&#039;. The latter means that NAT is not&lt;br /&gt;
performed on the matching packets (unless they match an &#039;&#039;&#039;include&#039;&#039;&#039;&lt;br /&gt;
rule processed earlier). The default value is &#039;&#039;&#039;include&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
==== Packet Marking Rules ====&lt;br /&gt;
&lt;br /&gt;
Packet marking rules are used to mark incoming packets matching the&lt;br /&gt;
specified criteria. The mark can be used as a basis for the routing&lt;br /&gt;
decision. Each marking rule must specify the mark using the &#039;&#039;&#039;mark&#039;&#039;&#039;&lt;br /&gt;
attribute, which is a 32-bit integer.&lt;br /&gt;
&lt;br /&gt;
Normal marking rules are contained by the top-level list attribute&lt;br /&gt;
named &#039;&#039;&#039;mark&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
There is another top-level list attribute, named &#039;&#039;&#039;route-track&#039;&#039;&#039;,&lt;br /&gt;
which contains route tracking rules. These are special marking rules&lt;br /&gt;
which cause all the subsequent packets related to the same connection&lt;br /&gt;
to be marked according to the rule.&lt;br /&gt;
&lt;br /&gt;
==== Transparent Proxy Rules ====&lt;br /&gt;
&lt;br /&gt;
Transparent proxy rules divert the matching packets to a local proxy&lt;br /&gt;
process without altering their headers. Such rules are contained in&lt;br /&gt;
the top-level list named &#039;&#039;&#039;tproxy&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
In addition to the firewall configuration, using a transparent proxy&lt;br /&gt;
requires a routing configuration where packets marked for proxying are&lt;br /&gt;
diverted to a local process. The &#039;&#039;&#039;awall_tproxy_mark&#039;&#039;&#039; variable can&lt;br /&gt;
be used to specify the mark for such packets, which defaults to 1.&lt;br /&gt;
&lt;br /&gt;
Proxy rules may also have an attribute named &#039;&#039;&#039;to-port&#039;&#039;&#039; for&lt;br /&gt;
specifying the TCP or UDP port of the proxy if it is different from&lt;br /&gt;
the original destination port.&lt;br /&gt;
&lt;br /&gt;
==== MSS Clamping Rules ====&lt;br /&gt;
&lt;br /&gt;
MSS Clamping Rules are used to deal with ISPs that block ICMP&lt;br /&gt;
Fragmentation Needed or ICMPv6 Packet Too Big packets. An MSS clamping&lt;br /&gt;
rule overwrites the MSS option with a value specified with the&lt;br /&gt;
&#039;&#039;&#039;mss&#039;&#039;&#039; attribute for the matching TCP connections. If &#039;&#039;&#039;mss&#039;&#039;&#039; is&lt;br /&gt;
not specified, a suitable value is automatically determined from the&lt;br /&gt;
path MTU. The MSS clamping rules are located in the top-level&lt;br /&gt;
dictionary named &#039;&#039;&#039;clamp-mss&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
==== Connection Tracking Bypass Rules ====&lt;br /&gt;
&lt;br /&gt;
Connection tracking bypass rules are used to disable connection&lt;br /&gt;
tracking for packets matching the specified criteria. The top-level&lt;br /&gt;
attribute &#039;&#039;&#039;no-track&#039;&#039;&#039; is a list of such rules.&lt;br /&gt;
&lt;br /&gt;
Like [[#NAT Rules|NAT rules]], connection tracking bypass rules may&lt;br /&gt;
have an &#039;&#039;&#039;action&#039;&#039;&#039; attribute set to value &#039;&#039;&#039;include&#039;&#039;&#039; or&lt;br /&gt;
&#039;&#039;&#039;exclude&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
=== IP Sets ===&lt;br /&gt;
&lt;br /&gt;
Any IP set referenced by rule objects should be created by&lt;br /&gt;
awall. Auxiliary &#039;&#039;IP set&#039;&#039; objects are used to defined them in awall&lt;br /&gt;
policy files. The top-level attribute &#039;&#039;&#039;ipset&#039;&#039;&#039; is a dictionary, the&lt;br /&gt;
keys of which are IP set names. The values are IP set objects, which&lt;br /&gt;
have two mandatory attributes. The attribute named &#039;&#039;&#039;type&#039;&#039;&#039; &lt;br /&gt;
corresponds to the type argument of the &amp;lt;tt&amp;gt;ipset create&amp;lt;/tt&amp;gt; &lt;br /&gt;
command. &#039;&#039;&#039;family&#039;&#039;&#039; specifies whether the set is for IPv4 or IPv6&lt;br /&gt;
addresses, and the possible values are &#039;&#039;&#039;inet&#039;&#039;&#039; and &#039;&#039;&#039;inet6&#039;&#039;&#039;,&lt;br /&gt;
correspondingly.&lt;br /&gt;
&lt;br /&gt;
For bitmap-type IP sets, the &#039;&#039;&#039;range&#039;&#039;&#039; attribute specifies the&lt;br /&gt;
range of allowed IPv4 addresses. It may be given as a network&lt;br /&gt;
address or two addresses separated by the &#039;&#039;&#039;-&#039;&#039;&#039; character. It&lt;br /&gt;
is not necessary to specify &#039;&#039;&#039;family&#039;&#039;&#039; for bitmaps, since the&lt;br /&gt;
kernel supports only IPv4 bitmaps.&lt;br /&gt;
&lt;br /&gt;
== Command Line Syntax ==&lt;br /&gt;
&lt;br /&gt;
=== Translating Policy Files to Firewall Configuration Files ===&lt;br /&gt;
&lt;br /&gt;
 &#039;&#039;&#039;awall translate&#039;&#039;&#039; [&#039;&#039;&#039;-o&#039;&#039;&#039;|&#039;&#039;&#039;--output&#039;&#039;&#039; DIRECTORY] [&#039;&#039;&#039;-V&#039;&#039;&#039;|&#039;&#039;&#039;--verify&#039;&#039;&#039;]&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;tt&amp;gt;--verify&amp;lt;/tt&amp;gt; option makes awall verify the configuration&lt;br /&gt;
using the test mode of iptables-restore before overwriting the old&lt;br /&gt;
files.&lt;br /&gt;
&lt;br /&gt;
Specifying the output directory allows testing awall policies without&lt;br /&gt;
overwriting the current iptables and ipset configuration files. By&lt;br /&gt;
default, awall generates the configuration to &amp;lt;tt&amp;gt;/etc/iptables&amp;lt;/tt&amp;gt; &lt;br /&gt;
and &amp;lt;tt&amp;gt;/etc/ipset.d&amp;lt;/tt&amp;gt;, which are read by the init scripts.&lt;br /&gt;
&lt;br /&gt;
=== Run-Time Configuration of Firewall ===&lt;br /&gt;
&lt;br /&gt;
 &#039;&#039;&#039;awall activate&#039;&#039;&#039; [&#039;&#039;&#039;-f&#039;&#039;&#039;|&#039;&#039;&#039;--force&#039;&#039;&#039;]&lt;br /&gt;
&lt;br /&gt;
This command genereates firewall configuration from the policy files&lt;br /&gt;
and enables it. If the user confirms the new configuration by hitting&lt;br /&gt;
the Return key within 10 seconds or the &amp;lt;tt&amp;gt;--force&amp;lt;/tt&amp;gt; option is&lt;br /&gt;
used, the configuration is saved to the files. Otherwise, the old&lt;br /&gt;
configuration is restored.&lt;br /&gt;
&lt;br /&gt;
There is also a command for deleting all firewall rules:&lt;br /&gt;
&lt;br /&gt;
 &#039;&#039;&#039;awall flush&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
This command configures the firewall to drop all packets.&lt;br /&gt;
&lt;br /&gt;
=== Optional Policies ===&lt;br /&gt;
&lt;br /&gt;
Optional policies can be enabled or disabled using this command:&lt;br /&gt;
&lt;br /&gt;
 &#039;&#039;&#039;awall&#039;&#039;&#039; {&#039;&#039;&#039;enable&#039;&#039;&#039;|&#039;&#039;&#039;disable&#039;&#039;&#039;} POLICY...&lt;br /&gt;
&lt;br /&gt;
Optional policies can be listed using this command:&lt;br /&gt;
&lt;br /&gt;
 &#039;&#039;&#039;awall list&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;&#039;enabled&#039;&#039;&#039; status means that the policy has been enabled by the&lt;br /&gt;
user. The &#039;&#039;&#039;disabled&#039;&#039;&#039; status means that the policy is not in&lt;br /&gt;
use. The &#039;&#039;&#039;required&#039;&#039;&#039; status means that the policy has not been&lt;br /&gt;
enabled by the user but is in use because it is required by another&lt;br /&gt;
policy which is in use.&lt;br /&gt;
&lt;br /&gt;
=== Debugging Policies ===&lt;br /&gt;
&lt;br /&gt;
This command can be used to dump variable, zone, and other definitions&lt;br /&gt;
as well as their source policies:&lt;br /&gt;
&lt;br /&gt;
 &#039;&#039;&#039;awall dump&#039;&#039;&#039; [LEVEL]&lt;br /&gt;
&lt;br /&gt;
The level is an integer in range 0&amp;amp;ndash;5 and defaults to 0. More&lt;br /&gt;
information is displayed on higher levels.&lt;br /&gt;
&lt;br /&gt;
[[Category:Networking]]&lt;br /&gt;
[[Category:Security]]&lt;/div&gt;</summary>
		<author><name>Kunkku</name></author>
	</entry>
	<entry>
		<id>https://wiki.alpinelinux.org/w/index.php?title=Alpine_Wall_User%27s_Guide&amp;diff=10167</id>
		<title>Alpine Wall User&#039;s Guide</title>
		<link rel="alternate" type="text/html" href="https://wiki.alpinelinux.org/w/index.php?title=Alpine_Wall_User%27s_Guide&amp;diff=10167"/>
		<updated>2014-09-29T10:43:35Z</updated>

		<summary type="html">&lt;p&gt;Kunkku: /* Filter Rules */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Configuration File Processing ==&lt;br /&gt;
&lt;br /&gt;
[[Alpine Wall]] (awall) reads its configuration from multiple&lt;br /&gt;
JSON-formatted files, called &#039;&#039;policy files&#039;&#039;. The files located in&lt;br /&gt;
directory &amp;lt;tt&amp;gt;/usr/share/awall/mandatory&amp;lt;/tt&amp;gt; are &#039;&#039;mandatory&#039;&#039;&lt;br /&gt;
policies shipped with APK packages. In addition, there can be&lt;br /&gt;
installation-specific mandatory policies in &amp;lt;tt&amp;gt;/etc/awall&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
The latter directory may also contain symbolic links to policy files&lt;br /&gt;
located in &amp;lt;tt&amp;gt;/usr/share/awall/optional&amp;lt;/tt&amp;gt; and&lt;br /&gt;
&amp;lt;tt&amp;gt;/etc/awall/optional&amp;lt;/tt&amp;gt;. These are &#039;&#039;optional&#039;&#039; policies, which&lt;br /&gt;
can be enabled on need basis. Such symbolic links are easily created&lt;br /&gt;
and destroyed using the &amp;lt;tt&amp;gt;awall enable&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;awall&lt;br /&gt;
disable&amp;lt;/tt&amp;gt; commands. &amp;lt;tt&amp;gt;awall list&amp;lt;/tt&amp;gt; shows which optional&lt;br /&gt;
policies are enabled and disabled. The command also prints the&lt;br /&gt;
description of the optional policy if defined in the file using a&lt;br /&gt;
top-level attribute named &#039;&#039;&#039;description&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Sometimes a policy file depends on other policy files. In this case,&lt;br /&gt;
the policy file must have a top-level attribute &#039;&#039;&#039;import&#039;&#039;&#039;, the&lt;br /&gt;
value of which is a list of policy names, which correspond to the file&lt;br /&gt;
names without the &amp;lt;tt&amp;gt;.json&amp;lt;/tt&amp;gt; suffix. The imported policies may be&lt;br /&gt;
either optional policies or &#039;&#039;private&#039;&#039; policies, located in&lt;br /&gt;
&amp;lt;tt&amp;gt;/usr/share/awall/private&amp;lt;/tt&amp;gt; or &amp;lt;tt&amp;gt;/etc/awall/private&amp;lt;/tt&amp;gt;. By&lt;br /&gt;
default, the policies listed there are processed before the importing&lt;br /&gt;
policy.&lt;br /&gt;
&lt;br /&gt;
The order of the generated iptables rules generally reflects the&lt;br /&gt;
processing order of their corresponding awall policies. The&lt;br /&gt;
processing order of policies can be adjusted by defining&lt;br /&gt;
top-level attributes &#039;&#039;&#039;after&#039;&#039;&#039; and &#039;&#039;&#039;before&#039;&#039;&#039; in policy&lt;br /&gt;
files. These attributes are lists of policies, after or before&lt;br /&gt;
which the declaring policy shall be processed. Putting a policy&lt;br /&gt;
name to either of these lists does not by itself import the&lt;br /&gt;
policy. The ordering directives are ignored with respect to those&lt;br /&gt;
policies that are not enabled by the user or imported by other&lt;br /&gt;
policies. If not defined, &#039;&#039;&#039;after&#039;&#039;&#039; is assumed to be equal to&lt;br /&gt;
the relative complement of the &#039;&#039;&#039;before&#039;&#039;&#039; definition in the&lt;br /&gt;
&#039;&#039;&#039;import&#039;&#039;&#039; definition of the policy.&lt;br /&gt;
&lt;br /&gt;
As the import directive does not require the path name to be&lt;br /&gt;
specified, awall expects policies to have unique names, even if&lt;br /&gt;
located in different directories. It is allowed to import optional&lt;br /&gt;
policies that are not explicitly enabled by the user. Such policies&lt;br /&gt;
show up with the &amp;lt;tt&amp;gt;required&amp;lt;/tt&amp;gt; status in the output of &amp;lt;tt&amp;gt;awall&lt;br /&gt;
list&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
== List Parameters ==&lt;br /&gt;
&lt;br /&gt;
Several awall parameters are defined as lists of values. In order to&lt;br /&gt;
facilitate manual editing of policy files, awall also accepts single&lt;br /&gt;
values in place of lists. Such values are semantically equivalent to&lt;br /&gt;
lists containing one element.&lt;br /&gt;
&lt;br /&gt;
== Variable Expansion ==&lt;br /&gt;
&lt;br /&gt;
Awall allows variable definitions in policy files. The top-level&lt;br /&gt;
attribute &#039;&#039;&#039;variable&#039;&#039;&#039; is a dictionary containing the&lt;br /&gt;
definitions. The value of a variable can be of any type (string,&lt;br /&gt;
integer, list, or dictionary).&lt;br /&gt;
&lt;br /&gt;
A variable is referenced in policy files by a string which equals the&lt;br /&gt;
variable name prepended with the &#039;&#039;&#039;$&#039;&#039;&#039; character. If the value of&lt;br /&gt;
the variable is a string, the reference can be embedded into a longer&lt;br /&gt;
string in order to substitute some part of that string (in shell&lt;br /&gt;
style). Variable references can be used when defining other variables,&lt;br /&gt;
as long as the definitions are not circular.&lt;br /&gt;
&lt;br /&gt;
Policy files can reference variables defined in other policy&lt;br /&gt;
files. Policy files can also override variables defined elsewhere by&lt;br /&gt;
redefining them. In this case, the new definition affects all policy&lt;br /&gt;
files, also those processed before the overriding policy. Awall&lt;br /&gt;
variables are in fact simple macros, since each variable remains&lt;br /&gt;
constant thoughout a single processing round. If multiple files define&lt;br /&gt;
the same variable, the definition in the file processed last takes&lt;br /&gt;
effect.&lt;br /&gt;
&lt;br /&gt;
If defined as an empty string, all non-embedded references to a&lt;br /&gt;
variable evaluate as if the attribute in question was not present in&lt;br /&gt;
the configuration. This is also the case when a string containing&lt;br /&gt;
embedded variable references finally evaluates to an empty string.&lt;br /&gt;
&lt;br /&gt;
== Configuration Objects ==&lt;br /&gt;
&lt;br /&gt;
Configuration objects can be divided into two main types.&lt;br /&gt;
&#039;&#039;Auxiliary objects&#039;&#039; model high-level concepts such as services and&lt;br /&gt;
zones. &#039;&#039;Rule objects&#039;&#039; translate into one or more iptables rules, and&lt;br /&gt;
are often defined with the help of some auxiliary objects.&lt;br /&gt;
&lt;br /&gt;
=== Services ===&lt;br /&gt;
&lt;br /&gt;
A &#039;&#039;service&#039;&#039; represents a set of network protocols. A top-level&lt;br /&gt;
attribute &#039;&#039;&#039;service&#039;&#039;&#039; is a dictionary that maps service names to&lt;br /&gt;
service definition objects, or lists thereof in more complex cases.&lt;br /&gt;
&lt;br /&gt;
A service definition object contains an attribute named&lt;br /&gt;
&#039;&#039;&#039;proto&#039;&#039;&#039;, which corresponds to the &amp;lt;tt&amp;gt;--protocol&amp;lt;/tt&amp;gt; option&lt;br /&gt;
of iptables. The protocol can be defined as a numerical value or&lt;br /&gt;
string as defined in &amp;lt;tt&amp;gt;/etc/protocols&amp;lt;/tt&amp;gt;. If the protocol is&lt;br /&gt;
&#039;&#039;&#039;tcp&#039;&#039;&#039; or &#039;&#039;&#039;udp&#039;&#039;&#039;, the scope of the service definition may&lt;br /&gt;
be constrained by defining an attribute named &#039;&#039;&#039;port&#039;&#039;&#039;, which&lt;br /&gt;
is a list of TCP or UDP port numbers or ranges thereof, separated&lt;br /&gt;
by the &#039;&#039;&#039;-&#039;&#039;&#039; character. If the protocol is &#039;&#039;&#039;icmp&#039;&#039;&#039; or&lt;br /&gt;
&#039;&#039;&#039;icmpv6&#039;&#039;&#039;, an analogous &#039;&#039;&#039;type&#039;&#039;&#039; attribute may be used. The&lt;br /&gt;
replies to ICMP messages have their own type codes, which may be&lt;br /&gt;
specified using the &#039;&#039;&#039;reply-type&#039;&#039;&#039; attribute.&lt;br /&gt;
&lt;br /&gt;
If the protocol is &#039;&#039;&#039;icmp&#039;&#039;&#039; or &#039;&#039;&#039;icmpv6&#039;&#039;&#039;, the scope of the&lt;br /&gt;
rule is also automatically limited to IPv4 or IPv6,&lt;br /&gt;
respectively. There are also other services which are specific to&lt;br /&gt;
IPv4 or IPv6. To constrain the scope of the service definition to&lt;br /&gt;
either protocol version, an optional &#039;&#039;&#039;family&#039;&#039;&#039; attribute can&lt;br /&gt;
be set to value &#039;&#039;&#039;inet&#039;&#039;&#039; or &#039;&#039;&#039;inet6&#039;&#039;&#039;, respectively.&lt;br /&gt;
&lt;br /&gt;
Some services require the server or client to open additional&lt;br /&gt;
connections to dynamically allocated ports or even different&lt;br /&gt;
hosts. &#039;&#039;Connection tracking helpers&#039;&#039; are used to make the firewall&lt;br /&gt;
aware of such additional connections. The &#039;&#039;&#039;ct-helper&#039;&#039;&#039; attribute is&lt;br /&gt;
used to associate such a helper to a service definition when&lt;br /&gt;
required by the service.&lt;br /&gt;
&lt;br /&gt;
All rule objects, except for policies, may have an attribute named&lt;br /&gt;
&#039;&#039;&#039;service&#039;&#039;&#039;, constraining the rule&#039;s scope to specific services&lt;br /&gt;
only. This attribute is a list of service names, referring to the keys&lt;br /&gt;
of the top-level service dictionary.&lt;br /&gt;
&lt;br /&gt;
=== Zones ===&lt;br /&gt;
&lt;br /&gt;
A &#039;&#039;zone&#039;&#039; represents a set of network hosts. A top-level attribute &lt;br /&gt;
&#039;&#039;&#039;zone&#039;&#039;&#039; is a dictionary that maps zone names to zone objects. A&lt;br /&gt;
zone object has an attribute named &#039;&#039;&#039;iface&#039;&#039;&#039;, &#039;&#039;&#039;addr&#039;&#039;&#039;, or&lt;br /&gt;
both. &#039;&#039;&#039;iface&#039;&#039;&#039; is a list of network interfaces and &#039;&#039;&#039;addr&#039;&#039;&#039; is a&lt;br /&gt;
list of IPv4/IPv6 host and network addresses (CIDR&lt;br /&gt;
notation). &#039;&#039;&#039;addr&#039;&#039;&#039; may also contain domain names, which are&lt;br /&gt;
expanded to IP addresses using DNS resolution. If not defined,&lt;br /&gt;
&#039;&#039;&#039;addr&#039;&#039;&#039; defaults to the entire address space and &#039;&#039;&#039;iface&#039;&#039;&#039; to all&lt;br /&gt;
interfaces. An empty zone can be defined by setting either &#039;&#039;&#039;addr&#039;&#039;&#039;&lt;br /&gt;
or &#039;&#039;&#039;iface&#039;&#039;&#039; to an empty list.&lt;br /&gt;
&lt;br /&gt;
Rule objects contain two attributes, &#039;&#039;&#039;in&#039;&#039;&#039; and &#039;&#039;&#039;out&#039;&#039;&#039;, which are&lt;br /&gt;
lists of zone names. These attributes control whether a packet matches&lt;br /&gt;
the rule or not. If a particular zone is referenced by the &#039;&#039;&#039;in&#039;&#039;&#039; &lt;br /&gt;
attribute, the rule applies to packets whose ingress interface and&lt;br /&gt;
source address are covered by the zone definition. Correspondingly, if&lt;br /&gt;
a zone is referenced by the &#039;&#039;&#039;out&#039;&#039;&#039; attribute, the rule applies to&lt;br /&gt;
packets whose egress interface and destination address are included in&lt;br /&gt;
the zone. If both &#039;&#039;&#039;in&#039;&#039;&#039; and &#039;&#039;&#039;out&#039;&#039;&#039; are defined, the packet must&lt;br /&gt;
fulfill both criteria in order to match the rule.&lt;br /&gt;
&lt;br /&gt;
The firewall host itself can be referred to using the special value&lt;br /&gt;
&#039;&#039;&#039;_fw&#039;&#039;&#039; as the zone name.&lt;br /&gt;
&lt;br /&gt;
By default, awall does not generate iptables rules with identical&lt;br /&gt;
ingress and egress interfaces. This behavior can be changed per zone&lt;br /&gt;
by setting the optional &#039;&#039;&#039;route-back&#039;&#039;&#039; attribute of the zone to&lt;br /&gt;
&#039;&#039;&#039;true&#039;&#039;&#039;. Note that this attribute can have an effect also in the&lt;br /&gt;
case where &#039;&#039;&#039;in&#039;&#039;&#039; and &#039;&#039;&#039;out&#039;&#039;&#039; attributes of a rule are not equal&lt;br /&gt;
but their definitions overlap. In this case, the &#039;&#039;&#039;route-back&#039;&#039;&#039;&lt;br /&gt;
attribute of the &#039;&#039;&#039;out&#039;&#039;&#039; zone determines the behavior.&lt;br /&gt;
&lt;br /&gt;
=== Limits ===&lt;br /&gt;
&lt;br /&gt;
A &#039;&#039;limit&#039;&#039; specifies the maximum rate for a flow of packets or new&lt;br /&gt;
connections. Unlike the other auxiliary objects, limits are not named&lt;br /&gt;
members of a top-level dictionary but are embedded into other objects.&lt;br /&gt;
&lt;br /&gt;
In its simplest form, a limit definition is an integer specifying the&lt;br /&gt;
maximum number of packets or connections per second. More complex&lt;br /&gt;
limits are defined as objects, where the &#039;&#039;&#039;count&#039;&#039;&#039; attribute define&lt;br /&gt;
the maximum during an interval defined by the &#039;&#039;&#039;interval&#039;&#039;&#039;&lt;br /&gt;
attribute. The unit of the &#039;&#039;&#039;interval&#039;&#039;&#039; attribute is second, and&lt;br /&gt;
the default value is 1.&lt;br /&gt;
&lt;br /&gt;
The maximum rate defined by a limit may be absolute or specific to&lt;br /&gt;
blocks of IP addresses or pairs thereof. The number of most&lt;br /&gt;
significant bits taken into account when mapping the source and&lt;br /&gt;
destination IP addresses to blocks can be specified with the&lt;br /&gt;
&#039;&#039;&#039;mask&#039;&#039;&#039; attribute. The &#039;&#039;&#039;mask&#039;&#039;&#039; attribute is an object with two&lt;br /&gt;
attributes defining the prefix lengths, named &#039;&#039;&#039;src&#039;&#039;&#039; and&lt;br /&gt;
&#039;&#039;&#039;dest&#039;&#039;&#039;. Alternatively, the &#039;&#039;&#039;mask&#039;&#039;&#039; object may have object&lt;br /&gt;
attributes named &#039;&#039;&#039;inet&#039;&#039;&#039; and &#039;&#039;&#039;inet6&#039;&#039;&#039; which contain address&lt;br /&gt;
family&amp;amp;ndash;specific prefix length pairs. If &#039;&#039;&#039;mask&#039;&#039;&#039; is defined as&lt;br /&gt;
an integer, it is interpreted as the source address prefix length.&lt;br /&gt;
&lt;br /&gt;
The default value for &#039;&#039;&#039;mask&#039;&#039;&#039; depends on the type of the enclosing&lt;br /&gt;
object. For [[#Filter Rules|filters]], the default behavior is to&lt;br /&gt;
apply the limit for each source address separately. For&lt;br /&gt;
[[#Logging Classes|logging classes]], the limit is considered absolute&lt;br /&gt;
by default.&lt;br /&gt;
&lt;br /&gt;
=== Logging Classes ===&lt;br /&gt;
&lt;br /&gt;
A &#039;&#039;logging class&#039;&#039; specifies how packets matching certain rules are&lt;br /&gt;
logged. A top-level attribute &#039;&#039;&#039;log&#039;&#039;&#039; is a dictionary that maps&lt;br /&gt;
logging class names to setting objects.&lt;br /&gt;
&lt;br /&gt;
A setting object may have an attribute named &#039;&#039;&#039;mode&#039;&#039;&#039;, which&lt;br /&gt;
specifies which logging facility to use. Allowed values are &#039;&#039;&#039;log&#039;&#039;&#039;,&lt;br /&gt;
&#039;&#039;&#039;nflog&#039;&#039;&#039;, and &#039;&#039;&#039;ulog&#039;&#039;&#039;. The default is &#039;&#039;&#039;log&#039;&#039;&#039;, i.e. in-kernel&lt;br /&gt;
logging.&lt;br /&gt;
&lt;br /&gt;
The following table shows the optional attributes valid for all&lt;br /&gt;
logging modes:&lt;br /&gt;
&lt;br /&gt;
{|&lt;br /&gt;
!Attribute!!Description&lt;br /&gt;
|-&lt;br /&gt;
|&#039;&#039;&#039;every&#039;&#039;&#039;&lt;br /&gt;
|Divide successive packets into groups, the size of which is specified by the value of this attribute, and log only the first packet of each group&lt;br /&gt;
|-&lt;br /&gt;
|&#039;&#039;&#039;limit&#039;&#039;&#039;&lt;br /&gt;
|Maximum number of packets to be logged defined as [[#Limits|limit]]&lt;br /&gt;
|-&lt;br /&gt;
|&#039;&#039;&#039;prefix&#039;&#039;&#039;&lt;br /&gt;
|String with which the log entries are prefixed&lt;br /&gt;
|-&lt;br /&gt;
|&#039;&#039;&#039;probability&#039;&#039;&#039;&lt;br /&gt;
|Probability for logging an individual packet (default: 1)&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
With the in-kernel log mode &#039;&#039;&#039;log&#039;&#039;&#039;, the level of logging may be&lt;br /&gt;
specified using the &#039;&#039;&#039;level&#039;&#039;&#039; attribute. Log modes &#039;&#039;&#039;nflog&#039;&#039;&#039; and&lt;br /&gt;
&#039;&#039;&#039;ulog&#039;&#039;&#039; are about copying the packets into user space, at least&lt;br /&gt;
partially. The following table shows the additional attributes valid&lt;br /&gt;
with these modes:&lt;br /&gt;
&lt;br /&gt;
{|&lt;br /&gt;
!Attribute!!Description&lt;br /&gt;
|-&lt;br /&gt;
|&#039;&#039;&#039;group&#039;&#039;&#039;&lt;br /&gt;
|Netlink group to be used&lt;br /&gt;
|-&lt;br /&gt;
|&#039;&#039;&#039;range&#039;&#039;&#039;&lt;br /&gt;
|Number of bytes to be copied&lt;br /&gt;
|-&lt;br /&gt;
|&#039;&#039;&#039;threshold&#039;&#039;&#039;&lt;br /&gt;
|Number of packets to queue inside the kernel before copying them&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
[[#Filter Rules|Filter]] and [[#Policy Rules|policy]] rules can have&lt;br /&gt;
an attribute named &#039;&#039;&#039;log&#039;&#039;&#039;. If it is a string, it is interpreted as&lt;br /&gt;
a reference to a logging class, and logging is performed according to&lt;br /&gt;
the definitions. If the value of the &#039;&#039;&#039;log&#039;&#039;&#039; attribute is &#039;&#039;&#039;true&#039;&#039;&#039;&lt;br /&gt;
(boolean), logging is done using default settings. If the value is&lt;br /&gt;
&#039;&#039;&#039;false&#039;&#039;&#039; (boolean), logging is disabled for the rule. If &#039;&#039;&#039;log&#039;&#039;&#039;&lt;br /&gt;
is not defined, logging is done using the default settings except for&lt;br /&gt;
accept rules, for which logging is omitted.&lt;br /&gt;
&lt;br /&gt;
Default logging settings can be set by defining a logging class named&lt;br /&gt;
&#039;&#039;&#039;_default&#039;&#039;&#039;. Normally, default logging uses the &#039;&#039;&#039;log&#039;&#039;&#039; mode with&lt;br /&gt;
packets limited to one per second.&lt;br /&gt;
&lt;br /&gt;
=== Rules ===&lt;br /&gt;
&lt;br /&gt;
There are several types of rule objects:&lt;br /&gt;
* Filter rules&lt;br /&gt;
* Policy rules&lt;br /&gt;
* Packet Logging rules&lt;br /&gt;
* NAT rules&lt;br /&gt;
* Packet Marking rules&lt;br /&gt;
* Transparent Proxy rules&lt;br /&gt;
* MSS Clamping rules&lt;br /&gt;
* Connection Tracking Bypass rules&lt;br /&gt;
&lt;br /&gt;
All rule objects can have the &#039;&#039;&#039;in&#039;&#039;&#039; and &#039;&#039;&#039;out&#039;&#039;&#039; attributes&lt;br /&gt;
referring to [[#Zones|zones]] as described in the previous section. In&lt;br /&gt;
addition, the scope of the rule can be further constrained with the&lt;br /&gt;
following attributes:&lt;br /&gt;
&lt;br /&gt;
{|&lt;br /&gt;
!Attribute!!Value format!!Effect&lt;br /&gt;
|-&lt;br /&gt;
|&#039;&#039;&#039;src&#039;&#039;&#039;&lt;br /&gt;
|Similar to &#039;&#039;&#039;addr&#039;&#039;&#039; attribute of [[#Zones|zone objects]]&lt;br /&gt;
|Packet&#039;s source address matches the value&lt;br /&gt;
|-&lt;br /&gt;
|&#039;&#039;&#039;dest&#039;&#039;&#039;&lt;br /&gt;
|Similar to &#039;&#039;&#039;addr&#039;&#039;&#039; attribute of [[#Zones|zone objects]]&lt;br /&gt;
|Packet&#039;s destination address matches the value&lt;br /&gt;
|-&lt;br /&gt;
|&#039;&#039;&#039;ipset&#039;&#039;&#039;&lt;br /&gt;
|Object containing two attributes: &#039;&#039;&#039;name&#039;&#039;&#039; referring to an [[#IP Sets|IP set]] and &#039;&#039;&#039;args&#039;&#039;&#039;, which is a list of strings &#039;&#039;&#039;in&#039;&#039;&#039; and &#039;&#039;&#039;out&#039;&#039;&#039;&lt;br /&gt;
|Packet matches the IP set referred here when the match arguments are taken from the source (&#039;&#039;&#039;in&#039;&#039;&#039;) and destination (&#039;&#039;&#039;out&#039;&#039;&#039;) address or port in the order specified by &#039;&#039;&#039;args&#039;&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
|&#039;&#039;&#039;ipsec&#039;&#039;&#039;&lt;br /&gt;
|&#039;&#039;&#039;in&#039;&#039;&#039; or &#039;&#039;&#039;out&#039;&#039;&#039;&lt;br /&gt;
|IPsec decapsulation perfomed on ingress (&#039;&#039;&#039;in&#039;&#039;&#039;) or encapsulation performed on egress (&#039;&#039;&#039;out&#039;&#039;&#039;)&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Rule objects are declared in type-specific top-level dictionaries in&lt;br /&gt;
awall policy files. If a packet matches multiple rules, the one&lt;br /&gt;
appearing earlier in the list takes precedence. If the matching rules&lt;br /&gt;
are defined in different policy files, the one that was processed&lt;br /&gt;
earlier takes precedence in the current implementation, but this may&lt;br /&gt;
change in future versions.&lt;br /&gt;
&lt;br /&gt;
==== Filter Rules ====&lt;br /&gt;
&lt;br /&gt;
Filter objects specify an action for packets fulfilling certain&lt;br /&gt;
criteria. The top-level attribute &#039;&#039;&#039;filter&#039;&#039;&#039; is a list of filter&lt;br /&gt;
objects.&lt;br /&gt;
&lt;br /&gt;
Filter objects must have an attribute named &#039;&#039;&#039;action&#039;&#039;&#039;, the value of&lt;br /&gt;
which can be one of the following:&lt;br /&gt;
&lt;br /&gt;
{|&lt;br /&gt;
!Value!!Action&lt;br /&gt;
|-&lt;br /&gt;
|&#039;&#039;&#039;accept&#039;&#039;&#039;&lt;br /&gt;
|Accept the packet (default)&lt;br /&gt;
|-&lt;br /&gt;
|&#039;&#039;&#039;reject&#039;&#039;&#039;&lt;br /&gt;
|Reject the packet with an ICMP error message&lt;br /&gt;
|-&lt;br /&gt;
|&#039;&#039;&#039;drop&#039;&#039;&#039;&lt;br /&gt;
|Silently drop the packet&lt;br /&gt;
|-&lt;br /&gt;
|&#039;&#039;&#039;tarpit&#039;&#039;&#039;&lt;br /&gt;
|Put incoming TCP connections into persist state and ignore attempts to close them. Silently drop non-TCP packets. (Connection tracking bypass is automatically enabled for the matching packets.)&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Filter objects, the action of which is &#039;&#039;&#039;accept&#039;&#039;&#039;, may also contain&lt;br /&gt;
limits for packet flow or new connections. These are specified with&lt;br /&gt;
the &#039;&#039;&#039;flow-limit&#039;&#039;&#039; and &#039;&#039;&#039;conn-limit&#039;&#039;&#039; attributes,&lt;br /&gt;
respectively. The values of these attributes are&lt;br /&gt;
[[#Limits|limit objects]]. The &#039;&#039;&#039;drop&#039;&#039;&#039; action is applied to the&lt;br /&gt;
packets exceeding the limit. Optionally, the limit object may have an&lt;br /&gt;
attribute named &#039;&#039;&#039;log&#039;&#039;&#039;. It defines how the dropped packets should&lt;br /&gt;
be logged and is semantically similar to the &#039;&#039;&#039;log&#039;&#039;&#039; attribute of&lt;br /&gt;
rule objects.&lt;br /&gt;
&lt;br /&gt;
Filter objects may have an attribute named &#039;&#039;&#039;dnat&#039;&#039;&#039;, the value&lt;br /&gt;
of which is an IPv4 address. If defined, this enables destination&lt;br /&gt;
NAT for all IPv4 packets matching the rule, such that the&lt;br /&gt;
specified address replaces the original destination address. If&lt;br /&gt;
also port translation is desired, the attribute may be defined as&lt;br /&gt;
an object consisting of attributes &#039;&#039;&#039;addr&#039;&#039;&#039; and &#039;&#039;&#039;port&#039;&#039;&#039;.&lt;br /&gt;
This option has no effect on IPv6 packets.&lt;br /&gt;
&lt;br /&gt;
Filter objects may have a boolean attribute named &#039;&#039;&#039;no-track&#039;&#039;&#039;. If&lt;br /&gt;
set to &#039;&#039;&#039;true&#039;&#039;&#039;, connection tracking is bypassed for the matching&lt;br /&gt;
packets. In addition, if &#039;&#039;&#039;action&#039;&#039;&#039; is set to &#039;&#039;&#039;accept&#039;&#039;&#039;, the&lt;br /&gt;
corresponding packets travelling to the reverse direction are also&lt;br /&gt;
allowed.&lt;br /&gt;
&lt;br /&gt;
If one or more connection tracking helpers are associated with the&lt;br /&gt;
services referred to by an accept rule, additional iptables rules are&lt;br /&gt;
generated for the related connections detected by the helpers. The&lt;br /&gt;
&#039;&#039;&#039;related&#039;&#039;&#039; attribute can be used to override the default rules&lt;br /&gt;
generated by awall. It is a list of basic rule objects, the packets&lt;br /&gt;
matching to which are accepted, provided that they are also detected&lt;br /&gt;
by at least one of the helpers.&lt;br /&gt;
&lt;br /&gt;
==== Policy Rules ====&lt;br /&gt;
&lt;br /&gt;
Policy objects describe the default action for packets that did not&lt;br /&gt;
match any filter. The top-level attribute &#039;&#039;&#039;policy&#039;&#039;&#039; is a list of&lt;br /&gt;
policy objects.&lt;br /&gt;
&lt;br /&gt;
Policy objects must have the &#039;&#039;&#039;action&#039;&#039;&#039; attribute defined. The&lt;br /&gt;
possible values and their semantics are the same as in&lt;br /&gt;
[[#Filter Rules|filter rules]].&lt;br /&gt;
&lt;br /&gt;
==== Packet Logging Rules ====&lt;br /&gt;
&lt;br /&gt;
Packet logging rules allow packets matching the specified criteria to&lt;br /&gt;
be logged before any filtering takes place. Such rules are contained&lt;br /&gt;
in the top-level list named &#039;&#039;&#039;packet-log&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Logging class may be specified using the &#039;&#039;&#039;log&#039;&#039;&#039;&lt;br /&gt;
attribute. Otherwise, default logging settings are used.&lt;br /&gt;
&lt;br /&gt;
==== NAT Rules ====&lt;br /&gt;
&lt;br /&gt;
NAT rules come in two flavors: &#039;&#039;source NAT rules&#039;&#039; and&lt;br /&gt;
&#039;&#039;destination NAT rules&#039;&#039;. These are contained in two top-level lists&lt;br /&gt;
named &#039;&#039;&#039;snat&#039;&#039;&#039; and &#039;&#039;&#039;dnat&#039;&#039;&#039;, respectively.&lt;br /&gt;
&lt;br /&gt;
Each NAT rule may have an attribute named &#039;&#039;&#039;to-addr&#039;&#039;&#039; that&lt;br /&gt;
specifies the IPv4 address range to which the original source or&lt;br /&gt;
destination address is mapped. The value can be a single IPv4 address&lt;br /&gt;
or a range specified by two addresses, separated with the &#039;&#039;&#039;-&#039;&#039;&#039;&lt;br /&gt;
character. If not defined, it defaults to the primary address of the&lt;br /&gt;
ingress interface in case of destination NAT, or that of the egress&lt;br /&gt;
interface in case of source NAT.&lt;br /&gt;
&lt;br /&gt;
Optionally, a NAT rule can specify the TCP and UDP port range to which&lt;br /&gt;
the original source or destination port is mapped. The attribute is&lt;br /&gt;
named &#039;&#039;&#039;to-port&#039;&#039;&#039;, and the value can be a single port number or a&lt;br /&gt;
range specified by two numbers, separated with the &#039;&#039;&#039;-&#039;&#039;&#039;&lt;br /&gt;
character. If &#039;&#039;&#039;to-port&#039;&#039;&#039; is not specified, the original port number&lt;br /&gt;
is kept intact.&lt;br /&gt;
&lt;br /&gt;
NAT rules, may have an &#039;&#039;&#039;action&#039;&#039;&#039; attribute set to value&lt;br /&gt;
&#039;&#039;&#039;include&#039;&#039;&#039; or &#039;&#039;&#039;exclude&#039;&#039;&#039;. The latter means that NAT is not&lt;br /&gt;
performed on the matching packets (unless they match an &#039;&#039;&#039;include&#039;&#039;&#039;&lt;br /&gt;
rule processed earlier). The default value is &#039;&#039;&#039;include&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
==== Packet Marking Rules ====&lt;br /&gt;
&lt;br /&gt;
Packet marking rules are used to mark incoming packets matching the&lt;br /&gt;
specified criteria. The mark can be used as a basis for the routing&lt;br /&gt;
decision. Each marking rule must specify the mark using the &#039;&#039;&#039;mark&#039;&#039;&#039;&lt;br /&gt;
attribute, which is a 32-bit integer.&lt;br /&gt;
&lt;br /&gt;
Normal marking rules are contained by the top-level list attribute&lt;br /&gt;
named &#039;&#039;&#039;mark&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
There is another top-level list attribute, named &#039;&#039;&#039;route-track&#039;&#039;&#039;,&lt;br /&gt;
which contains route tracking rules. These are special marking rules&lt;br /&gt;
which cause all the subsequent packets related to the same connection&lt;br /&gt;
to be marked according to the rule.&lt;br /&gt;
&lt;br /&gt;
==== Transparent Proxy Rules ====&lt;br /&gt;
&lt;br /&gt;
Transparent proxy rules divert the matching packets to a local proxy&lt;br /&gt;
process without altering their headers. Such rules are contained in&lt;br /&gt;
the top-level list named &#039;&#039;&#039;tproxy&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
In addition to the firewall configuration, using a transparent proxy&lt;br /&gt;
requires a routing configuration where packets marked for proxying are&lt;br /&gt;
diverted to a local process. The &#039;&#039;&#039;awall_tproxy_mark&#039;&#039;&#039; variable can&lt;br /&gt;
be used to specify the mark for such packets, which defaults to 1.&lt;br /&gt;
&lt;br /&gt;
Proxy rules may also have an attribute named &#039;&#039;&#039;to-port&#039;&#039;&#039; for&lt;br /&gt;
specifying the TCP or UDP port of the proxy if it is different from&lt;br /&gt;
the original destination port.&lt;br /&gt;
&lt;br /&gt;
==== MSS Clamping Rules ====&lt;br /&gt;
&lt;br /&gt;
MSS Clamping Rules are used to deal with ISPs that block ICMP&lt;br /&gt;
Fragmentation Needed or ICMPv6 Packet Too Big packets. An MSS clamping&lt;br /&gt;
rule overwrites the MSS option with a value specified with the&lt;br /&gt;
&#039;&#039;&#039;mss&#039;&#039;&#039; attribute for the matching TCP connections. If &#039;&#039;&#039;mss&#039;&#039;&#039; is&lt;br /&gt;
not specified, a suitable value is automatically determined from the&lt;br /&gt;
path MTU. The MSS clamping rules are located in the top-level&lt;br /&gt;
dictionary named &#039;&#039;&#039;clamp-mss&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
==== Connection Tracking Bypass Rules ====&lt;br /&gt;
&lt;br /&gt;
Connection tracking bypass rules are used to disable connection&lt;br /&gt;
tracking for packets matching the specified criteria. The top-level&lt;br /&gt;
attribute &#039;&#039;&#039;no-track&#039;&#039;&#039; is a list of such rules.&lt;br /&gt;
&lt;br /&gt;
Like [[#NAT Rules|NAT rules]], connection tracking bypass rules may&lt;br /&gt;
have an &#039;&#039;&#039;action&#039;&#039;&#039; attribute set to value &#039;&#039;&#039;include&#039;&#039;&#039; or&lt;br /&gt;
&#039;&#039;&#039;exclude&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
=== IP Sets ===&lt;br /&gt;
&lt;br /&gt;
Any IP set referenced by rule objects should be created by&lt;br /&gt;
awall. Auxiliary &#039;&#039;IP set&#039;&#039; objects are used to defined them in awall&lt;br /&gt;
policy files. The top-level attribute &#039;&#039;&#039;ipset&#039;&#039;&#039; is a dictionary, the&lt;br /&gt;
keys of which are IP set names. The values are IP set objects, which&lt;br /&gt;
have two mandatory attributes. The attribute named &#039;&#039;&#039;type&#039;&#039;&#039; &lt;br /&gt;
corresponds to the type argument of the &amp;lt;tt&amp;gt;ipset create&amp;lt;/tt&amp;gt; &lt;br /&gt;
command. &#039;&#039;&#039;family&#039;&#039;&#039; specifies whether the set is for IPv4 or IPv6&lt;br /&gt;
addresses, and the possible values are &#039;&#039;&#039;inet&#039;&#039;&#039; and &#039;&#039;&#039;inet6&#039;&#039;&#039;,&lt;br /&gt;
correspondingly.&lt;br /&gt;
&lt;br /&gt;
For bitmap-type IP sets, the &#039;&#039;&#039;range&#039;&#039;&#039; attribute specifies the&lt;br /&gt;
range of allowed IPv4 addresses. It may be given as a network&lt;br /&gt;
address or two addresses separated by the &#039;&#039;&#039;-&#039;&#039;&#039; character. It&lt;br /&gt;
is not necessary to specify &#039;&#039;&#039;family&#039;&#039;&#039; for bitmaps, since the&lt;br /&gt;
kernel supports only IPv4 bitmaps.&lt;br /&gt;
&lt;br /&gt;
== Command Line Syntax ==&lt;br /&gt;
&lt;br /&gt;
=== Translating Policy Files to Firewall Configuration Files ===&lt;br /&gt;
&lt;br /&gt;
 &#039;&#039;&#039;awall translate&#039;&#039;&#039; [&#039;&#039;&#039;-o&#039;&#039;&#039;|&#039;&#039;&#039;--output&#039;&#039;&#039; DIRECTORY] [&#039;&#039;&#039;-V&#039;&#039;&#039;|&#039;&#039;&#039;--verify&#039;&#039;&#039;]&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;tt&amp;gt;--verify&amp;lt;/tt&amp;gt; option makes awall verify the configuration&lt;br /&gt;
using the test mode of iptables-restore before overwriting the old&lt;br /&gt;
files.&lt;br /&gt;
&lt;br /&gt;
Specifying the output directory allows testing awall policies without&lt;br /&gt;
overwriting the current iptables and ipset configuration files. By&lt;br /&gt;
default, awall generates the configuration to &amp;lt;tt&amp;gt;/etc/iptables&amp;lt;/tt&amp;gt; &lt;br /&gt;
and &amp;lt;tt&amp;gt;/etc/ipset.d&amp;lt;/tt&amp;gt;, which are read by the init scripts.&lt;br /&gt;
&lt;br /&gt;
=== Run-Time Configuration of Firewall ===&lt;br /&gt;
&lt;br /&gt;
 &#039;&#039;&#039;awall activate&#039;&#039;&#039; [&#039;&#039;&#039;-f&#039;&#039;&#039;|&#039;&#039;&#039;--force&#039;&#039;&#039;]&lt;br /&gt;
&lt;br /&gt;
This command genereates firewall configuration from the policy files&lt;br /&gt;
and enables it. If the user confirms the new configuration by hitting&lt;br /&gt;
the Return key within 10 seconds or the &amp;lt;tt&amp;gt;--force&amp;lt;/tt&amp;gt; option is&lt;br /&gt;
used, the configuration is saved to the files. Otherwise, the old&lt;br /&gt;
configuration is restored.&lt;br /&gt;
&lt;br /&gt;
There is also a command for deleting all firewall rules:&lt;br /&gt;
&lt;br /&gt;
 &#039;&#039;&#039;awall flush&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
This command configures the firewall to drop all packets.&lt;br /&gt;
&lt;br /&gt;
=== Optional Policies ===&lt;br /&gt;
&lt;br /&gt;
Optional policies can be enabled or disabled using this command:&lt;br /&gt;
&lt;br /&gt;
 &#039;&#039;&#039;awall&#039;&#039;&#039; {&#039;&#039;&#039;enable&#039;&#039;&#039;|&#039;&#039;&#039;disable&#039;&#039;&#039;} POLICY...&lt;br /&gt;
&lt;br /&gt;
Optional policies can be listed using this command:&lt;br /&gt;
&lt;br /&gt;
 &#039;&#039;&#039;awall list&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;&#039;enabled&#039;&#039;&#039; status means that the policy has been enabled by the&lt;br /&gt;
user. The &#039;&#039;&#039;disabled&#039;&#039;&#039; status means that the policy is not in&lt;br /&gt;
use. The &#039;&#039;&#039;required&#039;&#039;&#039; status means that the policy has not been&lt;br /&gt;
enabled by the user but is in use because it is required by another&lt;br /&gt;
policy which is in use.&lt;br /&gt;
&lt;br /&gt;
=== Debugging Policies ===&lt;br /&gt;
&lt;br /&gt;
This command can be used to dump variable, zone, and other definitions&lt;br /&gt;
as well as their source policies:&lt;br /&gt;
&lt;br /&gt;
 &#039;&#039;&#039;awall dump&#039;&#039;&#039; [LEVEL]&lt;br /&gt;
&lt;br /&gt;
The level is an integer in range 0&amp;amp;ndash;5 and defaults to 0. More&lt;br /&gt;
information is displayed on higher levels.&lt;br /&gt;
&lt;br /&gt;
[[Category:Networking]]&lt;br /&gt;
[[Category:Security]]&lt;/div&gt;</summary>
		<author><name>Kunkku</name></author>
	</entry>
	<entry>
		<id>https://wiki.alpinelinux.org/w/index.php?title=Alpine_Wall_User%27s_Guide&amp;diff=10158</id>
		<title>Alpine Wall User&#039;s Guide</title>
		<link rel="alternate" type="text/html" href="https://wiki.alpinelinux.org/w/index.php?title=Alpine_Wall_User%27s_Guide&amp;diff=10158"/>
		<updated>2014-09-19T08:55:24Z</updated>

		<summary type="html">&lt;p&gt;Kunkku: /* Configuration Objects */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Configuration File Processing ==&lt;br /&gt;
&lt;br /&gt;
[[Alpine Wall]] (awall) reads its configuration from multiple&lt;br /&gt;
JSON-formatted files, called &#039;&#039;policy files&#039;&#039;. The files located in&lt;br /&gt;
directory &amp;lt;tt&amp;gt;/usr/share/awall/mandatory&amp;lt;/tt&amp;gt; are &#039;&#039;mandatory&#039;&#039;&lt;br /&gt;
policies shipped with APK packages. In addition, there can be&lt;br /&gt;
installation-specific mandatory policies in &amp;lt;tt&amp;gt;/etc/awall&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
The latter directory may also contain symbolic links to policy files&lt;br /&gt;
located in &amp;lt;tt&amp;gt;/usr/share/awall/optional&amp;lt;/tt&amp;gt; and&lt;br /&gt;
&amp;lt;tt&amp;gt;/etc/awall/optional&amp;lt;/tt&amp;gt;. These are &#039;&#039;optional&#039;&#039; policies, which&lt;br /&gt;
can be enabled on need basis. Such symbolic links are easily created&lt;br /&gt;
and destroyed using the &amp;lt;tt&amp;gt;awall enable&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;awall&lt;br /&gt;
disable&amp;lt;/tt&amp;gt; commands. &amp;lt;tt&amp;gt;awall list&amp;lt;/tt&amp;gt; shows which optional&lt;br /&gt;
policies are enabled and disabled. The command also prints the&lt;br /&gt;
description of the optional policy if defined in the file using a&lt;br /&gt;
top-level attribute named &#039;&#039;&#039;description&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Sometimes a policy file depends on other policy files. In this case,&lt;br /&gt;
the policy file must have a top-level attribute &#039;&#039;&#039;import&#039;&#039;&#039;, the&lt;br /&gt;
value of which is a list of policy names, which correspond to the file&lt;br /&gt;
names without the &amp;lt;tt&amp;gt;.json&amp;lt;/tt&amp;gt; suffix. The imported policies may be&lt;br /&gt;
either optional policies or &#039;&#039;private&#039;&#039; policies, located in&lt;br /&gt;
&amp;lt;tt&amp;gt;/usr/share/awall/private&amp;lt;/tt&amp;gt; or &amp;lt;tt&amp;gt;/etc/awall/private&amp;lt;/tt&amp;gt;. By&lt;br /&gt;
default, the policies listed there are processed before the importing&lt;br /&gt;
policy.&lt;br /&gt;
&lt;br /&gt;
The order of the generated iptables rules generally reflects the&lt;br /&gt;
processing order of their corresponding awall policies. The&lt;br /&gt;
processing order of policies can be adjusted by defining&lt;br /&gt;
top-level attributes &#039;&#039;&#039;after&#039;&#039;&#039; and &#039;&#039;&#039;before&#039;&#039;&#039; in policy&lt;br /&gt;
files. These attributes are lists of policies, after or before&lt;br /&gt;
which the declaring policy shall be processed. Putting a policy&lt;br /&gt;
name to either of these lists does not by itself import the&lt;br /&gt;
policy. The ordering directives are ignored with respect to those&lt;br /&gt;
policies that are not enabled by the user or imported by other&lt;br /&gt;
policies. If not defined, &#039;&#039;&#039;after&#039;&#039;&#039; is assumed to be equal to&lt;br /&gt;
the relative complement of the &#039;&#039;&#039;before&#039;&#039;&#039; definition in the&lt;br /&gt;
&#039;&#039;&#039;import&#039;&#039;&#039; definition of the policy.&lt;br /&gt;
&lt;br /&gt;
As the import directive does not require the path name to be&lt;br /&gt;
specified, awall expects policies to have unique names, even if&lt;br /&gt;
located in different directories. It is allowed to import optional&lt;br /&gt;
policies that are not explicitly enabled by the user. Such policies&lt;br /&gt;
show up with the &amp;lt;tt&amp;gt;required&amp;lt;/tt&amp;gt; status in the output of &amp;lt;tt&amp;gt;awall&lt;br /&gt;
list&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
== List Parameters ==&lt;br /&gt;
&lt;br /&gt;
Several awall parameters are defined as lists of values. In order to&lt;br /&gt;
facilitate manual editing of policy files, awall also accepts single&lt;br /&gt;
values in place of lists. Such values are semantically equivalent to&lt;br /&gt;
lists containing one element.&lt;br /&gt;
&lt;br /&gt;
== Variable Expansion ==&lt;br /&gt;
&lt;br /&gt;
Awall allows variable definitions in policy files. The top-level&lt;br /&gt;
attribute &#039;&#039;&#039;variable&#039;&#039;&#039; is a dictionary containing the&lt;br /&gt;
definitions. The value of a variable can be of any type (string,&lt;br /&gt;
integer, list, or dictionary).&lt;br /&gt;
&lt;br /&gt;
A variable is referenced in policy files by a string which equals the&lt;br /&gt;
variable name prepended with the &#039;&#039;&#039;$&#039;&#039;&#039; character. If the value of&lt;br /&gt;
the variable is a string, the reference can be embedded into a longer&lt;br /&gt;
string in order to substitute some part of that string (in shell&lt;br /&gt;
style). Variable references can be used when defining other variables,&lt;br /&gt;
as long as the definitions are not circular.&lt;br /&gt;
&lt;br /&gt;
Policy files can reference variables defined in other policy&lt;br /&gt;
files. Policy files can also override variables defined elsewhere by&lt;br /&gt;
redefining them. In this case, the new definition affects all policy&lt;br /&gt;
files, also those processed before the overriding policy. Awall&lt;br /&gt;
variables are in fact simple macros, since each variable remains&lt;br /&gt;
constant thoughout a single processing round. If multiple files define&lt;br /&gt;
the same variable, the definition in the file processed last takes&lt;br /&gt;
effect.&lt;br /&gt;
&lt;br /&gt;
If defined as an empty string, all non-embedded references to a&lt;br /&gt;
variable evaluate as if the attribute in question was not present in&lt;br /&gt;
the configuration. This is also the case when a string containing&lt;br /&gt;
embedded variable references finally evaluates to an empty string.&lt;br /&gt;
&lt;br /&gt;
== Configuration Objects ==&lt;br /&gt;
&lt;br /&gt;
Configuration objects can be divided into two main types.&lt;br /&gt;
&#039;&#039;Auxiliary objects&#039;&#039; model high-level concepts such as services and&lt;br /&gt;
zones. &#039;&#039;Rule objects&#039;&#039; translate into one or more iptables rules, and&lt;br /&gt;
are often defined with the help of some auxiliary objects.&lt;br /&gt;
&lt;br /&gt;
=== Services ===&lt;br /&gt;
&lt;br /&gt;
A &#039;&#039;service&#039;&#039; represents a set of network protocols. A top-level&lt;br /&gt;
attribute &#039;&#039;&#039;service&#039;&#039;&#039; is a dictionary that maps service names to&lt;br /&gt;
service definition objects, or lists thereof in more complex cases.&lt;br /&gt;
&lt;br /&gt;
A service definition object contains an attribute named&lt;br /&gt;
&#039;&#039;&#039;proto&#039;&#039;&#039;, which corresponds to the &amp;lt;tt&amp;gt;--protocol&amp;lt;/tt&amp;gt; option&lt;br /&gt;
of iptables. The protocol can be defined as a numerical value or&lt;br /&gt;
string as defined in &amp;lt;tt&amp;gt;/etc/protocols&amp;lt;/tt&amp;gt;. If the protocol is&lt;br /&gt;
&#039;&#039;&#039;tcp&#039;&#039;&#039; or &#039;&#039;&#039;udp&#039;&#039;&#039;, the scope of the service definition may&lt;br /&gt;
be constrained by defining an attribute named &#039;&#039;&#039;port&#039;&#039;&#039;, which&lt;br /&gt;
is a list of TCP or UDP port numbers or ranges thereof, separated&lt;br /&gt;
by the &#039;&#039;&#039;-&#039;&#039;&#039; character. If the protocol is &#039;&#039;&#039;icmp&#039;&#039;&#039; or&lt;br /&gt;
&#039;&#039;&#039;icmpv6&#039;&#039;&#039;, an analogous &#039;&#039;&#039;type&#039;&#039;&#039; attribute may be used. The&lt;br /&gt;
replies to ICMP messages have their own type codes, which may be&lt;br /&gt;
specified using the &#039;&#039;&#039;reply-type&#039;&#039;&#039; attribute.&lt;br /&gt;
&lt;br /&gt;
If the protocol is &#039;&#039;&#039;icmp&#039;&#039;&#039; or &#039;&#039;&#039;icmpv6&#039;&#039;&#039;, the scope of the&lt;br /&gt;
rule is also automatically limited to IPv4 or IPv6,&lt;br /&gt;
respectively. There are also other services which are specific to&lt;br /&gt;
IPv4 or IPv6. To constrain the scope of the service definition to&lt;br /&gt;
either protocol version, an optional &#039;&#039;&#039;family&#039;&#039;&#039; attribute can&lt;br /&gt;
be set to value &#039;&#039;&#039;inet&#039;&#039;&#039; or &#039;&#039;&#039;inet6&#039;&#039;&#039;, respectively.&lt;br /&gt;
&lt;br /&gt;
Some services require the server or client to open additional&lt;br /&gt;
connections to dynamically allocated ports or even different&lt;br /&gt;
hosts. &#039;&#039;Connection tracking helpers&#039;&#039; are used to make the firewall&lt;br /&gt;
aware of such additional connections. The &#039;&#039;&#039;ct-helper&#039;&#039;&#039; attribute is&lt;br /&gt;
used to associate such a helper to a service definition when&lt;br /&gt;
required by the service.&lt;br /&gt;
&lt;br /&gt;
All rule objects, except for policies, may have an attribute named&lt;br /&gt;
&#039;&#039;&#039;service&#039;&#039;&#039;, constraining the rule&#039;s scope to specific services&lt;br /&gt;
only. This attribute is a list of service names, referring to the keys&lt;br /&gt;
of the top-level service dictionary.&lt;br /&gt;
&lt;br /&gt;
=== Zones ===&lt;br /&gt;
&lt;br /&gt;
A &#039;&#039;zone&#039;&#039; represents a set of network hosts. A top-level attribute &lt;br /&gt;
&#039;&#039;&#039;zone&#039;&#039;&#039; is a dictionary that maps zone names to zone objects. A&lt;br /&gt;
zone object has an attribute named &#039;&#039;&#039;iface&#039;&#039;&#039;, &#039;&#039;&#039;addr&#039;&#039;&#039;, or&lt;br /&gt;
both. &#039;&#039;&#039;iface&#039;&#039;&#039; is a list of network interfaces and &#039;&#039;&#039;addr&#039;&#039;&#039; is a&lt;br /&gt;
list of IPv4/IPv6 host and network addresses (CIDR&lt;br /&gt;
notation). &#039;&#039;&#039;addr&#039;&#039;&#039; may also contain domain names, which are&lt;br /&gt;
expanded to IP addresses using DNS resolution. If not defined,&lt;br /&gt;
&#039;&#039;&#039;addr&#039;&#039;&#039; defaults to the entire address space and &#039;&#039;&#039;iface&#039;&#039;&#039; to all&lt;br /&gt;
interfaces. An empty zone can be defined by setting either &#039;&#039;&#039;addr&#039;&#039;&#039;&lt;br /&gt;
or &#039;&#039;&#039;iface&#039;&#039;&#039; to an empty list.&lt;br /&gt;
&lt;br /&gt;
Rule objects contain two attributes, &#039;&#039;&#039;in&#039;&#039;&#039; and &#039;&#039;&#039;out&#039;&#039;&#039;, which are&lt;br /&gt;
lists of zone names. These attributes control whether a packet matches&lt;br /&gt;
the rule or not. If a particular zone is referenced by the &#039;&#039;&#039;in&#039;&#039;&#039; &lt;br /&gt;
attribute, the rule applies to packets whose ingress interface and&lt;br /&gt;
source address are covered by the zone definition. Correspondingly, if&lt;br /&gt;
a zone is referenced by the &#039;&#039;&#039;out&#039;&#039;&#039; attribute, the rule applies to&lt;br /&gt;
packets whose egress interface and destination address are included in&lt;br /&gt;
the zone. If both &#039;&#039;&#039;in&#039;&#039;&#039; and &#039;&#039;&#039;out&#039;&#039;&#039; are defined, the packet must&lt;br /&gt;
fulfill both criteria in order to match the rule.&lt;br /&gt;
&lt;br /&gt;
The firewall host itself can be referred to using the special value&lt;br /&gt;
&#039;&#039;&#039;_fw&#039;&#039;&#039; as the zone name.&lt;br /&gt;
&lt;br /&gt;
By default, awall does not generate iptables rules with identical&lt;br /&gt;
ingress and egress interfaces. This behavior can be changed per zone&lt;br /&gt;
by setting the optional &#039;&#039;&#039;route-back&#039;&#039;&#039; attribute of the zone to&lt;br /&gt;
&#039;&#039;&#039;true&#039;&#039;&#039;. Note that this attribute can have an effect also in the&lt;br /&gt;
case where &#039;&#039;&#039;in&#039;&#039;&#039; and &#039;&#039;&#039;out&#039;&#039;&#039; attributes of a rule are not equal&lt;br /&gt;
but their definitions overlap. In this case, the &#039;&#039;&#039;route-back&#039;&#039;&#039;&lt;br /&gt;
attribute of the &#039;&#039;&#039;out&#039;&#039;&#039; zone determines the behavior.&lt;br /&gt;
&lt;br /&gt;
=== Limits ===&lt;br /&gt;
&lt;br /&gt;
A &#039;&#039;limit&#039;&#039; specifies the maximum rate for a flow of packets or new&lt;br /&gt;
connections. Unlike the other auxiliary objects, limits are not named&lt;br /&gt;
members of a top-level dictionary but are embedded into other objects.&lt;br /&gt;
&lt;br /&gt;
In its simplest form, a limit definition is an integer specifying the&lt;br /&gt;
maximum number of packets or connections per second. More complex&lt;br /&gt;
limits are defined as objects, where the &#039;&#039;&#039;count&#039;&#039;&#039; attribute define&lt;br /&gt;
the maximum during an interval defined by the &#039;&#039;&#039;interval&#039;&#039;&#039;&lt;br /&gt;
attribute. The unit of the &#039;&#039;&#039;interval&#039;&#039;&#039; attribute is second, and&lt;br /&gt;
the default value is 1.&lt;br /&gt;
&lt;br /&gt;
The maximum rate defined by a limit may be absolute or specific to&lt;br /&gt;
blocks of IP addresses or pairs thereof. The number of most&lt;br /&gt;
significant bits taken into account when mapping the source and&lt;br /&gt;
destination IP addresses to blocks can be specified with the&lt;br /&gt;
&#039;&#039;&#039;mask&#039;&#039;&#039; attribute. The &#039;&#039;&#039;mask&#039;&#039;&#039; attribute is an object with two&lt;br /&gt;
attributes defining the prefix lengths, named &#039;&#039;&#039;src&#039;&#039;&#039; and&lt;br /&gt;
&#039;&#039;&#039;dest&#039;&#039;&#039;. Alternatively, the &#039;&#039;&#039;mask&#039;&#039;&#039; object may have object&lt;br /&gt;
attributes named &#039;&#039;&#039;inet&#039;&#039;&#039; and &#039;&#039;&#039;inet6&#039;&#039;&#039; which contain address&lt;br /&gt;
family&amp;amp;ndash;specific prefix length pairs. If &#039;&#039;&#039;mask&#039;&#039;&#039; is defined as&lt;br /&gt;
an integer, it is interpreted as the source address prefix length.&lt;br /&gt;
&lt;br /&gt;
The default value for &#039;&#039;&#039;mask&#039;&#039;&#039; depends on the type of the enclosing&lt;br /&gt;
object. For [[#Filter Rules|filters]], the default behavior is to&lt;br /&gt;
apply the limit for each source address separately. For&lt;br /&gt;
[[#Logging Classes|logging classes]], the limit is considered absolute&lt;br /&gt;
by default.&lt;br /&gt;
&lt;br /&gt;
=== Logging Classes ===&lt;br /&gt;
&lt;br /&gt;
A &#039;&#039;logging class&#039;&#039; specifies how packets matching certain rules are&lt;br /&gt;
logged. A top-level attribute &#039;&#039;&#039;log&#039;&#039;&#039; is a dictionary that maps&lt;br /&gt;
logging class names to setting objects.&lt;br /&gt;
&lt;br /&gt;
A setting object may have an attribute named &#039;&#039;&#039;mode&#039;&#039;&#039;, which&lt;br /&gt;
specifies which logging facility to use. Allowed values are &#039;&#039;&#039;log&#039;&#039;&#039;,&lt;br /&gt;
&#039;&#039;&#039;nflog&#039;&#039;&#039;, and &#039;&#039;&#039;ulog&#039;&#039;&#039;. The default is &#039;&#039;&#039;log&#039;&#039;&#039;, i.e. in-kernel&lt;br /&gt;
logging.&lt;br /&gt;
&lt;br /&gt;
The following table shows the optional attributes valid for all&lt;br /&gt;
logging modes:&lt;br /&gt;
&lt;br /&gt;
{|&lt;br /&gt;
!Attribute!!Description&lt;br /&gt;
|-&lt;br /&gt;
|&#039;&#039;&#039;every&#039;&#039;&#039;&lt;br /&gt;
|Divide successive packets into groups, the size of which is specified by the value of this attribute, and log only the first packet of each group&lt;br /&gt;
|-&lt;br /&gt;
|&#039;&#039;&#039;limit&#039;&#039;&#039;&lt;br /&gt;
|Maximum number of packets to be logged defined as [[#Limits|limit]]&lt;br /&gt;
|-&lt;br /&gt;
|&#039;&#039;&#039;prefix&#039;&#039;&#039;&lt;br /&gt;
|String with which the log entries are prefixed&lt;br /&gt;
|-&lt;br /&gt;
|&#039;&#039;&#039;probability&#039;&#039;&#039;&lt;br /&gt;
|Probability for logging an individual packet (default: 1)&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
With the in-kernel log mode &#039;&#039;&#039;log&#039;&#039;&#039;, the level of logging may be&lt;br /&gt;
specified using the &#039;&#039;&#039;level&#039;&#039;&#039; attribute. Log modes &#039;&#039;&#039;nflog&#039;&#039;&#039; and&lt;br /&gt;
&#039;&#039;&#039;ulog&#039;&#039;&#039; are about copying the packets into user space, at least&lt;br /&gt;
partially. The following table shows the additional attributes valid&lt;br /&gt;
with these modes:&lt;br /&gt;
&lt;br /&gt;
{|&lt;br /&gt;
!Attribute!!Description&lt;br /&gt;
|-&lt;br /&gt;
|&#039;&#039;&#039;group&#039;&#039;&#039;&lt;br /&gt;
|Netlink group to be used&lt;br /&gt;
|-&lt;br /&gt;
|&#039;&#039;&#039;range&#039;&#039;&#039;&lt;br /&gt;
|Number of bytes to be copied&lt;br /&gt;
|-&lt;br /&gt;
|&#039;&#039;&#039;threshold&#039;&#039;&#039;&lt;br /&gt;
|Number of packets to queue inside the kernel before copying them&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
[[#Filter Rules|Filter]] and [[#Policy Rules|policy]] rules can have&lt;br /&gt;
an attribute named &#039;&#039;&#039;log&#039;&#039;&#039;. If it is a string, it is interpreted as&lt;br /&gt;
a reference to a logging class, and logging is performed according to&lt;br /&gt;
the definitions. If the value of the &#039;&#039;&#039;log&#039;&#039;&#039; attribute is &#039;&#039;&#039;true&#039;&#039;&#039;&lt;br /&gt;
(boolean), logging is done using default settings. If the value is&lt;br /&gt;
&#039;&#039;&#039;false&#039;&#039;&#039; (boolean), logging is disabled for the rule. If &#039;&#039;&#039;log&#039;&#039;&#039;&lt;br /&gt;
is not defined, logging is done using the default settings except for&lt;br /&gt;
accept rules, for which logging is omitted.&lt;br /&gt;
&lt;br /&gt;
Default logging settings can be set by defining a logging class named&lt;br /&gt;
&#039;&#039;&#039;_default&#039;&#039;&#039;. Normally, default logging uses the &#039;&#039;&#039;log&#039;&#039;&#039; mode with&lt;br /&gt;
packets limited to one per second.&lt;br /&gt;
&lt;br /&gt;
=== Rules ===&lt;br /&gt;
&lt;br /&gt;
There are several types of rule objects:&lt;br /&gt;
* Filter rules&lt;br /&gt;
* Policy rules&lt;br /&gt;
* Packet Logging rules&lt;br /&gt;
* NAT rules&lt;br /&gt;
* Packet Marking rules&lt;br /&gt;
* Transparent Proxy rules&lt;br /&gt;
* MSS Clamping rules&lt;br /&gt;
* Connection Tracking Bypass rules&lt;br /&gt;
&lt;br /&gt;
All rule objects can have the &#039;&#039;&#039;in&#039;&#039;&#039; and &#039;&#039;&#039;out&#039;&#039;&#039; attributes&lt;br /&gt;
referring to [[#Zones|zones]] as described in the previous section. In&lt;br /&gt;
addition, the scope of the rule can be further constrained with the&lt;br /&gt;
following attributes:&lt;br /&gt;
&lt;br /&gt;
{|&lt;br /&gt;
!Attribute!!Value format!!Effect&lt;br /&gt;
|-&lt;br /&gt;
|&#039;&#039;&#039;src&#039;&#039;&#039;&lt;br /&gt;
|Similar to &#039;&#039;&#039;addr&#039;&#039;&#039; attribute of [[#Zones|zone objects]]&lt;br /&gt;
|Packet&#039;s source address matches the value&lt;br /&gt;
|-&lt;br /&gt;
|&#039;&#039;&#039;dest&#039;&#039;&#039;&lt;br /&gt;
|Similar to &#039;&#039;&#039;addr&#039;&#039;&#039; attribute of [[#Zones|zone objects]]&lt;br /&gt;
|Packet&#039;s destination address matches the value&lt;br /&gt;
|-&lt;br /&gt;
|&#039;&#039;&#039;ipset&#039;&#039;&#039;&lt;br /&gt;
|Object containing two attributes: &#039;&#039;&#039;name&#039;&#039;&#039; referring to an [[#IP Sets|IP set]] and &#039;&#039;&#039;args&#039;&#039;&#039;, which is a list of strings &#039;&#039;&#039;in&#039;&#039;&#039; and &#039;&#039;&#039;out&#039;&#039;&#039;&lt;br /&gt;
|Packet matches the IP set referred here when the match arguments are taken from the source (&#039;&#039;&#039;in&#039;&#039;&#039;) and destination (&#039;&#039;&#039;out&#039;&#039;&#039;) address or port in the order specified by &#039;&#039;&#039;args&#039;&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
|&#039;&#039;&#039;ipsec&#039;&#039;&#039;&lt;br /&gt;
|&#039;&#039;&#039;in&#039;&#039;&#039; or &#039;&#039;&#039;out&#039;&#039;&#039;&lt;br /&gt;
|IPsec decapsulation perfomed on ingress (&#039;&#039;&#039;in&#039;&#039;&#039;) or encapsulation performed on egress (&#039;&#039;&#039;out&#039;&#039;&#039;)&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Rule objects are declared in type-specific top-level dictionaries in&lt;br /&gt;
awall policy files. If a packet matches multiple rules, the one&lt;br /&gt;
appearing earlier in the list takes precedence. If the matching rules&lt;br /&gt;
are defined in different policy files, the one that was processed&lt;br /&gt;
earlier takes precedence in the current implementation, but this may&lt;br /&gt;
change in future versions.&lt;br /&gt;
&lt;br /&gt;
==== Filter Rules ====&lt;br /&gt;
&lt;br /&gt;
Filter objects specify an action for packets fulfilling certain&lt;br /&gt;
criteria. The top-level attribute &#039;&#039;&#039;filter&#039;&#039;&#039; is a list of filter&lt;br /&gt;
objects.&lt;br /&gt;
&lt;br /&gt;
Filter objects must have an attribute named &#039;&#039;&#039;action&#039;&#039;&#039;, the value of&lt;br /&gt;
which can be one of the following:&lt;br /&gt;
&lt;br /&gt;
{|&lt;br /&gt;
!Value!!Action&lt;br /&gt;
|-&lt;br /&gt;
|&#039;&#039;&#039;accept&#039;&#039;&#039;&lt;br /&gt;
|Accept the packet (default)&lt;br /&gt;
|-&lt;br /&gt;
|&#039;&#039;&#039;reject&#039;&#039;&#039;&lt;br /&gt;
|Reject the packet with an ICMP error message&lt;br /&gt;
|-&lt;br /&gt;
|&#039;&#039;&#039;drop&#039;&#039;&#039;&lt;br /&gt;
|Silently drop the packet&lt;br /&gt;
|-&lt;br /&gt;
|&#039;&#039;&#039;tarpit&#039;&#039;&#039;&lt;br /&gt;
|Put incoming TCP connections into persist state and ignore attempts to close them. Silently drop non-TCP packets. (Connection tracking bypass is automatically enabled for the matching packets.)&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Filter objects, the action of which is &#039;&#039;&#039;accept&#039;&#039;&#039;, may also contain&lt;br /&gt;
limits for packet flow or new connections. These are specified with&lt;br /&gt;
the &#039;&#039;&#039;flow-limit&#039;&#039;&#039; and &#039;&#039;&#039;conn-limit&#039;&#039;&#039; attributes,&lt;br /&gt;
respectively. The values of these attributes are&lt;br /&gt;
[[#Limits|limit objects]]. The &#039;&#039;&#039;drop&#039;&#039;&#039; action is applied to the&lt;br /&gt;
packets exceeding the limit. Optionally, the limit object may have an&lt;br /&gt;
attribute named &#039;&#039;&#039;log&#039;&#039;&#039;. It defines how the dropped packets should&lt;br /&gt;
be logged and is semantically similar to the &#039;&#039;&#039;log&#039;&#039;&#039; attribute of&lt;br /&gt;
rule objects.&lt;br /&gt;
&lt;br /&gt;
Filter objects may have an attribute named &#039;&#039;&#039;dnat&#039;&#039;&#039;, the value of&lt;br /&gt;
which is an IPv4 address. If defined, this enables destination NAT for&lt;br /&gt;
all IPv4 packets matching the rule, such that the specified address&lt;br /&gt;
replaces the original destination address. This option has no effect&lt;br /&gt;
on IPv6 packets.&lt;br /&gt;
&lt;br /&gt;
Filter objects may have a boolean attribute named &#039;&#039;&#039;no-track&#039;&#039;&#039;. If&lt;br /&gt;
set to &#039;&#039;&#039;true&#039;&#039;&#039;, connection tracking is bypassed for the matching&lt;br /&gt;
packets. In addition, if &#039;&#039;&#039;action&#039;&#039;&#039; is set to &#039;&#039;&#039;accept&#039;&#039;&#039;, the&lt;br /&gt;
corresponding packets travelling to the reverse direction are also&lt;br /&gt;
allowed.&lt;br /&gt;
&lt;br /&gt;
If one or more connection tracking helpers are associated with the&lt;br /&gt;
services referred to by an accept rule, additional iptables rules are&lt;br /&gt;
generated for the related connections detected by the helpers. The&lt;br /&gt;
&#039;&#039;&#039;related&#039;&#039;&#039; attribute can be used to override the default rules&lt;br /&gt;
generated by awall. It is a list of basic rule objects, the packets&lt;br /&gt;
matching to which are accepted, provided that they are also detected&lt;br /&gt;
by at least one of the helpers.&lt;br /&gt;
&lt;br /&gt;
==== Policy Rules ====&lt;br /&gt;
&lt;br /&gt;
Policy objects describe the default action for packets that did not&lt;br /&gt;
match any filter. The top-level attribute &#039;&#039;&#039;policy&#039;&#039;&#039; is a list of&lt;br /&gt;
policy objects.&lt;br /&gt;
&lt;br /&gt;
Policy objects must have the &#039;&#039;&#039;action&#039;&#039;&#039; attribute defined. The&lt;br /&gt;
possible values and their semantics are the same as in&lt;br /&gt;
[[#Filter Rules|filter rules]].&lt;br /&gt;
&lt;br /&gt;
==== Packet Logging Rules ====&lt;br /&gt;
&lt;br /&gt;
Packet logging rules allow packets matching the specified criteria to&lt;br /&gt;
be logged before any filtering takes place. Such rules are contained&lt;br /&gt;
in the top-level list named &#039;&#039;&#039;packet-log&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Logging class may be specified using the &#039;&#039;&#039;log&#039;&#039;&#039;&lt;br /&gt;
attribute. Otherwise, default logging settings are used.&lt;br /&gt;
&lt;br /&gt;
==== NAT Rules ====&lt;br /&gt;
&lt;br /&gt;
NAT rules come in two flavors: &#039;&#039;source NAT rules&#039;&#039; and&lt;br /&gt;
&#039;&#039;destination NAT rules&#039;&#039;. These are contained in two top-level lists&lt;br /&gt;
named &#039;&#039;&#039;snat&#039;&#039;&#039; and &#039;&#039;&#039;dnat&#039;&#039;&#039;, respectively.&lt;br /&gt;
&lt;br /&gt;
Each NAT rule may have an attribute named &#039;&#039;&#039;to-addr&#039;&#039;&#039; that&lt;br /&gt;
specifies the IPv4 address range to which the original source or&lt;br /&gt;
destination address is mapped. The value can be a single IPv4 address&lt;br /&gt;
or a range specified by two addresses, separated with the &#039;&#039;&#039;-&#039;&#039;&#039;&lt;br /&gt;
character. If not defined, it defaults to the primary address of the&lt;br /&gt;
ingress interface in case of destination NAT, or that of the egress&lt;br /&gt;
interface in case of source NAT.&lt;br /&gt;
&lt;br /&gt;
Optionally, a NAT rule can specify the TCP and UDP port range to which&lt;br /&gt;
the original source or destination port is mapped. The attribute is&lt;br /&gt;
named &#039;&#039;&#039;to-port&#039;&#039;&#039;, and the value can be a single port number or a&lt;br /&gt;
range specified by two numbers, separated with the &#039;&#039;&#039;-&#039;&#039;&#039;&lt;br /&gt;
character. If &#039;&#039;&#039;to-port&#039;&#039;&#039; is not specified, the original port number&lt;br /&gt;
is kept intact.&lt;br /&gt;
&lt;br /&gt;
NAT rules, may have an &#039;&#039;&#039;action&#039;&#039;&#039; attribute set to value&lt;br /&gt;
&#039;&#039;&#039;include&#039;&#039;&#039; or &#039;&#039;&#039;exclude&#039;&#039;&#039;. The latter means that NAT is not&lt;br /&gt;
performed on the matching packets (unless they match an &#039;&#039;&#039;include&#039;&#039;&#039;&lt;br /&gt;
rule processed earlier). The default value is &#039;&#039;&#039;include&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
==== Packet Marking Rules ====&lt;br /&gt;
&lt;br /&gt;
Packet marking rules are used to mark incoming packets matching the&lt;br /&gt;
specified criteria. The mark can be used as a basis for the routing&lt;br /&gt;
decision. Each marking rule must specify the mark using the &#039;&#039;&#039;mark&#039;&#039;&#039;&lt;br /&gt;
attribute, which is a 32-bit integer.&lt;br /&gt;
&lt;br /&gt;
Normal marking rules are contained by the top-level list attribute&lt;br /&gt;
named &#039;&#039;&#039;mark&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
There is another top-level list attribute, named &#039;&#039;&#039;route-track&#039;&#039;&#039;,&lt;br /&gt;
which contains route tracking rules. These are special marking rules&lt;br /&gt;
which cause all the subsequent packets related to the same connection&lt;br /&gt;
to be marked according to the rule.&lt;br /&gt;
&lt;br /&gt;
==== Transparent Proxy Rules ====&lt;br /&gt;
&lt;br /&gt;
Transparent proxy rules divert the matching packets to a local proxy&lt;br /&gt;
process without altering their headers. Such rules are contained in&lt;br /&gt;
the top-level list named &#039;&#039;&#039;tproxy&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
In addition to the firewall configuration, using a transparent proxy&lt;br /&gt;
requires a routing configuration where packets marked for proxying are&lt;br /&gt;
diverted to a local process. The &#039;&#039;&#039;awall_tproxy_mark&#039;&#039;&#039; variable can&lt;br /&gt;
be used to specify the mark for such packets, which defaults to 1.&lt;br /&gt;
&lt;br /&gt;
Proxy rules may also have an attribute named &#039;&#039;&#039;to-port&#039;&#039;&#039; for&lt;br /&gt;
specifying the TCP or UDP port of the proxy if it is different from&lt;br /&gt;
the original destination port.&lt;br /&gt;
&lt;br /&gt;
==== MSS Clamping Rules ====&lt;br /&gt;
&lt;br /&gt;
MSS Clamping Rules are used to deal with ISPs that block ICMP&lt;br /&gt;
Fragmentation Needed or ICMPv6 Packet Too Big packets. An MSS clamping&lt;br /&gt;
rule overwrites the MSS option with a value specified with the&lt;br /&gt;
&#039;&#039;&#039;mss&#039;&#039;&#039; attribute for the matching TCP connections. If &#039;&#039;&#039;mss&#039;&#039;&#039; is&lt;br /&gt;
not specified, a suitable value is automatically determined from the&lt;br /&gt;
path MTU. The MSS clamping rules are located in the top-level&lt;br /&gt;
dictionary named &#039;&#039;&#039;clamp-mss&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
==== Connection Tracking Bypass Rules ====&lt;br /&gt;
&lt;br /&gt;
Connection tracking bypass rules are used to disable connection&lt;br /&gt;
tracking for packets matching the specified criteria. The top-level&lt;br /&gt;
attribute &#039;&#039;&#039;no-track&#039;&#039;&#039; is a list of such rules.&lt;br /&gt;
&lt;br /&gt;
Like [[#NAT Rules|NAT rules]], connection tracking bypass rules may&lt;br /&gt;
have an &#039;&#039;&#039;action&#039;&#039;&#039; attribute set to value &#039;&#039;&#039;include&#039;&#039;&#039; or&lt;br /&gt;
&#039;&#039;&#039;exclude&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
=== IP Sets ===&lt;br /&gt;
&lt;br /&gt;
Any IP set referenced by rule objects should be created by&lt;br /&gt;
awall. Auxiliary &#039;&#039;IP set&#039;&#039; objects are used to defined them in awall&lt;br /&gt;
policy files. The top-level attribute &#039;&#039;&#039;ipset&#039;&#039;&#039; is a dictionary, the&lt;br /&gt;
keys of which are IP set names. The values are IP set objects, which&lt;br /&gt;
have two mandatory attributes. The attribute named &#039;&#039;&#039;type&#039;&#039;&#039; &lt;br /&gt;
corresponds to the type argument of the &amp;lt;tt&amp;gt;ipset create&amp;lt;/tt&amp;gt; &lt;br /&gt;
command. &#039;&#039;&#039;family&#039;&#039;&#039; specifies whether the set is for IPv4 or IPv6&lt;br /&gt;
addresses, and the possible values are &#039;&#039;&#039;inet&#039;&#039;&#039; and &#039;&#039;&#039;inet6&#039;&#039;&#039;,&lt;br /&gt;
correspondingly.&lt;br /&gt;
&lt;br /&gt;
For bitmap-type IP sets, the &#039;&#039;&#039;range&#039;&#039;&#039; attribute specifies the&lt;br /&gt;
range of allowed IPv4 addresses. It may be given as a network&lt;br /&gt;
address or two addresses separated by the &#039;&#039;&#039;-&#039;&#039;&#039; character. It&lt;br /&gt;
is not necessary to specify &#039;&#039;&#039;family&#039;&#039;&#039; for bitmaps, since the&lt;br /&gt;
kernel supports only IPv4 bitmaps.&lt;br /&gt;
&lt;br /&gt;
== Command Line Syntax ==&lt;br /&gt;
&lt;br /&gt;
=== Translating Policy Files to Firewall Configuration Files ===&lt;br /&gt;
&lt;br /&gt;
 &#039;&#039;&#039;awall translate&#039;&#039;&#039; [&#039;&#039;&#039;-o&#039;&#039;&#039;|&#039;&#039;&#039;--output&#039;&#039;&#039; DIRECTORY] [&#039;&#039;&#039;-V&#039;&#039;&#039;|&#039;&#039;&#039;--verify&#039;&#039;&#039;]&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;tt&amp;gt;--verify&amp;lt;/tt&amp;gt; option makes awall verify the configuration&lt;br /&gt;
using the test mode of iptables-restore before overwriting the old&lt;br /&gt;
files.&lt;br /&gt;
&lt;br /&gt;
Specifying the output directory allows testing awall policies without&lt;br /&gt;
overwriting the current iptables and ipset configuration files. By&lt;br /&gt;
default, awall generates the configuration to &amp;lt;tt&amp;gt;/etc/iptables&amp;lt;/tt&amp;gt; &lt;br /&gt;
and &amp;lt;tt&amp;gt;/etc/ipset.d&amp;lt;/tt&amp;gt;, which are read by the init scripts.&lt;br /&gt;
&lt;br /&gt;
=== Run-Time Configuration of Firewall ===&lt;br /&gt;
&lt;br /&gt;
 &#039;&#039;&#039;awall activate&#039;&#039;&#039; [&#039;&#039;&#039;-f&#039;&#039;&#039;|&#039;&#039;&#039;--force&#039;&#039;&#039;]&lt;br /&gt;
&lt;br /&gt;
This command genereates firewall configuration from the policy files&lt;br /&gt;
and enables it. If the user confirms the new configuration by hitting&lt;br /&gt;
the Return key within 10 seconds or the &amp;lt;tt&amp;gt;--force&amp;lt;/tt&amp;gt; option is&lt;br /&gt;
used, the configuration is saved to the files. Otherwise, the old&lt;br /&gt;
configuration is restored.&lt;br /&gt;
&lt;br /&gt;
There is also a command for deleting all firewall rules:&lt;br /&gt;
&lt;br /&gt;
 &#039;&#039;&#039;awall flush&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
This command configures the firewall to drop all packets.&lt;br /&gt;
&lt;br /&gt;
=== Optional Policies ===&lt;br /&gt;
&lt;br /&gt;
Optional policies can be enabled or disabled using this command:&lt;br /&gt;
&lt;br /&gt;
 &#039;&#039;&#039;awall&#039;&#039;&#039; {&#039;&#039;&#039;enable&#039;&#039;&#039;|&#039;&#039;&#039;disable&#039;&#039;&#039;} POLICY...&lt;br /&gt;
&lt;br /&gt;
Optional policies can be listed using this command:&lt;br /&gt;
&lt;br /&gt;
 &#039;&#039;&#039;awall list&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;&#039;enabled&#039;&#039;&#039; status means that the policy has been enabled by the&lt;br /&gt;
user. The &#039;&#039;&#039;disabled&#039;&#039;&#039; status means that the policy is not in&lt;br /&gt;
use. The &#039;&#039;&#039;required&#039;&#039;&#039; status means that the policy has not been&lt;br /&gt;
enabled by the user but is in use because it is required by another&lt;br /&gt;
policy which is in use.&lt;br /&gt;
&lt;br /&gt;
=== Debugging Policies ===&lt;br /&gt;
&lt;br /&gt;
This command can be used to dump variable, zone, and other definitions&lt;br /&gt;
as well as their source policies:&lt;br /&gt;
&lt;br /&gt;
 &#039;&#039;&#039;awall dump&#039;&#039;&#039; [LEVEL]&lt;br /&gt;
&lt;br /&gt;
The level is an integer in range 0&amp;amp;ndash;5 and defaults to 0. More&lt;br /&gt;
information is displayed on higher levels.&lt;br /&gt;
&lt;br /&gt;
[[Category:Networking]]&lt;br /&gt;
[[Category:Security]]&lt;/div&gt;</summary>
		<author><name>Kunkku</name></author>
	</entry>
	<entry>
		<id>https://wiki.alpinelinux.org/w/index.php?title=Alpine_Wall_User%27s_Guide&amp;diff=10157</id>
		<title>Alpine Wall User&#039;s Guide</title>
		<link rel="alternate" type="text/html" href="https://wiki.alpinelinux.org/w/index.php?title=Alpine_Wall_User%27s_Guide&amp;diff=10157"/>
		<updated>2014-09-19T08:19:07Z</updated>

		<summary type="html">&lt;p&gt;Kunkku: /* Configuration Objects */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Configuration File Processing ==&lt;br /&gt;
&lt;br /&gt;
[[Alpine Wall]] (awall) reads its configuration from multiple&lt;br /&gt;
JSON-formatted files, called &#039;&#039;policy files&#039;&#039;. The files located in&lt;br /&gt;
directory &amp;lt;tt&amp;gt;/usr/share/awall/mandatory&amp;lt;/tt&amp;gt; are &#039;&#039;mandatory&#039;&#039;&lt;br /&gt;
policies shipped with APK packages. In addition, there can be&lt;br /&gt;
installation-specific mandatory policies in &amp;lt;tt&amp;gt;/etc/awall&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
The latter directory may also contain symbolic links to policy files&lt;br /&gt;
located in &amp;lt;tt&amp;gt;/usr/share/awall/optional&amp;lt;/tt&amp;gt; and&lt;br /&gt;
&amp;lt;tt&amp;gt;/etc/awall/optional&amp;lt;/tt&amp;gt;. These are &#039;&#039;optional&#039;&#039; policies, which&lt;br /&gt;
can be enabled on need basis. Such symbolic links are easily created&lt;br /&gt;
and destroyed using the &amp;lt;tt&amp;gt;awall enable&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;awall&lt;br /&gt;
disable&amp;lt;/tt&amp;gt; commands. &amp;lt;tt&amp;gt;awall list&amp;lt;/tt&amp;gt; shows which optional&lt;br /&gt;
policies are enabled and disabled. The command also prints the&lt;br /&gt;
description of the optional policy if defined in the file using a&lt;br /&gt;
top-level attribute named &#039;&#039;&#039;description&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Sometimes a policy file depends on other policy files. In this case,&lt;br /&gt;
the policy file must have a top-level attribute &#039;&#039;&#039;import&#039;&#039;&#039;, the&lt;br /&gt;
value of which is a list of policy names, which correspond to the file&lt;br /&gt;
names without the &amp;lt;tt&amp;gt;.json&amp;lt;/tt&amp;gt; suffix. The imported policies may be&lt;br /&gt;
either optional policies or &#039;&#039;private&#039;&#039; policies, located in&lt;br /&gt;
&amp;lt;tt&amp;gt;/usr/share/awall/private&amp;lt;/tt&amp;gt; or &amp;lt;tt&amp;gt;/etc/awall/private&amp;lt;/tt&amp;gt;. By&lt;br /&gt;
default, the policies listed there are processed before the importing&lt;br /&gt;
policy.&lt;br /&gt;
&lt;br /&gt;
The order of the generated iptables rules generally reflects the&lt;br /&gt;
processing order of their corresponding awall policies. The&lt;br /&gt;
processing order of policies can be adjusted by defining&lt;br /&gt;
top-level attributes &#039;&#039;&#039;after&#039;&#039;&#039; and &#039;&#039;&#039;before&#039;&#039;&#039; in policy&lt;br /&gt;
files. These attributes are lists of policies, after or before&lt;br /&gt;
which the declaring policy shall be processed. Putting a policy&lt;br /&gt;
name to either of these lists does not by itself import the&lt;br /&gt;
policy. The ordering directives are ignored with respect to those&lt;br /&gt;
policies that are not enabled by the user or imported by other&lt;br /&gt;
policies. If not defined, &#039;&#039;&#039;after&#039;&#039;&#039; is assumed to be equal to&lt;br /&gt;
the relative complement of the &#039;&#039;&#039;before&#039;&#039;&#039; definition in the&lt;br /&gt;
&#039;&#039;&#039;import&#039;&#039;&#039; definition of the policy.&lt;br /&gt;
&lt;br /&gt;
As the import directive does not require the path name to be&lt;br /&gt;
specified, awall expects policies to have unique names, even if&lt;br /&gt;
located in different directories. It is allowed to import optional&lt;br /&gt;
policies that are not explicitly enabled by the user. Such policies&lt;br /&gt;
show up with the &amp;lt;tt&amp;gt;required&amp;lt;/tt&amp;gt; status in the output of &amp;lt;tt&amp;gt;awall&lt;br /&gt;
list&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
== List Parameters ==&lt;br /&gt;
&lt;br /&gt;
Several awall parameters are defined as lists of values. In order to&lt;br /&gt;
facilitate manual editing of policy files, awall also accepts single&lt;br /&gt;
values in place of lists. Such values are semantically equivalent to&lt;br /&gt;
lists containing one element.&lt;br /&gt;
&lt;br /&gt;
== Variable Expansion ==&lt;br /&gt;
&lt;br /&gt;
Awall allows variable definitions in policy files. The top-level&lt;br /&gt;
attribute &#039;&#039;&#039;variable&#039;&#039;&#039; is a dictionary containing the&lt;br /&gt;
definitions. The value of a variable can be of any type (string,&lt;br /&gt;
integer, list, or dictionary).&lt;br /&gt;
&lt;br /&gt;
A variable is referenced in policy files by a string which equals the&lt;br /&gt;
variable name prepended with the &#039;&#039;&#039;$&#039;&#039;&#039; character. If the value of&lt;br /&gt;
the variable is a string, the reference can be embedded into a longer&lt;br /&gt;
string in order to substitute some part of that string (in shell&lt;br /&gt;
style). Variable references can be used when defining other variables,&lt;br /&gt;
as long as the definitions are not circular.&lt;br /&gt;
&lt;br /&gt;
Policy files can reference variables defined in other policy&lt;br /&gt;
files. Policy files can also override variables defined elsewhere by&lt;br /&gt;
redefining them. In this case, the new definition affects all policy&lt;br /&gt;
files, also those processed before the overriding policy. Awall&lt;br /&gt;
variables are in fact simple macros, since each variable remains&lt;br /&gt;
constant thoughout a single processing round. If multiple files define&lt;br /&gt;
the same variable, the definition in the file processed last takes&lt;br /&gt;
effect.&lt;br /&gt;
&lt;br /&gt;
If defined as an empty string, all non-embedded references to a&lt;br /&gt;
variable evaluate as if the attribute in question was not present in&lt;br /&gt;
the configuration. This is also the case when a string containing&lt;br /&gt;
embedded variable references finally evaluates to an empty string.&lt;br /&gt;
&lt;br /&gt;
== Configuration Objects ==&lt;br /&gt;
&lt;br /&gt;
Configuration objects can be divided into two main types.&lt;br /&gt;
&#039;&#039;Auxiliary objects&#039;&#039; model high-level concepts such as services and&lt;br /&gt;
zones. &#039;&#039;Rule objects&#039;&#039; translate into one or more iptables rules, and&lt;br /&gt;
are often defined with the help of some auxiliary objects.&lt;br /&gt;
&lt;br /&gt;
=== Services ===&lt;br /&gt;
&lt;br /&gt;
A &#039;&#039;service&#039;&#039; represents a set of network protocols. A top-level&lt;br /&gt;
attribute &#039;&#039;&#039;service&#039;&#039;&#039; is a dictionary that maps service names to&lt;br /&gt;
service definition objects, or lists thereof in more complex cases.&lt;br /&gt;
&lt;br /&gt;
A service definition object contains an attribute named&lt;br /&gt;
&#039;&#039;&#039;proto&#039;&#039;&#039;, which corresponds to the &amp;lt;tt&amp;gt;--protocol&amp;lt;/tt&amp;gt; option&lt;br /&gt;
of iptables. The protocol can be defined as a numerical value or&lt;br /&gt;
string as defined in &amp;lt;tt&amp;gt;/etc/protocols&amp;lt;/tt&amp;gt;. If the protocol is&lt;br /&gt;
&#039;&#039;&#039;tcp&#039;&#039;&#039; or &#039;&#039;&#039;udp&#039;&#039;&#039;, the scope of the service definition may&lt;br /&gt;
be constrained by defining an attribute named &#039;&#039;&#039;port&#039;&#039;&#039;, which&lt;br /&gt;
is a list of TCP or UDP port numbers or ranges thereof, separated&lt;br /&gt;
by the &#039;&#039;&#039;-&#039;&#039;&#039; character. If the protocol is &#039;&#039;&#039;icmp&#039;&#039;&#039; or&lt;br /&gt;
&#039;&#039;&#039;icmpv6&#039;&#039;&#039;, an analogous &#039;&#039;&#039;type&#039;&#039;&#039; attribute may be used. The&lt;br /&gt;
replies to ICMP messages have their own type codes, which may be&lt;br /&gt;
specified using the &#039;&#039;&#039;reply-type&#039;&#039;&#039; attribute.&lt;br /&gt;
&lt;br /&gt;
If the protocol is &#039;&#039;&#039;icmp&#039;&#039;&#039; or &#039;&#039;&#039;icmpv6&#039;&#039;&#039;, the scope of the&lt;br /&gt;
rule is also automatically limited to IPv4 or IPv6,&lt;br /&gt;
respectively. There are also other services which are specific to&lt;br /&gt;
IPv4 or IPv6. To constrain the scope of the service definition to&lt;br /&gt;
either protocol version, an optional &#039;&#039;&#039;family&#039;&#039;&#039; attribute can&lt;br /&gt;
be set to value &#039;&#039;&#039;inet&#039;&#039;&#039; or &#039;&#039;&#039;inet6&#039;&#039;&#039;, respectively.&lt;br /&gt;
&lt;br /&gt;
Some services require the server or client to open additional&lt;br /&gt;
connections to dynamically allocated ports or even different&lt;br /&gt;
hosts. &#039;&#039;Connection tracking helpers&#039;&#039; are used to make the firewall&lt;br /&gt;
aware of such additional connections. The &#039;&#039;&#039;ct-helper&#039;&#039;&#039; attribute is&lt;br /&gt;
used to associate such a helper to a service definition when&lt;br /&gt;
required by the service.&lt;br /&gt;
&lt;br /&gt;
All rule objects, except for policies, may have an attribute named&lt;br /&gt;
&#039;&#039;&#039;service&#039;&#039;&#039;, constraining the rule&#039;s scope to specific services&lt;br /&gt;
only. This attribute is a list of service names, referring to the keys&lt;br /&gt;
of the top-level service dictionary.&lt;br /&gt;
&lt;br /&gt;
=== Zones ===&lt;br /&gt;
&lt;br /&gt;
A &#039;&#039;zone&#039;&#039; represents a set of network hosts. A top-level attribute &lt;br /&gt;
&#039;&#039;&#039;zone&#039;&#039;&#039; is a dictionary that maps zone names to zone objects. A&lt;br /&gt;
zone object has an attribute named &#039;&#039;&#039;iface&#039;&#039;&#039;, &#039;&#039;&#039;addr&#039;&#039;&#039;, or&lt;br /&gt;
both. &#039;&#039;&#039;iface&#039;&#039;&#039; is a list of network interfaces and &#039;&#039;&#039;addr&#039;&#039;&#039; is a&lt;br /&gt;
list of IPv4/IPv6 host and network addresses (CIDR&lt;br /&gt;
notation). &#039;&#039;&#039;addr&#039;&#039;&#039; may also contain domain names, which are&lt;br /&gt;
expanded to IP addresses using DNS resolution. If not defined,&lt;br /&gt;
&#039;&#039;&#039;addr&#039;&#039;&#039; defaults to the entire address space and &#039;&#039;&#039;iface&#039;&#039;&#039; to all&lt;br /&gt;
interfaces. An empty zone can be defined by setting either &#039;&#039;&#039;addr&#039;&#039;&#039;&lt;br /&gt;
or &#039;&#039;&#039;iface&#039;&#039;&#039; to an empty list.&lt;br /&gt;
&lt;br /&gt;
Rule objects contain two attributes, &#039;&#039;&#039;in&#039;&#039;&#039; and &#039;&#039;&#039;out&#039;&#039;&#039;, which are&lt;br /&gt;
lists of zone names. These attributes control whether a packet matches&lt;br /&gt;
the rule or not. If a particular zone is referenced by the &#039;&#039;&#039;in&#039;&#039;&#039; &lt;br /&gt;
attribute, the rule applies to packets whose ingress interface and&lt;br /&gt;
source address are covered by the zone definition. Correspondingly, if&lt;br /&gt;
a zone is referenced by the &#039;&#039;&#039;out&#039;&#039;&#039; attribute, the rule applies to&lt;br /&gt;
packets whose egress interface and destination address are included in&lt;br /&gt;
the zone. If both &#039;&#039;&#039;in&#039;&#039;&#039; and &#039;&#039;&#039;out&#039;&#039;&#039; are defined, the packet must&lt;br /&gt;
fulfill both criteria in order to match the rule.&lt;br /&gt;
&lt;br /&gt;
The firewall host itself can be referred to using the special value&lt;br /&gt;
&#039;&#039;&#039;_fw&#039;&#039;&#039; as the zone name.&lt;br /&gt;
&lt;br /&gt;
By default, awall does not generate iptables rules with identical&lt;br /&gt;
ingress and egress interfaces. This behavior can be changed per zone&lt;br /&gt;
by setting the optional &#039;&#039;&#039;route-back&#039;&#039;&#039; attribute of the zone to&lt;br /&gt;
&#039;&#039;&#039;true&#039;&#039;&#039;. Note that this attribute can have an effect also in the&lt;br /&gt;
case where &#039;&#039;&#039;in&#039;&#039;&#039; and &#039;&#039;&#039;out&#039;&#039;&#039; attributes of a rule are not equal&lt;br /&gt;
but their definitions overlap. In this case, the &#039;&#039;&#039;route-back&#039;&#039;&#039;&lt;br /&gt;
attribute of the &#039;&#039;&#039;out&#039;&#039;&#039; zone determines the behavior.&lt;br /&gt;
&lt;br /&gt;
=== Logging Classes ===&lt;br /&gt;
&lt;br /&gt;
A &#039;&#039;logging class&#039;&#039; specifies how packets matching certain rules are&lt;br /&gt;
logged. A top-level attribute &#039;&#039;&#039;log&#039;&#039;&#039; is a dictionary that maps&lt;br /&gt;
logging class names to setting objects.&lt;br /&gt;
&lt;br /&gt;
A setting object may have an attribute named &#039;&#039;&#039;mode&#039;&#039;&#039;, which&lt;br /&gt;
specifies which logging facility to use. Allowed values are &#039;&#039;&#039;log&#039;&#039;&#039;,&lt;br /&gt;
&#039;&#039;&#039;nflog&#039;&#039;&#039;, and &#039;&#039;&#039;ulog&#039;&#039;&#039;. The default is &#039;&#039;&#039;log&#039;&#039;&#039;, i.e. in-kernel&lt;br /&gt;
logging.&lt;br /&gt;
&lt;br /&gt;
The following table shows the optional attributes valid for all&lt;br /&gt;
logging modes:&lt;br /&gt;
&lt;br /&gt;
{|&lt;br /&gt;
!Attribute!!Description&lt;br /&gt;
|-&lt;br /&gt;
|&#039;&#039;&#039;every&#039;&#039;&#039;&lt;br /&gt;
|Divide successive packets into groups, the size of which is specified by the value of this attribute, and log only the first packet of each group&lt;br /&gt;
|-&lt;br /&gt;
|&#039;&#039;&#039;limit&#039;&#039;&#039;&lt;br /&gt;
|Maximum number of packets to be logged per second per this rule&lt;br /&gt;
|-&lt;br /&gt;
|&#039;&#039;&#039;prefix&#039;&#039;&#039;&lt;br /&gt;
|String with which the log entries are prefixed&lt;br /&gt;
|-&lt;br /&gt;
|&#039;&#039;&#039;probability&#039;&#039;&#039;&lt;br /&gt;
|Probability for logging an individual packet (default: 1)&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
With the in-kernel log mode &#039;&#039;&#039;log&#039;&#039;&#039;, the level of logging may be&lt;br /&gt;
specified using the &#039;&#039;&#039;level&#039;&#039;&#039; attribute. Log modes &#039;&#039;&#039;nflog&#039;&#039;&#039; and&lt;br /&gt;
&#039;&#039;&#039;ulog&#039;&#039;&#039; are about copying the packets into user space, at least&lt;br /&gt;
partially. The following table shows the additional attributes valid&lt;br /&gt;
with these modes:&lt;br /&gt;
&lt;br /&gt;
{|&lt;br /&gt;
!Attribute!!Description&lt;br /&gt;
|-&lt;br /&gt;
|&#039;&#039;&#039;group&#039;&#039;&#039;&lt;br /&gt;
|Netlink group to be used&lt;br /&gt;
|-&lt;br /&gt;
|&#039;&#039;&#039;range&#039;&#039;&#039;&lt;br /&gt;
|Number of bytes to be copied&lt;br /&gt;
|-&lt;br /&gt;
|&#039;&#039;&#039;threshold&#039;&#039;&#039;&lt;br /&gt;
|Number of packets to queue inside the kernel before copying them&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
[[#Filter Rules|Filter]] and [[#Policy Rules|policy]] rules can have&lt;br /&gt;
an attribute named &#039;&#039;&#039;log&#039;&#039;&#039;. If it is a string, it is interpreted as&lt;br /&gt;
a reference to a logging class, and logging is performed according to&lt;br /&gt;
the definitions. If the value of the &#039;&#039;&#039;log&#039;&#039;&#039; attribute is &#039;&#039;&#039;true&#039;&#039;&#039;&lt;br /&gt;
(boolean), logging is done using default settings. If the value is&lt;br /&gt;
&#039;&#039;&#039;false&#039;&#039;&#039; (boolean), logging is disabled for the rule. If &#039;&#039;&#039;log&#039;&#039;&#039;&lt;br /&gt;
is not defined, logging is done using the default settings except for&lt;br /&gt;
accept rules, for which logging is omitted.&lt;br /&gt;
&lt;br /&gt;
Default logging settings can be set by defining a logging class named&lt;br /&gt;
&#039;&#039;&#039;_default&#039;&#039;&#039;. Normally, default logging uses the &#039;&#039;&#039;log&#039;&#039;&#039; mode with&lt;br /&gt;
packets limited to one per second.&lt;br /&gt;
&lt;br /&gt;
=== Rules ===&lt;br /&gt;
&lt;br /&gt;
There are several types of rule objects:&lt;br /&gt;
* Filter rules&lt;br /&gt;
* Policy rules&lt;br /&gt;
* Packet Logging rules&lt;br /&gt;
* NAT rules&lt;br /&gt;
* Packet Marking rules&lt;br /&gt;
* Transparent Proxy rules&lt;br /&gt;
* MSS Clamping rules&lt;br /&gt;
* Connection Tracking Bypass rules&lt;br /&gt;
&lt;br /&gt;
All rule objects can have the &#039;&#039;&#039;in&#039;&#039;&#039; and &#039;&#039;&#039;out&#039;&#039;&#039; attributes&lt;br /&gt;
referring to [[#Zones|zones]] as described in the previous section. In&lt;br /&gt;
addition, the scope of the rule can be further constrained with the&lt;br /&gt;
following attributes:&lt;br /&gt;
&lt;br /&gt;
{|&lt;br /&gt;
!Attribute!!Value format!!Effect&lt;br /&gt;
|-&lt;br /&gt;
|&#039;&#039;&#039;src&#039;&#039;&#039;&lt;br /&gt;
|Similar to &#039;&#039;&#039;addr&#039;&#039;&#039; attribute of [[#Zones|zone objects]]&lt;br /&gt;
|Packet&#039;s source address matches the value&lt;br /&gt;
|-&lt;br /&gt;
|&#039;&#039;&#039;dest&#039;&#039;&#039;&lt;br /&gt;
|Similar to &#039;&#039;&#039;addr&#039;&#039;&#039; attribute of [[#Zones|zone objects]]&lt;br /&gt;
|Packet&#039;s destination address matches the value&lt;br /&gt;
|-&lt;br /&gt;
|&#039;&#039;&#039;ipset&#039;&#039;&#039;&lt;br /&gt;
|Object containing two attributes: &#039;&#039;&#039;name&#039;&#039;&#039; referring to an [[#IP Sets|IP set]] and &#039;&#039;&#039;args&#039;&#039;&#039;, which is a list of strings &#039;&#039;&#039;in&#039;&#039;&#039; and &#039;&#039;&#039;out&#039;&#039;&#039;&lt;br /&gt;
|Packet matches the IP set referred here when the match arguments are taken from the source (&#039;&#039;&#039;in&#039;&#039;&#039;) and destination (&#039;&#039;&#039;out&#039;&#039;&#039;) address or port in the order specified by &#039;&#039;&#039;args&#039;&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
|&#039;&#039;&#039;ipsec&#039;&#039;&#039;&lt;br /&gt;
|&#039;&#039;&#039;in&#039;&#039;&#039; or &#039;&#039;&#039;out&#039;&#039;&#039;&lt;br /&gt;
|IPsec decapsulation perfomed on ingress (&#039;&#039;&#039;in&#039;&#039;&#039;) or encapsulation performed on egress (&#039;&#039;&#039;out&#039;&#039;&#039;)&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Rule objects are declared in type-specific top-level dictionaries in&lt;br /&gt;
awall policy files. If a packet matches multiple rules, the one&lt;br /&gt;
appearing earlier in the list takes precedence. If the matching rules&lt;br /&gt;
are defined in different policy files, the one that was processed&lt;br /&gt;
earlier takes precedence in the current implementation, but this may&lt;br /&gt;
change in future versions.&lt;br /&gt;
&lt;br /&gt;
==== Filter Rules ====&lt;br /&gt;
&lt;br /&gt;
Filter objects specify an action for packets fulfilling certain&lt;br /&gt;
criteria. The top-level attribute &#039;&#039;&#039;filter&#039;&#039;&#039; is a list of filter&lt;br /&gt;
objects.&lt;br /&gt;
&lt;br /&gt;
Filter objects must have an attribute named &#039;&#039;&#039;action&#039;&#039;&#039;, the value of&lt;br /&gt;
which can be one of the following:&lt;br /&gt;
&lt;br /&gt;
{|&lt;br /&gt;
!Value!!Action&lt;br /&gt;
|-&lt;br /&gt;
|&#039;&#039;&#039;accept&#039;&#039;&#039;&lt;br /&gt;
|Accept the packet (default)&lt;br /&gt;
|-&lt;br /&gt;
|&#039;&#039;&#039;reject&#039;&#039;&#039;&lt;br /&gt;
|Reject the packet with an ICMP error message&lt;br /&gt;
|-&lt;br /&gt;
|&#039;&#039;&#039;drop&#039;&#039;&#039;&lt;br /&gt;
|Silently drop the packet&lt;br /&gt;
|-&lt;br /&gt;
|&#039;&#039;&#039;tarpit&#039;&#039;&#039;&lt;br /&gt;
|Put incoming TCP connections into persist state and ignore attempts to close them. Silently drop non-TCP packets. (Connection tracking bypass is automatically enabled for the matching packets.)&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Filter objects, the action of which is &#039;&#039;&#039;accept&#039;&#039;&#039;, may also contain&lt;br /&gt;
limits for packet flow or new connections. These are specified with&lt;br /&gt;
the &#039;&#039;&#039;flow-limit&#039;&#039;&#039; and &#039;&#039;&#039;conn-limit&#039;&#039;&#039; attributes,&lt;br /&gt;
respectively. The values of these attributes are limit objects that&lt;br /&gt;
have two attributes: &#039;&#039;&#039;count&#039;&#039;&#039; and &#039;&#039;&#039;interval&#039;&#039;&#039;. &#039;&#039;&#039;count&#039;&#039;&#039;&lt;br /&gt;
specifies how many new connections or packets are allowed within the&lt;br /&gt;
time frame specified by &#039;&#039;&#039;interval&#039;&#039;&#039; in seconds (default: 1). The&lt;br /&gt;
&#039;&#039;&#039;drop&#039;&#039;&#039; action is applied to the packets exceeding the&lt;br /&gt;
limit. Optionally, the limit object may have an attribute named&lt;br /&gt;
&#039;&#039;&#039;log&#039;&#039;&#039;. It defines how the dropped packets should be logged and is&lt;br /&gt;
semantically similar to the &#039;&#039;&#039;log&#039;&#039;&#039; attribute of rule objects. A&lt;br /&gt;
limit may also be specified by a plain integer, which is interpreted&lt;br /&gt;
as the count while using default interval and log settings.&lt;br /&gt;
&lt;br /&gt;
Filter objects may have an attribute named &#039;&#039;&#039;dnat&#039;&#039;&#039;, the value of&lt;br /&gt;
which is an IPv4 address. If defined, this enables destination NAT for&lt;br /&gt;
all IPv4 packets matching the rule, such that the specified address&lt;br /&gt;
replaces the original destination address. This option has no effect&lt;br /&gt;
on IPv6 packets.&lt;br /&gt;
&lt;br /&gt;
Filter objects may have a boolean attribute named &#039;&#039;&#039;no-track&#039;&#039;&#039;. If&lt;br /&gt;
set to &#039;&#039;&#039;true&#039;&#039;&#039;, connection tracking is bypassed for the matching&lt;br /&gt;
packets. In addition, if &#039;&#039;&#039;action&#039;&#039;&#039; is set to &#039;&#039;&#039;accept&#039;&#039;&#039;, the&lt;br /&gt;
corresponding packets travelling to the reverse direction are also&lt;br /&gt;
allowed.&lt;br /&gt;
&lt;br /&gt;
If one or more connection tracking helpers are associated with the&lt;br /&gt;
services referred to by an accept rule, additional iptables rules are&lt;br /&gt;
generated for the related connections detected by the helpers. The&lt;br /&gt;
&#039;&#039;&#039;related&#039;&#039;&#039; attribute can be used to override the default rules&lt;br /&gt;
generated by awall. It is a list of basic rule objects, the packets&lt;br /&gt;
matching to which are accepted, provided that they are also detected&lt;br /&gt;
by at least one of the helpers.&lt;br /&gt;
&lt;br /&gt;
==== Policy Rules ====&lt;br /&gt;
&lt;br /&gt;
Policy objects describe the default action for packets that did not&lt;br /&gt;
match any filter. The top-level attribute &#039;&#039;&#039;policy&#039;&#039;&#039; is a list of&lt;br /&gt;
policy objects.&lt;br /&gt;
&lt;br /&gt;
Policy objects must have the &#039;&#039;&#039;action&#039;&#039;&#039; attribute defined. The&lt;br /&gt;
possible values and their semantics are the same as in&lt;br /&gt;
[[#Filter Rules|filter rules]].&lt;br /&gt;
&lt;br /&gt;
==== Packet Logging Rules ====&lt;br /&gt;
&lt;br /&gt;
Packet logging rules allow packets matching the specified criteria to&lt;br /&gt;
be logged before any filtering takes place. Such rules are contained&lt;br /&gt;
in the top-level list named &#039;&#039;&#039;packet-log&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Logging class may be specified using the &#039;&#039;&#039;log&#039;&#039;&#039;&lt;br /&gt;
attribute. Otherwise, default logging settings are used.&lt;br /&gt;
&lt;br /&gt;
==== NAT Rules ====&lt;br /&gt;
&lt;br /&gt;
NAT rules come in two flavors: &#039;&#039;source NAT rules&#039;&#039; and&lt;br /&gt;
&#039;&#039;destination NAT rules&#039;&#039;. These are contained in two top-level lists&lt;br /&gt;
named &#039;&#039;&#039;snat&#039;&#039;&#039; and &#039;&#039;&#039;dnat&#039;&#039;&#039;, respectively.&lt;br /&gt;
&lt;br /&gt;
Each NAT rule may have an attribute named &#039;&#039;&#039;to-addr&#039;&#039;&#039; that&lt;br /&gt;
specifies the IPv4 address range to which the original source or&lt;br /&gt;
destination address is mapped. The value can be a single IPv4 address&lt;br /&gt;
or a range specified by two addresses, separated with the &#039;&#039;&#039;-&#039;&#039;&#039;&lt;br /&gt;
character. If not defined, it defaults to the primary address of the&lt;br /&gt;
ingress interface in case of destination NAT, or that of the egress&lt;br /&gt;
interface in case of source NAT.&lt;br /&gt;
&lt;br /&gt;
Optionally, a NAT rule can specify the TCP and UDP port range to which&lt;br /&gt;
the original source or destination port is mapped. The attribute is&lt;br /&gt;
named &#039;&#039;&#039;to-port&#039;&#039;&#039;, and the value can be a single port number or a&lt;br /&gt;
range specified by two numbers, separated with the &#039;&#039;&#039;-&#039;&#039;&#039;&lt;br /&gt;
character. If &#039;&#039;&#039;to-port&#039;&#039;&#039; is not specified, the original port number&lt;br /&gt;
is kept intact.&lt;br /&gt;
&lt;br /&gt;
NAT rules, may have an &#039;&#039;&#039;action&#039;&#039;&#039; attribute set to value&lt;br /&gt;
&#039;&#039;&#039;include&#039;&#039;&#039; or &#039;&#039;&#039;exclude&#039;&#039;&#039;. The latter means that NAT is not&lt;br /&gt;
performed on the matching packets (unless they match an &#039;&#039;&#039;include&#039;&#039;&#039;&lt;br /&gt;
rule processed earlier). The default value is &#039;&#039;&#039;include&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
==== Packet Marking Rules ====&lt;br /&gt;
&lt;br /&gt;
Packet marking rules are used to mark incoming packets matching the&lt;br /&gt;
specified criteria. The mark can be used as a basis for the routing&lt;br /&gt;
decision. Each marking rule must specify the mark using the &#039;&#039;&#039;mark&#039;&#039;&#039;&lt;br /&gt;
attribute, which is a 32-bit integer.&lt;br /&gt;
&lt;br /&gt;
Normal marking rules are contained by the top-level list attribute&lt;br /&gt;
named &#039;&#039;&#039;mark&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
There is another top-level list attribute, named &#039;&#039;&#039;route-track&#039;&#039;&#039;,&lt;br /&gt;
which contains route tracking rules. These are special marking rules&lt;br /&gt;
which cause all the subsequent packets related to the same connection&lt;br /&gt;
to be marked according to the rule.&lt;br /&gt;
&lt;br /&gt;
==== Transparent Proxy Rules ====&lt;br /&gt;
&lt;br /&gt;
Transparent proxy rules divert the matching packets to a local proxy&lt;br /&gt;
process without altering their headers. Such rules are contained in&lt;br /&gt;
the top-level list named &#039;&#039;&#039;tproxy&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
In addition to the firewall configuration, using a transparent proxy&lt;br /&gt;
requires a routing configuration where packets marked for proxying are&lt;br /&gt;
diverted to a local process. The &#039;&#039;&#039;awall_tproxy_mark&#039;&#039;&#039; variable can&lt;br /&gt;
be used to specify the mark for such packets, which defaults to 1.&lt;br /&gt;
&lt;br /&gt;
Proxy rules may also have an attribute named &#039;&#039;&#039;to-port&#039;&#039;&#039; for&lt;br /&gt;
specifying the TCP or UDP port of the proxy if it is different from&lt;br /&gt;
the original destination port.&lt;br /&gt;
&lt;br /&gt;
==== MSS Clamping Rules ====&lt;br /&gt;
&lt;br /&gt;
MSS Clamping Rules are used to deal with ISPs that block ICMP&lt;br /&gt;
Fragmentation Needed or ICMPv6 Packet Too Big packets. An MSS clamping&lt;br /&gt;
rule overwrites the MSS option with a value specified with the&lt;br /&gt;
&#039;&#039;&#039;mss&#039;&#039;&#039; attribute for the matching TCP connections. If &#039;&#039;&#039;mss&#039;&#039;&#039; is&lt;br /&gt;
not specified, a suitable value is automatically determined from the&lt;br /&gt;
path MTU. The MSS clamping rules are located in the top-level&lt;br /&gt;
dictionary named &#039;&#039;&#039;clamp-mss&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
==== Connection Tracking Bypass Rules ====&lt;br /&gt;
&lt;br /&gt;
Connection tracking bypass rules are used to disable connection&lt;br /&gt;
tracking for packets matching the specified criteria. The top-level&lt;br /&gt;
attribute &#039;&#039;&#039;no-track&#039;&#039;&#039; is a list of such rules.&lt;br /&gt;
&lt;br /&gt;
Like [[#NAT Rules|NAT rules]], connection tracking bypass rules may&lt;br /&gt;
have an &#039;&#039;&#039;action&#039;&#039;&#039; attribute set to value &#039;&#039;&#039;include&#039;&#039;&#039; or&lt;br /&gt;
&#039;&#039;&#039;exclude&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
=== IP Sets ===&lt;br /&gt;
&lt;br /&gt;
Any IP set referenced by rule objects should be created by&lt;br /&gt;
awall. Auxiliary &#039;&#039;IP set&#039;&#039; objects are used to defined them in awall&lt;br /&gt;
policy files. The top-level attribute &#039;&#039;&#039;ipset&#039;&#039;&#039; is a dictionary, the&lt;br /&gt;
keys of which are IP set names. The values are IP set objects, which&lt;br /&gt;
have two mandatory attributes. The attribute named &#039;&#039;&#039;type&#039;&#039;&#039; &lt;br /&gt;
corresponds to the type argument of the &amp;lt;tt&amp;gt;ipset create&amp;lt;/tt&amp;gt; &lt;br /&gt;
command. &#039;&#039;&#039;family&#039;&#039;&#039; specifies whether the set is for IPv4 or IPv6&lt;br /&gt;
addresses, and the possible values are &#039;&#039;&#039;inet&#039;&#039;&#039; and &#039;&#039;&#039;inet6&#039;&#039;&#039;,&lt;br /&gt;
correspondingly.&lt;br /&gt;
&lt;br /&gt;
For bitmap-type IP sets, the &#039;&#039;&#039;range&#039;&#039;&#039; attribute specifies the&lt;br /&gt;
range of allowed IPv4 addresses. It may be given as a network&lt;br /&gt;
address or two addresses separated by the &#039;&#039;&#039;-&#039;&#039;&#039; character. It&lt;br /&gt;
is not necessary to specify &#039;&#039;&#039;family&#039;&#039;&#039; for bitmaps, since the&lt;br /&gt;
kernel supports only IPv4 bitmaps.&lt;br /&gt;
&lt;br /&gt;
== Command Line Syntax ==&lt;br /&gt;
&lt;br /&gt;
=== Translating Policy Files to Firewall Configuration Files ===&lt;br /&gt;
&lt;br /&gt;
 &#039;&#039;&#039;awall translate&#039;&#039;&#039; [&#039;&#039;&#039;-o&#039;&#039;&#039;|&#039;&#039;&#039;--output&#039;&#039;&#039; DIRECTORY] [&#039;&#039;&#039;-V&#039;&#039;&#039;|&#039;&#039;&#039;--verify&#039;&#039;&#039;]&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;tt&amp;gt;--verify&amp;lt;/tt&amp;gt; option makes awall verify the configuration&lt;br /&gt;
using the test mode of iptables-restore before overwriting the old&lt;br /&gt;
files.&lt;br /&gt;
&lt;br /&gt;
Specifying the output directory allows testing awall policies without&lt;br /&gt;
overwriting the current iptables and ipset configuration files. By&lt;br /&gt;
default, awall generates the configuration to &amp;lt;tt&amp;gt;/etc/iptables&amp;lt;/tt&amp;gt; &lt;br /&gt;
and &amp;lt;tt&amp;gt;/etc/ipset.d&amp;lt;/tt&amp;gt;, which are read by the init scripts.&lt;br /&gt;
&lt;br /&gt;
=== Run-Time Configuration of Firewall ===&lt;br /&gt;
&lt;br /&gt;
 &#039;&#039;&#039;awall activate&#039;&#039;&#039; [&#039;&#039;&#039;-f&#039;&#039;&#039;|&#039;&#039;&#039;--force&#039;&#039;&#039;]&lt;br /&gt;
&lt;br /&gt;
This command genereates firewall configuration from the policy files&lt;br /&gt;
and enables it. If the user confirms the new configuration by hitting&lt;br /&gt;
the Return key within 10 seconds or the &amp;lt;tt&amp;gt;--force&amp;lt;/tt&amp;gt; option is&lt;br /&gt;
used, the configuration is saved to the files. Otherwise, the old&lt;br /&gt;
configuration is restored.&lt;br /&gt;
&lt;br /&gt;
There is also a command for deleting all firewall rules:&lt;br /&gt;
&lt;br /&gt;
 &#039;&#039;&#039;awall flush&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
This command configures the firewall to drop all packets.&lt;br /&gt;
&lt;br /&gt;
=== Optional Policies ===&lt;br /&gt;
&lt;br /&gt;
Optional policies can be enabled or disabled using this command:&lt;br /&gt;
&lt;br /&gt;
 &#039;&#039;&#039;awall&#039;&#039;&#039; {&#039;&#039;&#039;enable&#039;&#039;&#039;|&#039;&#039;&#039;disable&#039;&#039;&#039;} POLICY...&lt;br /&gt;
&lt;br /&gt;
Optional policies can be listed using this command:&lt;br /&gt;
&lt;br /&gt;
 &#039;&#039;&#039;awall list&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;&#039;enabled&#039;&#039;&#039; status means that the policy has been enabled by the&lt;br /&gt;
user. The &#039;&#039;&#039;disabled&#039;&#039;&#039; status means that the policy is not in&lt;br /&gt;
use. The &#039;&#039;&#039;required&#039;&#039;&#039; status means that the policy has not been&lt;br /&gt;
enabled by the user but is in use because it is required by another&lt;br /&gt;
policy which is in use.&lt;br /&gt;
&lt;br /&gt;
=== Debugging Policies ===&lt;br /&gt;
&lt;br /&gt;
This command can be used to dump variable, zone, and other definitions&lt;br /&gt;
as well as their source policies:&lt;br /&gt;
&lt;br /&gt;
 &#039;&#039;&#039;awall dump&#039;&#039;&#039; [LEVEL]&lt;br /&gt;
&lt;br /&gt;
The level is an integer in range 0&amp;amp;ndash;5 and defaults to 0. More&lt;br /&gt;
information is displayed on higher levels.&lt;br /&gt;
&lt;br /&gt;
[[Category:Networking]]&lt;br /&gt;
[[Category:Security]]&lt;/div&gt;</summary>
		<author><name>Kunkku</name></author>
	</entry>
	<entry>
		<id>https://wiki.alpinelinux.org/w/index.php?title=Alpine_Wall_User%27s_Guide&amp;diff=9917</id>
		<title>Alpine Wall User&#039;s Guide</title>
		<link rel="alternate" type="text/html" href="https://wiki.alpinelinux.org/w/index.php?title=Alpine_Wall_User%27s_Guide&amp;diff=9917"/>
		<updated>2014-03-31T16:50:44Z</updated>

		<summary type="html">&lt;p&gt;Kunkku: /* Connection Tracking Bypass Rules */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Configuration File Processing ==&lt;br /&gt;
&lt;br /&gt;
[[Alpine Wall]] (awall) reads its configuration from multiple&lt;br /&gt;
JSON-formatted files, called &#039;&#039;policy files&#039;&#039;. The files located in&lt;br /&gt;
directory &amp;lt;tt&amp;gt;/usr/share/awall/mandatory&amp;lt;/tt&amp;gt; are &#039;&#039;mandatory&#039;&#039;&lt;br /&gt;
policies shipped with APK packages. In addition, there can be&lt;br /&gt;
installation-specific mandatory policies in &amp;lt;tt&amp;gt;/etc/awall&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
The latter directory may also contain symbolic links to policy files&lt;br /&gt;
located in &amp;lt;tt&amp;gt;/usr/share/awall/optional&amp;lt;/tt&amp;gt; and&lt;br /&gt;
&amp;lt;tt&amp;gt;/etc/awall/optional&amp;lt;/tt&amp;gt;. These are &#039;&#039;optional&#039;&#039; policies, which&lt;br /&gt;
can be enabled on need basis. Such symbolic links are easily created&lt;br /&gt;
and destroyed using the &amp;lt;tt&amp;gt;awall enable&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;awall&lt;br /&gt;
disable&amp;lt;/tt&amp;gt; commands. &amp;lt;tt&amp;gt;awall list&amp;lt;/tt&amp;gt; shows which optional&lt;br /&gt;
policies are enabled and disabled. The command also prints the&lt;br /&gt;
description of the optional policy if defined in the file using a&lt;br /&gt;
top-level attribute named &#039;&#039;&#039;description&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Sometimes a policy file depends on other policy files. In this case,&lt;br /&gt;
the policy file must have a top-level attribute &#039;&#039;&#039;import&#039;&#039;&#039;, the&lt;br /&gt;
value of which is a list of policy names, which correspond to the file&lt;br /&gt;
names without the &amp;lt;tt&amp;gt;.json&amp;lt;/tt&amp;gt; suffix. The imported policies may be&lt;br /&gt;
either optional policies or &#039;&#039;private&#039;&#039; policies, located in&lt;br /&gt;
&amp;lt;tt&amp;gt;/usr/share/awall/private&amp;lt;/tt&amp;gt; or &amp;lt;tt&amp;gt;/etc/awall/private&amp;lt;/tt&amp;gt;. By&lt;br /&gt;
default, the policies listed there are processed before the importing&lt;br /&gt;
policy.&lt;br /&gt;
&lt;br /&gt;
The order of the generated iptables rules generally reflects the&lt;br /&gt;
processing order of their corresponding awall policies. The&lt;br /&gt;
processing order of policies can be adjusted by defining&lt;br /&gt;
top-level attributes &#039;&#039;&#039;after&#039;&#039;&#039; and &#039;&#039;&#039;before&#039;&#039;&#039; in policy&lt;br /&gt;
files. These attributes are lists of policies, after or before&lt;br /&gt;
which the declaring policy shall be processed. Putting a policy&lt;br /&gt;
name to either of these lists does not by itself import the&lt;br /&gt;
policy. The ordering directives are ignored with respect to those&lt;br /&gt;
policies that are not enabled by the user or imported by other&lt;br /&gt;
policies. If not defined, &#039;&#039;&#039;after&#039;&#039;&#039; is assumed to be equal to&lt;br /&gt;
the relative complement of the &#039;&#039;&#039;before&#039;&#039;&#039; definition in the&lt;br /&gt;
&#039;&#039;&#039;import&#039;&#039;&#039; definition of the policy.&lt;br /&gt;
&lt;br /&gt;
As the import directive does not require the path name to be&lt;br /&gt;
specified, awall expects policies to have unique names, even if&lt;br /&gt;
located in different directories. It is allowed to import optional&lt;br /&gt;
policies that are not explicitly enabled by the user. Such policies&lt;br /&gt;
show up with the &amp;lt;tt&amp;gt;required&amp;lt;/tt&amp;gt; status in the output of &amp;lt;tt&amp;gt;awall&lt;br /&gt;
list&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
== List Parameters ==&lt;br /&gt;
&lt;br /&gt;
Several awall parameters are defined as lists of values. In order to&lt;br /&gt;
facilitate manual editing of policy files, awall also accepts single&lt;br /&gt;
values in place of lists. Such values are semantically equivalent to&lt;br /&gt;
lists containing one element.&lt;br /&gt;
&lt;br /&gt;
== Variable Expansion ==&lt;br /&gt;
&lt;br /&gt;
Awall allows variable definitions in policy files. The top-level&lt;br /&gt;
attribute &#039;&#039;&#039;variable&#039;&#039;&#039; is a dictionary containing the&lt;br /&gt;
definitions. The value of a variable can be of any type (string,&lt;br /&gt;
integer, list, or dictionary).&lt;br /&gt;
&lt;br /&gt;
A variable is referenced in policy files by a string which equals the&lt;br /&gt;
variable name prepended with the &#039;&#039;&#039;$&#039;&#039;&#039; character. If the value of&lt;br /&gt;
the variable is a string, the reference can be embedded into a longer&lt;br /&gt;
string in order to substitute some part of that string (in shell&lt;br /&gt;
style). Variable references can be used when defining other variables,&lt;br /&gt;
as long as the definitions are not circular.&lt;br /&gt;
&lt;br /&gt;
Policy files can reference variables defined in other policy&lt;br /&gt;
files. Policy files can also override variables defined elsewhere by&lt;br /&gt;
redefining them. In this case, the new definition affects all policy&lt;br /&gt;
files, also those processed before the overriding policy. Awall&lt;br /&gt;
variables are in fact simple macros, since each variable remains&lt;br /&gt;
constant thoughout a single processing round. If multiple files define&lt;br /&gt;
the same variable, the definition in the file processed last takes&lt;br /&gt;
effect.&lt;br /&gt;
&lt;br /&gt;
If defined as an empty string, all non-embedded references to a&lt;br /&gt;
variable evaluate as if the attribute in question was not present in&lt;br /&gt;
the configuration. This is also the case when a string containing&lt;br /&gt;
embedded variable references finally evaluates to an empty string.&lt;br /&gt;
&lt;br /&gt;
== Configuration Objects ==&lt;br /&gt;
&lt;br /&gt;
Configuration objects can be divided into two main types.&lt;br /&gt;
&#039;&#039;Auxiliary objects&#039;&#039; model high-level concepts such as services and&lt;br /&gt;
zones. &#039;&#039;Rule objects&#039;&#039; translate into one or more iptables rules, and&lt;br /&gt;
are often defined with the help of some auxiliary objects.&lt;br /&gt;
&lt;br /&gt;
=== Services ===&lt;br /&gt;
&lt;br /&gt;
A &#039;&#039;service&#039;&#039; represents a set of network protocols. A top-level&lt;br /&gt;
attribute &#039;&#039;&#039;service&#039;&#039;&#039; is a dictionary that maps service names to&lt;br /&gt;
service definition objects, or lists thereof in more complex cases.&lt;br /&gt;
&lt;br /&gt;
A service definition object contains an attribute named&lt;br /&gt;
&#039;&#039;&#039;proto&#039;&#039;&#039;, which corresponds to the &amp;lt;tt&amp;gt;--protocol&amp;lt;/tt&amp;gt; option&lt;br /&gt;
of iptables. The protocol can be defined as a numerical value or&lt;br /&gt;
string as defined in &amp;lt;tt&amp;gt;/etc/protocols&amp;lt;/tt&amp;gt;. If the protocol is&lt;br /&gt;
&#039;&#039;&#039;tcp&#039;&#039;&#039; or &#039;&#039;&#039;udp&#039;&#039;&#039;, the scope of the service definition may&lt;br /&gt;
be constrained by defining an attribute named &#039;&#039;&#039;port&#039;&#039;&#039;, which&lt;br /&gt;
is a list of TCP or UDP port numbers or ranges thereof, separated&lt;br /&gt;
by the &#039;&#039;&#039;-&#039;&#039;&#039; character. If the protocol is &#039;&#039;&#039;icmp&#039;&#039;&#039; or&lt;br /&gt;
&#039;&#039;&#039;icmpv6&#039;&#039;&#039;, an analogous &#039;&#039;&#039;type&#039;&#039;&#039; attribute may be used. The&lt;br /&gt;
replies to ICMP messages have their own type codes, which may be&lt;br /&gt;
specified using the &#039;&#039;&#039;reply-type&#039;&#039;&#039; attribute.&lt;br /&gt;
&lt;br /&gt;
If the protocol is &#039;&#039;&#039;icmp&#039;&#039;&#039; or &#039;&#039;&#039;icmpv6&#039;&#039;&#039;, the scope of the&lt;br /&gt;
rule is also automatically limited to IPv4 or IPv6,&lt;br /&gt;
respectively. There are also other services which are specific to&lt;br /&gt;
IPv4 or IPv6. To constrain the scope of the service definition to&lt;br /&gt;
either protocol version, an optional &#039;&#039;&#039;family&#039;&#039;&#039; attribute can&lt;br /&gt;
be set to value &#039;&#039;&#039;inet&#039;&#039;&#039; or &#039;&#039;&#039;inet6&#039;&#039;&#039;, respectively.&lt;br /&gt;
&lt;br /&gt;
Some services require the server or client to open additional&lt;br /&gt;
connections to dynamically allocated ports or even different&lt;br /&gt;
hosts. &#039;&#039;Connection tracking helpers&#039;&#039; are used to make the firewall&lt;br /&gt;
aware of such additional connections. The &#039;&#039;&#039;ct-helper&#039;&#039;&#039; attribute is&lt;br /&gt;
used to associate such a helper to a service definition when&lt;br /&gt;
required by the service.&lt;br /&gt;
&lt;br /&gt;
All rule objects, except for policies, may have an attribute named&lt;br /&gt;
&#039;&#039;&#039;service&#039;&#039;&#039;, constraining the rule&#039;s scope to specific services&lt;br /&gt;
only. This attribute is a list of service names, referring to the keys&lt;br /&gt;
of the top-level service dictionary.&lt;br /&gt;
&lt;br /&gt;
=== Zones ===&lt;br /&gt;
&lt;br /&gt;
A &#039;&#039;zone&#039;&#039; represents a set of network hosts. A top-level attribute &lt;br /&gt;
&#039;&#039;&#039;zone&#039;&#039;&#039; is a dictionary that maps zone names to zone objects. A&lt;br /&gt;
zone object has an attribute named &#039;&#039;&#039;iface&#039;&#039;&#039;, &#039;&#039;&#039;addr&#039;&#039;&#039;, or&lt;br /&gt;
both. &#039;&#039;&#039;iface&#039;&#039;&#039; is a list of network interfaces and &#039;&#039;&#039;addr&#039;&#039;&#039; is a&lt;br /&gt;
list of IPv4/IPv6 host and network addresses (CIDR&lt;br /&gt;
notation). &#039;&#039;&#039;addr&#039;&#039;&#039; may also contain domain names, which are&lt;br /&gt;
expanded to IP addresses using DNS resolution. If not defined,&lt;br /&gt;
&#039;&#039;&#039;addr&#039;&#039;&#039; defaults to the entire address space and &#039;&#039;&#039;iface&#039;&#039;&#039; to all&lt;br /&gt;
interfaces. An empty zone can be defined by setting either &#039;&#039;&#039;addr&#039;&#039;&#039;&lt;br /&gt;
or &#039;&#039;&#039;iface&#039;&#039;&#039; to an empty list.&lt;br /&gt;
&lt;br /&gt;
Rule objects contain two attributes, &#039;&#039;&#039;in&#039;&#039;&#039; and &#039;&#039;&#039;out&#039;&#039;&#039;, which are&lt;br /&gt;
lists of zone names. These attributes control whether a packet matches&lt;br /&gt;
the rule or not. If a particular zone is referenced by the &#039;&#039;&#039;in&#039;&#039;&#039; &lt;br /&gt;
attribute, the rule applies to packets whose ingress interface and&lt;br /&gt;
source address are covered by the zone definition. Correspondingly, if&lt;br /&gt;
a zone is referenced by the &#039;&#039;&#039;out&#039;&#039;&#039; attribute, the rule applies to&lt;br /&gt;
packets whose egress interface and destination address are included in&lt;br /&gt;
the zone. If both &#039;&#039;&#039;in&#039;&#039;&#039; and &#039;&#039;&#039;out&#039;&#039;&#039; are defined, the packet must&lt;br /&gt;
fulfill both criteria in order to match the rule.&lt;br /&gt;
&lt;br /&gt;
The firewall host itself can be referred to using the special value&lt;br /&gt;
&#039;&#039;&#039;_fw&#039;&#039;&#039; as the zone name.&lt;br /&gt;
&lt;br /&gt;
By default, awall does not generate iptables rules with identical&lt;br /&gt;
ingress and egress interfaces. This behavior can be changed per zone&lt;br /&gt;
by setting the optional &#039;&#039;&#039;route-back&#039;&#039;&#039; attribute of the zone to&lt;br /&gt;
&#039;&#039;&#039;true&#039;&#039;&#039;. Note that this attribute can have an effect also in the&lt;br /&gt;
case where &#039;&#039;&#039;in&#039;&#039;&#039; and &#039;&#039;&#039;out&#039;&#039;&#039; attributes of a rule are not equal&lt;br /&gt;
but their definitions overlap. In this case, the &#039;&#039;&#039;route-back&#039;&#039;&#039;&lt;br /&gt;
attribute of the &#039;&#039;&#039;out&#039;&#039;&#039; zone determines the behavior.&lt;br /&gt;
&lt;br /&gt;
=== Logging Classes ===&lt;br /&gt;
&lt;br /&gt;
A &#039;&#039;logging class&#039;&#039; specifies how packets matching certain rules are&lt;br /&gt;
logged. A top-level attribute &#039;&#039;&#039;log&#039;&#039;&#039; is a dictionary that maps&lt;br /&gt;
logging class names to setting objects.&lt;br /&gt;
&lt;br /&gt;
A setting object may have an attribute named &#039;&#039;&#039;mode&#039;&#039;&#039;, which&lt;br /&gt;
specifies which logging facility to use. Allowed values are &#039;&#039;&#039;log&#039;&#039;&#039;,&lt;br /&gt;
&#039;&#039;&#039;nflog&#039;&#039;&#039;, and &#039;&#039;&#039;ulog&#039;&#039;&#039;. The default is &#039;&#039;&#039;log&#039;&#039;&#039;, i.e. in-kernel&lt;br /&gt;
logging.&lt;br /&gt;
&lt;br /&gt;
The following table shows the optional attributes valid for all&lt;br /&gt;
logging modes:&lt;br /&gt;
&lt;br /&gt;
{|&lt;br /&gt;
!Attribute!!Description&lt;br /&gt;
|-&lt;br /&gt;
|&#039;&#039;&#039;every&#039;&#039;&#039;&lt;br /&gt;
|Divide successive packets into groups, the size of which is specified by the value of this attribute, and log only the first packet of each group&lt;br /&gt;
|-&lt;br /&gt;
|&#039;&#039;&#039;limit&#039;&#039;&#039;&lt;br /&gt;
|Maximum number of packets to be logged per second per this rule&lt;br /&gt;
|-&lt;br /&gt;
|&#039;&#039;&#039;prefix&#039;&#039;&#039;&lt;br /&gt;
|String with which the log entries are prefixed&lt;br /&gt;
|-&lt;br /&gt;
|&#039;&#039;&#039;probability&#039;&#039;&#039;&lt;br /&gt;
|Probability for logging an individual packet (default: 1)&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
With the in-kernel log mode &#039;&#039;&#039;log&#039;&#039;&#039;, the level of logging may be&lt;br /&gt;
specified using the &#039;&#039;&#039;level&#039;&#039;&#039; attribute. Log modes &#039;&#039;&#039;nflog&#039;&#039;&#039; and&lt;br /&gt;
&#039;&#039;&#039;ulog&#039;&#039;&#039; are about copying the packets into user space, at least&lt;br /&gt;
partially. The following table shows the additional attributes valid&lt;br /&gt;
with these modes:&lt;br /&gt;
&lt;br /&gt;
{|&lt;br /&gt;
!Attribute!!Description&lt;br /&gt;
|-&lt;br /&gt;
|&#039;&#039;&#039;group&#039;&#039;&#039;&lt;br /&gt;
|Netlink group to be used&lt;br /&gt;
|-&lt;br /&gt;
|&#039;&#039;&#039;range&#039;&#039;&#039;&lt;br /&gt;
|Number of bytes to be copied&lt;br /&gt;
|-&lt;br /&gt;
|&#039;&#039;&#039;threshold&#039;&#039;&#039;&lt;br /&gt;
|Number of packets to queue inside the kernel before copying them&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Filter and policy rules can have an attribute named &#039;&#039;&#039;log&#039;&#039;&#039;. If it&lt;br /&gt;
is a string, it is interpreted as a reference to a logging class, and&lt;br /&gt;
logging is performed according to the definitions. If the value of the&lt;br /&gt;
&#039;&#039;&#039;log&#039;&#039;&#039; attribute is &#039;&#039;&#039;true&#039;&#039;&#039; (boolean), logging is done using&lt;br /&gt;
default settings. If the value is &#039;&#039;&#039;false&#039;&#039;&#039; (boolean), logging is&lt;br /&gt;
disabled for the rule. If &#039;&#039;&#039;log&#039;&#039;&#039; is not defined, logging is done&lt;br /&gt;
using the default settings except for accept rules, for which logging&lt;br /&gt;
is omitted.&lt;br /&gt;
&lt;br /&gt;
Default logging settings can be set by defining a logging class named&lt;br /&gt;
&#039;&#039;&#039;_default&#039;&#039;&#039;. Normally, default logging uses the &#039;&#039;&#039;log&#039;&#039;&#039; mode with&lt;br /&gt;
packets limited to one per second.&lt;br /&gt;
&lt;br /&gt;
=== Rules ===&lt;br /&gt;
&lt;br /&gt;
There are several types of rule objects:&lt;br /&gt;
* Filter rules&lt;br /&gt;
* Policy rules&lt;br /&gt;
* Packet Logging rules&lt;br /&gt;
* NAT rules&lt;br /&gt;
* Packet Marking rules&lt;br /&gt;
* Transparent Proxy rules&lt;br /&gt;
* MSS Clamping rules&lt;br /&gt;
* Connection Tracking Bypass rules&lt;br /&gt;
&lt;br /&gt;
All rule objects can have the &#039;&#039;&#039;in&#039;&#039;&#039; and &#039;&#039;&#039;out&#039;&#039;&#039; attributes&lt;br /&gt;
referring to zones as described in the previous section. In addition,&lt;br /&gt;
the scope of the rule can be further constrained with the following&lt;br /&gt;
attributes:&lt;br /&gt;
&lt;br /&gt;
{|&lt;br /&gt;
!Attribute!!Value format!!Effect&lt;br /&gt;
|-&lt;br /&gt;
|&#039;&#039;&#039;src&#039;&#039;&#039;&lt;br /&gt;
|Similar to &#039;&#039;&#039;addr&#039;&#039;&#039; attribute of zone objects&lt;br /&gt;
|Packet&#039;s source address matches the value&lt;br /&gt;
|-&lt;br /&gt;
|&#039;&#039;&#039;dest&#039;&#039;&#039;&lt;br /&gt;
|Similar to &#039;&#039;&#039;addr&#039;&#039;&#039; attribute of zone objects&lt;br /&gt;
|Packet&#039;s destination address matches the value&lt;br /&gt;
|-&lt;br /&gt;
|&#039;&#039;&#039;ipset&#039;&#039;&#039;&lt;br /&gt;
|Object containing two attributes: &#039;&#039;&#039;name&#039;&#039;&#039; referring to an IP set and &#039;&#039;&#039;args&#039;&#039;&#039;, which is a list of strings &#039;&#039;&#039;in&#039;&#039;&#039; and &#039;&#039;&#039;out&#039;&#039;&#039;&lt;br /&gt;
|Packet matches the IP set referred here when the match arguments are taken from the source (&#039;&#039;&#039;in&#039;&#039;&#039;) and destination (&#039;&#039;&#039;out&#039;&#039;&#039;) address or port in the order specified by &#039;&#039;&#039;args&#039;&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
|&#039;&#039;&#039;ipsec&#039;&#039;&#039;&lt;br /&gt;
|&#039;&#039;&#039;in&#039;&#039;&#039; or &#039;&#039;&#039;out&#039;&#039;&#039;&lt;br /&gt;
|IPsec decapsulation perfomed on ingress (&#039;&#039;&#039;in&#039;&#039;&#039;) or encapsulation performed on egress (&#039;&#039;&#039;out&#039;&#039;&#039;)&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Rule objects are declared in type-specific top-level dictionaries in&lt;br /&gt;
awall policy files. If a packet matches multiple rules, the one&lt;br /&gt;
appearing earlier in the list takes precedence. If the matching rules&lt;br /&gt;
are defined in different policy files, the one that was processed&lt;br /&gt;
earlier takes precedence in the current implementation, but this may&lt;br /&gt;
change in future versions.&lt;br /&gt;
&lt;br /&gt;
==== Filter Rules ====&lt;br /&gt;
&lt;br /&gt;
Filter objects specify an action for packets fulfilling certain&lt;br /&gt;
criteria. The top-level attribute &#039;&#039;&#039;filter&#039;&#039;&#039; is a list of filter&lt;br /&gt;
objects. The precedence rules are similar to those of policy objects.&lt;br /&gt;
&lt;br /&gt;
Filter objects must have an attribute named &#039;&#039;&#039;action&#039;&#039;&#039;, the value of&lt;br /&gt;
which can be one of the following:&lt;br /&gt;
&lt;br /&gt;
{|&lt;br /&gt;
!Value!!Action&lt;br /&gt;
|-&lt;br /&gt;
|&#039;&#039;&#039;accept&#039;&#039;&#039;&lt;br /&gt;
|Accept the packet (default)&lt;br /&gt;
|-&lt;br /&gt;
|&#039;&#039;&#039;reject&#039;&#039;&#039;&lt;br /&gt;
|Reject the packet with an ICMP error message&lt;br /&gt;
|-&lt;br /&gt;
|&#039;&#039;&#039;drop&#039;&#039;&#039;&lt;br /&gt;
|Silently drop the packet&lt;br /&gt;
|-&lt;br /&gt;
|&#039;&#039;&#039;tarpit&#039;&#039;&#039;&lt;br /&gt;
|Put incoming TCP connections into persist state and ignore attempts to close them. Silently drop non-TCP packets. (Connection tracking bypass is automatically enabled for the matching packets.)&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Filter objects, the action of which is &#039;&#039;&#039;accept&#039;&#039;&#039;, may also contain&lt;br /&gt;
limits for packet flow or new connections. These are specified with&lt;br /&gt;
the &#039;&#039;&#039;flow-limit&#039;&#039;&#039; and &#039;&#039;&#039;conn-limit&#039;&#039;&#039; attributes,&lt;br /&gt;
respectively. The values of these attributes are limit objects that&lt;br /&gt;
have two attributes: &#039;&#039;&#039;count&#039;&#039;&#039; and &#039;&#039;&#039;interval&#039;&#039;&#039;. &#039;&#039;&#039;count&#039;&#039;&#039;&lt;br /&gt;
specifies how many new connections or packets are allowed within the&lt;br /&gt;
time frame specified by &#039;&#039;&#039;interval&#039;&#039;&#039; in seconds (default: 1). The&lt;br /&gt;
&#039;&#039;&#039;drop&#039;&#039;&#039; action is applied to the packets exceeding the&lt;br /&gt;
limit. Optionally, the limit object may have an attribute named&lt;br /&gt;
&#039;&#039;&#039;log&#039;&#039;&#039;. It defines how the dropped packets should be logged and is&lt;br /&gt;
semantically similar to the &#039;&#039;&#039;log&#039;&#039;&#039; attribute of rule objects. A&lt;br /&gt;
limit may also be specified by a plain integer, which is interpreted&lt;br /&gt;
as the count while using default interval and log settings.&lt;br /&gt;
&lt;br /&gt;
Filter objects may have an attribute named &#039;&#039;&#039;dnat&#039;&#039;&#039;, the value of&lt;br /&gt;
which is an IPv4 address. If defined, this enables destination NAT for&lt;br /&gt;
all IPv4 packets matching the rule, such that the specified address&lt;br /&gt;
replaces the original destination address. This option has no effect&lt;br /&gt;
on IPv6 packets.&lt;br /&gt;
&lt;br /&gt;
Filter objects may have a boolean attribute named &#039;&#039;&#039;no-track&#039;&#039;&#039;. If&lt;br /&gt;
set to &#039;&#039;&#039;true&#039;&#039;&#039;, connection tracking is bypassed for the matching&lt;br /&gt;
packets. In addition, if &#039;&#039;&#039;action&#039;&#039;&#039; is set to &#039;&#039;&#039;accept&#039;&#039;&#039;, the&lt;br /&gt;
corresponding packets travelling to the reverse direction are also&lt;br /&gt;
allowed.&lt;br /&gt;
&lt;br /&gt;
If one or more connection tracking helpers are associated with the&lt;br /&gt;
services referred to by an accept rule, additional iptables rules are&lt;br /&gt;
generated for the related connections detected by the helpers. The&lt;br /&gt;
&#039;&#039;&#039;related&#039;&#039;&#039; attribute can be used to override the default rules&lt;br /&gt;
generated by awall. It is a list of basic rule objects, the packets&lt;br /&gt;
matching to which are accepted, provided that they are also detected&lt;br /&gt;
by at least one of the helpers.&lt;br /&gt;
&lt;br /&gt;
==== Policy Rules ====&lt;br /&gt;
&lt;br /&gt;
Policy objects describe the default action for packets that did not&lt;br /&gt;
match any filter. The top-level attribute &#039;&#039;&#039;policy&#039;&#039;&#039; is a list of&lt;br /&gt;
policy objects.&lt;br /&gt;
&lt;br /&gt;
Policy objects must have the &#039;&#039;&#039;action&#039;&#039;&#039; attribute defined. The&lt;br /&gt;
possible values and their semantics are the same as in filter objects.&lt;br /&gt;
&lt;br /&gt;
==== Packet Logging Rules ====&lt;br /&gt;
&lt;br /&gt;
Packet logging rules allow packets matching the specified criteria to&lt;br /&gt;
be logged before any filtering takes place. Such rules are contained&lt;br /&gt;
in the top-level list named &#039;&#039;&#039;packet-log&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Logging class may be specified using the &#039;&#039;&#039;log&#039;&#039;&#039;&lt;br /&gt;
attribute. Otherwise, default logging settings are used.&lt;br /&gt;
&lt;br /&gt;
==== NAT Rules ====&lt;br /&gt;
&lt;br /&gt;
NAT rules come in two flavors: &#039;&#039;source NAT rules&#039;&#039; and&lt;br /&gt;
&#039;&#039;destination NAT rules&#039;&#039;. These are contained in two top-level lists&lt;br /&gt;
named &#039;&#039;&#039;snat&#039;&#039;&#039; and &#039;&#039;&#039;dnat&#039;&#039;&#039;, respectively.&lt;br /&gt;
&lt;br /&gt;
Each NAT rule may have an attribute named &#039;&#039;&#039;to-addr&#039;&#039;&#039; that&lt;br /&gt;
specifies the IPv4 address range to which the original source or&lt;br /&gt;
destination address is mapped. The value can be a single IPv4 address&lt;br /&gt;
or a range specified by two addresses, separated with the &#039;&#039;&#039;-&#039;&#039;&#039;&lt;br /&gt;
character. If not defined, it defaults to the primary address of the&lt;br /&gt;
ingress interface in case of destination NAT, or that of the egress&lt;br /&gt;
interface in case of source NAT.&lt;br /&gt;
&lt;br /&gt;
Optionally, a NAT rule can specify the TCP and UDP port range to which&lt;br /&gt;
the original source or destination port is mapped. The attribute is&lt;br /&gt;
named &#039;&#039;&#039;to-port&#039;&#039;&#039;, and the value can be a single port number or a&lt;br /&gt;
range specified by two numbers, separated with the &#039;&#039;&#039;-&#039;&#039;&#039;&lt;br /&gt;
character. If &#039;&#039;&#039;to-port&#039;&#039;&#039; is not specified, the original port number&lt;br /&gt;
is kept intact.&lt;br /&gt;
&lt;br /&gt;
Like NAT rules, connection tracking bypass rules may have an&lt;br /&gt;
&#039;&#039;&#039;action&#039;&#039;&#039; attribute set to value &#039;&#039;&#039;include&#039;&#039;&#039; or&lt;br /&gt;
&#039;&#039;&#039;exclude&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
==== Packet Marking Rules ====&lt;br /&gt;
&lt;br /&gt;
Packet marking rules are used to mark incoming packets matching the&lt;br /&gt;
specified criteria. The mark can be used as a basis for the routing&lt;br /&gt;
decision. Each marking rule must specify the mark using the &#039;&#039;&#039;mark&#039;&#039;&#039;&lt;br /&gt;
attribute, which is a 32-bit integer.&lt;br /&gt;
&lt;br /&gt;
Normal marking rules are contained by the top-level list attribute&lt;br /&gt;
named &#039;&#039;&#039;mark&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
There is another top-level list attribute, named &#039;&#039;&#039;route-track&#039;&#039;&#039;,&lt;br /&gt;
which contains route tracking rules. These are special marking rules&lt;br /&gt;
which cause all the subsequent packets related to the same connection&lt;br /&gt;
to be marked according to the rule.&lt;br /&gt;
&lt;br /&gt;
==== Transparent Proxy Rules ====&lt;br /&gt;
&lt;br /&gt;
Transparent proxy rules divert the matching packets to a local proxy&lt;br /&gt;
process without altering their headers. Such rules are contained in&lt;br /&gt;
the top-level list named &#039;&#039;&#039;tproxy&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
In addition to the firewall configuration, using a transparent proxy&lt;br /&gt;
requires a routing configuration where packets marked for proxying are&lt;br /&gt;
diverted to a local process. The &#039;&#039;&#039;awall_tproxy_mark&#039;&#039;&#039; variable can&lt;br /&gt;
be used to specify the mark for such packets, which defaults to 1.&lt;br /&gt;
&lt;br /&gt;
Proxy rules may also have an attribute named &#039;&#039;&#039;to-port&#039;&#039;&#039; for&lt;br /&gt;
specifying the TCP or UDP port of the proxy if it is different from&lt;br /&gt;
the original destination port.&lt;br /&gt;
&lt;br /&gt;
==== MSS Clamping Rules ====&lt;br /&gt;
&lt;br /&gt;
MSS Clamping Rules are used to deal with ISPs that block ICMP&lt;br /&gt;
Fragmentation Needed or ICMPv6 Packet Too Big packets. An MSS clamping&lt;br /&gt;
rule overwrites the MSS option with a value specified with the&lt;br /&gt;
&#039;&#039;&#039;mss&#039;&#039;&#039; attribute for the matching TCP connections. If &#039;&#039;&#039;mss&#039;&#039;&#039; is&lt;br /&gt;
not specified, a suitable value is automatically determined from the&lt;br /&gt;
path MTU. The MSS clamping rules are located in the top-level&lt;br /&gt;
dictionary named &#039;&#039;&#039;clamp-mss&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
==== Connection Tracking Bypass Rules ====&lt;br /&gt;
&lt;br /&gt;
Connection tracking bypass rules are used to disable connection&lt;br /&gt;
tracking for packets matching the specified criteria. The top-level&lt;br /&gt;
attribute &#039;&#039;&#039;no-track&#039;&#039;&#039; is a list of such rules.&lt;br /&gt;
&lt;br /&gt;
Like NAT rules, connection tracking bypass rules may have an&lt;br /&gt;
&#039;&#039;&#039;action&#039;&#039;&#039; attribute set to value &#039;&#039;&#039;include&#039;&#039;&#039; or&lt;br /&gt;
&#039;&#039;&#039;exclude&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
=== IP Sets ===&lt;br /&gt;
&lt;br /&gt;
Any IP set referenced by rule objects should be created by&lt;br /&gt;
awall. Auxiliary &#039;&#039;IP set&#039;&#039; objects are used to defined them in awall&lt;br /&gt;
policy files. The top-level attribute &#039;&#039;&#039;ipset&#039;&#039;&#039; is a dictionary, the&lt;br /&gt;
keys of which are IP set names. The values are IP set objects, which&lt;br /&gt;
have two mandatory attributes. The attribute named &#039;&#039;&#039;type&#039;&#039;&#039; &lt;br /&gt;
corresponds to the type argument of the &amp;lt;tt&amp;gt;ipset create&amp;lt;/tt&amp;gt; &lt;br /&gt;
command. &#039;&#039;&#039;family&#039;&#039;&#039; specifies whether the set is for IPv4 or IPv6&lt;br /&gt;
addresses, and the possible values are &#039;&#039;&#039;inet&#039;&#039;&#039; and &#039;&#039;&#039;inet6&#039;&#039;&#039;,&lt;br /&gt;
correspondingly.&lt;br /&gt;
&lt;br /&gt;
For bitmap-type IP sets, the &#039;&#039;&#039;range&#039;&#039;&#039; attribute specifies the&lt;br /&gt;
range of allowed IPv4 addresses. It may be given as a network&lt;br /&gt;
address or two addresses separated by the &#039;&#039;&#039;-&#039;&#039;&#039; character. It&lt;br /&gt;
is not necessary to specify &#039;&#039;&#039;family&#039;&#039;&#039; for bitmaps, since the&lt;br /&gt;
kernel supports only IPv4 bitmaps.&lt;br /&gt;
&lt;br /&gt;
== Command Line Syntax ==&lt;br /&gt;
&lt;br /&gt;
=== Translating Policy Files to Firewall Configuration Files ===&lt;br /&gt;
&lt;br /&gt;
 &#039;&#039;&#039;awall translate&#039;&#039;&#039; [&#039;&#039;&#039;-o&#039;&#039;&#039;|&#039;&#039;&#039;--output&#039;&#039;&#039; DIRECTORY] [&#039;&#039;&#039;-V&#039;&#039;&#039;|&#039;&#039;&#039;--verify&#039;&#039;&#039;]&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;tt&amp;gt;--verify&amp;lt;/tt&amp;gt; option makes awall verify the configuration&lt;br /&gt;
using the test mode of iptables-restore before overwriting the old&lt;br /&gt;
files.&lt;br /&gt;
&lt;br /&gt;
Specifying the output directory allows testing awall policies without&lt;br /&gt;
overwriting the current iptables and ipset configuration files. By&lt;br /&gt;
default, awall generates the configuration to &amp;lt;tt&amp;gt;/etc/iptables&amp;lt;/tt&amp;gt; &lt;br /&gt;
and &amp;lt;tt&amp;gt;/etc/ipset.d&amp;lt;/tt&amp;gt;, which are read by the init scripts.&lt;br /&gt;
&lt;br /&gt;
=== Run-Time Configuration of Firewall ===&lt;br /&gt;
&lt;br /&gt;
 &#039;&#039;&#039;awall activate&#039;&#039;&#039; [&#039;&#039;&#039;-f&#039;&#039;&#039;|&#039;&#039;&#039;--force&#039;&#039;&#039;]&lt;br /&gt;
&lt;br /&gt;
This command genereates firewall configuration from the policy files&lt;br /&gt;
and enables it. If the user confirms the new configuration by hitting&lt;br /&gt;
the Return key within 10 seconds or the &amp;lt;tt&amp;gt;--force&amp;lt;/tt&amp;gt; option is&lt;br /&gt;
used, the configuration is saved to the files. Otherwise, the old&lt;br /&gt;
configuration is restored.&lt;br /&gt;
&lt;br /&gt;
There is also a command for deleting all firewall rules:&lt;br /&gt;
&lt;br /&gt;
 &#039;&#039;&#039;awall flush&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
This command configures the firewall to drop all packets.&lt;br /&gt;
&lt;br /&gt;
=== Optional Policies ===&lt;br /&gt;
&lt;br /&gt;
Optional policies can be enabled or disabled using this command:&lt;br /&gt;
&lt;br /&gt;
 &#039;&#039;&#039;awall&#039;&#039;&#039; {&#039;&#039;&#039;enable&#039;&#039;&#039;|&#039;&#039;&#039;disable&#039;&#039;&#039;} POLICY...&lt;br /&gt;
&lt;br /&gt;
Optional policies can be listed using this command:&lt;br /&gt;
&lt;br /&gt;
 &#039;&#039;&#039;awall list&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;&#039;enabled&#039;&#039;&#039; status means that the policy has been enabled by the&lt;br /&gt;
user. The &#039;&#039;&#039;disabled&#039;&#039;&#039; status means that the policy is not in&lt;br /&gt;
use. The &#039;&#039;&#039;required&#039;&#039;&#039; status means that the policy has not been&lt;br /&gt;
enabled by the user but is in use because it is required by another&lt;br /&gt;
policy which is in use.&lt;br /&gt;
&lt;br /&gt;
=== Debugging Policies ===&lt;br /&gt;
&lt;br /&gt;
This command can be used to dump variable, zone, and other definitions&lt;br /&gt;
as well as their source policies:&lt;br /&gt;
&lt;br /&gt;
 &#039;&#039;&#039;awall dump&#039;&#039;&#039; [LEVEL]&lt;br /&gt;
&lt;br /&gt;
The level is an integer in range 0&amp;amp;ndash;5 and defaults to 0. More&lt;br /&gt;
information is displayed on higher levels.&lt;br /&gt;
&lt;br /&gt;
[[Category:Networking]]&lt;br /&gt;
[[Category:Security]]&lt;/div&gt;</summary>
		<author><name>Kunkku</name></author>
	</entry>
	<entry>
		<id>https://wiki.alpinelinux.org/w/index.php?title=Alpine_Wall_User%27s_Guide&amp;diff=9916</id>
		<title>Alpine Wall User&#039;s Guide</title>
		<link rel="alternate" type="text/html" href="https://wiki.alpinelinux.org/w/index.php?title=Alpine_Wall_User%27s_Guide&amp;diff=9916"/>
		<updated>2014-03-31T16:50:11Z</updated>

		<summary type="html">&lt;p&gt;Kunkku: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Configuration File Processing ==&lt;br /&gt;
&lt;br /&gt;
[[Alpine Wall]] (awall) reads its configuration from multiple&lt;br /&gt;
JSON-formatted files, called &#039;&#039;policy files&#039;&#039;. The files located in&lt;br /&gt;
directory &amp;lt;tt&amp;gt;/usr/share/awall/mandatory&amp;lt;/tt&amp;gt; are &#039;&#039;mandatory&#039;&#039;&lt;br /&gt;
policies shipped with APK packages. In addition, there can be&lt;br /&gt;
installation-specific mandatory policies in &amp;lt;tt&amp;gt;/etc/awall&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
The latter directory may also contain symbolic links to policy files&lt;br /&gt;
located in &amp;lt;tt&amp;gt;/usr/share/awall/optional&amp;lt;/tt&amp;gt; and&lt;br /&gt;
&amp;lt;tt&amp;gt;/etc/awall/optional&amp;lt;/tt&amp;gt;. These are &#039;&#039;optional&#039;&#039; policies, which&lt;br /&gt;
can be enabled on need basis. Such symbolic links are easily created&lt;br /&gt;
and destroyed using the &amp;lt;tt&amp;gt;awall enable&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;awall&lt;br /&gt;
disable&amp;lt;/tt&amp;gt; commands. &amp;lt;tt&amp;gt;awall list&amp;lt;/tt&amp;gt; shows which optional&lt;br /&gt;
policies are enabled and disabled. The command also prints the&lt;br /&gt;
description of the optional policy if defined in the file using a&lt;br /&gt;
top-level attribute named &#039;&#039;&#039;description&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Sometimes a policy file depends on other policy files. In this case,&lt;br /&gt;
the policy file must have a top-level attribute &#039;&#039;&#039;import&#039;&#039;&#039;, the&lt;br /&gt;
value of which is a list of policy names, which correspond to the file&lt;br /&gt;
names without the &amp;lt;tt&amp;gt;.json&amp;lt;/tt&amp;gt; suffix. The imported policies may be&lt;br /&gt;
either optional policies or &#039;&#039;private&#039;&#039; policies, located in&lt;br /&gt;
&amp;lt;tt&amp;gt;/usr/share/awall/private&amp;lt;/tt&amp;gt; or &amp;lt;tt&amp;gt;/etc/awall/private&amp;lt;/tt&amp;gt;. By&lt;br /&gt;
default, the policies listed there are processed before the importing&lt;br /&gt;
policy.&lt;br /&gt;
&lt;br /&gt;
The order of the generated iptables rules generally reflects the&lt;br /&gt;
processing order of their corresponding awall policies. The&lt;br /&gt;
processing order of policies can be adjusted by defining&lt;br /&gt;
top-level attributes &#039;&#039;&#039;after&#039;&#039;&#039; and &#039;&#039;&#039;before&#039;&#039;&#039; in policy&lt;br /&gt;
files. These attributes are lists of policies, after or before&lt;br /&gt;
which the declaring policy shall be processed. Putting a policy&lt;br /&gt;
name to either of these lists does not by itself import the&lt;br /&gt;
policy. The ordering directives are ignored with respect to those&lt;br /&gt;
policies that are not enabled by the user or imported by other&lt;br /&gt;
policies. If not defined, &#039;&#039;&#039;after&#039;&#039;&#039; is assumed to be equal to&lt;br /&gt;
the relative complement of the &#039;&#039;&#039;before&#039;&#039;&#039; definition in the&lt;br /&gt;
&#039;&#039;&#039;import&#039;&#039;&#039; definition of the policy.&lt;br /&gt;
&lt;br /&gt;
As the import directive does not require the path name to be&lt;br /&gt;
specified, awall expects policies to have unique names, even if&lt;br /&gt;
located in different directories. It is allowed to import optional&lt;br /&gt;
policies that are not explicitly enabled by the user. Such policies&lt;br /&gt;
show up with the &amp;lt;tt&amp;gt;required&amp;lt;/tt&amp;gt; status in the output of &amp;lt;tt&amp;gt;awall&lt;br /&gt;
list&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
== List Parameters ==&lt;br /&gt;
&lt;br /&gt;
Several awall parameters are defined as lists of values. In order to&lt;br /&gt;
facilitate manual editing of policy files, awall also accepts single&lt;br /&gt;
values in place of lists. Such values are semantically equivalent to&lt;br /&gt;
lists containing one element.&lt;br /&gt;
&lt;br /&gt;
== Variable Expansion ==&lt;br /&gt;
&lt;br /&gt;
Awall allows variable definitions in policy files. The top-level&lt;br /&gt;
attribute &#039;&#039;&#039;variable&#039;&#039;&#039; is a dictionary containing the&lt;br /&gt;
definitions. The value of a variable can be of any type (string,&lt;br /&gt;
integer, list, or dictionary).&lt;br /&gt;
&lt;br /&gt;
A variable is referenced in policy files by a string which equals the&lt;br /&gt;
variable name prepended with the &#039;&#039;&#039;$&#039;&#039;&#039; character. If the value of&lt;br /&gt;
the variable is a string, the reference can be embedded into a longer&lt;br /&gt;
string in order to substitute some part of that string (in shell&lt;br /&gt;
style). Variable references can be used when defining other variables,&lt;br /&gt;
as long as the definitions are not circular.&lt;br /&gt;
&lt;br /&gt;
Policy files can reference variables defined in other policy&lt;br /&gt;
files. Policy files can also override variables defined elsewhere by&lt;br /&gt;
redefining them. In this case, the new definition affects all policy&lt;br /&gt;
files, also those processed before the overriding policy. Awall&lt;br /&gt;
variables are in fact simple macros, since each variable remains&lt;br /&gt;
constant thoughout a single processing round. If multiple files define&lt;br /&gt;
the same variable, the definition in the file processed last takes&lt;br /&gt;
effect.&lt;br /&gt;
&lt;br /&gt;
If defined as an empty string, all non-embedded references to a&lt;br /&gt;
variable evaluate as if the attribute in question was not present in&lt;br /&gt;
the configuration. This is also the case when a string containing&lt;br /&gt;
embedded variable references finally evaluates to an empty string.&lt;br /&gt;
&lt;br /&gt;
== Configuration Objects ==&lt;br /&gt;
&lt;br /&gt;
Configuration objects can be divided into two main types.&lt;br /&gt;
&#039;&#039;Auxiliary objects&#039;&#039; model high-level concepts such as services and&lt;br /&gt;
zones. &#039;&#039;Rule objects&#039;&#039; translate into one or more iptables rules, and&lt;br /&gt;
are often defined with the help of some auxiliary objects.&lt;br /&gt;
&lt;br /&gt;
=== Services ===&lt;br /&gt;
&lt;br /&gt;
A &#039;&#039;service&#039;&#039; represents a set of network protocols. A top-level&lt;br /&gt;
attribute &#039;&#039;&#039;service&#039;&#039;&#039; is a dictionary that maps service names to&lt;br /&gt;
service definition objects, or lists thereof in more complex cases.&lt;br /&gt;
&lt;br /&gt;
A service definition object contains an attribute named&lt;br /&gt;
&#039;&#039;&#039;proto&#039;&#039;&#039;, which corresponds to the &amp;lt;tt&amp;gt;--protocol&amp;lt;/tt&amp;gt; option&lt;br /&gt;
of iptables. The protocol can be defined as a numerical value or&lt;br /&gt;
string as defined in &amp;lt;tt&amp;gt;/etc/protocols&amp;lt;/tt&amp;gt;. If the protocol is&lt;br /&gt;
&#039;&#039;&#039;tcp&#039;&#039;&#039; or &#039;&#039;&#039;udp&#039;&#039;&#039;, the scope of the service definition may&lt;br /&gt;
be constrained by defining an attribute named &#039;&#039;&#039;port&#039;&#039;&#039;, which&lt;br /&gt;
is a list of TCP or UDP port numbers or ranges thereof, separated&lt;br /&gt;
by the &#039;&#039;&#039;-&#039;&#039;&#039; character. If the protocol is &#039;&#039;&#039;icmp&#039;&#039;&#039; or&lt;br /&gt;
&#039;&#039;&#039;icmpv6&#039;&#039;&#039;, an analogous &#039;&#039;&#039;type&#039;&#039;&#039; attribute may be used. The&lt;br /&gt;
replies to ICMP messages have their own type codes, which may be&lt;br /&gt;
specified using the &#039;&#039;&#039;reply-type&#039;&#039;&#039; attribute.&lt;br /&gt;
&lt;br /&gt;
If the protocol is &#039;&#039;&#039;icmp&#039;&#039;&#039; or &#039;&#039;&#039;icmpv6&#039;&#039;&#039;, the scope of the&lt;br /&gt;
rule is also automatically limited to IPv4 or IPv6,&lt;br /&gt;
respectively. There are also other services which are specific to&lt;br /&gt;
IPv4 or IPv6. To constrain the scope of the service definition to&lt;br /&gt;
either protocol version, an optional &#039;&#039;&#039;family&#039;&#039;&#039; attribute can&lt;br /&gt;
be set to value &#039;&#039;&#039;inet&#039;&#039;&#039; or &#039;&#039;&#039;inet6&#039;&#039;&#039;, respectively.&lt;br /&gt;
&lt;br /&gt;
Some services require the server or client to open additional&lt;br /&gt;
connections to dynamically allocated ports or even different&lt;br /&gt;
hosts. &#039;&#039;Connection tracking helpers&#039;&#039; are used to make the firewall&lt;br /&gt;
aware of such additional connections. The &#039;&#039;&#039;ct-helper&#039;&#039;&#039; attribute is&lt;br /&gt;
used to associate such a helper to a service definition when&lt;br /&gt;
required by the service.&lt;br /&gt;
&lt;br /&gt;
All rule objects, except for policies, may have an attribute named&lt;br /&gt;
&#039;&#039;&#039;service&#039;&#039;&#039;, constraining the rule&#039;s scope to specific services&lt;br /&gt;
only. This attribute is a list of service names, referring to the keys&lt;br /&gt;
of the top-level service dictionary.&lt;br /&gt;
&lt;br /&gt;
=== Zones ===&lt;br /&gt;
&lt;br /&gt;
A &#039;&#039;zone&#039;&#039; represents a set of network hosts. A top-level attribute &lt;br /&gt;
&#039;&#039;&#039;zone&#039;&#039;&#039; is a dictionary that maps zone names to zone objects. A&lt;br /&gt;
zone object has an attribute named &#039;&#039;&#039;iface&#039;&#039;&#039;, &#039;&#039;&#039;addr&#039;&#039;&#039;, or&lt;br /&gt;
both. &#039;&#039;&#039;iface&#039;&#039;&#039; is a list of network interfaces and &#039;&#039;&#039;addr&#039;&#039;&#039; is a&lt;br /&gt;
list of IPv4/IPv6 host and network addresses (CIDR&lt;br /&gt;
notation). &#039;&#039;&#039;addr&#039;&#039;&#039; may also contain domain names, which are&lt;br /&gt;
expanded to IP addresses using DNS resolution. If not defined,&lt;br /&gt;
&#039;&#039;&#039;addr&#039;&#039;&#039; defaults to the entire address space and &#039;&#039;&#039;iface&#039;&#039;&#039; to all&lt;br /&gt;
interfaces. An empty zone can be defined by setting either &#039;&#039;&#039;addr&#039;&#039;&#039;&lt;br /&gt;
or &#039;&#039;&#039;iface&#039;&#039;&#039; to an empty list.&lt;br /&gt;
&lt;br /&gt;
Rule objects contain two attributes, &#039;&#039;&#039;in&#039;&#039;&#039; and &#039;&#039;&#039;out&#039;&#039;&#039;, which are&lt;br /&gt;
lists of zone names. These attributes control whether a packet matches&lt;br /&gt;
the rule or not. If a particular zone is referenced by the &#039;&#039;&#039;in&#039;&#039;&#039; &lt;br /&gt;
attribute, the rule applies to packets whose ingress interface and&lt;br /&gt;
source address are covered by the zone definition. Correspondingly, if&lt;br /&gt;
a zone is referenced by the &#039;&#039;&#039;out&#039;&#039;&#039; attribute, the rule applies to&lt;br /&gt;
packets whose egress interface and destination address are included in&lt;br /&gt;
the zone. If both &#039;&#039;&#039;in&#039;&#039;&#039; and &#039;&#039;&#039;out&#039;&#039;&#039; are defined, the packet must&lt;br /&gt;
fulfill both criteria in order to match the rule.&lt;br /&gt;
&lt;br /&gt;
The firewall host itself can be referred to using the special value&lt;br /&gt;
&#039;&#039;&#039;_fw&#039;&#039;&#039; as the zone name.&lt;br /&gt;
&lt;br /&gt;
By default, awall does not generate iptables rules with identical&lt;br /&gt;
ingress and egress interfaces. This behavior can be changed per zone&lt;br /&gt;
by setting the optional &#039;&#039;&#039;route-back&#039;&#039;&#039; attribute of the zone to&lt;br /&gt;
&#039;&#039;&#039;true&#039;&#039;&#039;. Note that this attribute can have an effect also in the&lt;br /&gt;
case where &#039;&#039;&#039;in&#039;&#039;&#039; and &#039;&#039;&#039;out&#039;&#039;&#039; attributes of a rule are not equal&lt;br /&gt;
but their definitions overlap. In this case, the &#039;&#039;&#039;route-back&#039;&#039;&#039;&lt;br /&gt;
attribute of the &#039;&#039;&#039;out&#039;&#039;&#039; zone determines the behavior.&lt;br /&gt;
&lt;br /&gt;
=== Logging Classes ===&lt;br /&gt;
&lt;br /&gt;
A &#039;&#039;logging class&#039;&#039; specifies how packets matching certain rules are&lt;br /&gt;
logged. A top-level attribute &#039;&#039;&#039;log&#039;&#039;&#039; is a dictionary that maps&lt;br /&gt;
logging class names to setting objects.&lt;br /&gt;
&lt;br /&gt;
A setting object may have an attribute named &#039;&#039;&#039;mode&#039;&#039;&#039;, which&lt;br /&gt;
specifies which logging facility to use. Allowed values are &#039;&#039;&#039;log&#039;&#039;&#039;,&lt;br /&gt;
&#039;&#039;&#039;nflog&#039;&#039;&#039;, and &#039;&#039;&#039;ulog&#039;&#039;&#039;. The default is &#039;&#039;&#039;log&#039;&#039;&#039;, i.e. in-kernel&lt;br /&gt;
logging.&lt;br /&gt;
&lt;br /&gt;
The following table shows the optional attributes valid for all&lt;br /&gt;
logging modes:&lt;br /&gt;
&lt;br /&gt;
{|&lt;br /&gt;
!Attribute!!Description&lt;br /&gt;
|-&lt;br /&gt;
|&#039;&#039;&#039;every&#039;&#039;&#039;&lt;br /&gt;
|Divide successive packets into groups, the size of which is specified by the value of this attribute, and log only the first packet of each group&lt;br /&gt;
|-&lt;br /&gt;
|&#039;&#039;&#039;limit&#039;&#039;&#039;&lt;br /&gt;
|Maximum number of packets to be logged per second per this rule&lt;br /&gt;
|-&lt;br /&gt;
|&#039;&#039;&#039;prefix&#039;&#039;&#039;&lt;br /&gt;
|String with which the log entries are prefixed&lt;br /&gt;
|-&lt;br /&gt;
|&#039;&#039;&#039;probability&#039;&#039;&#039;&lt;br /&gt;
|Probability for logging an individual packet (default: 1)&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
With the in-kernel log mode &#039;&#039;&#039;log&#039;&#039;&#039;, the level of logging may be&lt;br /&gt;
specified using the &#039;&#039;&#039;level&#039;&#039;&#039; attribute. Log modes &#039;&#039;&#039;nflog&#039;&#039;&#039; and&lt;br /&gt;
&#039;&#039;&#039;ulog&#039;&#039;&#039; are about copying the packets into user space, at least&lt;br /&gt;
partially. The following table shows the additional attributes valid&lt;br /&gt;
with these modes:&lt;br /&gt;
&lt;br /&gt;
{|&lt;br /&gt;
!Attribute!!Description&lt;br /&gt;
|-&lt;br /&gt;
|&#039;&#039;&#039;group&#039;&#039;&#039;&lt;br /&gt;
|Netlink group to be used&lt;br /&gt;
|-&lt;br /&gt;
|&#039;&#039;&#039;range&#039;&#039;&#039;&lt;br /&gt;
|Number of bytes to be copied&lt;br /&gt;
|-&lt;br /&gt;
|&#039;&#039;&#039;threshold&#039;&#039;&#039;&lt;br /&gt;
|Number of packets to queue inside the kernel before copying them&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Filter and policy rules can have an attribute named &#039;&#039;&#039;log&#039;&#039;&#039;. If it&lt;br /&gt;
is a string, it is interpreted as a reference to a logging class, and&lt;br /&gt;
logging is performed according to the definitions. If the value of the&lt;br /&gt;
&#039;&#039;&#039;log&#039;&#039;&#039; attribute is &#039;&#039;&#039;true&#039;&#039;&#039; (boolean), logging is done using&lt;br /&gt;
default settings. If the value is &#039;&#039;&#039;false&#039;&#039;&#039; (boolean), logging is&lt;br /&gt;
disabled for the rule. If &#039;&#039;&#039;log&#039;&#039;&#039; is not defined, logging is done&lt;br /&gt;
using the default settings except for accept rules, for which logging&lt;br /&gt;
is omitted.&lt;br /&gt;
&lt;br /&gt;
Default logging settings can be set by defining a logging class named&lt;br /&gt;
&#039;&#039;&#039;_default&#039;&#039;&#039;. Normally, default logging uses the &#039;&#039;&#039;log&#039;&#039;&#039; mode with&lt;br /&gt;
packets limited to one per second.&lt;br /&gt;
&lt;br /&gt;
=== Rules ===&lt;br /&gt;
&lt;br /&gt;
There are several types of rule objects:&lt;br /&gt;
* Filter rules&lt;br /&gt;
* Policy rules&lt;br /&gt;
* Packet Logging rules&lt;br /&gt;
* NAT rules&lt;br /&gt;
* Packet Marking rules&lt;br /&gt;
* Transparent Proxy rules&lt;br /&gt;
* MSS Clamping rules&lt;br /&gt;
* Connection Tracking Bypass rules&lt;br /&gt;
&lt;br /&gt;
All rule objects can have the &#039;&#039;&#039;in&#039;&#039;&#039; and &#039;&#039;&#039;out&#039;&#039;&#039; attributes&lt;br /&gt;
referring to zones as described in the previous section. In addition,&lt;br /&gt;
the scope of the rule can be further constrained with the following&lt;br /&gt;
attributes:&lt;br /&gt;
&lt;br /&gt;
{|&lt;br /&gt;
!Attribute!!Value format!!Effect&lt;br /&gt;
|-&lt;br /&gt;
|&#039;&#039;&#039;src&#039;&#039;&#039;&lt;br /&gt;
|Similar to &#039;&#039;&#039;addr&#039;&#039;&#039; attribute of zone objects&lt;br /&gt;
|Packet&#039;s source address matches the value&lt;br /&gt;
|-&lt;br /&gt;
|&#039;&#039;&#039;dest&#039;&#039;&#039;&lt;br /&gt;
|Similar to &#039;&#039;&#039;addr&#039;&#039;&#039; attribute of zone objects&lt;br /&gt;
|Packet&#039;s destination address matches the value&lt;br /&gt;
|-&lt;br /&gt;
|&#039;&#039;&#039;ipset&#039;&#039;&#039;&lt;br /&gt;
|Object containing two attributes: &#039;&#039;&#039;name&#039;&#039;&#039; referring to an IP set and &#039;&#039;&#039;args&#039;&#039;&#039;, which is a list of strings &#039;&#039;&#039;in&#039;&#039;&#039; and &#039;&#039;&#039;out&#039;&#039;&#039;&lt;br /&gt;
|Packet matches the IP set referred here when the match arguments are taken from the source (&#039;&#039;&#039;in&#039;&#039;&#039;) and destination (&#039;&#039;&#039;out&#039;&#039;&#039;) address or port in the order specified by &#039;&#039;&#039;args&#039;&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
|&#039;&#039;&#039;ipsec&#039;&#039;&#039;&lt;br /&gt;
|&#039;&#039;&#039;in&#039;&#039;&#039; or &#039;&#039;&#039;out&#039;&#039;&#039;&lt;br /&gt;
|IPsec decapsulation perfomed on ingress (&#039;&#039;&#039;in&#039;&#039;&#039;) or encapsulation performed on egress (&#039;&#039;&#039;out&#039;&#039;&#039;)&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Rule objects are declared in type-specific top-level dictionaries in&lt;br /&gt;
awall policy files. If a packet matches multiple rules, the one&lt;br /&gt;
appearing earlier in the list takes precedence. If the matching rules&lt;br /&gt;
are defined in different policy files, the one that was processed&lt;br /&gt;
earlier takes precedence in the current implementation, but this may&lt;br /&gt;
change in future versions.&lt;br /&gt;
&lt;br /&gt;
==== Filter Rules ====&lt;br /&gt;
&lt;br /&gt;
Filter objects specify an action for packets fulfilling certain&lt;br /&gt;
criteria. The top-level attribute &#039;&#039;&#039;filter&#039;&#039;&#039; is a list of filter&lt;br /&gt;
objects. The precedence rules are similar to those of policy objects.&lt;br /&gt;
&lt;br /&gt;
Filter objects must have an attribute named &#039;&#039;&#039;action&#039;&#039;&#039;, the value of&lt;br /&gt;
which can be one of the following:&lt;br /&gt;
&lt;br /&gt;
{|&lt;br /&gt;
!Value!!Action&lt;br /&gt;
|-&lt;br /&gt;
|&#039;&#039;&#039;accept&#039;&#039;&#039;&lt;br /&gt;
|Accept the packet (default)&lt;br /&gt;
|-&lt;br /&gt;
|&#039;&#039;&#039;reject&#039;&#039;&#039;&lt;br /&gt;
|Reject the packet with an ICMP error message&lt;br /&gt;
|-&lt;br /&gt;
|&#039;&#039;&#039;drop&#039;&#039;&#039;&lt;br /&gt;
|Silently drop the packet&lt;br /&gt;
|-&lt;br /&gt;
|&#039;&#039;&#039;tarpit&#039;&#039;&#039;&lt;br /&gt;
|Put incoming TCP connections into persist state and ignore attempts to close them. Silently drop non-TCP packets. (Connection tracking bypass is automatically enabled for the matching packets.)&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Filter objects, the action of which is &#039;&#039;&#039;accept&#039;&#039;&#039;, may also contain&lt;br /&gt;
limits for packet flow or new connections. These are specified with&lt;br /&gt;
the &#039;&#039;&#039;flow-limit&#039;&#039;&#039; and &#039;&#039;&#039;conn-limit&#039;&#039;&#039; attributes,&lt;br /&gt;
respectively. The values of these attributes are limit objects that&lt;br /&gt;
have two attributes: &#039;&#039;&#039;count&#039;&#039;&#039; and &#039;&#039;&#039;interval&#039;&#039;&#039;. &#039;&#039;&#039;count&#039;&#039;&#039;&lt;br /&gt;
specifies how many new connections or packets are allowed within the&lt;br /&gt;
time frame specified by &#039;&#039;&#039;interval&#039;&#039;&#039; in seconds (default: 1). The&lt;br /&gt;
&#039;&#039;&#039;drop&#039;&#039;&#039; action is applied to the packets exceeding the&lt;br /&gt;
limit. Optionally, the limit object may have an attribute named&lt;br /&gt;
&#039;&#039;&#039;log&#039;&#039;&#039;. It defines how the dropped packets should be logged and is&lt;br /&gt;
semantically similar to the &#039;&#039;&#039;log&#039;&#039;&#039; attribute of rule objects. A&lt;br /&gt;
limit may also be specified by a plain integer, which is interpreted&lt;br /&gt;
as the count while using default interval and log settings.&lt;br /&gt;
&lt;br /&gt;
Filter objects may have an attribute named &#039;&#039;&#039;dnat&#039;&#039;&#039;, the value of&lt;br /&gt;
which is an IPv4 address. If defined, this enables destination NAT for&lt;br /&gt;
all IPv4 packets matching the rule, such that the specified address&lt;br /&gt;
replaces the original destination address. This option has no effect&lt;br /&gt;
on IPv6 packets.&lt;br /&gt;
&lt;br /&gt;
Filter objects may have a boolean attribute named &#039;&#039;&#039;no-track&#039;&#039;&#039;. If&lt;br /&gt;
set to &#039;&#039;&#039;true&#039;&#039;&#039;, connection tracking is bypassed for the matching&lt;br /&gt;
packets. In addition, if &#039;&#039;&#039;action&#039;&#039;&#039; is set to &#039;&#039;&#039;accept&#039;&#039;&#039;, the&lt;br /&gt;
corresponding packets travelling to the reverse direction are also&lt;br /&gt;
allowed.&lt;br /&gt;
&lt;br /&gt;
If one or more connection tracking helpers are associated with the&lt;br /&gt;
services referred to by an accept rule, additional iptables rules are&lt;br /&gt;
generated for the related connections detected by the helpers. The&lt;br /&gt;
&#039;&#039;&#039;related&#039;&#039;&#039; attribute can be used to override the default rules&lt;br /&gt;
generated by awall. It is a list of basic rule objects, the packets&lt;br /&gt;
matching to which are accepted, provided that they are also detected&lt;br /&gt;
by at least one of the helpers.&lt;br /&gt;
&lt;br /&gt;
==== Policy Rules ====&lt;br /&gt;
&lt;br /&gt;
Policy objects describe the default action for packets that did not&lt;br /&gt;
match any filter. The top-level attribute &#039;&#039;&#039;policy&#039;&#039;&#039; is a list of&lt;br /&gt;
policy objects.&lt;br /&gt;
&lt;br /&gt;
Policy objects must have the &#039;&#039;&#039;action&#039;&#039;&#039; attribute defined. The&lt;br /&gt;
possible values and their semantics are the same as in filter objects.&lt;br /&gt;
&lt;br /&gt;
==== Packet Logging Rules ====&lt;br /&gt;
&lt;br /&gt;
Packet logging rules allow packets matching the specified criteria to&lt;br /&gt;
be logged before any filtering takes place. Such rules are contained&lt;br /&gt;
in the top-level list named &#039;&#039;&#039;packet-log&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Logging class may be specified using the &#039;&#039;&#039;log&#039;&#039;&#039;&lt;br /&gt;
attribute. Otherwise, default logging settings are used.&lt;br /&gt;
&lt;br /&gt;
==== NAT Rules ====&lt;br /&gt;
&lt;br /&gt;
NAT rules come in two flavors: &#039;&#039;source NAT rules&#039;&#039; and&lt;br /&gt;
&#039;&#039;destination NAT rules&#039;&#039;. These are contained in two top-level lists&lt;br /&gt;
named &#039;&#039;&#039;snat&#039;&#039;&#039; and &#039;&#039;&#039;dnat&#039;&#039;&#039;, respectively.&lt;br /&gt;
&lt;br /&gt;
Each NAT rule may have an attribute named &#039;&#039;&#039;to-addr&#039;&#039;&#039; that&lt;br /&gt;
specifies the IPv4 address range to which the original source or&lt;br /&gt;
destination address is mapped. The value can be a single IPv4 address&lt;br /&gt;
or a range specified by two addresses, separated with the &#039;&#039;&#039;-&#039;&#039;&#039;&lt;br /&gt;
character. If not defined, it defaults to the primary address of the&lt;br /&gt;
ingress interface in case of destination NAT, or that of the egress&lt;br /&gt;
interface in case of source NAT.&lt;br /&gt;
&lt;br /&gt;
Optionally, a NAT rule can specify the TCP and UDP port range to which&lt;br /&gt;
the original source or destination port is mapped. The attribute is&lt;br /&gt;
named &#039;&#039;&#039;to-port&#039;&#039;&#039;, and the value can be a single port number or a&lt;br /&gt;
range specified by two numbers, separated with the &#039;&#039;&#039;-&#039;&#039;&#039;&lt;br /&gt;
character. If &#039;&#039;&#039;to-port&#039;&#039;&#039; is not specified, the original port number&lt;br /&gt;
is kept intact.&lt;br /&gt;
&lt;br /&gt;
Like NAT rules, connection tracking bypass rules may have an&lt;br /&gt;
&#039;&#039;&#039;action&#039;&#039;&#039; attribute set to value &#039;&#039;&#039;include&#039;&#039;&#039; or&lt;br /&gt;
&#039;&#039;&#039;exclude&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
==== Packet Marking Rules ====&lt;br /&gt;
&lt;br /&gt;
Packet marking rules are used to mark incoming packets matching the&lt;br /&gt;
specified criteria. The mark can be used as a basis for the routing&lt;br /&gt;
decision. Each marking rule must specify the mark using the &#039;&#039;&#039;mark&#039;&#039;&#039;&lt;br /&gt;
attribute, which is a 32-bit integer.&lt;br /&gt;
&lt;br /&gt;
Normal marking rules are contained by the top-level list attribute&lt;br /&gt;
named &#039;&#039;&#039;mark&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
There is another top-level list attribute, named &#039;&#039;&#039;route-track&#039;&#039;&#039;,&lt;br /&gt;
which contains route tracking rules. These are special marking rules&lt;br /&gt;
which cause all the subsequent packets related to the same connection&lt;br /&gt;
to be marked according to the rule.&lt;br /&gt;
&lt;br /&gt;
==== Transparent Proxy Rules ====&lt;br /&gt;
&lt;br /&gt;
Transparent proxy rules divert the matching packets to a local proxy&lt;br /&gt;
process without altering their headers. Such rules are contained in&lt;br /&gt;
the top-level list named &#039;&#039;&#039;tproxy&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
In addition to the firewall configuration, using a transparent proxy&lt;br /&gt;
requires a routing configuration where packets marked for proxying are&lt;br /&gt;
diverted to a local process. The &#039;&#039;&#039;awall_tproxy_mark&#039;&#039;&#039; variable can&lt;br /&gt;
be used to specify the mark for such packets, which defaults to 1.&lt;br /&gt;
&lt;br /&gt;
Proxy rules may also have an attribute named &#039;&#039;&#039;to-port&#039;&#039;&#039; for&lt;br /&gt;
specifying the TCP or UDP port of the proxy if it is different from&lt;br /&gt;
the original destination port.&lt;br /&gt;
&lt;br /&gt;
==== MSS Clamping Rules ====&lt;br /&gt;
&lt;br /&gt;
MSS Clamping Rules are used to deal with ISPs that block ICMP&lt;br /&gt;
Fragmentation Needed or ICMPv6 Packet Too Big packets. An MSS clamping&lt;br /&gt;
rule overwrites the MSS option with a value specified with the&lt;br /&gt;
&#039;&#039;&#039;mss&#039;&#039;&#039; attribute for the matching TCP connections. If &#039;&#039;&#039;mss&#039;&#039;&#039; is&lt;br /&gt;
not specified, a suitable value is automatically determined from the&lt;br /&gt;
path MTU. The MSS clamping rules are located in the top-level&lt;br /&gt;
dictionary named &#039;&#039;&#039;clamp-mss&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
==== Connection Tracking Bypass Rules ====&lt;br /&gt;
&lt;br /&gt;
Connection tracking bypass rules are used to disable connection&lt;br /&gt;
tracking for packets matching the specified criteria. The top-level&lt;br /&gt;
attribute &#039;&#039;&#039;no-track&#039;&#039;&#039; is a list of such rules.&lt;br /&gt;
&lt;br /&gt;
Connection tracking bypass rules may have an &#039;&#039;&#039;action&#039;&#039;&#039;&lt;br /&gt;
attribute set to value &#039;&#039;&#039;include&#039;&#039;&#039; or &#039;&#039;&#039;exclude&#039;&#039;&#039;, with&lt;br /&gt;
behavior similar to that of NAT rules.&lt;br /&gt;
&lt;br /&gt;
=== IP Sets ===&lt;br /&gt;
&lt;br /&gt;
Any IP set referenced by rule objects should be created by&lt;br /&gt;
awall. Auxiliary &#039;&#039;IP set&#039;&#039; objects are used to defined them in awall&lt;br /&gt;
policy files. The top-level attribute &#039;&#039;&#039;ipset&#039;&#039;&#039; is a dictionary, the&lt;br /&gt;
keys of which are IP set names. The values are IP set objects, which&lt;br /&gt;
have two mandatory attributes. The attribute named &#039;&#039;&#039;type&#039;&#039;&#039; &lt;br /&gt;
corresponds to the type argument of the &amp;lt;tt&amp;gt;ipset create&amp;lt;/tt&amp;gt; &lt;br /&gt;
command. &#039;&#039;&#039;family&#039;&#039;&#039; specifies whether the set is for IPv4 or IPv6&lt;br /&gt;
addresses, and the possible values are &#039;&#039;&#039;inet&#039;&#039;&#039; and &#039;&#039;&#039;inet6&#039;&#039;&#039;,&lt;br /&gt;
correspondingly.&lt;br /&gt;
&lt;br /&gt;
For bitmap-type IP sets, the &#039;&#039;&#039;range&#039;&#039;&#039; attribute specifies the&lt;br /&gt;
range of allowed IPv4 addresses. It may be given as a network&lt;br /&gt;
address or two addresses separated by the &#039;&#039;&#039;-&#039;&#039;&#039; character. It&lt;br /&gt;
is not necessary to specify &#039;&#039;&#039;family&#039;&#039;&#039; for bitmaps, since the&lt;br /&gt;
kernel supports only IPv4 bitmaps.&lt;br /&gt;
&lt;br /&gt;
== Command Line Syntax ==&lt;br /&gt;
&lt;br /&gt;
=== Translating Policy Files to Firewall Configuration Files ===&lt;br /&gt;
&lt;br /&gt;
 &#039;&#039;&#039;awall translate&#039;&#039;&#039; [&#039;&#039;&#039;-o&#039;&#039;&#039;|&#039;&#039;&#039;--output&#039;&#039;&#039; DIRECTORY] [&#039;&#039;&#039;-V&#039;&#039;&#039;|&#039;&#039;&#039;--verify&#039;&#039;&#039;]&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;tt&amp;gt;--verify&amp;lt;/tt&amp;gt; option makes awall verify the configuration&lt;br /&gt;
using the test mode of iptables-restore before overwriting the old&lt;br /&gt;
files.&lt;br /&gt;
&lt;br /&gt;
Specifying the output directory allows testing awall policies without&lt;br /&gt;
overwriting the current iptables and ipset configuration files. By&lt;br /&gt;
default, awall generates the configuration to &amp;lt;tt&amp;gt;/etc/iptables&amp;lt;/tt&amp;gt; &lt;br /&gt;
and &amp;lt;tt&amp;gt;/etc/ipset.d&amp;lt;/tt&amp;gt;, which are read by the init scripts.&lt;br /&gt;
&lt;br /&gt;
=== Run-Time Configuration of Firewall ===&lt;br /&gt;
&lt;br /&gt;
 &#039;&#039;&#039;awall activate&#039;&#039;&#039; [&#039;&#039;&#039;-f&#039;&#039;&#039;|&#039;&#039;&#039;--force&#039;&#039;&#039;]&lt;br /&gt;
&lt;br /&gt;
This command genereates firewall configuration from the policy files&lt;br /&gt;
and enables it. If the user confirms the new configuration by hitting&lt;br /&gt;
the Return key within 10 seconds or the &amp;lt;tt&amp;gt;--force&amp;lt;/tt&amp;gt; option is&lt;br /&gt;
used, the configuration is saved to the files. Otherwise, the old&lt;br /&gt;
configuration is restored.&lt;br /&gt;
&lt;br /&gt;
There is also a command for deleting all firewall rules:&lt;br /&gt;
&lt;br /&gt;
 &#039;&#039;&#039;awall flush&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
This command configures the firewall to drop all packets.&lt;br /&gt;
&lt;br /&gt;
=== Optional Policies ===&lt;br /&gt;
&lt;br /&gt;
Optional policies can be enabled or disabled using this command:&lt;br /&gt;
&lt;br /&gt;
 &#039;&#039;&#039;awall&#039;&#039;&#039; {&#039;&#039;&#039;enable&#039;&#039;&#039;|&#039;&#039;&#039;disable&#039;&#039;&#039;} POLICY...&lt;br /&gt;
&lt;br /&gt;
Optional policies can be listed using this command:&lt;br /&gt;
&lt;br /&gt;
 &#039;&#039;&#039;awall list&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;&#039;enabled&#039;&#039;&#039; status means that the policy has been enabled by the&lt;br /&gt;
user. The &#039;&#039;&#039;disabled&#039;&#039;&#039; status means that the policy is not in&lt;br /&gt;
use. The &#039;&#039;&#039;required&#039;&#039;&#039; status means that the policy has not been&lt;br /&gt;
enabled by the user but is in use because it is required by another&lt;br /&gt;
policy which is in use.&lt;br /&gt;
&lt;br /&gt;
=== Debugging Policies ===&lt;br /&gt;
&lt;br /&gt;
This command can be used to dump variable, zone, and other definitions&lt;br /&gt;
as well as their source policies:&lt;br /&gt;
&lt;br /&gt;
 &#039;&#039;&#039;awall dump&#039;&#039;&#039; [LEVEL]&lt;br /&gt;
&lt;br /&gt;
The level is an integer in range 0&amp;amp;ndash;5 and defaults to 0. More&lt;br /&gt;
information is displayed on higher levels.&lt;br /&gt;
&lt;br /&gt;
[[Category:Networking]]&lt;br /&gt;
[[Category:Security]]&lt;/div&gt;</summary>
		<author><name>Kunkku</name></author>
	</entry>
	<entry>
		<id>https://wiki.alpinelinux.org/w/index.php?title=Alpine_Wall_User%27s_Guide&amp;diff=9878</id>
		<title>Alpine Wall User&#039;s Guide</title>
		<link rel="alternate" type="text/html" href="https://wiki.alpinelinux.org/w/index.php?title=Alpine_Wall_User%27s_Guide&amp;diff=9878"/>
		<updated>2014-03-07T10:52:18Z</updated>

		<summary type="html">&lt;p&gt;Kunkku: /* Services */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Configuration File Processing ==&lt;br /&gt;
&lt;br /&gt;
[[Alpine Wall]] (awall) reads its configuration from multiple&lt;br /&gt;
JSON-formatted files, called &#039;&#039;policy files&#039;&#039;. The files located in&lt;br /&gt;
directory &amp;lt;tt&amp;gt;/usr/share/awall/mandatory&amp;lt;/tt&amp;gt; are &#039;&#039;mandatory&#039;&#039;&lt;br /&gt;
policies shipped with APK packages. In addition, there can be&lt;br /&gt;
installation-specific mandatory policies in &amp;lt;tt&amp;gt;/etc/awall&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
The latter directory may also contain symbolic links to policy files&lt;br /&gt;
located in &amp;lt;tt&amp;gt;/usr/share/awall/optional&amp;lt;/tt&amp;gt; and&lt;br /&gt;
&amp;lt;tt&amp;gt;/etc/awall/optional&amp;lt;/tt&amp;gt;. These are &#039;&#039;optional&#039;&#039; policies, which&lt;br /&gt;
can be enabled on need basis. Such symbolic links are easily created&lt;br /&gt;
and destroyed using the &amp;lt;tt&amp;gt;awall enable&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;awall&lt;br /&gt;
disable&amp;lt;/tt&amp;gt; commands. &amp;lt;tt&amp;gt;awall list&amp;lt;/tt&amp;gt; shows which optional&lt;br /&gt;
policies are enabled and disabled. The command also prints the&lt;br /&gt;
description of the optional policy if defined in the file using a&lt;br /&gt;
top-level attribute named &#039;&#039;&#039;description&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Sometimes a policy file depends on other policy files. In this case,&lt;br /&gt;
the policy file must have a top-level attribute &#039;&#039;&#039;import&#039;&#039;&#039;, the&lt;br /&gt;
value of which is a list of policy names, which correspond to the file&lt;br /&gt;
names without the &amp;lt;tt&amp;gt;.json&amp;lt;/tt&amp;gt; suffix. The imported policies may be&lt;br /&gt;
either optional policies or &#039;&#039;private&#039;&#039; policies, located in&lt;br /&gt;
&amp;lt;tt&amp;gt;/usr/share/awall/private&amp;lt;/tt&amp;gt; or &amp;lt;tt&amp;gt;/etc/awall/private&amp;lt;/tt&amp;gt;. By&lt;br /&gt;
default, the policies listed there are processed before the importing&lt;br /&gt;
policy.&lt;br /&gt;
&lt;br /&gt;
The order of the generated iptables rules generally reflects the&lt;br /&gt;
processing order of their corresponding awall policies. The processing&lt;br /&gt;
order of policies can be adjusted by defining top-level attributes&lt;br /&gt;
&#039;&#039;&#039;after&#039;&#039;&#039; and &#039;&#039;&#039;before&#039;&#039;&#039; in policy files. These attributes are&lt;br /&gt;
lists of policies, after or before which the declaring policy shall be&lt;br /&gt;
processed. Putting a policy name to either of these lists does not by&lt;br /&gt;
itself import the policy. The ordering directives are ignored with&lt;br /&gt;
respect to those policies that are not enabled by the user or imported&lt;br /&gt;
by other policies. If not defined, &#039;&#039;&#039;after&#039;&#039;&#039; is assumed to be equal&lt;br /&gt;
to the &#039;&#039;&#039;import&#039;&#039;&#039; definition of the policy.&lt;br /&gt;
&lt;br /&gt;
As the import directive does not require the path name to be&lt;br /&gt;
specified, awall expects policies to have unique names, even if&lt;br /&gt;
located in different directories. It is allowed to import optional&lt;br /&gt;
policies that are not explicitly enabled by the user. Such policies&lt;br /&gt;
show up with the &amp;lt;tt&amp;gt;required&amp;lt;/tt&amp;gt; status in the output of &amp;lt;tt&amp;gt;awall&lt;br /&gt;
list&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
== List Parameters ==&lt;br /&gt;
&lt;br /&gt;
Several awall parameters are defined as lists of values. In order to&lt;br /&gt;
facilitate manual editing of policy files, awall also accepts single&lt;br /&gt;
values in place of lists. Such values are semantically equivalent to&lt;br /&gt;
lists containing one element.&lt;br /&gt;
&lt;br /&gt;
== Variable Expansion ==&lt;br /&gt;
&lt;br /&gt;
Awall allows variable definitions in policy files. The top-level&lt;br /&gt;
attribute &#039;&#039;&#039;variable&#039;&#039;&#039; is a dictionary containing the&lt;br /&gt;
definitions. The value of a variable can be of any type (string,&lt;br /&gt;
integer, list, or dictionary).&lt;br /&gt;
&lt;br /&gt;
A variable is referenced in policy files by a string which equals the&lt;br /&gt;
variable name prepended with the &#039;&#039;&#039;$&#039;&#039;&#039; character. If the value of&lt;br /&gt;
the variable is a string, the reference can be embedded into a longer&lt;br /&gt;
string in order to substitute some part of that string (in shell&lt;br /&gt;
style). Variable references can be used when defining other variables,&lt;br /&gt;
as long as the definitions are not circular.&lt;br /&gt;
&lt;br /&gt;
Policy files can reference variables defined in other policy&lt;br /&gt;
files. Policy files can also override variables defined elsewhere by&lt;br /&gt;
redefining them. In this case, the new definition affects all policy&lt;br /&gt;
files, also those processed before the overriding policy. Awall&lt;br /&gt;
variables are in fact simple macros, since each variable remains&lt;br /&gt;
constant thoughout a single processing round. If multiple files define&lt;br /&gt;
the same variable, the definition in the file processed last takes&lt;br /&gt;
effect.&lt;br /&gt;
&lt;br /&gt;
If defined as an empty string, all non-embedded references to a&lt;br /&gt;
variable evaluate as if the attribute in question was not present in&lt;br /&gt;
the configuration. This is also the case when a string containing&lt;br /&gt;
embedded variable references finally evaluates to an empty string.&lt;br /&gt;
&lt;br /&gt;
== Configuration Objects ==&lt;br /&gt;
&lt;br /&gt;
Configuration objects can be divided into two main types.&lt;br /&gt;
&#039;&#039;Auxiliary objects&#039;&#039; model high-level concepts such as services and&lt;br /&gt;
zones. &#039;&#039;Rule objects&#039;&#039; translate into one or more iptables rules, and&lt;br /&gt;
are often defined with the help of some auxiliary objects.&lt;br /&gt;
&lt;br /&gt;
=== Services ===&lt;br /&gt;
&lt;br /&gt;
A &#039;&#039;service&#039;&#039; represents a set of network protocols. A top-level&lt;br /&gt;
attribute &#039;&#039;&#039;service&#039;&#039;&#039; is a dictionary that maps service names to&lt;br /&gt;
service definition objects, or lists thereof in more complex cases.&lt;br /&gt;
&lt;br /&gt;
A service definition object contains an attribute named&lt;br /&gt;
&#039;&#039;&#039;proto&#039;&#039;&#039;, which corresponds to the &amp;lt;tt&amp;gt;--protocol&amp;lt;/tt&amp;gt; option&lt;br /&gt;
of iptables. The protocol can be defined as a numerical value or&lt;br /&gt;
string as defined in &amp;lt;tt&amp;gt;/etc/protocols&amp;lt;/tt&amp;gt;. If the protocol is&lt;br /&gt;
&#039;&#039;&#039;tcp&#039;&#039;&#039; or &#039;&#039;&#039;udp&#039;&#039;&#039;, the scope of the service definition may&lt;br /&gt;
be constrained by defining an attribute named &#039;&#039;&#039;port&#039;&#039;&#039;, which&lt;br /&gt;
is a list of TCP or UDP port numbers or ranges thereof, separated&lt;br /&gt;
by the &#039;&#039;&#039;-&#039;&#039;&#039; character. If the protocol is &#039;&#039;&#039;icmp&#039;&#039;&#039; or&lt;br /&gt;
&#039;&#039;&#039;icmpv6&#039;&#039;&#039;, an analogous &#039;&#039;&#039;type&#039;&#039;&#039; attribute may be used. The&lt;br /&gt;
replies to ICMP messages have their own type codes, which may be&lt;br /&gt;
specified using the &#039;&#039;&#039;reply-type&#039;&#039;&#039; attribute.&lt;br /&gt;
&lt;br /&gt;
If the protocol is &#039;&#039;&#039;icmp&#039;&#039;&#039; or &#039;&#039;&#039;icmpv6&#039;&#039;&#039;, the scope of the&lt;br /&gt;
rule is also automatically limited to IPv4 or IPv6,&lt;br /&gt;
respectively. There are also other services which are specific to&lt;br /&gt;
IPv4 or IPv6. To constrain the scope of the service definition to&lt;br /&gt;
either protocol version, an optional &#039;&#039;&#039;family&#039;&#039;&#039; attribute can&lt;br /&gt;
be set to value &#039;&#039;&#039;inet&#039;&#039;&#039; or &#039;&#039;&#039;inet6&#039;&#039;&#039;, respectively.&lt;br /&gt;
&lt;br /&gt;
Some services require the server or client to open additional&lt;br /&gt;
connections to dynamically allocated ports or even different&lt;br /&gt;
hosts. &#039;&#039;Connection tracking helpers&#039;&#039; are used to make the firewall&lt;br /&gt;
aware of such additional connections. The &#039;&#039;&#039;ct-helper&#039;&#039;&#039; attribute is&lt;br /&gt;
used to associate such a helper to a service definition when&lt;br /&gt;
required by the service.&lt;br /&gt;
&lt;br /&gt;
All rule objects, except for policies, may have an attribute named&lt;br /&gt;
&#039;&#039;&#039;service&#039;&#039;&#039;, constraining the rule&#039;s scope to specific services&lt;br /&gt;
only. This attribute is a list of service names, referring to the keys&lt;br /&gt;
of the top-level service dictionary.&lt;br /&gt;
&lt;br /&gt;
=== Zones ===&lt;br /&gt;
&lt;br /&gt;
A &#039;&#039;zone&#039;&#039; represents a set of network hosts. A top-level attribute &lt;br /&gt;
&#039;&#039;&#039;zone&#039;&#039;&#039; is a dictionary that maps zone names to zone objects. A&lt;br /&gt;
zone object has an attribute named &#039;&#039;&#039;iface&#039;&#039;&#039;, &#039;&#039;&#039;addr&#039;&#039;&#039;, or&lt;br /&gt;
both. &#039;&#039;&#039;iface&#039;&#039;&#039; is a list of network interfaces and &#039;&#039;&#039;addr&#039;&#039;&#039; is a&lt;br /&gt;
list of IPv4/IPv6 host and network addresses (CIDR&lt;br /&gt;
notation). &#039;&#039;&#039;addr&#039;&#039;&#039; may also contain domain names, which are&lt;br /&gt;
expanded to IP addresses using DNS resolution. If not defined,&lt;br /&gt;
&#039;&#039;&#039;addr&#039;&#039;&#039; defaults to the entire address space and &#039;&#039;&#039;iface&#039;&#039;&#039; to all&lt;br /&gt;
interfaces. An empty zone can be defined by setting either &#039;&#039;&#039;addr&#039;&#039;&#039;&lt;br /&gt;
or &#039;&#039;&#039;iface&#039;&#039;&#039; to an empty list.&lt;br /&gt;
&lt;br /&gt;
Rule objects contain two attributes, &#039;&#039;&#039;in&#039;&#039;&#039; and &#039;&#039;&#039;out&#039;&#039;&#039;, which are&lt;br /&gt;
lists of zone names. These attributes control whether a packet matches&lt;br /&gt;
the rule or not. If a particular zone is referenced by the &#039;&#039;&#039;in&#039;&#039;&#039; &lt;br /&gt;
attribute, the rule applies to packets whose ingress interface and&lt;br /&gt;
source address are covered by the zone definition. Correspondingly, if&lt;br /&gt;
a zone is referenced by the &#039;&#039;&#039;out&#039;&#039;&#039; attribute, the rule applies to&lt;br /&gt;
packets whose egress interface and destination address are included in&lt;br /&gt;
the zone. If both &#039;&#039;&#039;in&#039;&#039;&#039; and &#039;&#039;&#039;out&#039;&#039;&#039; are defined, the packet must&lt;br /&gt;
fulfill both criteria in order to match the rule.&lt;br /&gt;
&lt;br /&gt;
The firewall host itself can be referred to using the special value&lt;br /&gt;
&#039;&#039;&#039;_fw&#039;&#039;&#039; as the zone name.&lt;br /&gt;
&lt;br /&gt;
By default, awall does not generate iptables rules with identical&lt;br /&gt;
ingress and egress interfaces. This behavior can be changed per zone&lt;br /&gt;
by setting the optional &#039;&#039;&#039;route-back&#039;&#039;&#039; attribute of the zone to&lt;br /&gt;
&#039;&#039;&#039;true&#039;&#039;&#039;. Note that this attribute can have an effect also in the&lt;br /&gt;
case where &#039;&#039;&#039;in&#039;&#039;&#039; and &#039;&#039;&#039;out&#039;&#039;&#039; attributes of a rule are not equal&lt;br /&gt;
but their definitions overlap. In this case, the &#039;&#039;&#039;route-back&#039;&#039;&#039;&lt;br /&gt;
attribute of the &#039;&#039;&#039;out&#039;&#039;&#039; zone determines the behavior.&lt;br /&gt;
&lt;br /&gt;
=== Logging Classes ===&lt;br /&gt;
&lt;br /&gt;
A &#039;&#039;logging class&#039;&#039; specifies how packets matching certain rules are&lt;br /&gt;
logged. A top-level attribute &#039;&#039;&#039;log&#039;&#039;&#039; is a dictionary that maps&lt;br /&gt;
logging class names to setting objects.&lt;br /&gt;
&lt;br /&gt;
A setting object may have an attribute named &#039;&#039;&#039;mode&#039;&#039;&#039;, which&lt;br /&gt;
specifies which logging facility to use. Allowed values are &#039;&#039;&#039;log&#039;&#039;&#039;,&lt;br /&gt;
&#039;&#039;&#039;nflog&#039;&#039;&#039;, and &#039;&#039;&#039;ulog&#039;&#039;&#039;. The default is &#039;&#039;&#039;log&#039;&#039;&#039;, i.e. in-kernel&lt;br /&gt;
logging.&lt;br /&gt;
&lt;br /&gt;
The following table shows the optional attributes valid for all&lt;br /&gt;
logging modes:&lt;br /&gt;
&lt;br /&gt;
{|&lt;br /&gt;
!Attribute!!Description&lt;br /&gt;
|-&lt;br /&gt;
|&#039;&#039;&#039;every&#039;&#039;&#039;&lt;br /&gt;
|Divide successive packets into groups, the size of which is specified by the value of this attribute, and log only the first packet of each group&lt;br /&gt;
|-&lt;br /&gt;
|&#039;&#039;&#039;limit&#039;&#039;&#039;&lt;br /&gt;
|Maximum number of packets to be logged per second per this rule&lt;br /&gt;
|-&lt;br /&gt;
|&#039;&#039;&#039;prefix&#039;&#039;&#039;&lt;br /&gt;
|String with which the log entries are prefixed&lt;br /&gt;
|-&lt;br /&gt;
|&#039;&#039;&#039;probability&#039;&#039;&#039;&lt;br /&gt;
|Probability for logging an individual packet (default: 1)&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
With the in-kernel log mode &#039;&#039;&#039;log&#039;&#039;&#039;, the level of logging may be&lt;br /&gt;
specified using the &#039;&#039;&#039;level&#039;&#039;&#039; attribute. Log modes &#039;&#039;&#039;nflog&#039;&#039;&#039; and&lt;br /&gt;
&#039;&#039;&#039;ulog&#039;&#039;&#039; are about copying the packets into user space, at least&lt;br /&gt;
partially. The following table shows the additional attributes valid&lt;br /&gt;
with these modes:&lt;br /&gt;
&lt;br /&gt;
{|&lt;br /&gt;
!Attribute!!Description&lt;br /&gt;
|-&lt;br /&gt;
|&#039;&#039;&#039;group&#039;&#039;&#039;&lt;br /&gt;
|Netlink group to be used&lt;br /&gt;
|-&lt;br /&gt;
|&#039;&#039;&#039;range&#039;&#039;&#039;&lt;br /&gt;
|Number of bytes to be copied&lt;br /&gt;
|-&lt;br /&gt;
|&#039;&#039;&#039;threshold&#039;&#039;&#039;&lt;br /&gt;
|Number of packets to queue inside the kernel before copying them&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Filter and policy rules can have an attribute named &#039;&#039;&#039;log&#039;&#039;&#039;. If it&lt;br /&gt;
is a string, it is interpreted as a reference to a logging class, and&lt;br /&gt;
logging is performed according to the definitions. If the value of the&lt;br /&gt;
&#039;&#039;&#039;log&#039;&#039;&#039; attribute is &#039;&#039;&#039;true&#039;&#039;&#039; (boolean), logging is done using&lt;br /&gt;
default settings. If the value is &#039;&#039;&#039;false&#039;&#039;&#039; (boolean), logging is&lt;br /&gt;
disabled for the rule. If &#039;&#039;&#039;log&#039;&#039;&#039; is not defined, logging is done&lt;br /&gt;
using the default settings except for accept rules, for which logging&lt;br /&gt;
is omitted.&lt;br /&gt;
&lt;br /&gt;
Default logging settings can be set by defining a logging class named&lt;br /&gt;
&#039;&#039;&#039;_default&#039;&#039;&#039;. Normally, default logging uses the &#039;&#039;&#039;log&#039;&#039;&#039; mode with&lt;br /&gt;
packets limited to one per second.&lt;br /&gt;
&lt;br /&gt;
=== Rules ===&lt;br /&gt;
&lt;br /&gt;
There are several types of rule objects:&lt;br /&gt;
* Filter rules&lt;br /&gt;
* Policy rules&lt;br /&gt;
* Packet Logging rules&lt;br /&gt;
* NAT rules&lt;br /&gt;
* Packet Marking rules&lt;br /&gt;
* Transparent Proxy rules&lt;br /&gt;
* MSS Clamping rules&lt;br /&gt;
* Connection Tracking Bypass rules&lt;br /&gt;
&lt;br /&gt;
All rule objects can have the &#039;&#039;&#039;in&#039;&#039;&#039; and &#039;&#039;&#039;out&#039;&#039;&#039; attributes&lt;br /&gt;
referring to zones as described in the previous section. In addition,&lt;br /&gt;
the scope of the rule can be further constrained with the following&lt;br /&gt;
attributes:&lt;br /&gt;
&lt;br /&gt;
{|&lt;br /&gt;
!Attribute!!Value format!!Effect&lt;br /&gt;
|-&lt;br /&gt;
|&#039;&#039;&#039;src&#039;&#039;&#039;&lt;br /&gt;
|Similar to &#039;&#039;&#039;addr&#039;&#039;&#039; attribute of zone objects&lt;br /&gt;
|Packet&#039;s source address matches the value&lt;br /&gt;
|-&lt;br /&gt;
|&#039;&#039;&#039;dest&#039;&#039;&#039;&lt;br /&gt;
|Similar to &#039;&#039;&#039;addr&#039;&#039;&#039; attribute of zone objects&lt;br /&gt;
|Packet&#039;s destination address matches the value&lt;br /&gt;
|-&lt;br /&gt;
|&#039;&#039;&#039;ipset&#039;&#039;&#039;&lt;br /&gt;
|Object containing two attributes: &#039;&#039;&#039;name&#039;&#039;&#039; referring to an IP set and &#039;&#039;&#039;args&#039;&#039;&#039;, which is a list of strings &#039;&#039;&#039;in&#039;&#039;&#039; and &#039;&#039;&#039;out&#039;&#039;&#039;&lt;br /&gt;
|Packet matches the IP set referred here when the match arguments are taken from the source (&#039;&#039;&#039;in&#039;&#039;&#039;) and destination (&#039;&#039;&#039;out&#039;&#039;&#039;) address or port in the order specified by &#039;&#039;&#039;args&#039;&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
|&#039;&#039;&#039;ipsec&#039;&#039;&#039;&lt;br /&gt;
|&#039;&#039;&#039;in&#039;&#039;&#039; or &#039;&#039;&#039;out&#039;&#039;&#039;&lt;br /&gt;
|IPsec decapsulation perfomed on ingress (&#039;&#039;&#039;in&#039;&#039;&#039;) or encapsulation performed on egress (&#039;&#039;&#039;out&#039;&#039;&#039;)&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Rule objects are declared in type-specific top-level dictionaries in&lt;br /&gt;
awall policy files. If a packet matches multiple rules, the one&lt;br /&gt;
appearing earlier in the list takes precedence. If the matching rules&lt;br /&gt;
are defined in different policy files, the one that was processed&lt;br /&gt;
earlier takes precedence in the current implementation, but this may&lt;br /&gt;
change in future versions.&lt;br /&gt;
&lt;br /&gt;
==== Filter Rules ====&lt;br /&gt;
&lt;br /&gt;
Filter objects specify an action for packets fulfilling certain&lt;br /&gt;
criteria. The top-level attribute &#039;&#039;&#039;filter&#039;&#039;&#039; is a list of filter&lt;br /&gt;
objects. The precedence rules are similar to those of policy objects.&lt;br /&gt;
&lt;br /&gt;
Filter objects must have an attribute named &#039;&#039;&#039;action&#039;&#039;&#039;, the value of&lt;br /&gt;
which can be one of the following:&lt;br /&gt;
&lt;br /&gt;
{|&lt;br /&gt;
!Value!!Action&lt;br /&gt;
|-&lt;br /&gt;
|&#039;&#039;&#039;accept&#039;&#039;&#039;&lt;br /&gt;
|Accept the packet&lt;br /&gt;
|-&lt;br /&gt;
|&#039;&#039;&#039;reject&#039;&#039;&#039;&lt;br /&gt;
|Reject the packet with an ICMP error message&lt;br /&gt;
|-&lt;br /&gt;
|&#039;&#039;&#039;drop&#039;&#039;&#039;&lt;br /&gt;
|Silently drop the packet&lt;br /&gt;
|-&lt;br /&gt;
|&#039;&#039;&#039;tarpit&#039;&#039;&#039;&lt;br /&gt;
|Put incoming TCP connections into persist state and ignore attempts to close them. Silently drop non-TCP packets. (Connection tracking bypass is automatically enabled for the matching packets.)&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Filter objects, the action of which is &#039;&#039;&#039;accept&#039;&#039;&#039;, may also contain&lt;br /&gt;
limits for packet flow or new connections. These are specified with&lt;br /&gt;
the &#039;&#039;&#039;flow-limit&#039;&#039;&#039; and &#039;&#039;&#039;conn-limit&#039;&#039;&#039; attributes,&lt;br /&gt;
respectively. The values of these attributes are limit objects that&lt;br /&gt;
have two attributes: &#039;&#039;&#039;count&#039;&#039;&#039; and &#039;&#039;&#039;interval&#039;&#039;&#039;. &#039;&#039;&#039;count&#039;&#039;&#039;&lt;br /&gt;
specifies how many new connections or packets are allowed within the&lt;br /&gt;
time frame specified by &#039;&#039;&#039;interval&#039;&#039;&#039; in seconds (default: 1). The&lt;br /&gt;
&#039;&#039;&#039;drop&#039;&#039;&#039; action is applied to the packets exceeding the&lt;br /&gt;
limit. Optionally, the limit object may have an attribute named&lt;br /&gt;
&#039;&#039;&#039;log&#039;&#039;&#039;. It defines how the dropped packets should be logged and is&lt;br /&gt;
semantically similar to the &#039;&#039;&#039;log&#039;&#039;&#039; attribute of rule objects. A&lt;br /&gt;
limit may also be specified by a plain integer, which is interpreted&lt;br /&gt;
as the count while using default interval and log settings.&lt;br /&gt;
&lt;br /&gt;
Filter objects may have an attribute named &#039;&#039;&#039;dnat&#039;&#039;&#039;, the value of&lt;br /&gt;
which is an IPv4 address. If defined, this enables destination NAT for&lt;br /&gt;
all IPv4 packets matching the rule, such that the specified address&lt;br /&gt;
replaces the original destination address. This option has no effect&lt;br /&gt;
on IPv6 packets.&lt;br /&gt;
&lt;br /&gt;
Filter objects may have a boolean attribute named &#039;&#039;&#039;no-track&#039;&#039;&#039;. If&lt;br /&gt;
set to &#039;&#039;&#039;true&#039;&#039;&#039;, connection tracking is bypassed for the matching&lt;br /&gt;
packets. In addition, if &#039;&#039;&#039;action&#039;&#039;&#039; is set to &#039;&#039;&#039;accept&#039;&#039;&#039;, the&lt;br /&gt;
corresponding packets travelling to the reverse direction are also&lt;br /&gt;
allowed.&lt;br /&gt;
&lt;br /&gt;
If one or more connection tracking helpers are associated with the&lt;br /&gt;
services referred to by an accept rule, additional iptables rules are&lt;br /&gt;
generated for the related connections detected by the helpers. The&lt;br /&gt;
&#039;&#039;&#039;related&#039;&#039;&#039; attribute can be used to override the default rules&lt;br /&gt;
generated by awall. It is a list of basic rule objects, the packets&lt;br /&gt;
matching to which are accepted, provided that they are also detected&lt;br /&gt;
by at least one of the helpers.&lt;br /&gt;
&lt;br /&gt;
==== Policy Rules ====&lt;br /&gt;
&lt;br /&gt;
Policy objects describe the default action for packets that did not&lt;br /&gt;
match any filter. The top-level attribute &#039;&#039;&#039;policy&#039;&#039;&#039; is a list of&lt;br /&gt;
policy objects.&lt;br /&gt;
&lt;br /&gt;
Policy objects must have the &#039;&#039;&#039;action&#039;&#039;&#039; attribute defined. The&lt;br /&gt;
possible values and their semantics are the same as in filter objects.&lt;br /&gt;
&lt;br /&gt;
==== Packet Logging Rules ====&lt;br /&gt;
&lt;br /&gt;
Packet logging rules allow packets matching the specified criteria to&lt;br /&gt;
be logged before any filtering takes place. Such rules are contained&lt;br /&gt;
in the top-level list named &#039;&#039;&#039;packet-log&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Logging class may be specified using the &#039;&#039;&#039;log&#039;&#039;&#039;&lt;br /&gt;
attribute. Otherwise, default logging settings are used.&lt;br /&gt;
&lt;br /&gt;
==== NAT Rules ====&lt;br /&gt;
&lt;br /&gt;
NAT rules come in two flavors: &#039;&#039;source NAT rules&#039;&#039; and&lt;br /&gt;
&#039;&#039;destination NAT rules&#039;&#039;. These are contained in two top-level lists&lt;br /&gt;
named &#039;&#039;&#039;snat&#039;&#039;&#039; and &#039;&#039;&#039;dnat&#039;&#039;&#039;, respectively.&lt;br /&gt;
&lt;br /&gt;
Each NAT rule may have an attribute named &#039;&#039;&#039;to-addr&#039;&#039;&#039; that&lt;br /&gt;
specifies the IPv4 address range to which the original source or&lt;br /&gt;
destination address is mapped. The value can be a single IPv4 address&lt;br /&gt;
or a range specified by two addresses, separated with the &#039;&#039;&#039;-&#039;&#039;&#039;&lt;br /&gt;
character. If not defined, it defaults to the primary address of the&lt;br /&gt;
ingress interface in case of destination NAT, or that of the egress&lt;br /&gt;
interface in case of source NAT.&lt;br /&gt;
&lt;br /&gt;
Optionally, a NAT rule can specify the TCP and UDP port range to which&lt;br /&gt;
the original source or destination port is mapped. The attribute is&lt;br /&gt;
named &#039;&#039;&#039;to-port&#039;&#039;&#039;, and the value can be a single port number or a&lt;br /&gt;
range specified by two numbers, separated with the &#039;&#039;&#039;-&#039;&#039;&#039;&lt;br /&gt;
character. If &#039;&#039;&#039;to-port&#039;&#039;&#039; is not specified, the original port number&lt;br /&gt;
is kept intact.&lt;br /&gt;
&lt;br /&gt;
NAT rules may have an &#039;&#039;&#039;action&#039;&#039;&#039; attribute set to value&lt;br /&gt;
&#039;&#039;&#039;accept&#039;&#039;&#039;. In this case, NAT is not performed on the packets&lt;br /&gt;
reaching and matching this rule.&lt;br /&gt;
&lt;br /&gt;
==== Packet Marking Rules ====&lt;br /&gt;
&lt;br /&gt;
Packet marking rules are used to mark incoming packets matching the&lt;br /&gt;
specified criteria. The mark can be used as a basis for the routing&lt;br /&gt;
decision. Each marking rule must specify the mark using the &#039;&#039;&#039;mark&#039;&#039;&#039;&lt;br /&gt;
attribute, which is a 32-bit integer.&lt;br /&gt;
&lt;br /&gt;
Normal marking rules are contained by the top-level list attribute&lt;br /&gt;
named &#039;&#039;&#039;mark&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
There is another top-level list attribute, named &#039;&#039;&#039;route-track&#039;&#039;&#039;,&lt;br /&gt;
which contains route tracking rules. These are special marking rules&lt;br /&gt;
which cause all the subsequent packets related to the same connection&lt;br /&gt;
to be marked according to the rule.&lt;br /&gt;
&lt;br /&gt;
==== Transparent Proxy Rules ====&lt;br /&gt;
&lt;br /&gt;
Transparent proxy rules divert the matching packets to a local proxy&lt;br /&gt;
process without altering their headers. Such rules are contained in&lt;br /&gt;
the top-level list named &#039;&#039;&#039;tproxy&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
In addition to the firewall configuration, using a transparent proxy&lt;br /&gt;
requires a routing configuration where packets marked for proxying are&lt;br /&gt;
diverted to a local process. The &#039;&#039;&#039;awall_tproxy_mark&#039;&#039;&#039; variable can&lt;br /&gt;
be used to specify the mark for such packets, which defaults to 1.&lt;br /&gt;
&lt;br /&gt;
Proxy rules may also have an attribute named &#039;&#039;&#039;to-port&#039;&#039;&#039; for&lt;br /&gt;
specifying the TCP or UDP port of the proxy if it is different from&lt;br /&gt;
the original destination port.&lt;br /&gt;
&lt;br /&gt;
==== MSS Clamping Rules ====&lt;br /&gt;
&lt;br /&gt;
MSS Clamping Rules are used to deal with ISPs that block ICMP&lt;br /&gt;
Fragmentation Needed or ICMPv6 Packet Too Big packets. An MSS clamping&lt;br /&gt;
rule overwrites the MSS option with a value specified with the&lt;br /&gt;
&#039;&#039;&#039;mss&#039;&#039;&#039; attribute for the matching TCP connections. If &#039;&#039;&#039;mss&#039;&#039;&#039; is&lt;br /&gt;
not specified, a suitable value is automatically determined from the&lt;br /&gt;
path MTU. The MSS clamping rules are located in the top-level&lt;br /&gt;
dictionary named &#039;&#039;&#039;clamp-mss&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
==== Connection Tracking Bypass Rules ====&lt;br /&gt;
&lt;br /&gt;
Connection tracking bypass rules are used to disable connection&lt;br /&gt;
tracking for packets matching the specified criteria. The top-level&lt;br /&gt;
attribute &#039;&#039;&#039;no-track&#039;&#039;&#039; is a list of such rules.&lt;br /&gt;
&lt;br /&gt;
Connection tracking bypass rules may have an &#039;&#039;&#039;action&#039;&#039;&#039; attribute&lt;br /&gt;
set to value &#039;&#039;&#039;accept&#039;&#039;&#039;. The effect is similar to corresponding NAT&lt;br /&gt;
rules, i.e. connection tracking is not bypassed for the matching&lt;br /&gt;
packets.&lt;br /&gt;
&lt;br /&gt;
=== IP Sets ===&lt;br /&gt;
&lt;br /&gt;
Any IP set referenced by rule objects should be created by&lt;br /&gt;
awall. Auxiliary &#039;&#039;IP set&#039;&#039; objects are used to defined them in awall&lt;br /&gt;
policy files. The top-level attribute &#039;&#039;&#039;ipset&#039;&#039;&#039; is a dictionary, the&lt;br /&gt;
keys of which are IP set names. The values are IP set objects, which&lt;br /&gt;
have two mandatory attributes. The attribute named &#039;&#039;&#039;type&#039;&#039;&#039; &lt;br /&gt;
corresponds to the type argument of the &amp;lt;tt&amp;gt;ipset create&amp;lt;/tt&amp;gt; &lt;br /&gt;
command. &#039;&#039;&#039;family&#039;&#039;&#039; specifies whether the set is for IPv4 or IPv6&lt;br /&gt;
addresses, and the possible values are &#039;&#039;&#039;inet&#039;&#039;&#039; and &#039;&#039;&#039;inet6&#039;&#039;&#039;,&lt;br /&gt;
correspondingly.&lt;br /&gt;
&lt;br /&gt;
For bitmap-type IP sets, the &#039;&#039;&#039;range&#039;&#039;&#039; attribute specifies the&lt;br /&gt;
range of allowed IPv4 addresses. It may be given as a network&lt;br /&gt;
address or two addresses separated by the &#039;&#039;&#039;-&#039;&#039;&#039; character. It&lt;br /&gt;
is not necessary to specify &#039;&#039;&#039;family&#039;&#039;&#039; for bitmaps, since the&lt;br /&gt;
kernel supports only IPv4 bitmaps.&lt;br /&gt;
&lt;br /&gt;
== Command Line Syntax ==&lt;br /&gt;
&lt;br /&gt;
=== Translating Policy Files to Firewall Configuration Files ===&lt;br /&gt;
&lt;br /&gt;
 &#039;&#039;&#039;awall translate&#039;&#039;&#039; [&#039;&#039;&#039;-o&#039;&#039;&#039;|&#039;&#039;&#039;--output&#039;&#039;&#039; DIRECTORY] [&#039;&#039;&#039;-V&#039;&#039;&#039;|&#039;&#039;&#039;--verify&#039;&#039;&#039;]&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;tt&amp;gt;--verify&amp;lt;/tt&amp;gt; option makes awall verify the configuration&lt;br /&gt;
using the test mode of iptables-restore before overwriting the old&lt;br /&gt;
files.&lt;br /&gt;
&lt;br /&gt;
Specifying the output directory allows testing awall policies without&lt;br /&gt;
overwriting the current iptables and ipset configuration files. By&lt;br /&gt;
default, awall generates the configuration to &amp;lt;tt&amp;gt;/etc/iptables&amp;lt;/tt&amp;gt; &lt;br /&gt;
and &amp;lt;tt&amp;gt;/etc/ipset.d&amp;lt;/tt&amp;gt;, which are read by the init scripts.&lt;br /&gt;
&lt;br /&gt;
=== Run-Time Configuration of Firewall ===&lt;br /&gt;
&lt;br /&gt;
 &#039;&#039;&#039;awall activate&#039;&#039;&#039; [&#039;&#039;&#039;-f&#039;&#039;&#039;|&#039;&#039;&#039;--force&#039;&#039;&#039;]&lt;br /&gt;
&lt;br /&gt;
This command genereates firewall configuration from the policy files&lt;br /&gt;
and enables it. If the user confirms the new configuration by hitting&lt;br /&gt;
the Return key within 10 seconds or the &amp;lt;tt&amp;gt;--force&amp;lt;/tt&amp;gt; option is&lt;br /&gt;
used, the configuration is saved to the files. Otherwise, the old&lt;br /&gt;
configuration is restored.&lt;br /&gt;
&lt;br /&gt;
There is also a command for deleting all firewall rules:&lt;br /&gt;
&lt;br /&gt;
 &#039;&#039;&#039;awall flush&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
This command configures the firewall to drop all packets.&lt;br /&gt;
&lt;br /&gt;
=== Optional Policies ===&lt;br /&gt;
&lt;br /&gt;
Optional policies can be enabled or disabled using this command:&lt;br /&gt;
&lt;br /&gt;
 &#039;&#039;&#039;awall&#039;&#039;&#039; {&#039;&#039;&#039;enable&#039;&#039;&#039;|&#039;&#039;&#039;disable&#039;&#039;&#039;} POLICY...&lt;br /&gt;
&lt;br /&gt;
Optional policies can be listed using this command:&lt;br /&gt;
&lt;br /&gt;
 &#039;&#039;&#039;awall list&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;&#039;enabled&#039;&#039;&#039; status means that the policy has been enabled by the&lt;br /&gt;
user. The &#039;&#039;&#039;disabled&#039;&#039;&#039; status means that the policy is not in&lt;br /&gt;
use. The &#039;&#039;&#039;required&#039;&#039;&#039; status means that the policy has not been&lt;br /&gt;
enabled by the user but is in use because it is required by another&lt;br /&gt;
policy which is in use.&lt;br /&gt;
&lt;br /&gt;
=== Debugging Policies ===&lt;br /&gt;
&lt;br /&gt;
This command can be used to dump variable, zone, and other definitions&lt;br /&gt;
as well as their source policies:&lt;br /&gt;
&lt;br /&gt;
 &#039;&#039;&#039;awall dump&#039;&#039;&#039; [LEVEL]&lt;br /&gt;
&lt;br /&gt;
The level is an integer in range 0&amp;amp;ndash;5 and defaults to 0. More&lt;br /&gt;
information is displayed on higher levels.&lt;br /&gt;
&lt;br /&gt;
[[Category:Networking]]&lt;br /&gt;
[[Category:Security]]&lt;/div&gt;</summary>
		<author><name>Kunkku</name></author>
	</entry>
	<entry>
		<id>https://wiki.alpinelinux.org/w/index.php?title=Alpine_Wall_User%27s_Guide&amp;diff=9393</id>
		<title>Alpine Wall User&#039;s Guide</title>
		<link rel="alternate" type="text/html" href="https://wiki.alpinelinux.org/w/index.php?title=Alpine_Wall_User%27s_Guide&amp;diff=9393"/>
		<updated>2013-10-07T19:34:57Z</updated>

		<summary type="html">&lt;p&gt;Kunkku: /* Services */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Configuration File Processing ==&lt;br /&gt;
&lt;br /&gt;
[[Alpine Wall]] (awall) reads its configuration from multiple&lt;br /&gt;
JSON-formatted files, called &#039;&#039;policy files&#039;&#039;. The files located in&lt;br /&gt;
directory &amp;lt;tt&amp;gt;/usr/share/awall/mandatory&amp;lt;/tt&amp;gt; are &#039;&#039;mandatory&#039;&#039;&lt;br /&gt;
policies shipped with APK packages. In addition, there can be&lt;br /&gt;
installation-specific mandatory policies in &amp;lt;tt&amp;gt;/etc/awall&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
The latter directory may also contain symbolic links to policy files&lt;br /&gt;
located in &amp;lt;tt&amp;gt;/usr/share/awall/optional&amp;lt;/tt&amp;gt; and&lt;br /&gt;
&amp;lt;tt&amp;gt;/etc/awall/optional&amp;lt;/tt&amp;gt;. These are &#039;&#039;optional&#039;&#039; policies, which&lt;br /&gt;
can be enabled on need basis. Such symbolic links are easily created&lt;br /&gt;
and destroyed using the &amp;lt;tt&amp;gt;awall enable&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;awall&lt;br /&gt;
disable&amp;lt;/tt&amp;gt; commands. &amp;lt;tt&amp;gt;awall list&amp;lt;/tt&amp;gt; shows which optional&lt;br /&gt;
policies are enabled and disabled. The command also prints the&lt;br /&gt;
description of the optional policy if defined in the file using a&lt;br /&gt;
top-level attribute named &#039;&#039;&#039;description&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Sometimes a policy file depends on other policy files. In this case,&lt;br /&gt;
the policy file must have a top-level attribute &#039;&#039;&#039;import&#039;&#039;&#039;, the&lt;br /&gt;
value of which is a list of policy names, which correspond to the file&lt;br /&gt;
names without the &amp;lt;tt&amp;gt;.json&amp;lt;/tt&amp;gt; suffix. The imported policies may be&lt;br /&gt;
either optional policies or &#039;&#039;private&#039;&#039; policies, located in&lt;br /&gt;
&amp;lt;tt&amp;gt;/usr/share/awall/private&amp;lt;/tt&amp;gt; or &amp;lt;tt&amp;gt;/etc/awall/private&amp;lt;/tt&amp;gt;. By&lt;br /&gt;
default, the policies listed there are processed before the importing&lt;br /&gt;
policy.&lt;br /&gt;
&lt;br /&gt;
The order of the generated iptables rules generally reflects the&lt;br /&gt;
processing order of their corresponding awall policies. The processing&lt;br /&gt;
order of policies can be adjusted by defining top-level attributes&lt;br /&gt;
&#039;&#039;&#039;after&#039;&#039;&#039; and &#039;&#039;&#039;before&#039;&#039;&#039; in policy files. These attributes are&lt;br /&gt;
lists of policies, after or before which the declaring policy shall be&lt;br /&gt;
processed. Putting a policy name to either of these lists does not by&lt;br /&gt;
itself import the policy. The ordering directives are ignored with&lt;br /&gt;
respect to those policies that are not enabled by the user or imported&lt;br /&gt;
by other policies. If not defined, &#039;&#039;&#039;after&#039;&#039;&#039; is assumed to be equal&lt;br /&gt;
to the &#039;&#039;&#039;import&#039;&#039;&#039; definition of the policy.&lt;br /&gt;
&lt;br /&gt;
As the import directive does not require the path name to be&lt;br /&gt;
specified, awall expects policies to have unique names, even if&lt;br /&gt;
located in different directories. It is allowed to import optional&lt;br /&gt;
policies that are not explicitly enabled by the user. Such policies&lt;br /&gt;
show up with the &amp;lt;tt&amp;gt;required&amp;lt;/tt&amp;gt; status in the output of &amp;lt;tt&amp;gt;awall&lt;br /&gt;
list&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
== List Parameters ==&lt;br /&gt;
&lt;br /&gt;
Several awall parameters are defined as lists of values. In order to&lt;br /&gt;
facilitate manual editing of policy files, awall also accepts single&lt;br /&gt;
values in place of lists. Such values are semantically equivalent to&lt;br /&gt;
lists containing one element.&lt;br /&gt;
&lt;br /&gt;
== Variable Expansion ==&lt;br /&gt;
&lt;br /&gt;
Awall allows variable definitions in policy files. The top-level&lt;br /&gt;
attribute &#039;&#039;&#039;variable&#039;&#039;&#039; is a dictionary containing the&lt;br /&gt;
definitions. The value of a variable can be of any type (string,&lt;br /&gt;
integer, list, or dictionary).&lt;br /&gt;
&lt;br /&gt;
A variable is referenced in policy files by a string which equals the&lt;br /&gt;
variable name prepended with the &#039;&#039;&#039;$&#039;&#039;&#039; character. If the value of&lt;br /&gt;
the variable is a string, the reference can be embedded into a longer&lt;br /&gt;
string in order to substitute some part of that string (in shell&lt;br /&gt;
style). Variable references can be used when defining other variables,&lt;br /&gt;
as long as the definitions are not circular.&lt;br /&gt;
&lt;br /&gt;
Policy files can reference variables defined in other policy&lt;br /&gt;
files. Policy files can also override variables defined elsewhere by&lt;br /&gt;
redefining them. In this case, the new definition affects all policy&lt;br /&gt;
files, also those processed before the overriding policy. Awall&lt;br /&gt;
variables are in fact simple macros, since each variable remains&lt;br /&gt;
constant thoughout a single processing round. If multiple files define&lt;br /&gt;
the same variable, the definition in the file processed last takes&lt;br /&gt;
effect.&lt;br /&gt;
&lt;br /&gt;
If defined as an empty string, all non-embedded references to a&lt;br /&gt;
variable evaluate as if the attribute in question was not present in&lt;br /&gt;
the configuration. This is also the case when a string containing&lt;br /&gt;
embedded variable references finally evaluates to an empty string.&lt;br /&gt;
&lt;br /&gt;
== Configuration Objects ==&lt;br /&gt;
&lt;br /&gt;
Configuration objects can be divided into two main types.&lt;br /&gt;
&#039;&#039;Auxiliary objects&#039;&#039; model high-level concepts such as services and&lt;br /&gt;
zones. &#039;&#039;Rule objects&#039;&#039; translate into one or more iptables rules, and&lt;br /&gt;
are often defined with the help of some auxiliary objects.&lt;br /&gt;
&lt;br /&gt;
=== Services ===&lt;br /&gt;
&lt;br /&gt;
A &#039;&#039;service&#039;&#039; represents a set of network protocols. A top-level&lt;br /&gt;
attribute &#039;&#039;&#039;service&#039;&#039;&#039; is a dictionary that maps service names to&lt;br /&gt;
service definition objects, or lists thereof in more complex cases.&lt;br /&gt;
&lt;br /&gt;
A service definition object contains an attribute named &#039;&#039;&#039;proto&#039;&#039;&#039;,&lt;br /&gt;
which corresponds to the &amp;lt;tt&amp;gt;--protocol&amp;lt;/tt&amp;gt; option of iptables. The&lt;br /&gt;
protocol can be defined as a numerical value or string as defined in&lt;br /&gt;
&amp;lt;tt&amp;gt;/etc/protocols&amp;lt;/tt&amp;gt;. If the protocol is &#039;&#039;&#039;tcp&#039;&#039;&#039; or &#039;&#039;&#039;udp&#039;&#039;&#039;,&lt;br /&gt;
the scope of the service definition may be constrained by defining an&lt;br /&gt;
attribute named &#039;&#039;&#039;port&#039;&#039;&#039;, which is a list of TCP or UDP port numbers&lt;br /&gt;
or ranges thereof, separated by the &#039;&#039;&#039;-&#039;&#039;&#039; character. If the protocol&lt;br /&gt;
is &#039;&#039;&#039;icmp&#039;&#039;&#039; or &#039;&#039;&#039;icmpv6&#039;&#039;&#039;, an analogous &#039;&#039;&#039;type&#039;&#039;&#039; attribute&lt;br /&gt;
may be used. In addition, the scope of the rule is also automatically&lt;br /&gt;
limited to IPv4 or IPv6, respectively.&lt;br /&gt;
&lt;br /&gt;
There are also other services which are specific to IPv4 or IPv6. To&lt;br /&gt;
constrain the scope of the service definition to either protocol&lt;br /&gt;
version, an optional &#039;&#039;&#039;family&#039;&#039;&#039; attribute can be set to value&lt;br /&gt;
&#039;&#039;&#039;inet&#039;&#039;&#039; or &#039;&#039;&#039;inet6&#039;&#039;&#039;, respectively.&lt;br /&gt;
&lt;br /&gt;
Some services require the server or client to open additional&lt;br /&gt;
connections to dynamically allocated ports or even different&lt;br /&gt;
hosts. &#039;&#039;Connection tracking helpers&#039;&#039; are used to make the firewall&lt;br /&gt;
aware of such additional connections. The &#039;&#039;&#039;ct-helper&#039;&#039;&#039; attribute is&lt;br /&gt;
used to associate such a helper to a service definition when&lt;br /&gt;
required by the service.&lt;br /&gt;
&lt;br /&gt;
All rule objects, except for policies, may have an attribute named&lt;br /&gt;
&#039;&#039;&#039;service&#039;&#039;&#039;, constraining the rule&#039;s scope to specific services&lt;br /&gt;
only. This attribute is a list of service names, referring to the keys&lt;br /&gt;
of the top-level service dictionary.&lt;br /&gt;
&lt;br /&gt;
=== Zones ===&lt;br /&gt;
&lt;br /&gt;
A &#039;&#039;zone&#039;&#039; represents a set of network hosts. A top-level attribute &lt;br /&gt;
&#039;&#039;&#039;zone&#039;&#039;&#039; is a dictionary that maps zone names to zone objects. A&lt;br /&gt;
zone object has an attribute named &#039;&#039;&#039;iface&#039;&#039;&#039;, &#039;&#039;&#039;addr&#039;&#039;&#039;, or&lt;br /&gt;
both. &#039;&#039;&#039;iface&#039;&#039;&#039; is a list of network interfaces and &#039;&#039;&#039;addr&#039;&#039;&#039; is a&lt;br /&gt;
list of IPv4/IPv6 host and network addresses (CIDR&lt;br /&gt;
notation). &#039;&#039;&#039;addr&#039;&#039;&#039; may also contain domain names, which are&lt;br /&gt;
expanded to IP addresses using DNS resolution. If not defined,&lt;br /&gt;
&#039;&#039;&#039;addr&#039;&#039;&#039; defaults to the entire address space and &#039;&#039;&#039;iface&#039;&#039;&#039; to all&lt;br /&gt;
interfaces. An empty zone can be defined by setting either &#039;&#039;&#039;addr&#039;&#039;&#039;&lt;br /&gt;
or &#039;&#039;&#039;iface&#039;&#039;&#039; to an empty list.&lt;br /&gt;
&lt;br /&gt;
Rule objects contain two attributes, &#039;&#039;&#039;in&#039;&#039;&#039; and &#039;&#039;&#039;out&#039;&#039;&#039;, which are&lt;br /&gt;
lists of zone names. These attributes control whether a packet matches&lt;br /&gt;
the rule or not. If a particular zone is referenced by the &#039;&#039;&#039;in&#039;&#039;&#039; &lt;br /&gt;
attribute, the rule applies to packets whose ingress interface and&lt;br /&gt;
source address are covered by the zone definition. Correspondingly, if&lt;br /&gt;
a zone is referenced by the &#039;&#039;&#039;out&#039;&#039;&#039; attribute, the rule applies to&lt;br /&gt;
packets whose egress interface and destination address are included in&lt;br /&gt;
the zone. If both &#039;&#039;&#039;in&#039;&#039;&#039; and &#039;&#039;&#039;out&#039;&#039;&#039; are defined, the packet must&lt;br /&gt;
fulfill both criteria in order to match the rule.&lt;br /&gt;
&lt;br /&gt;
The firewall host itself can be referred to using the special value&lt;br /&gt;
&#039;&#039;&#039;_fw&#039;&#039;&#039; as the zone name.&lt;br /&gt;
&lt;br /&gt;
By default, awall does not generate iptables rules with identical&lt;br /&gt;
ingress and egress interfaces. This behavior can be changed per zone&lt;br /&gt;
by setting the optional &#039;&#039;&#039;route-back&#039;&#039;&#039; attribute of the zone to&lt;br /&gt;
&#039;&#039;&#039;true&#039;&#039;&#039;. Note that this attribute can have an effect also in the&lt;br /&gt;
case where &#039;&#039;&#039;in&#039;&#039;&#039; and &#039;&#039;&#039;out&#039;&#039;&#039; attributes of a rule are not equal&lt;br /&gt;
but their definitions overlap. In this case, the &#039;&#039;&#039;route-back&#039;&#039;&#039;&lt;br /&gt;
attribute of the &#039;&#039;&#039;out&#039;&#039;&#039; zone determines the behavior.&lt;br /&gt;
&lt;br /&gt;
=== Logging Classes ===&lt;br /&gt;
&lt;br /&gt;
A &#039;&#039;logging class&#039;&#039; specifies how packets matching certain rules are&lt;br /&gt;
logged. A top-level attribute &#039;&#039;&#039;log&#039;&#039;&#039; is a dictionary that maps&lt;br /&gt;
logging class names to setting objects.&lt;br /&gt;
&lt;br /&gt;
A setting object may have an attribute named &#039;&#039;&#039;mode&#039;&#039;&#039;, which&lt;br /&gt;
specifies which logging facility to use. Allowed values are &#039;&#039;&#039;log&#039;&#039;&#039;,&lt;br /&gt;
&#039;&#039;&#039;nflog&#039;&#039;&#039;, and &#039;&#039;&#039;ulog&#039;&#039;&#039;. The default is &#039;&#039;&#039;log&#039;&#039;&#039;, i.e. in-kernel&lt;br /&gt;
logging.&lt;br /&gt;
&lt;br /&gt;
The following table shows the optional attributes valid for all&lt;br /&gt;
logging modes:&lt;br /&gt;
&lt;br /&gt;
{|&lt;br /&gt;
!Attribute!!Description&lt;br /&gt;
|-&lt;br /&gt;
|&#039;&#039;&#039;every&#039;&#039;&#039;&lt;br /&gt;
|Divide successive packets into groups, the size of which is specified by the value of this attribute, and log only the first packet of each group&lt;br /&gt;
|-&lt;br /&gt;
|&#039;&#039;&#039;limit&#039;&#039;&#039;&lt;br /&gt;
|Maximum number of packets to be logged per second per this rule&lt;br /&gt;
|-&lt;br /&gt;
|&#039;&#039;&#039;prefix&#039;&#039;&#039;&lt;br /&gt;
|String with which the log entries are prefixed&lt;br /&gt;
|-&lt;br /&gt;
|&#039;&#039;&#039;probability&#039;&#039;&#039;&lt;br /&gt;
|Probability for logging an individual packet (default: 1)&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
With the in-kernel log mode &#039;&#039;&#039;log&#039;&#039;&#039;, the level of logging may be&lt;br /&gt;
specified using the &#039;&#039;&#039;level&#039;&#039;&#039; attribute. Log modes &#039;&#039;&#039;nflog&#039;&#039;&#039; and&lt;br /&gt;
&#039;&#039;&#039;ulog&#039;&#039;&#039; are about copying the packets into user space, at least&lt;br /&gt;
partially. The following table shows the additional attributes valid&lt;br /&gt;
with these modes:&lt;br /&gt;
&lt;br /&gt;
{|&lt;br /&gt;
!Attribute!!Description&lt;br /&gt;
|-&lt;br /&gt;
|&#039;&#039;&#039;group&#039;&#039;&#039;&lt;br /&gt;
|Netlink group to be used&lt;br /&gt;
|-&lt;br /&gt;
|&#039;&#039;&#039;range&#039;&#039;&#039;&lt;br /&gt;
|Number of bytes to be copied&lt;br /&gt;
|-&lt;br /&gt;
|&#039;&#039;&#039;threshold&#039;&#039;&#039;&lt;br /&gt;
|Number of packets to queue inside the kernel before copying them&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Filter and policy rules can have an attribute named &#039;&#039;&#039;log&#039;&#039;&#039;. If it&lt;br /&gt;
is a string, it is interpreted as a reference to a logging class, and&lt;br /&gt;
logging is performed according to the definitions. If the value of the&lt;br /&gt;
&#039;&#039;&#039;log&#039;&#039;&#039; attribute is &#039;&#039;&#039;true&#039;&#039;&#039; (boolean), logging is done using&lt;br /&gt;
default settings. If the value is &#039;&#039;&#039;false&#039;&#039;&#039; (boolean), logging is&lt;br /&gt;
disabled for the rule. If &#039;&#039;&#039;log&#039;&#039;&#039; is not defined, logging is done&lt;br /&gt;
using the default settings except for accept rules, for which logging&lt;br /&gt;
is omitted.&lt;br /&gt;
&lt;br /&gt;
Default logging settings can be set by defining a logging class named&lt;br /&gt;
&#039;&#039;&#039;_default&#039;&#039;&#039;. Normally, default logging uses the &#039;&#039;&#039;log&#039;&#039;&#039; mode with&lt;br /&gt;
packets limited to one per second.&lt;br /&gt;
&lt;br /&gt;
=== Rules ===&lt;br /&gt;
&lt;br /&gt;
There are several types of rule objects:&lt;br /&gt;
* Filter rules&lt;br /&gt;
* Policy rules&lt;br /&gt;
* Packet Logging rules&lt;br /&gt;
* NAT rules&lt;br /&gt;
* Packet Marking rules&lt;br /&gt;
* Transparent Proxy rules&lt;br /&gt;
* MSS Clamping rules&lt;br /&gt;
* Connection Tracking Bypass rules&lt;br /&gt;
&lt;br /&gt;
All rule objects can have the &#039;&#039;&#039;in&#039;&#039;&#039; and &#039;&#039;&#039;out&#039;&#039;&#039; attributes&lt;br /&gt;
referring to zones as described in the previous section. In addition,&lt;br /&gt;
the scope of the rule can be further constrained with the following&lt;br /&gt;
attributes:&lt;br /&gt;
&lt;br /&gt;
{|&lt;br /&gt;
!Attribute!!Value format!!Effect&lt;br /&gt;
|-&lt;br /&gt;
|&#039;&#039;&#039;src&#039;&#039;&#039;&lt;br /&gt;
|Similar to &#039;&#039;&#039;addr&#039;&#039;&#039; attribute of zone objects&lt;br /&gt;
|Packet&#039;s source address matches the value&lt;br /&gt;
|-&lt;br /&gt;
|&#039;&#039;&#039;dest&#039;&#039;&#039;&lt;br /&gt;
|Similar to &#039;&#039;&#039;addr&#039;&#039;&#039; attribute of zone objects&lt;br /&gt;
|Packet&#039;s destination address matches the value&lt;br /&gt;
|-&lt;br /&gt;
|&#039;&#039;&#039;ipset&#039;&#039;&#039;&lt;br /&gt;
|Object containing two attributes: &#039;&#039;&#039;name&#039;&#039;&#039; referring to an IP set and &#039;&#039;&#039;args&#039;&#039;&#039;, which is a list of strings &#039;&#039;&#039;in&#039;&#039;&#039; and &#039;&#039;&#039;out&#039;&#039;&#039;&lt;br /&gt;
|Packet matches the IP set referred here when the match arguments are taken from the source (&#039;&#039;&#039;in&#039;&#039;&#039;) and destination (&#039;&#039;&#039;out&#039;&#039;&#039;) address or port in the order specified by &#039;&#039;&#039;args&#039;&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
|&#039;&#039;&#039;ipsec&#039;&#039;&#039;&lt;br /&gt;
|&#039;&#039;&#039;in&#039;&#039;&#039; or &#039;&#039;&#039;out&#039;&#039;&#039;&lt;br /&gt;
|IPsec decapsulation perfomed on ingress (&#039;&#039;&#039;in&#039;&#039;&#039;) or encapsulation performed on egress (&#039;&#039;&#039;out&#039;&#039;&#039;)&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Rule objects are declared in type-specific top-level dictionaries in&lt;br /&gt;
awall policy files. If a packet matches multiple rules, the one&lt;br /&gt;
appearing earlier in the list takes precedence. If the matching rules&lt;br /&gt;
are defined in different policy files, the one that was processed&lt;br /&gt;
earlier takes precedence in the current implementation, but this may&lt;br /&gt;
change in future versions.&lt;br /&gt;
&lt;br /&gt;
==== Filter Rules ====&lt;br /&gt;
&lt;br /&gt;
Filter objects specify an action for packets fulfilling certain&lt;br /&gt;
criteria. The top-level attribute &#039;&#039;&#039;filter&#039;&#039;&#039; is a list of filter&lt;br /&gt;
objects. The precedence rules are similar to those of policy objects.&lt;br /&gt;
&lt;br /&gt;
Filter objects must have an attribute named &#039;&#039;&#039;action&#039;&#039;&#039;, the value of&lt;br /&gt;
which can be one of the following:&lt;br /&gt;
&lt;br /&gt;
{|&lt;br /&gt;
!Value!!Action&lt;br /&gt;
|-&lt;br /&gt;
|&#039;&#039;&#039;accept&#039;&#039;&#039;&lt;br /&gt;
|Accept the packet&lt;br /&gt;
|-&lt;br /&gt;
|&#039;&#039;&#039;reject&#039;&#039;&#039;&lt;br /&gt;
|Reject the packet with an ICMP error message&lt;br /&gt;
|-&lt;br /&gt;
|&#039;&#039;&#039;drop&#039;&#039;&#039;&lt;br /&gt;
|Silently drop the packet&lt;br /&gt;
|-&lt;br /&gt;
|&#039;&#039;&#039;tarpit&#039;&#039;&#039;&lt;br /&gt;
|Put incoming TCP connections into persist state and ignore attempts to close them. Silently drop non-TCP packets. (Connection tracking bypass is automatically enabled for the matching packets.)&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Filter objects, the action of which is &#039;&#039;&#039;accept&#039;&#039;&#039;, may also contain&lt;br /&gt;
limits for packet flow or new connections. These are specified with&lt;br /&gt;
the &#039;&#039;&#039;flow-limit&#039;&#039;&#039; and &#039;&#039;&#039;conn-limit&#039;&#039;&#039; attributes,&lt;br /&gt;
respectively. The values of these attributes are limit objects that&lt;br /&gt;
have two attributes: &#039;&#039;&#039;count&#039;&#039;&#039; and &#039;&#039;&#039;interval&#039;&#039;&#039;. &#039;&#039;&#039;count&#039;&#039;&#039;&lt;br /&gt;
specifies how many new connections or packets are allowed within the&lt;br /&gt;
time frame specified by &#039;&#039;&#039;interval&#039;&#039;&#039; in seconds (default: 1). The&lt;br /&gt;
&#039;&#039;&#039;drop&#039;&#039;&#039; action is applied to the packets exceeding the&lt;br /&gt;
limit. Optionally, the limit object may have an attribute named&lt;br /&gt;
&#039;&#039;&#039;log&#039;&#039;&#039;. It defines how the dropped packets should be logged and is&lt;br /&gt;
semantically similar to the &#039;&#039;&#039;log&#039;&#039;&#039; attribute of rule objects. A&lt;br /&gt;
limit may also be specified by a plain integer, which is interpreted&lt;br /&gt;
as the count while using default interval and log settings.&lt;br /&gt;
&lt;br /&gt;
Filter objects may have an attribute named &#039;&#039;&#039;dnat&#039;&#039;&#039;, the value of&lt;br /&gt;
which is an IPv4 address. If defined, this enables destination NAT for&lt;br /&gt;
all IPv4 packets matching the rule, such that the specified address&lt;br /&gt;
replaces the original destination address. This option has no effect&lt;br /&gt;
on IPv6 packets.&lt;br /&gt;
&lt;br /&gt;
Filter objects may have a boolean attribute named &#039;&#039;&#039;no-track&#039;&#039;&#039;. If&lt;br /&gt;
set to &#039;&#039;&#039;true&#039;&#039;&#039;, connection tracking is bypassed for the matching&lt;br /&gt;
packets. In addition, if &#039;&#039;&#039;action&#039;&#039;&#039; is set to &#039;&#039;&#039;accept&#039;&#039;&#039;, the&lt;br /&gt;
corresponding packets travelling to the reverse direction are also&lt;br /&gt;
allowed.&lt;br /&gt;
&lt;br /&gt;
If one or more connection tracking helpers are associated with the&lt;br /&gt;
services referred to by an accept rule, additional iptables rules are&lt;br /&gt;
generated for the related connections detected by the helpers. The&lt;br /&gt;
&#039;&#039;&#039;related&#039;&#039;&#039; attribute can be used to override the default rules&lt;br /&gt;
generated by awall. It is a list of basic rule objects, the packets&lt;br /&gt;
matching to which are accepted, provided that they are also detected&lt;br /&gt;
by at least one of the helpers.&lt;br /&gt;
&lt;br /&gt;
==== Policy Rules ====&lt;br /&gt;
&lt;br /&gt;
Policy objects describe the default action for packets that did not&lt;br /&gt;
match any filter. The top-level attribute &#039;&#039;&#039;policy&#039;&#039;&#039; is a list of&lt;br /&gt;
policy objects.&lt;br /&gt;
&lt;br /&gt;
Policy objects must have the &#039;&#039;&#039;action&#039;&#039;&#039; attribute defined. The&lt;br /&gt;
possible values and their semantics are the same as in filter objects.&lt;br /&gt;
&lt;br /&gt;
==== Packet Logging Rules ====&lt;br /&gt;
&lt;br /&gt;
Packet logging rules allow packets matching the specified criteria to&lt;br /&gt;
be logged before any filtering takes place. Such rules are contained&lt;br /&gt;
in the top-level list named &#039;&#039;&#039;packet-log&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Logging class may be specified using the &#039;&#039;&#039;log&#039;&#039;&#039;&lt;br /&gt;
attribute. Otherwise, default logging settings are used.&lt;br /&gt;
&lt;br /&gt;
==== NAT Rules ====&lt;br /&gt;
&lt;br /&gt;
NAT rules come in two flavors: &#039;&#039;source NAT rules&#039;&#039; and&lt;br /&gt;
&#039;&#039;destination NAT rules&#039;&#039;. These are contained in two top-level lists&lt;br /&gt;
named &#039;&#039;&#039;snat&#039;&#039;&#039; and &#039;&#039;&#039;dnat&#039;&#039;&#039;, respectively.&lt;br /&gt;
&lt;br /&gt;
Each NAT rule may have an attribute named &#039;&#039;&#039;to-addr&#039;&#039;&#039; that&lt;br /&gt;
specifies the IPv4 address range to which the original source or&lt;br /&gt;
destination address is mapped. The value can be a single IPv4 address&lt;br /&gt;
or a range specified by two addresses, separated with the &#039;&#039;&#039;-&#039;&#039;&#039;&lt;br /&gt;
character. If not defined, it defaults to the primary address of the&lt;br /&gt;
ingress interface in case of destination NAT, or that of the egress&lt;br /&gt;
interface in case of source NAT.&lt;br /&gt;
&lt;br /&gt;
Optionally, a NAT rule can specify the TCP and UDP port range to which&lt;br /&gt;
the original source or destination port is mapped. The attribute is&lt;br /&gt;
named &#039;&#039;&#039;to-port&#039;&#039;&#039;, and the value can be a single port number or a&lt;br /&gt;
range specified by two numbers, separated with the &#039;&#039;&#039;-&#039;&#039;&#039;&lt;br /&gt;
character. If &#039;&#039;&#039;to-port&#039;&#039;&#039; is not specified, the original port number&lt;br /&gt;
is kept intact.&lt;br /&gt;
&lt;br /&gt;
NAT rules may have an &#039;&#039;&#039;action&#039;&#039;&#039; attribute set to value&lt;br /&gt;
&#039;&#039;&#039;accept&#039;&#039;&#039;. In this case, NAT is not performed on the packets&lt;br /&gt;
reaching and matching this rule.&lt;br /&gt;
&lt;br /&gt;
==== Packet Marking Rules ====&lt;br /&gt;
&lt;br /&gt;
Packet marking rules are used to mark incoming packets matching the&lt;br /&gt;
specified criteria. The mark can be used as a basis for the routing&lt;br /&gt;
decision. Each marking rule must specify the mark using the &#039;&#039;&#039;mark&#039;&#039;&#039;&lt;br /&gt;
attribute, which is a 32-bit integer.&lt;br /&gt;
&lt;br /&gt;
Normal marking rules are contained by the top-level list attribute&lt;br /&gt;
named &#039;&#039;&#039;mark&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
There is another top-level list attribute, named &#039;&#039;&#039;route-track&#039;&#039;&#039;,&lt;br /&gt;
which contains route tracking rules. These are special marking rules&lt;br /&gt;
which cause all the subsequent packets related to the same connection&lt;br /&gt;
to be marked according to the rule.&lt;br /&gt;
&lt;br /&gt;
==== Transparent Proxy Rules ====&lt;br /&gt;
&lt;br /&gt;
Transparent proxy rules divert the matching packets to a local proxy&lt;br /&gt;
process without altering their headers. Such rules are contained in&lt;br /&gt;
the top-level list named &#039;&#039;&#039;tproxy&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
In addition to the firewall configuration, using a transparent proxy&lt;br /&gt;
requires a routing configuration where packets marked for proxying are&lt;br /&gt;
diverted to a local process. The &#039;&#039;&#039;awall_tproxy_mark&#039;&#039;&#039; variable can&lt;br /&gt;
be used to specify the mark for such packets, which defaults to 1.&lt;br /&gt;
&lt;br /&gt;
Proxy rules may also have an attribute named &#039;&#039;&#039;to-port&#039;&#039;&#039; for&lt;br /&gt;
specifying the TCP or UDP port of the proxy if it is different from&lt;br /&gt;
the original destination port.&lt;br /&gt;
&lt;br /&gt;
==== MSS Clamping Rules ====&lt;br /&gt;
&lt;br /&gt;
MSS Clamping Rules are used to deal with ISPs that block ICMP&lt;br /&gt;
Fragmentation Needed or ICMPv6 Packet Too Big packets. An MSS clamping&lt;br /&gt;
rule overwrites the MSS option with a value specified with the&lt;br /&gt;
&#039;&#039;&#039;mss&#039;&#039;&#039; attribute for the matching TCP connections. If &#039;&#039;&#039;mss&#039;&#039;&#039; is&lt;br /&gt;
not specified, a suitable value is automatically determined from the&lt;br /&gt;
path MTU. The MSS clamping rules are located in the top-level&lt;br /&gt;
dictionary named &#039;&#039;&#039;clamp-mss&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
==== Connection Tracking Bypass Rules ====&lt;br /&gt;
&lt;br /&gt;
Connection tracking bypass rules are used to disable connection&lt;br /&gt;
tracking for packets matching the specified criteria. The top-level&lt;br /&gt;
attribute &#039;&#039;&#039;no-track&#039;&#039;&#039; is a list of such rules.&lt;br /&gt;
&lt;br /&gt;
Connection tracking bypass rules may have an &#039;&#039;&#039;action&#039;&#039;&#039; attribute&lt;br /&gt;
set to value &#039;&#039;&#039;accept&#039;&#039;&#039;. The effect is similar to corresponding NAT&lt;br /&gt;
rules, i.e. connection tracking is not bypassed for the matching&lt;br /&gt;
packets.&lt;br /&gt;
&lt;br /&gt;
=== IP Sets ===&lt;br /&gt;
&lt;br /&gt;
Any IP set referenced by rule objects should be created by&lt;br /&gt;
awall. Auxiliary &#039;&#039;IP set&#039;&#039; objects are used to defined them in awall&lt;br /&gt;
policy files. The top-level attribute &#039;&#039;&#039;ipset&#039;&#039;&#039; is a dictionary, the&lt;br /&gt;
keys of which are IP set names. The values are IP set objects, which&lt;br /&gt;
have two mandatory attributes. The attribute named &#039;&#039;&#039;type&#039;&#039;&#039; &lt;br /&gt;
corresponds to the type argument of the &amp;lt;tt&amp;gt;ipset create&amp;lt;/tt&amp;gt; &lt;br /&gt;
command. &#039;&#039;&#039;family&#039;&#039;&#039; specifies whether the set is for IPv4 or IPv6&lt;br /&gt;
addresses, and the possible values are &#039;&#039;&#039;inet&#039;&#039;&#039; and &#039;&#039;&#039;inet6&#039;&#039;&#039;,&lt;br /&gt;
correspondingly.&lt;br /&gt;
&lt;br /&gt;
For bitmap-type IP sets, the &#039;&#039;&#039;range&#039;&#039;&#039; attribute specifies the&lt;br /&gt;
range of allowed IPv4 addresses. It may be given as a network&lt;br /&gt;
address or two addresses separated by the &#039;&#039;&#039;-&#039;&#039;&#039; character. It&lt;br /&gt;
is not necessary to specify &#039;&#039;&#039;family&#039;&#039;&#039; for bitmaps, since the&lt;br /&gt;
kernel supports only IPv4 bitmaps.&lt;br /&gt;
&lt;br /&gt;
== Command Line Syntax ==&lt;br /&gt;
&lt;br /&gt;
=== Translating Policy Files to Firewall Configuration Files ===&lt;br /&gt;
&lt;br /&gt;
 &#039;&#039;&#039;awall translate&#039;&#039;&#039; [&#039;&#039;&#039;-o&#039;&#039;&#039;|&#039;&#039;&#039;--output&#039;&#039;&#039; DIRECTORY] [&#039;&#039;&#039;-V&#039;&#039;&#039;|&#039;&#039;&#039;--verify&#039;&#039;&#039;]&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;tt&amp;gt;--verify&amp;lt;/tt&amp;gt; option makes awall verify the configuration&lt;br /&gt;
using the test mode of iptables-restore before overwriting the old&lt;br /&gt;
files.&lt;br /&gt;
&lt;br /&gt;
Specifying the output directory allows testing awall policies without&lt;br /&gt;
overwriting the current iptables and ipset configuration files. By&lt;br /&gt;
default, awall generates the configuration to &amp;lt;tt&amp;gt;/etc/iptables&amp;lt;/tt&amp;gt; &lt;br /&gt;
and &amp;lt;tt&amp;gt;/etc/ipset.d&amp;lt;/tt&amp;gt;, which are read by the init scripts.&lt;br /&gt;
&lt;br /&gt;
=== Run-Time Configuration of Firewall ===&lt;br /&gt;
&lt;br /&gt;
 &#039;&#039;&#039;awall activate&#039;&#039;&#039; [&#039;&#039;&#039;-f&#039;&#039;&#039;|&#039;&#039;&#039;--force&#039;&#039;&#039;]&lt;br /&gt;
&lt;br /&gt;
This command genereates firewall configuration from the policy files&lt;br /&gt;
and enables it. If the user confirms the new configuration by hitting&lt;br /&gt;
the Return key within 10 seconds or the &amp;lt;tt&amp;gt;--force&amp;lt;/tt&amp;gt; option is&lt;br /&gt;
used, the configuration is saved to the files. Otherwise, the old&lt;br /&gt;
configuration is restored.&lt;br /&gt;
&lt;br /&gt;
There is also a command for deleting all firewall rules:&lt;br /&gt;
&lt;br /&gt;
 &#039;&#039;&#039;awall flush&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
This command configures the firewall to drop all packets.&lt;br /&gt;
&lt;br /&gt;
=== Optional Policies ===&lt;br /&gt;
&lt;br /&gt;
Optional policies can be enabled or disabled using this command:&lt;br /&gt;
&lt;br /&gt;
 &#039;&#039;&#039;awall&#039;&#039;&#039; {&#039;&#039;&#039;enable&#039;&#039;&#039;|&#039;&#039;&#039;disable&#039;&#039;&#039;} POLICY...&lt;br /&gt;
&lt;br /&gt;
Optional policies can be listed using this command:&lt;br /&gt;
&lt;br /&gt;
 &#039;&#039;&#039;awall list&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;&#039;enabled&#039;&#039;&#039; status means that the policy has been enabled by the&lt;br /&gt;
user. The &#039;&#039;&#039;disabled&#039;&#039;&#039; status means that the policy is not in&lt;br /&gt;
use. The &#039;&#039;&#039;required&#039;&#039;&#039; status means that the policy has not been&lt;br /&gt;
enabled by the user but is in use because it is required by another&lt;br /&gt;
policy which is in use.&lt;br /&gt;
&lt;br /&gt;
=== Debugging Policies ===&lt;br /&gt;
&lt;br /&gt;
This command can be used to dump variable, zone, and other definitions&lt;br /&gt;
as well as their source policies:&lt;br /&gt;
&lt;br /&gt;
 &#039;&#039;&#039;awall dump&#039;&#039;&#039; [LEVEL]&lt;br /&gt;
&lt;br /&gt;
The level is an integer in range 0&amp;amp;ndash;5 and defaults to 0. More&lt;br /&gt;
information is displayed on higher levels.&lt;br /&gt;
&lt;br /&gt;
[[Category:Networking]]&lt;br /&gt;
[[Category:Security]]&lt;/div&gt;</summary>
		<author><name>Kunkku</name></author>
	</entry>
	<entry>
		<id>https://wiki.alpinelinux.org/w/index.php?title=Alpine_Wall_User%27s_Guide&amp;diff=9392</id>
		<title>Alpine Wall User&#039;s Guide</title>
		<link rel="alternate" type="text/html" href="https://wiki.alpinelinux.org/w/index.php?title=Alpine_Wall_User%27s_Guide&amp;diff=9392"/>
		<updated>2013-10-07T19:25:24Z</updated>

		<summary type="html">&lt;p&gt;Kunkku: /* Services */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Configuration File Processing ==&lt;br /&gt;
&lt;br /&gt;
[[Alpine Wall]] (awall) reads its configuration from multiple&lt;br /&gt;
JSON-formatted files, called &#039;&#039;policy files&#039;&#039;. The files located in&lt;br /&gt;
directory &amp;lt;tt&amp;gt;/usr/share/awall/mandatory&amp;lt;/tt&amp;gt; are &#039;&#039;mandatory&#039;&#039;&lt;br /&gt;
policies shipped with APK packages. In addition, there can be&lt;br /&gt;
installation-specific mandatory policies in &amp;lt;tt&amp;gt;/etc/awall&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
The latter directory may also contain symbolic links to policy files&lt;br /&gt;
located in &amp;lt;tt&amp;gt;/usr/share/awall/optional&amp;lt;/tt&amp;gt; and&lt;br /&gt;
&amp;lt;tt&amp;gt;/etc/awall/optional&amp;lt;/tt&amp;gt;. These are &#039;&#039;optional&#039;&#039; policies, which&lt;br /&gt;
can be enabled on need basis. Such symbolic links are easily created&lt;br /&gt;
and destroyed using the &amp;lt;tt&amp;gt;awall enable&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;awall&lt;br /&gt;
disable&amp;lt;/tt&amp;gt; commands. &amp;lt;tt&amp;gt;awall list&amp;lt;/tt&amp;gt; shows which optional&lt;br /&gt;
policies are enabled and disabled. The command also prints the&lt;br /&gt;
description of the optional policy if defined in the file using a&lt;br /&gt;
top-level attribute named &#039;&#039;&#039;description&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Sometimes a policy file depends on other policy files. In this case,&lt;br /&gt;
the policy file must have a top-level attribute &#039;&#039;&#039;import&#039;&#039;&#039;, the&lt;br /&gt;
value of which is a list of policy names, which correspond to the file&lt;br /&gt;
names without the &amp;lt;tt&amp;gt;.json&amp;lt;/tt&amp;gt; suffix. The imported policies may be&lt;br /&gt;
either optional policies or &#039;&#039;private&#039;&#039; policies, located in&lt;br /&gt;
&amp;lt;tt&amp;gt;/usr/share/awall/private&amp;lt;/tt&amp;gt; or &amp;lt;tt&amp;gt;/etc/awall/private&amp;lt;/tt&amp;gt;. By&lt;br /&gt;
default, the policies listed there are processed before the importing&lt;br /&gt;
policy.&lt;br /&gt;
&lt;br /&gt;
The order of the generated iptables rules generally reflects the&lt;br /&gt;
processing order of their corresponding awall policies. The processing&lt;br /&gt;
order of policies can be adjusted by defining top-level attributes&lt;br /&gt;
&#039;&#039;&#039;after&#039;&#039;&#039; and &#039;&#039;&#039;before&#039;&#039;&#039; in policy files. These attributes are&lt;br /&gt;
lists of policies, after or before which the declaring policy shall be&lt;br /&gt;
processed. Putting a policy name to either of these lists does not by&lt;br /&gt;
itself import the policy. The ordering directives are ignored with&lt;br /&gt;
respect to those policies that are not enabled by the user or imported&lt;br /&gt;
by other policies. If not defined, &#039;&#039;&#039;after&#039;&#039;&#039; is assumed to be equal&lt;br /&gt;
to the &#039;&#039;&#039;import&#039;&#039;&#039; definition of the policy.&lt;br /&gt;
&lt;br /&gt;
As the import directive does not require the path name to be&lt;br /&gt;
specified, awall expects policies to have unique names, even if&lt;br /&gt;
located in different directories. It is allowed to import optional&lt;br /&gt;
policies that are not explicitly enabled by the user. Such policies&lt;br /&gt;
show up with the &amp;lt;tt&amp;gt;required&amp;lt;/tt&amp;gt; status in the output of &amp;lt;tt&amp;gt;awall&lt;br /&gt;
list&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
== List Parameters ==&lt;br /&gt;
&lt;br /&gt;
Several awall parameters are defined as lists of values. In order to&lt;br /&gt;
facilitate manual editing of policy files, awall also accepts single&lt;br /&gt;
values in place of lists. Such values are semantically equivalent to&lt;br /&gt;
lists containing one element.&lt;br /&gt;
&lt;br /&gt;
== Variable Expansion ==&lt;br /&gt;
&lt;br /&gt;
Awall allows variable definitions in policy files. The top-level&lt;br /&gt;
attribute &#039;&#039;&#039;variable&#039;&#039;&#039; is a dictionary containing the&lt;br /&gt;
definitions. The value of a variable can be of any type (string,&lt;br /&gt;
integer, list, or dictionary).&lt;br /&gt;
&lt;br /&gt;
A variable is referenced in policy files by a string which equals the&lt;br /&gt;
variable name prepended with the &#039;&#039;&#039;$&#039;&#039;&#039; character. If the value of&lt;br /&gt;
the variable is a string, the reference can be embedded into a longer&lt;br /&gt;
string in order to substitute some part of that string (in shell&lt;br /&gt;
style). Variable references can be used when defining other variables,&lt;br /&gt;
as long as the definitions are not circular.&lt;br /&gt;
&lt;br /&gt;
Policy files can reference variables defined in other policy&lt;br /&gt;
files. Policy files can also override variables defined elsewhere by&lt;br /&gt;
redefining them. In this case, the new definition affects all policy&lt;br /&gt;
files, also those processed before the overriding policy. Awall&lt;br /&gt;
variables are in fact simple macros, since each variable remains&lt;br /&gt;
constant thoughout a single processing round. If multiple files define&lt;br /&gt;
the same variable, the definition in the file processed last takes&lt;br /&gt;
effect.&lt;br /&gt;
&lt;br /&gt;
If defined as an empty string, all non-embedded references to a&lt;br /&gt;
variable evaluate as if the attribute in question was not present in&lt;br /&gt;
the configuration. This is also the case when a string containing&lt;br /&gt;
embedded variable references finally evaluates to an empty string.&lt;br /&gt;
&lt;br /&gt;
== Configuration Objects ==&lt;br /&gt;
&lt;br /&gt;
Configuration objects can be divided into two main types.&lt;br /&gt;
&#039;&#039;Auxiliary objects&#039;&#039; model high-level concepts such as services and&lt;br /&gt;
zones. &#039;&#039;Rule objects&#039;&#039; translate into one or more iptables rules, and&lt;br /&gt;
are often defined with the help of some auxiliary objects.&lt;br /&gt;
&lt;br /&gt;
=== Services ===&lt;br /&gt;
&lt;br /&gt;
A &#039;&#039;service&#039;&#039; represents a set of network protocols. A top-level&lt;br /&gt;
attribute &#039;&#039;&#039;service&#039;&#039;&#039; is a dictionary that maps service names to&lt;br /&gt;
service definition objects, or lists thereof in more complex cases.&lt;br /&gt;
&lt;br /&gt;
A service definition object contains an attribute named &#039;&#039;&#039;proto&#039;&#039;&#039;,&lt;br /&gt;
which corresponds to the &amp;lt;tt&amp;gt;--protocol&amp;lt;/tt&amp;gt; option of iptables. The&lt;br /&gt;
protocol can be defined as a numerical value or string as defined in&lt;br /&gt;
&amp;lt;tt&amp;gt;/etc/protocols&amp;lt;/tt&amp;gt;. If the protocol is &#039;&#039;&#039;tcp&#039;&#039;&#039; or &#039;&#039;&#039;udp&#039;&#039;&#039;,&lt;br /&gt;
the scope of the service definition may be constrained by defining an&lt;br /&gt;
attribute named &#039;&#039;&#039;port&#039;&#039;&#039;, which is a list of TCP or UDP port numbers&lt;br /&gt;
or ranges thereof, separated by the &#039;&#039;&#039;-&#039;&#039;&#039; character. If the protocol&lt;br /&gt;
is &#039;&#039;&#039;icmp&#039;&#039;&#039; or &#039;&#039;&#039;icmpv6&#039;&#039;&#039;, an analogous &#039;&#039;&#039;type&#039;&#039;&#039; attribute&lt;br /&gt;
may be used. In addition, the scope of the rule is also automatically&lt;br /&gt;
limited to IPv4 or IPv6, respectively.&lt;br /&gt;
&lt;br /&gt;
Some services require the server or client to open additional&lt;br /&gt;
connections to dynamically allocated ports or even different&lt;br /&gt;
hosts. &#039;&#039;Connection tracking helpers&#039;&#039; are used to make the firewall&lt;br /&gt;
aware of such additional connections. The &#039;&#039;&#039;ct-helper&#039;&#039;&#039; attribute is&lt;br /&gt;
used to associate such a helper to a service definition when&lt;br /&gt;
required by the service.&lt;br /&gt;
&lt;br /&gt;
All rule objects, except for policies, may have an attribute named&lt;br /&gt;
&#039;&#039;&#039;service&#039;&#039;&#039;, constraining the rule&#039;s scope to specific services&lt;br /&gt;
only. This attribute is a list of service names, referring to the keys&lt;br /&gt;
of the top-level service dictionary.&lt;br /&gt;
&lt;br /&gt;
=== Zones ===&lt;br /&gt;
&lt;br /&gt;
A &#039;&#039;zone&#039;&#039; represents a set of network hosts. A top-level attribute &lt;br /&gt;
&#039;&#039;&#039;zone&#039;&#039;&#039; is a dictionary that maps zone names to zone objects. A&lt;br /&gt;
zone object has an attribute named &#039;&#039;&#039;iface&#039;&#039;&#039;, &#039;&#039;&#039;addr&#039;&#039;&#039;, or&lt;br /&gt;
both. &#039;&#039;&#039;iface&#039;&#039;&#039; is a list of network interfaces and &#039;&#039;&#039;addr&#039;&#039;&#039; is a&lt;br /&gt;
list of IPv4/IPv6 host and network addresses (CIDR&lt;br /&gt;
notation). &#039;&#039;&#039;addr&#039;&#039;&#039; may also contain domain names, which are&lt;br /&gt;
expanded to IP addresses using DNS resolution. If not defined,&lt;br /&gt;
&#039;&#039;&#039;addr&#039;&#039;&#039; defaults to the entire address space and &#039;&#039;&#039;iface&#039;&#039;&#039; to all&lt;br /&gt;
interfaces. An empty zone can be defined by setting either &#039;&#039;&#039;addr&#039;&#039;&#039;&lt;br /&gt;
or &#039;&#039;&#039;iface&#039;&#039;&#039; to an empty list.&lt;br /&gt;
&lt;br /&gt;
Rule objects contain two attributes, &#039;&#039;&#039;in&#039;&#039;&#039; and &#039;&#039;&#039;out&#039;&#039;&#039;, which are&lt;br /&gt;
lists of zone names. These attributes control whether a packet matches&lt;br /&gt;
the rule or not. If a particular zone is referenced by the &#039;&#039;&#039;in&#039;&#039;&#039; &lt;br /&gt;
attribute, the rule applies to packets whose ingress interface and&lt;br /&gt;
source address are covered by the zone definition. Correspondingly, if&lt;br /&gt;
a zone is referenced by the &#039;&#039;&#039;out&#039;&#039;&#039; attribute, the rule applies to&lt;br /&gt;
packets whose egress interface and destination address are included in&lt;br /&gt;
the zone. If both &#039;&#039;&#039;in&#039;&#039;&#039; and &#039;&#039;&#039;out&#039;&#039;&#039; are defined, the packet must&lt;br /&gt;
fulfill both criteria in order to match the rule.&lt;br /&gt;
&lt;br /&gt;
The firewall host itself can be referred to using the special value&lt;br /&gt;
&#039;&#039;&#039;_fw&#039;&#039;&#039; as the zone name.&lt;br /&gt;
&lt;br /&gt;
By default, awall does not generate iptables rules with identical&lt;br /&gt;
ingress and egress interfaces. This behavior can be changed per zone&lt;br /&gt;
by setting the optional &#039;&#039;&#039;route-back&#039;&#039;&#039; attribute of the zone to&lt;br /&gt;
&#039;&#039;&#039;true&#039;&#039;&#039;. Note that this attribute can have an effect also in the&lt;br /&gt;
case where &#039;&#039;&#039;in&#039;&#039;&#039; and &#039;&#039;&#039;out&#039;&#039;&#039; attributes of a rule are not equal&lt;br /&gt;
but their definitions overlap. In this case, the &#039;&#039;&#039;route-back&#039;&#039;&#039;&lt;br /&gt;
attribute of the &#039;&#039;&#039;out&#039;&#039;&#039; zone determines the behavior.&lt;br /&gt;
&lt;br /&gt;
=== Logging Classes ===&lt;br /&gt;
&lt;br /&gt;
A &#039;&#039;logging class&#039;&#039; specifies how packets matching certain rules are&lt;br /&gt;
logged. A top-level attribute &#039;&#039;&#039;log&#039;&#039;&#039; is a dictionary that maps&lt;br /&gt;
logging class names to setting objects.&lt;br /&gt;
&lt;br /&gt;
A setting object may have an attribute named &#039;&#039;&#039;mode&#039;&#039;&#039;, which&lt;br /&gt;
specifies which logging facility to use. Allowed values are &#039;&#039;&#039;log&#039;&#039;&#039;,&lt;br /&gt;
&#039;&#039;&#039;nflog&#039;&#039;&#039;, and &#039;&#039;&#039;ulog&#039;&#039;&#039;. The default is &#039;&#039;&#039;log&#039;&#039;&#039;, i.e. in-kernel&lt;br /&gt;
logging.&lt;br /&gt;
&lt;br /&gt;
The following table shows the optional attributes valid for all&lt;br /&gt;
logging modes:&lt;br /&gt;
&lt;br /&gt;
{|&lt;br /&gt;
!Attribute!!Description&lt;br /&gt;
|-&lt;br /&gt;
|&#039;&#039;&#039;every&#039;&#039;&#039;&lt;br /&gt;
|Divide successive packets into groups, the size of which is specified by the value of this attribute, and log only the first packet of each group&lt;br /&gt;
|-&lt;br /&gt;
|&#039;&#039;&#039;limit&#039;&#039;&#039;&lt;br /&gt;
|Maximum number of packets to be logged per second per this rule&lt;br /&gt;
|-&lt;br /&gt;
|&#039;&#039;&#039;prefix&#039;&#039;&#039;&lt;br /&gt;
|String with which the log entries are prefixed&lt;br /&gt;
|-&lt;br /&gt;
|&#039;&#039;&#039;probability&#039;&#039;&#039;&lt;br /&gt;
|Probability for logging an individual packet (default: 1)&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
With the in-kernel log mode &#039;&#039;&#039;log&#039;&#039;&#039;, the level of logging may be&lt;br /&gt;
specified using the &#039;&#039;&#039;level&#039;&#039;&#039; attribute. Log modes &#039;&#039;&#039;nflog&#039;&#039;&#039; and&lt;br /&gt;
&#039;&#039;&#039;ulog&#039;&#039;&#039; are about copying the packets into user space, at least&lt;br /&gt;
partially. The following table shows the additional attributes valid&lt;br /&gt;
with these modes:&lt;br /&gt;
&lt;br /&gt;
{|&lt;br /&gt;
!Attribute!!Description&lt;br /&gt;
|-&lt;br /&gt;
|&#039;&#039;&#039;group&#039;&#039;&#039;&lt;br /&gt;
|Netlink group to be used&lt;br /&gt;
|-&lt;br /&gt;
|&#039;&#039;&#039;range&#039;&#039;&#039;&lt;br /&gt;
|Number of bytes to be copied&lt;br /&gt;
|-&lt;br /&gt;
|&#039;&#039;&#039;threshold&#039;&#039;&#039;&lt;br /&gt;
|Number of packets to queue inside the kernel before copying them&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Filter and policy rules can have an attribute named &#039;&#039;&#039;log&#039;&#039;&#039;. If it&lt;br /&gt;
is a string, it is interpreted as a reference to a logging class, and&lt;br /&gt;
logging is performed according to the definitions. If the value of the&lt;br /&gt;
&#039;&#039;&#039;log&#039;&#039;&#039; attribute is &#039;&#039;&#039;true&#039;&#039;&#039; (boolean), logging is done using&lt;br /&gt;
default settings. If the value is &#039;&#039;&#039;false&#039;&#039;&#039; (boolean), logging is&lt;br /&gt;
disabled for the rule. If &#039;&#039;&#039;log&#039;&#039;&#039; is not defined, logging is done&lt;br /&gt;
using the default settings except for accept rules, for which logging&lt;br /&gt;
is omitted.&lt;br /&gt;
&lt;br /&gt;
Default logging settings can be set by defining a logging class named&lt;br /&gt;
&#039;&#039;&#039;_default&#039;&#039;&#039;. Normally, default logging uses the &#039;&#039;&#039;log&#039;&#039;&#039; mode with&lt;br /&gt;
packets limited to one per second.&lt;br /&gt;
&lt;br /&gt;
=== Rules ===&lt;br /&gt;
&lt;br /&gt;
There are several types of rule objects:&lt;br /&gt;
* Filter rules&lt;br /&gt;
* Policy rules&lt;br /&gt;
* Packet Logging rules&lt;br /&gt;
* NAT rules&lt;br /&gt;
* Packet Marking rules&lt;br /&gt;
* Transparent Proxy rules&lt;br /&gt;
* MSS Clamping rules&lt;br /&gt;
* Connection Tracking Bypass rules&lt;br /&gt;
&lt;br /&gt;
All rule objects can have the &#039;&#039;&#039;in&#039;&#039;&#039; and &#039;&#039;&#039;out&#039;&#039;&#039; attributes&lt;br /&gt;
referring to zones as described in the previous section. In addition,&lt;br /&gt;
the scope of the rule can be further constrained with the following&lt;br /&gt;
attributes:&lt;br /&gt;
&lt;br /&gt;
{|&lt;br /&gt;
!Attribute!!Value format!!Effect&lt;br /&gt;
|-&lt;br /&gt;
|&#039;&#039;&#039;src&#039;&#039;&#039;&lt;br /&gt;
|Similar to &#039;&#039;&#039;addr&#039;&#039;&#039; attribute of zone objects&lt;br /&gt;
|Packet&#039;s source address matches the value&lt;br /&gt;
|-&lt;br /&gt;
|&#039;&#039;&#039;dest&#039;&#039;&#039;&lt;br /&gt;
|Similar to &#039;&#039;&#039;addr&#039;&#039;&#039; attribute of zone objects&lt;br /&gt;
|Packet&#039;s destination address matches the value&lt;br /&gt;
|-&lt;br /&gt;
|&#039;&#039;&#039;ipset&#039;&#039;&#039;&lt;br /&gt;
|Object containing two attributes: &#039;&#039;&#039;name&#039;&#039;&#039; referring to an IP set and &#039;&#039;&#039;args&#039;&#039;&#039;, which is a list of strings &#039;&#039;&#039;in&#039;&#039;&#039; and &#039;&#039;&#039;out&#039;&#039;&#039;&lt;br /&gt;
|Packet matches the IP set referred here when the match arguments are taken from the source (&#039;&#039;&#039;in&#039;&#039;&#039;) and destination (&#039;&#039;&#039;out&#039;&#039;&#039;) address or port in the order specified by &#039;&#039;&#039;args&#039;&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
|&#039;&#039;&#039;ipsec&#039;&#039;&#039;&lt;br /&gt;
|&#039;&#039;&#039;in&#039;&#039;&#039; or &#039;&#039;&#039;out&#039;&#039;&#039;&lt;br /&gt;
|IPsec decapsulation perfomed on ingress (&#039;&#039;&#039;in&#039;&#039;&#039;) or encapsulation performed on egress (&#039;&#039;&#039;out&#039;&#039;&#039;)&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Rule objects are declared in type-specific top-level dictionaries in&lt;br /&gt;
awall policy files. If a packet matches multiple rules, the one&lt;br /&gt;
appearing earlier in the list takes precedence. If the matching rules&lt;br /&gt;
are defined in different policy files, the one that was processed&lt;br /&gt;
earlier takes precedence in the current implementation, but this may&lt;br /&gt;
change in future versions.&lt;br /&gt;
&lt;br /&gt;
==== Filter Rules ====&lt;br /&gt;
&lt;br /&gt;
Filter objects specify an action for packets fulfilling certain&lt;br /&gt;
criteria. The top-level attribute &#039;&#039;&#039;filter&#039;&#039;&#039; is a list of filter&lt;br /&gt;
objects. The precedence rules are similar to those of policy objects.&lt;br /&gt;
&lt;br /&gt;
Filter objects must have an attribute named &#039;&#039;&#039;action&#039;&#039;&#039;, the value of&lt;br /&gt;
which can be one of the following:&lt;br /&gt;
&lt;br /&gt;
{|&lt;br /&gt;
!Value!!Action&lt;br /&gt;
|-&lt;br /&gt;
|&#039;&#039;&#039;accept&#039;&#039;&#039;&lt;br /&gt;
|Accept the packet&lt;br /&gt;
|-&lt;br /&gt;
|&#039;&#039;&#039;reject&#039;&#039;&#039;&lt;br /&gt;
|Reject the packet with an ICMP error message&lt;br /&gt;
|-&lt;br /&gt;
|&#039;&#039;&#039;drop&#039;&#039;&#039;&lt;br /&gt;
|Silently drop the packet&lt;br /&gt;
|-&lt;br /&gt;
|&#039;&#039;&#039;tarpit&#039;&#039;&#039;&lt;br /&gt;
|Put incoming TCP connections into persist state and ignore attempts to close them. Silently drop non-TCP packets. (Connection tracking bypass is automatically enabled for the matching packets.)&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Filter objects, the action of which is &#039;&#039;&#039;accept&#039;&#039;&#039;, may also contain&lt;br /&gt;
limits for packet flow or new connections. These are specified with&lt;br /&gt;
the &#039;&#039;&#039;flow-limit&#039;&#039;&#039; and &#039;&#039;&#039;conn-limit&#039;&#039;&#039; attributes,&lt;br /&gt;
respectively. The values of these attributes are limit objects that&lt;br /&gt;
have two attributes: &#039;&#039;&#039;count&#039;&#039;&#039; and &#039;&#039;&#039;interval&#039;&#039;&#039;. &#039;&#039;&#039;count&#039;&#039;&#039;&lt;br /&gt;
specifies how many new connections or packets are allowed within the&lt;br /&gt;
time frame specified by &#039;&#039;&#039;interval&#039;&#039;&#039; in seconds (default: 1). The&lt;br /&gt;
&#039;&#039;&#039;drop&#039;&#039;&#039; action is applied to the packets exceeding the&lt;br /&gt;
limit. Optionally, the limit object may have an attribute named&lt;br /&gt;
&#039;&#039;&#039;log&#039;&#039;&#039;. It defines how the dropped packets should be logged and is&lt;br /&gt;
semantically similar to the &#039;&#039;&#039;log&#039;&#039;&#039; attribute of rule objects. A&lt;br /&gt;
limit may also be specified by a plain integer, which is interpreted&lt;br /&gt;
as the count while using default interval and log settings.&lt;br /&gt;
&lt;br /&gt;
Filter objects may have an attribute named &#039;&#039;&#039;dnat&#039;&#039;&#039;, the value of&lt;br /&gt;
which is an IPv4 address. If defined, this enables destination NAT for&lt;br /&gt;
all IPv4 packets matching the rule, such that the specified address&lt;br /&gt;
replaces the original destination address. This option has no effect&lt;br /&gt;
on IPv6 packets.&lt;br /&gt;
&lt;br /&gt;
Filter objects may have a boolean attribute named &#039;&#039;&#039;no-track&#039;&#039;&#039;. If&lt;br /&gt;
set to &#039;&#039;&#039;true&#039;&#039;&#039;, connection tracking is bypassed for the matching&lt;br /&gt;
packets. In addition, if &#039;&#039;&#039;action&#039;&#039;&#039; is set to &#039;&#039;&#039;accept&#039;&#039;&#039;, the&lt;br /&gt;
corresponding packets travelling to the reverse direction are also&lt;br /&gt;
allowed.&lt;br /&gt;
&lt;br /&gt;
If one or more connection tracking helpers are associated with the&lt;br /&gt;
services referred to by an accept rule, additional iptables rules are&lt;br /&gt;
generated for the related connections detected by the helpers. The&lt;br /&gt;
&#039;&#039;&#039;related&#039;&#039;&#039; attribute can be used to override the default rules&lt;br /&gt;
generated by awall. It is a list of basic rule objects, the packets&lt;br /&gt;
matching to which are accepted, provided that they are also detected&lt;br /&gt;
by at least one of the helpers.&lt;br /&gt;
&lt;br /&gt;
==== Policy Rules ====&lt;br /&gt;
&lt;br /&gt;
Policy objects describe the default action for packets that did not&lt;br /&gt;
match any filter. The top-level attribute &#039;&#039;&#039;policy&#039;&#039;&#039; is a list of&lt;br /&gt;
policy objects.&lt;br /&gt;
&lt;br /&gt;
Policy objects must have the &#039;&#039;&#039;action&#039;&#039;&#039; attribute defined. The&lt;br /&gt;
possible values and their semantics are the same as in filter objects.&lt;br /&gt;
&lt;br /&gt;
==== Packet Logging Rules ====&lt;br /&gt;
&lt;br /&gt;
Packet logging rules allow packets matching the specified criteria to&lt;br /&gt;
be logged before any filtering takes place. Such rules are contained&lt;br /&gt;
in the top-level list named &#039;&#039;&#039;packet-log&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Logging class may be specified using the &#039;&#039;&#039;log&#039;&#039;&#039;&lt;br /&gt;
attribute. Otherwise, default logging settings are used.&lt;br /&gt;
&lt;br /&gt;
==== NAT Rules ====&lt;br /&gt;
&lt;br /&gt;
NAT rules come in two flavors: &#039;&#039;source NAT rules&#039;&#039; and&lt;br /&gt;
&#039;&#039;destination NAT rules&#039;&#039;. These are contained in two top-level lists&lt;br /&gt;
named &#039;&#039;&#039;snat&#039;&#039;&#039; and &#039;&#039;&#039;dnat&#039;&#039;&#039;, respectively.&lt;br /&gt;
&lt;br /&gt;
Each NAT rule may have an attribute named &#039;&#039;&#039;to-addr&#039;&#039;&#039; that&lt;br /&gt;
specifies the IPv4 address range to which the original source or&lt;br /&gt;
destination address is mapped. The value can be a single IPv4 address&lt;br /&gt;
or a range specified by two addresses, separated with the &#039;&#039;&#039;-&#039;&#039;&#039;&lt;br /&gt;
character. If not defined, it defaults to the primary address of the&lt;br /&gt;
ingress interface in case of destination NAT, or that of the egress&lt;br /&gt;
interface in case of source NAT.&lt;br /&gt;
&lt;br /&gt;
Optionally, a NAT rule can specify the TCP and UDP port range to which&lt;br /&gt;
the original source or destination port is mapped. The attribute is&lt;br /&gt;
named &#039;&#039;&#039;to-port&#039;&#039;&#039;, and the value can be a single port number or a&lt;br /&gt;
range specified by two numbers, separated with the &#039;&#039;&#039;-&#039;&#039;&#039;&lt;br /&gt;
character. If &#039;&#039;&#039;to-port&#039;&#039;&#039; is not specified, the original port number&lt;br /&gt;
is kept intact.&lt;br /&gt;
&lt;br /&gt;
NAT rules may have an &#039;&#039;&#039;action&#039;&#039;&#039; attribute set to value&lt;br /&gt;
&#039;&#039;&#039;accept&#039;&#039;&#039;. In this case, NAT is not performed on the packets&lt;br /&gt;
reaching and matching this rule.&lt;br /&gt;
&lt;br /&gt;
==== Packet Marking Rules ====&lt;br /&gt;
&lt;br /&gt;
Packet marking rules are used to mark incoming packets matching the&lt;br /&gt;
specified criteria. The mark can be used as a basis for the routing&lt;br /&gt;
decision. Each marking rule must specify the mark using the &#039;&#039;&#039;mark&#039;&#039;&#039;&lt;br /&gt;
attribute, which is a 32-bit integer.&lt;br /&gt;
&lt;br /&gt;
Normal marking rules are contained by the top-level list attribute&lt;br /&gt;
named &#039;&#039;&#039;mark&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
There is another top-level list attribute, named &#039;&#039;&#039;route-track&#039;&#039;&#039;,&lt;br /&gt;
which contains route tracking rules. These are special marking rules&lt;br /&gt;
which cause all the subsequent packets related to the same connection&lt;br /&gt;
to be marked according to the rule.&lt;br /&gt;
&lt;br /&gt;
==== Transparent Proxy Rules ====&lt;br /&gt;
&lt;br /&gt;
Transparent proxy rules divert the matching packets to a local proxy&lt;br /&gt;
process without altering their headers. Such rules are contained in&lt;br /&gt;
the top-level list named &#039;&#039;&#039;tproxy&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
In addition to the firewall configuration, using a transparent proxy&lt;br /&gt;
requires a routing configuration where packets marked for proxying are&lt;br /&gt;
diverted to a local process. The &#039;&#039;&#039;awall_tproxy_mark&#039;&#039;&#039; variable can&lt;br /&gt;
be used to specify the mark for such packets, which defaults to 1.&lt;br /&gt;
&lt;br /&gt;
Proxy rules may also have an attribute named &#039;&#039;&#039;to-port&#039;&#039;&#039; for&lt;br /&gt;
specifying the TCP or UDP port of the proxy if it is different from&lt;br /&gt;
the original destination port.&lt;br /&gt;
&lt;br /&gt;
==== MSS Clamping Rules ====&lt;br /&gt;
&lt;br /&gt;
MSS Clamping Rules are used to deal with ISPs that block ICMP&lt;br /&gt;
Fragmentation Needed or ICMPv6 Packet Too Big packets. An MSS clamping&lt;br /&gt;
rule overwrites the MSS option with a value specified with the&lt;br /&gt;
&#039;&#039;&#039;mss&#039;&#039;&#039; attribute for the matching TCP connections. If &#039;&#039;&#039;mss&#039;&#039;&#039; is&lt;br /&gt;
not specified, a suitable value is automatically determined from the&lt;br /&gt;
path MTU. The MSS clamping rules are located in the top-level&lt;br /&gt;
dictionary named &#039;&#039;&#039;clamp-mss&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
==== Connection Tracking Bypass Rules ====&lt;br /&gt;
&lt;br /&gt;
Connection tracking bypass rules are used to disable connection&lt;br /&gt;
tracking for packets matching the specified criteria. The top-level&lt;br /&gt;
attribute &#039;&#039;&#039;no-track&#039;&#039;&#039; is a list of such rules.&lt;br /&gt;
&lt;br /&gt;
Connection tracking bypass rules may have an &#039;&#039;&#039;action&#039;&#039;&#039; attribute&lt;br /&gt;
set to value &#039;&#039;&#039;accept&#039;&#039;&#039;. The effect is similar to corresponding NAT&lt;br /&gt;
rules, i.e. connection tracking is not bypassed for the matching&lt;br /&gt;
packets.&lt;br /&gt;
&lt;br /&gt;
=== IP Sets ===&lt;br /&gt;
&lt;br /&gt;
Any IP set referenced by rule objects should be created by&lt;br /&gt;
awall. Auxiliary &#039;&#039;IP set&#039;&#039; objects are used to defined them in awall&lt;br /&gt;
policy files. The top-level attribute &#039;&#039;&#039;ipset&#039;&#039;&#039; is a dictionary, the&lt;br /&gt;
keys of which are IP set names. The values are IP set objects, which&lt;br /&gt;
have two mandatory attributes. The attribute named &#039;&#039;&#039;type&#039;&#039;&#039; &lt;br /&gt;
corresponds to the type argument of the &amp;lt;tt&amp;gt;ipset create&amp;lt;/tt&amp;gt; &lt;br /&gt;
command. &#039;&#039;&#039;family&#039;&#039;&#039; specifies whether the set is for IPv4 or IPv6&lt;br /&gt;
addresses, and the possible values are &#039;&#039;&#039;inet&#039;&#039;&#039; and &#039;&#039;&#039;inet6&#039;&#039;&#039;,&lt;br /&gt;
correspondingly.&lt;br /&gt;
&lt;br /&gt;
For bitmap-type IP sets, the &#039;&#039;&#039;range&#039;&#039;&#039; attribute specifies the&lt;br /&gt;
range of allowed IPv4 addresses. It may be given as a network&lt;br /&gt;
address or two addresses separated by the &#039;&#039;&#039;-&#039;&#039;&#039; character. It&lt;br /&gt;
is not necessary to specify &#039;&#039;&#039;family&#039;&#039;&#039; for bitmaps, since the&lt;br /&gt;
kernel supports only IPv4 bitmaps.&lt;br /&gt;
&lt;br /&gt;
== Command Line Syntax ==&lt;br /&gt;
&lt;br /&gt;
=== Translating Policy Files to Firewall Configuration Files ===&lt;br /&gt;
&lt;br /&gt;
 &#039;&#039;&#039;awall translate&#039;&#039;&#039; [&#039;&#039;&#039;-o&#039;&#039;&#039;|&#039;&#039;&#039;--output&#039;&#039;&#039; DIRECTORY] [&#039;&#039;&#039;-V&#039;&#039;&#039;|&#039;&#039;&#039;--verify&#039;&#039;&#039;]&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;tt&amp;gt;--verify&amp;lt;/tt&amp;gt; option makes awall verify the configuration&lt;br /&gt;
using the test mode of iptables-restore before overwriting the old&lt;br /&gt;
files.&lt;br /&gt;
&lt;br /&gt;
Specifying the output directory allows testing awall policies without&lt;br /&gt;
overwriting the current iptables and ipset configuration files. By&lt;br /&gt;
default, awall generates the configuration to &amp;lt;tt&amp;gt;/etc/iptables&amp;lt;/tt&amp;gt; &lt;br /&gt;
and &amp;lt;tt&amp;gt;/etc/ipset.d&amp;lt;/tt&amp;gt;, which are read by the init scripts.&lt;br /&gt;
&lt;br /&gt;
=== Run-Time Configuration of Firewall ===&lt;br /&gt;
&lt;br /&gt;
 &#039;&#039;&#039;awall activate&#039;&#039;&#039; [&#039;&#039;&#039;-f&#039;&#039;&#039;|&#039;&#039;&#039;--force&#039;&#039;&#039;]&lt;br /&gt;
&lt;br /&gt;
This command genereates firewall configuration from the policy files&lt;br /&gt;
and enables it. If the user confirms the new configuration by hitting&lt;br /&gt;
the Return key within 10 seconds or the &amp;lt;tt&amp;gt;--force&amp;lt;/tt&amp;gt; option is&lt;br /&gt;
used, the configuration is saved to the files. Otherwise, the old&lt;br /&gt;
configuration is restored.&lt;br /&gt;
&lt;br /&gt;
There is also a command for deleting all firewall rules:&lt;br /&gt;
&lt;br /&gt;
 &#039;&#039;&#039;awall flush&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
This command configures the firewall to drop all packets.&lt;br /&gt;
&lt;br /&gt;
=== Optional Policies ===&lt;br /&gt;
&lt;br /&gt;
Optional policies can be enabled or disabled using this command:&lt;br /&gt;
&lt;br /&gt;
 &#039;&#039;&#039;awall&#039;&#039;&#039; {&#039;&#039;&#039;enable&#039;&#039;&#039;|&#039;&#039;&#039;disable&#039;&#039;&#039;} POLICY...&lt;br /&gt;
&lt;br /&gt;
Optional policies can be listed using this command:&lt;br /&gt;
&lt;br /&gt;
 &#039;&#039;&#039;awall list&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;&#039;enabled&#039;&#039;&#039; status means that the policy has been enabled by the&lt;br /&gt;
user. The &#039;&#039;&#039;disabled&#039;&#039;&#039; status means that the policy is not in&lt;br /&gt;
use. The &#039;&#039;&#039;required&#039;&#039;&#039; status means that the policy has not been&lt;br /&gt;
enabled by the user but is in use because it is required by another&lt;br /&gt;
policy which is in use.&lt;br /&gt;
&lt;br /&gt;
=== Debugging Policies ===&lt;br /&gt;
&lt;br /&gt;
This command can be used to dump variable, zone, and other definitions&lt;br /&gt;
as well as their source policies:&lt;br /&gt;
&lt;br /&gt;
 &#039;&#039;&#039;awall dump&#039;&#039;&#039; [LEVEL]&lt;br /&gt;
&lt;br /&gt;
The level is an integer in range 0&amp;amp;ndash;5 and defaults to 0. More&lt;br /&gt;
information is displayed on higher levels.&lt;br /&gt;
&lt;br /&gt;
[[Category:Networking]]&lt;br /&gt;
[[Category:Security]]&lt;/div&gt;</summary>
		<author><name>Kunkku</name></author>
	</entry>
	<entry>
		<id>https://wiki.alpinelinux.org/w/index.php?title=Alpine_Wall_User%27s_Guide&amp;diff=9033</id>
		<title>Alpine Wall User&#039;s Guide</title>
		<link rel="alternate" type="text/html" href="https://wiki.alpinelinux.org/w/index.php?title=Alpine_Wall_User%27s_Guide&amp;diff=9033"/>
		<updated>2013-02-19T11:21:46Z</updated>

		<summary type="html">&lt;p&gt;Kunkku: /* Configuration Objects */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Configuration File Processing ==&lt;br /&gt;
&lt;br /&gt;
[[Alpine Wall]] (awall) reads its configuration from multiple&lt;br /&gt;
JSON-formatted files, called &#039;&#039;policy files&#039;&#039;. The files located in&lt;br /&gt;
directory &amp;lt;tt&amp;gt;/usr/share/awall/mandatory&amp;lt;/tt&amp;gt; are &#039;&#039;mandatory&#039;&#039;&lt;br /&gt;
policies shipped with APK packages. In addition, there can be&lt;br /&gt;
installation-specific mandatory policies in &amp;lt;tt&amp;gt;/etc/awall&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
The latter directory may also contain symbolic links to policy files&lt;br /&gt;
located in &amp;lt;tt&amp;gt;/usr/share/awall/optional&amp;lt;/tt&amp;gt; and&lt;br /&gt;
&amp;lt;tt&amp;gt;/etc/awall/optional&amp;lt;/tt&amp;gt;. These are &#039;&#039;optional&#039;&#039; policies, which&lt;br /&gt;
can be enabled on need basis. Such symbolic links are easily created&lt;br /&gt;
and destroyed using the &amp;lt;tt&amp;gt;awall enable&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;awall&lt;br /&gt;
disable&amp;lt;/tt&amp;gt; commands. &amp;lt;tt&amp;gt;awall list&amp;lt;/tt&amp;gt; shows which optional&lt;br /&gt;
policies are enabled and disabled. The command also prints the&lt;br /&gt;
description of the optional policy if defined in the file using a&lt;br /&gt;
top-level attribute named &#039;&#039;&#039;description&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Sometimes a policy file depends on other policy files. In this case,&lt;br /&gt;
the policy file must have a top-level attribute &#039;&#039;&#039;import&#039;&#039;&#039;, the&lt;br /&gt;
value of which is a list of policy names, which correspond to the file&lt;br /&gt;
names without the &amp;lt;tt&amp;gt;.json&amp;lt;/tt&amp;gt; suffix. The imported policies may be&lt;br /&gt;
either optional policies or &#039;&#039;private&#039;&#039; policies, located in&lt;br /&gt;
&amp;lt;tt&amp;gt;/usr/share/awall/private&amp;lt;/tt&amp;gt; or &amp;lt;tt&amp;gt;/etc/awall/private&amp;lt;/tt&amp;gt;. By&lt;br /&gt;
default, the policies listed there are processed before the importing&lt;br /&gt;
policy.&lt;br /&gt;
&lt;br /&gt;
The order of the generated iptables rules generally reflects the&lt;br /&gt;
processing order of their corresponding awall policies. The processing&lt;br /&gt;
order of policies can be adjusted by defining top-level attributes&lt;br /&gt;
&#039;&#039;&#039;after&#039;&#039;&#039; and &#039;&#039;&#039;before&#039;&#039;&#039; in policy files. These attributes are&lt;br /&gt;
lists of policies, after or before which the declaring policy shall be&lt;br /&gt;
processed. Putting a policy name to either of these lists does not by&lt;br /&gt;
itself import the policy. The ordering directives are ignored with&lt;br /&gt;
respect to those policies that are not enabled by the user or imported&lt;br /&gt;
by other policies. If not defined, &#039;&#039;&#039;after&#039;&#039;&#039; is assumed to be equal&lt;br /&gt;
to the &#039;&#039;&#039;import&#039;&#039;&#039; definition of the policy.&lt;br /&gt;
&lt;br /&gt;
As the import directive does not require the path name to be&lt;br /&gt;
specified, awall expects policies to have unique names, even if&lt;br /&gt;
located in different directories. It is allowed to import optional&lt;br /&gt;
policies that are not explicitly enabled by the user. Such policies&lt;br /&gt;
show up with the &amp;lt;tt&amp;gt;required&amp;lt;/tt&amp;gt; status in the output of &amp;lt;tt&amp;gt;awall&lt;br /&gt;
list&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
== List Parameters ==&lt;br /&gt;
&lt;br /&gt;
Several awall parameters are defined as lists of values. In order to&lt;br /&gt;
facilitate manual editing of policy files, awall also accepts single&lt;br /&gt;
values in place of lists. Such values are semantically equivalent to&lt;br /&gt;
lists containing one element.&lt;br /&gt;
&lt;br /&gt;
== Variable Expansion ==&lt;br /&gt;
&lt;br /&gt;
Awall allows variable definitions in policy files. The top-level&lt;br /&gt;
attribute &#039;&#039;&#039;variable&#039;&#039;&#039; is a dictionary containing the&lt;br /&gt;
definitions. The value of a variable can be of any type (string,&lt;br /&gt;
integer, list, or dictionary).&lt;br /&gt;
&lt;br /&gt;
A variable is referenced in policy files by a string which equals the&lt;br /&gt;
variable name prepended with the &#039;&#039;&#039;$&#039;&#039;&#039; character. If the value of&lt;br /&gt;
the variable is a string, the reference can be embedded into a longer&lt;br /&gt;
string in order to substitute some part of that string (in shell&lt;br /&gt;
style). Variable references can be used when defining other variables,&lt;br /&gt;
as long as the definitions are not circular.&lt;br /&gt;
&lt;br /&gt;
Policy files can reference variables defined in other policy&lt;br /&gt;
files. Policy files can also override variables defined elsewhere by&lt;br /&gt;
redefining them. In this case, the new definition affects all policy&lt;br /&gt;
files, also those processed before the overriding policy. Awall&lt;br /&gt;
variables are in fact simple macros, since each variable remains&lt;br /&gt;
constant thoughout a single processing round. If multiple files define&lt;br /&gt;
the same variable, the definition in the file processed last takes&lt;br /&gt;
effect.&lt;br /&gt;
&lt;br /&gt;
If defined as an empty string, all non-embedded references to a&lt;br /&gt;
variable evaluate as if the attribute in question was not present in&lt;br /&gt;
the configuration. This is also the case when a string containing&lt;br /&gt;
embedded variable references finally evaluates to an empty string.&lt;br /&gt;
&lt;br /&gt;
== Configuration Objects ==&lt;br /&gt;
&lt;br /&gt;
Configuration objects can be divided into two main types.&lt;br /&gt;
&#039;&#039;Auxiliary objects&#039;&#039; model high-level concepts such as services and&lt;br /&gt;
zones. &#039;&#039;Rule objects&#039;&#039; translate into one or more iptables rules, and&lt;br /&gt;
are often defined with the help of some auxiliary objects.&lt;br /&gt;
&lt;br /&gt;
=== Services ===&lt;br /&gt;
&lt;br /&gt;
A &#039;&#039;service&#039;&#039; represents a set of network protocols. A top-level&lt;br /&gt;
attribute &#039;&#039;&#039;service&#039;&#039;&#039; is a dictionary that maps service names to&lt;br /&gt;
service definition objects, or lists thereof in more complex cases.&lt;br /&gt;
&lt;br /&gt;
A service definition object contains an attribute named &#039;&#039;&#039;proto&#039;&#039;&#039;,&lt;br /&gt;
which corresponds to the &amp;lt;tt&amp;gt;--protocol&amp;lt;/tt&amp;gt; option of iptables. The&lt;br /&gt;
protocol can be defined as a numerical value or string as defined in&lt;br /&gt;
&amp;lt;tt&amp;gt;/etc/protocols&amp;lt;/tt&amp;gt;. If the protocol is &#039;&#039;&#039;tcp&#039;&#039;&#039; or &#039;&#039;&#039;udp&#039;&#039;&#039;,&lt;br /&gt;
the scope of the service definition may be constrained by defining an&lt;br /&gt;
attribute named &#039;&#039;&#039;port&#039;&#039;&#039;, which is a list of TCP or UDP port numbers&lt;br /&gt;
or ranges thereof, separated by the &#039;&#039;&#039;-&#039;&#039;&#039; character. If the protocol&lt;br /&gt;
is &#039;&#039;&#039;icmp&#039;&#039;&#039; or &#039;&#039;&#039;icmpv6&#039;&#039;&#039;, an analogous &#039;&#039;&#039;icmp-type&#039;&#039;&#039; attribute&lt;br /&gt;
may be used. In addition, the scope of the rule is also automatically&lt;br /&gt;
limited to IPv4 or IPv6, respectively.&lt;br /&gt;
&lt;br /&gt;
Some services require the server or client to open additional&lt;br /&gt;
connections to dynamically allocated ports or even different&lt;br /&gt;
hosts. &#039;&#039;Connection tracking helpers&#039;&#039; are used to make the firewall&lt;br /&gt;
aware of such additional connections. The &#039;&#039;&#039;ct-helper&#039;&#039;&#039; attribute is&lt;br /&gt;
used to associate such a helper to a service definition when&lt;br /&gt;
required by the service.&lt;br /&gt;
&lt;br /&gt;
All rule objects, except for policies, may have an attribute named&lt;br /&gt;
&#039;&#039;&#039;service&#039;&#039;&#039;, constraining the rule&#039;s scope to specific services&lt;br /&gt;
only. This attribute is a list of service names, referring to the keys&lt;br /&gt;
of the top-level service dictionary.&lt;br /&gt;
&lt;br /&gt;
=== Zones ===&lt;br /&gt;
&lt;br /&gt;
A &#039;&#039;zone&#039;&#039; represents a set of network hosts. A top-level attribute &lt;br /&gt;
&#039;&#039;&#039;zone&#039;&#039;&#039; is a dictionary that maps zone names to zone objects. A&lt;br /&gt;
zone object has an attribute named &#039;&#039;&#039;iface&#039;&#039;&#039;, &#039;&#039;&#039;addr&#039;&#039;&#039;, or&lt;br /&gt;
both. &#039;&#039;&#039;iface&#039;&#039;&#039; is a list of network interfaces and &#039;&#039;&#039;addr&#039;&#039;&#039; is a&lt;br /&gt;
list of IPv4/IPv6 host and network addresses (CIDR&lt;br /&gt;
notation). &#039;&#039;&#039;addr&#039;&#039;&#039; may also contain domain names, which are&lt;br /&gt;
expanded to IP addresses using DNS resolution. If not defined,&lt;br /&gt;
&#039;&#039;&#039;addr&#039;&#039;&#039; defaults to the entire address space and &#039;&#039;&#039;iface&#039;&#039;&#039; to all&lt;br /&gt;
interfaces. An empty zone can be defined by setting either &#039;&#039;&#039;addr&#039;&#039;&#039;&lt;br /&gt;
or &#039;&#039;&#039;iface&#039;&#039;&#039; to an empty list.&lt;br /&gt;
&lt;br /&gt;
Rule objects contain two attributes, &#039;&#039;&#039;in&#039;&#039;&#039; and &#039;&#039;&#039;out&#039;&#039;&#039;, which are&lt;br /&gt;
lists of zone names. These attributes control whether a packet matches&lt;br /&gt;
the rule or not. If a particular zone is referenced by the &#039;&#039;&#039;in&#039;&#039;&#039; &lt;br /&gt;
attribute, the rule applies to packets whose ingress interface and&lt;br /&gt;
source address are covered by the zone definition. Correspondingly, if&lt;br /&gt;
a zone is referenced by the &#039;&#039;&#039;out&#039;&#039;&#039; attribute, the rule applies to&lt;br /&gt;
packets whose egress interface and destination address are included in&lt;br /&gt;
the zone. If both &#039;&#039;&#039;in&#039;&#039;&#039; and &#039;&#039;&#039;out&#039;&#039;&#039; are defined, the packet must&lt;br /&gt;
fulfill both criteria in order to match the rule.&lt;br /&gt;
&lt;br /&gt;
The firewall host itself can be referred to using the special value&lt;br /&gt;
&#039;&#039;&#039;_fw&#039;&#039;&#039; as the zone name.&lt;br /&gt;
&lt;br /&gt;
By default, awall does not generate iptables rules with identical&lt;br /&gt;
ingress and egress interfaces. This behavior can be changed per zone&lt;br /&gt;
by setting the optional &#039;&#039;&#039;route-back&#039;&#039;&#039; attribute of the zone to&lt;br /&gt;
&#039;&#039;&#039;true&#039;&#039;&#039;. Note that this attribute can have an effect also in the&lt;br /&gt;
case where &#039;&#039;&#039;in&#039;&#039;&#039; and &#039;&#039;&#039;out&#039;&#039;&#039; attributes of a rule are not equal&lt;br /&gt;
but their definitions overlap. In this case, the &#039;&#039;&#039;route-back&#039;&#039;&#039;&lt;br /&gt;
attribute of the &#039;&#039;&#039;out&#039;&#039;&#039; zone determines the behavior.&lt;br /&gt;
&lt;br /&gt;
=== Logging Classes ===&lt;br /&gt;
&lt;br /&gt;
A &#039;&#039;logging class&#039;&#039; specifies how packets matching certain rules are&lt;br /&gt;
logged. A top-level attribute &#039;&#039;&#039;log&#039;&#039;&#039; is a dictionary that maps&lt;br /&gt;
logging class names to setting objects.&lt;br /&gt;
&lt;br /&gt;
A setting object may have an attribute named &#039;&#039;&#039;mode&#039;&#039;&#039;, which&lt;br /&gt;
specifies which logging facility to use. Allowed values are &#039;&#039;&#039;log&#039;&#039;&#039;,&lt;br /&gt;
&#039;&#039;&#039;nflog&#039;&#039;&#039;, and &#039;&#039;&#039;ulog&#039;&#039;&#039;. The default is &#039;&#039;&#039;log&#039;&#039;&#039;, i.e. in-kernel&lt;br /&gt;
logging.&lt;br /&gt;
&lt;br /&gt;
The following table shows the optional attributes valid for all&lt;br /&gt;
logging modes:&lt;br /&gt;
&lt;br /&gt;
{|&lt;br /&gt;
!Attribute!!Description&lt;br /&gt;
|-&lt;br /&gt;
|&#039;&#039;&#039;every&#039;&#039;&#039;&lt;br /&gt;
|Divide successive packets into groups, the size of which is specified by the value of this attribute, and log only the first packet of each group&lt;br /&gt;
|-&lt;br /&gt;
|&#039;&#039;&#039;limit&#039;&#039;&#039;&lt;br /&gt;
|Maximum number of packets to be logged per second per this rule&lt;br /&gt;
|-&lt;br /&gt;
|&#039;&#039;&#039;prefix&#039;&#039;&#039;&lt;br /&gt;
|String with which the log entries are prefixed&lt;br /&gt;
|-&lt;br /&gt;
|&#039;&#039;&#039;probability&#039;&#039;&#039;&lt;br /&gt;
|Probability for logging an individual packet (default: 1)&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
With the in-kernel log mode &#039;&#039;&#039;log&#039;&#039;&#039;, the level of logging may be&lt;br /&gt;
specified using the &#039;&#039;&#039;level&#039;&#039;&#039; attribute. Log modes &#039;&#039;&#039;nflog&#039;&#039;&#039; and&lt;br /&gt;
&#039;&#039;&#039;ulog&#039;&#039;&#039; are about copying the packets into user space, at least&lt;br /&gt;
partially. The following table shows the additional attributes valid&lt;br /&gt;
with these modes:&lt;br /&gt;
&lt;br /&gt;
{|&lt;br /&gt;
!Attribute!!Description&lt;br /&gt;
|-&lt;br /&gt;
|&#039;&#039;&#039;group&#039;&#039;&#039;&lt;br /&gt;
|Netlink group to be used&lt;br /&gt;
|-&lt;br /&gt;
|&#039;&#039;&#039;range&#039;&#039;&#039;&lt;br /&gt;
|Number of bytes to be copied&lt;br /&gt;
|-&lt;br /&gt;
|&#039;&#039;&#039;threshold&#039;&#039;&#039;&lt;br /&gt;
|Number of packets to queue inside the kernel before copying them&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Filter and policy rules can have an attribute named &#039;&#039;&#039;log&#039;&#039;&#039;. If it&lt;br /&gt;
is a string, it is interpreted as a reference to a logging class, and&lt;br /&gt;
logging is performed according to the definitions. If the value of the&lt;br /&gt;
&#039;&#039;&#039;log&#039;&#039;&#039; attribute is &#039;&#039;&#039;true&#039;&#039;&#039; (boolean), logging is done using&lt;br /&gt;
default settings. If the value is &#039;&#039;&#039;false&#039;&#039;&#039; (boolean), logging is&lt;br /&gt;
disabled for the rule. If &#039;&#039;&#039;log&#039;&#039;&#039; is not defined, logging is done&lt;br /&gt;
using the default settings except for accept rules, for which logging&lt;br /&gt;
is omitted.&lt;br /&gt;
&lt;br /&gt;
Default logging settings can be set by defining a logging class named&lt;br /&gt;
&#039;&#039;&#039;_default&#039;&#039;&#039;. Normally, default logging uses the &#039;&#039;&#039;log&#039;&#039;&#039; mode with&lt;br /&gt;
packets limited to one per second.&lt;br /&gt;
&lt;br /&gt;
=== Rules ===&lt;br /&gt;
&lt;br /&gt;
There are several types of rule objects:&lt;br /&gt;
* Filter rules&lt;br /&gt;
* Policy rules&lt;br /&gt;
* Packet Logging rules&lt;br /&gt;
* NAT rules&lt;br /&gt;
* Packet Marking rules&lt;br /&gt;
* Transparent Proxy rules&lt;br /&gt;
* MSS Clamping rules&lt;br /&gt;
* Connection Tracking Bypass rules&lt;br /&gt;
&lt;br /&gt;
All rule objects can have the &#039;&#039;&#039;in&#039;&#039;&#039; and &#039;&#039;&#039;out&#039;&#039;&#039; attributes&lt;br /&gt;
referring to zones as described in the previous section. In addition,&lt;br /&gt;
the scope of the rule can be further constrained with the following&lt;br /&gt;
attributes:&lt;br /&gt;
&lt;br /&gt;
{|&lt;br /&gt;
!Attribute!!Value format!!Effect&lt;br /&gt;
|-&lt;br /&gt;
|&#039;&#039;&#039;src&#039;&#039;&#039;&lt;br /&gt;
|Similar to &#039;&#039;&#039;addr&#039;&#039;&#039; attribute of zone objects&lt;br /&gt;
|Packet&#039;s source address matches the value&lt;br /&gt;
|-&lt;br /&gt;
|&#039;&#039;&#039;dest&#039;&#039;&#039;&lt;br /&gt;
|Similar to &#039;&#039;&#039;addr&#039;&#039;&#039; attribute of zone objects&lt;br /&gt;
|Packet&#039;s destination address matches the value&lt;br /&gt;
|-&lt;br /&gt;
|&#039;&#039;&#039;ipset&#039;&#039;&#039;&lt;br /&gt;
|Object containing two attributes: &#039;&#039;&#039;name&#039;&#039;&#039; referring to an IP set and &#039;&#039;&#039;args&#039;&#039;&#039;, which is a list of strings &#039;&#039;&#039;in&#039;&#039;&#039; and &#039;&#039;&#039;out&#039;&#039;&#039;&lt;br /&gt;
|Packet matches the IP set referred here when the match arguments are taken from the source (&#039;&#039;&#039;in&#039;&#039;&#039;) and destination (&#039;&#039;&#039;out&#039;&#039;&#039;) address or port in the order specified by &#039;&#039;&#039;args&#039;&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
|&#039;&#039;&#039;ipsec&#039;&#039;&#039;&lt;br /&gt;
|&#039;&#039;&#039;in&#039;&#039;&#039; or &#039;&#039;&#039;out&#039;&#039;&#039;&lt;br /&gt;
|IPsec decapsulation perfomed on ingress (&#039;&#039;&#039;in&#039;&#039;&#039;) or encapsulation performed on egress (&#039;&#039;&#039;out&#039;&#039;&#039;)&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Rule objects are declared in type-specific top-level dictionaries in&lt;br /&gt;
awall policy files. If a packet matches multiple rules, the one&lt;br /&gt;
appearing earlier in the list takes precedence. If the matching rules&lt;br /&gt;
are defined in different policy files, the one that was processed&lt;br /&gt;
earlier takes precedence in the current implementation, but this may&lt;br /&gt;
change in future versions.&lt;br /&gt;
&lt;br /&gt;
==== Filter Rules ====&lt;br /&gt;
&lt;br /&gt;
Filter objects specify an action for packets fulfilling certain&lt;br /&gt;
criteria. The top-level attribute &#039;&#039;&#039;filter&#039;&#039;&#039; is a list of filter&lt;br /&gt;
objects. The precedence rules are similar to those of policy objects.&lt;br /&gt;
&lt;br /&gt;
Filter objects must have an attribute named &#039;&#039;&#039;action&#039;&#039;&#039;, the value of&lt;br /&gt;
which can be one of the following:&lt;br /&gt;
&lt;br /&gt;
{|&lt;br /&gt;
!Value!!Action&lt;br /&gt;
|-&lt;br /&gt;
|&#039;&#039;&#039;accept&#039;&#039;&#039;&lt;br /&gt;
|Accept the packet&lt;br /&gt;
|-&lt;br /&gt;
|&#039;&#039;&#039;reject&#039;&#039;&#039;&lt;br /&gt;
|Reject the packet with an ICMP error message&lt;br /&gt;
|-&lt;br /&gt;
|&#039;&#039;&#039;drop&#039;&#039;&#039;&lt;br /&gt;
|Silently drop the packet&lt;br /&gt;
|-&lt;br /&gt;
|&#039;&#039;&#039;tarpit&#039;&#039;&#039;&lt;br /&gt;
|Put incoming TCP connections into persist state and ignore attempts to close them. Silently drop non-TCP packets. (Connection tracking bypass is automatically enabled for the matching packets.)&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Filter objects, the action of which is &#039;&#039;&#039;accept&#039;&#039;&#039;, may also contain&lt;br /&gt;
limits for packet flow or new connections. These are specified with&lt;br /&gt;
the &#039;&#039;&#039;flow-limit&#039;&#039;&#039; and &#039;&#039;&#039;conn-limit&#039;&#039;&#039; attributes,&lt;br /&gt;
respectively. The values of these attributes are limit objects that&lt;br /&gt;
have two attributes: &#039;&#039;&#039;count&#039;&#039;&#039; and &#039;&#039;&#039;interval&#039;&#039;&#039;. &#039;&#039;&#039;count&#039;&#039;&#039;&lt;br /&gt;
specifies how many new connections or packets are allowed within the&lt;br /&gt;
time frame specified by &#039;&#039;&#039;interval&#039;&#039;&#039; in seconds (default: 1). The&lt;br /&gt;
&#039;&#039;&#039;drop&#039;&#039;&#039; action is applied to the packets exceeding the&lt;br /&gt;
limit. Optionally, the limit object may have an attribute named&lt;br /&gt;
&#039;&#039;&#039;log&#039;&#039;&#039;. It defines how the dropped packets should be logged and is&lt;br /&gt;
semantically similar to the &#039;&#039;&#039;log&#039;&#039;&#039; attribute of rule objects. A&lt;br /&gt;
limit may also be specified by a plain integer, which is interpreted&lt;br /&gt;
as the count while using default interval and log settings.&lt;br /&gt;
&lt;br /&gt;
Filter objects may have an attribute named &#039;&#039;&#039;dnat&#039;&#039;&#039;, the value of&lt;br /&gt;
which is an IPv4 address. If defined, this enables destination NAT for&lt;br /&gt;
all IPv4 packets matching the rule, such that the specified address&lt;br /&gt;
replaces the original destination address. This option has no effect&lt;br /&gt;
on IPv6 packets.&lt;br /&gt;
&lt;br /&gt;
Filter objects may have a boolean attribute named &#039;&#039;&#039;no-track&#039;&#039;&#039;. If&lt;br /&gt;
set to &#039;&#039;&#039;true&#039;&#039;&#039;, connection tracking is bypassed for the matching&lt;br /&gt;
packets. In addition, if &#039;&#039;&#039;action&#039;&#039;&#039; is set to &#039;&#039;&#039;accept&#039;&#039;&#039;, the&lt;br /&gt;
corresponding packets travelling to the reverse direction are also&lt;br /&gt;
allowed.&lt;br /&gt;
&lt;br /&gt;
If one or more connection tracking helpers are associated with the&lt;br /&gt;
services referred to by an accept rule, additional iptables rules are&lt;br /&gt;
generated for the related connections detected by the helpers. The&lt;br /&gt;
&#039;&#039;&#039;related&#039;&#039;&#039; attribute can be used to override the default rules&lt;br /&gt;
generated by awall. It is a list of basic rule objects, the packets&lt;br /&gt;
matching to which are accepted, provided that they are also detected&lt;br /&gt;
by at least one of the helpers.&lt;br /&gt;
&lt;br /&gt;
==== Policy Rules ====&lt;br /&gt;
&lt;br /&gt;
Policy objects describe the default action for packets that did not&lt;br /&gt;
match any filter. The top-level attribute &#039;&#039;&#039;policy&#039;&#039;&#039; is a list of&lt;br /&gt;
policy objects.&lt;br /&gt;
&lt;br /&gt;
Policy objects must have the &#039;&#039;&#039;action&#039;&#039;&#039; attribute defined. The&lt;br /&gt;
possible values and their semantics are the same as in filter objects.&lt;br /&gt;
&lt;br /&gt;
==== Packet Logging Rules ====&lt;br /&gt;
&lt;br /&gt;
Packet logging rules allow packets matching the specified criteria to&lt;br /&gt;
be logged before any filtering takes place. Such rules are contained&lt;br /&gt;
in the top-level list named &#039;&#039;&#039;packet-log&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Logging class may be specified using the &#039;&#039;&#039;log&#039;&#039;&#039;&lt;br /&gt;
attribute. Otherwise, default logging settings are used.&lt;br /&gt;
&lt;br /&gt;
==== NAT Rules ====&lt;br /&gt;
&lt;br /&gt;
NAT rules come in two flavors: &#039;&#039;source NAT rules&#039;&#039; and&lt;br /&gt;
&#039;&#039;destination NAT rules&#039;&#039;. These are contained in two top-level lists&lt;br /&gt;
named &#039;&#039;&#039;snat&#039;&#039;&#039; and &#039;&#039;&#039;dnat&#039;&#039;&#039;, respectively.&lt;br /&gt;
&lt;br /&gt;
Each NAT rule may have an attribute named &#039;&#039;&#039;to-addr&#039;&#039;&#039; that&lt;br /&gt;
specifies the IPv4 address range to which the original source or&lt;br /&gt;
destination address is mapped. The value can be a single IPv4 address&lt;br /&gt;
or a range specified by two addresses, separated with the &#039;&#039;&#039;-&#039;&#039;&#039;&lt;br /&gt;
character. If not defined, it defaults to the primary address of the&lt;br /&gt;
ingress interface in case of destination NAT, or that of the egress&lt;br /&gt;
interface in case of source NAT.&lt;br /&gt;
&lt;br /&gt;
Optionally, a NAT rule can specify the TCP and UDP port range to which&lt;br /&gt;
the original source or destination port is mapped. The attribute is&lt;br /&gt;
named &#039;&#039;&#039;to-port&#039;&#039;&#039;, and the value can be a single port number or a&lt;br /&gt;
range specified by two numbers, separated with the &#039;&#039;&#039;-&#039;&#039;&#039;&lt;br /&gt;
character. If &#039;&#039;&#039;to-port&#039;&#039;&#039; is not specified, the original port number&lt;br /&gt;
is kept intact.&lt;br /&gt;
&lt;br /&gt;
NAT rules may have an &#039;&#039;&#039;action&#039;&#039;&#039; attribute set to value&lt;br /&gt;
&#039;&#039;&#039;accept&#039;&#039;&#039;. In this case, NAT is not performed on the packets&lt;br /&gt;
reaching and matching this rule.&lt;br /&gt;
&lt;br /&gt;
==== Packet Marking Rules ====&lt;br /&gt;
&lt;br /&gt;
Packet marking rules are used to mark incoming packets matching the&lt;br /&gt;
specified criteria. The mark can be used as a basis for the routing&lt;br /&gt;
decision. Each marking rule must specify the mark using the &#039;&#039;&#039;mark&#039;&#039;&#039;&lt;br /&gt;
attribute, which is a 32-bit integer.&lt;br /&gt;
&lt;br /&gt;
Normal marking rules are contained by the top-level list attribute&lt;br /&gt;
named &#039;&#039;&#039;mark&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
There is another top-level list attribute, named &#039;&#039;&#039;route-track&#039;&#039;&#039;,&lt;br /&gt;
which contains route tracking rules. These are special marking rules&lt;br /&gt;
which cause all the subsequent packets related to the same connection&lt;br /&gt;
to be marked according to the rule.&lt;br /&gt;
&lt;br /&gt;
==== Transparent Proxy Rules ====&lt;br /&gt;
&lt;br /&gt;
Transparent proxy rules divert the matching packets to a local proxy&lt;br /&gt;
process without altering their headers. Such rules are contained in&lt;br /&gt;
the top-level list named &#039;&#039;&#039;tproxy&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
In addition to the firewall configuration, using a transparent proxy&lt;br /&gt;
requires a routing configuration where packets marked for proxying are&lt;br /&gt;
diverted to a local process. The &#039;&#039;&#039;awall_tproxy_mark&#039;&#039;&#039; variable can&lt;br /&gt;
be used to specify the mark for such packets, which defaults to 1.&lt;br /&gt;
&lt;br /&gt;
Proxy rules may also have an attribute named &#039;&#039;&#039;to-port&#039;&#039;&#039; for&lt;br /&gt;
specifying the TCP or UDP port of the proxy if it is different from&lt;br /&gt;
the original destination port.&lt;br /&gt;
&lt;br /&gt;
==== MSS Clamping Rules ====&lt;br /&gt;
&lt;br /&gt;
MSS Clamping Rules are used to deal with ISPs that block ICMP&lt;br /&gt;
Fragmentation Needed or ICMPv6 Packet Too Big packets. An MSS clamping&lt;br /&gt;
rule overwrites the MSS option with a value specified with the&lt;br /&gt;
&#039;&#039;&#039;mss&#039;&#039;&#039; attribute for the matching TCP connections. If &#039;&#039;&#039;mss&#039;&#039;&#039; is&lt;br /&gt;
not specified, a suitable value is automatically determined from the&lt;br /&gt;
path MTU. The MSS clamping rules are located in the top-level&lt;br /&gt;
dictionary named &#039;&#039;&#039;clamp-mss&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
==== Connection Tracking Bypass Rules ====&lt;br /&gt;
&lt;br /&gt;
Connection tracking bypass rules are used to disable connection&lt;br /&gt;
tracking for packets matching the specified criteria. The top-level&lt;br /&gt;
attribute &#039;&#039;&#039;no-track&#039;&#039;&#039; is a list of such rules.&lt;br /&gt;
&lt;br /&gt;
Connection tracking bypass rules may have an &#039;&#039;&#039;action&#039;&#039;&#039; attribute&lt;br /&gt;
set to value &#039;&#039;&#039;accept&#039;&#039;&#039;. The effect is similar to corresponding NAT&lt;br /&gt;
rules, i.e. connection tracking is not bypassed for the matching&lt;br /&gt;
packets.&lt;br /&gt;
&lt;br /&gt;
=== IP Sets ===&lt;br /&gt;
&lt;br /&gt;
Any IP set referenced by rule objects should be created by&lt;br /&gt;
awall. Auxiliary &#039;&#039;IP set&#039;&#039; objects are used to defined them in awall&lt;br /&gt;
policy files. The top-level attribute &#039;&#039;&#039;ipset&#039;&#039;&#039; is a dictionary, the&lt;br /&gt;
keys of which are IP set names. The values are IP set objects, which&lt;br /&gt;
have two mandatory attributes. The attribute named &#039;&#039;&#039;type&#039;&#039;&#039; &lt;br /&gt;
corresponds to the type argument of the &amp;lt;tt&amp;gt;ipset create&amp;lt;/tt&amp;gt; &lt;br /&gt;
command. &#039;&#039;&#039;family&#039;&#039;&#039; specifies whether the set is for IPv4 or IPv6&lt;br /&gt;
addresses, and the possible values are &#039;&#039;&#039;inet&#039;&#039;&#039; and &#039;&#039;&#039;inet6&#039;&#039;&#039;,&lt;br /&gt;
correspondingly.&lt;br /&gt;
&lt;br /&gt;
For bitmap-type IP sets, the &#039;&#039;&#039;range&#039;&#039;&#039; attribute specifies the&lt;br /&gt;
range of allowed IPv4 addresses. It may be given as a network&lt;br /&gt;
address or two addresses separated by the &#039;&#039;&#039;-&#039;&#039;&#039; character. It&lt;br /&gt;
is not necessary to specify &#039;&#039;&#039;family&#039;&#039;&#039; for bitmaps, since the&lt;br /&gt;
kernel supports only IPv4 bitmaps.&lt;br /&gt;
&lt;br /&gt;
== Command Line Syntax ==&lt;br /&gt;
&lt;br /&gt;
=== Translating Policy Files to Firewall Configuration Files ===&lt;br /&gt;
&lt;br /&gt;
 &#039;&#039;&#039;awall translate&#039;&#039;&#039; [&#039;&#039;&#039;-o&#039;&#039;&#039;|&#039;&#039;&#039;--output&#039;&#039;&#039; DIRECTORY] [&#039;&#039;&#039;-V&#039;&#039;&#039;|&#039;&#039;&#039;--verify&#039;&#039;&#039;]&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;tt&amp;gt;--verify&amp;lt;/tt&amp;gt; option makes awall verify the configuration&lt;br /&gt;
using the test mode of iptables-restore before overwriting the old&lt;br /&gt;
files.&lt;br /&gt;
&lt;br /&gt;
Specifying the output directory allows testing awall policies without&lt;br /&gt;
overwriting the current iptables and ipset configuration files. By&lt;br /&gt;
default, awall generates the configuration to &amp;lt;tt&amp;gt;/etc/iptables&amp;lt;/tt&amp;gt; &lt;br /&gt;
and &amp;lt;tt&amp;gt;/etc/ipset.d&amp;lt;/tt&amp;gt;, which are read by the init scripts.&lt;br /&gt;
&lt;br /&gt;
=== Run-Time Configuration of Firewall ===&lt;br /&gt;
&lt;br /&gt;
 &#039;&#039;&#039;awall activate&#039;&#039;&#039; [&#039;&#039;&#039;-f&#039;&#039;&#039;|&#039;&#039;&#039;--force&#039;&#039;&#039;]&lt;br /&gt;
&lt;br /&gt;
This command genereates firewall configuration from the policy files&lt;br /&gt;
and enables it. If the user confirms the new configuration by hitting&lt;br /&gt;
the Return key within 10 seconds or the &amp;lt;tt&amp;gt;--force&amp;lt;/tt&amp;gt; option is&lt;br /&gt;
used, the configuration is saved to the files. Otherwise, the old&lt;br /&gt;
configuration is restored.&lt;br /&gt;
&lt;br /&gt;
There is also a command for deleting all firewall rules:&lt;br /&gt;
&lt;br /&gt;
 &#039;&#039;&#039;awall flush&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
This command configures the firewall to drop all packets.&lt;br /&gt;
&lt;br /&gt;
=== Optional Policies ===&lt;br /&gt;
&lt;br /&gt;
Optional policies can be enabled or disabled using this command:&lt;br /&gt;
&lt;br /&gt;
 &#039;&#039;&#039;awall&#039;&#039;&#039; {&#039;&#039;&#039;enable&#039;&#039;&#039;|&#039;&#039;&#039;disable&#039;&#039;&#039;} POLICY...&lt;br /&gt;
&lt;br /&gt;
Optional policies can be listed using this command:&lt;br /&gt;
&lt;br /&gt;
 &#039;&#039;&#039;awall list&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;&#039;enabled&#039;&#039;&#039; status means that the policy has been enabled by the&lt;br /&gt;
user. The &#039;&#039;&#039;disabled&#039;&#039;&#039; status means that the policy is not in&lt;br /&gt;
use. The &#039;&#039;&#039;required&#039;&#039;&#039; status means that the policy has not been&lt;br /&gt;
enabled by the user but is in use because it is required by another&lt;br /&gt;
policy which is in use.&lt;br /&gt;
&lt;br /&gt;
=== Debugging Policies ===&lt;br /&gt;
&lt;br /&gt;
This command can be used to dump variable, zone, and other definitions&lt;br /&gt;
as well as their source policies:&lt;br /&gt;
&lt;br /&gt;
 &#039;&#039;&#039;awall dump&#039;&#039;&#039; [LEVEL]&lt;br /&gt;
&lt;br /&gt;
The level is an integer in range 0&amp;amp;ndash;5 and defaults to 0. More&lt;br /&gt;
information is displayed on higher levels.&lt;br /&gt;
&lt;br /&gt;
[[Category:Networking]]&lt;br /&gt;
[[Category:Security]]&lt;/div&gt;</summary>
		<author><name>Kunkku</name></author>
	</entry>
	<entry>
		<id>https://wiki.alpinelinux.org/w/index.php?title=Alpine_Wall_User%27s_Guide&amp;diff=9032</id>
		<title>Alpine Wall User&#039;s Guide</title>
		<link rel="alternate" type="text/html" href="https://wiki.alpinelinux.org/w/index.php?title=Alpine_Wall_User%27s_Guide&amp;diff=9032"/>
		<updated>2013-02-19T08:15:16Z</updated>

		<summary type="html">&lt;p&gt;Kunkku: /* Transparent Proxy Rules */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Configuration File Processing ==&lt;br /&gt;
&lt;br /&gt;
[[Alpine Wall]] (awall) reads its configuration from multiple&lt;br /&gt;
JSON-formatted files, called &#039;&#039;policy files&#039;&#039;. The files located in&lt;br /&gt;
directory &amp;lt;tt&amp;gt;/usr/share/awall/mandatory&amp;lt;/tt&amp;gt; are &#039;&#039;mandatory&#039;&#039;&lt;br /&gt;
policies shipped with APK packages. In addition, there can be&lt;br /&gt;
installation-specific mandatory policies in &amp;lt;tt&amp;gt;/etc/awall&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
The latter directory may also contain symbolic links to policy files&lt;br /&gt;
located in &amp;lt;tt&amp;gt;/usr/share/awall/optional&amp;lt;/tt&amp;gt; and&lt;br /&gt;
&amp;lt;tt&amp;gt;/etc/awall/optional&amp;lt;/tt&amp;gt;. These are &#039;&#039;optional&#039;&#039; policies, which&lt;br /&gt;
can be enabled on need basis. Such symbolic links are easily created&lt;br /&gt;
and destroyed using the &amp;lt;tt&amp;gt;awall enable&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;awall&lt;br /&gt;
disable&amp;lt;/tt&amp;gt; commands. &amp;lt;tt&amp;gt;awall list&amp;lt;/tt&amp;gt; shows which optional&lt;br /&gt;
policies are enabled and disabled. The command also prints the&lt;br /&gt;
description of the optional policy if defined in the file using a&lt;br /&gt;
top-level attribute named &#039;&#039;&#039;description&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Sometimes a policy file depends on other policy files. In this case,&lt;br /&gt;
the policy file must have a top-level attribute &#039;&#039;&#039;import&#039;&#039;&#039;, the&lt;br /&gt;
value of which is a list of policy names, which correspond to the file&lt;br /&gt;
names without the &amp;lt;tt&amp;gt;.json&amp;lt;/tt&amp;gt; suffix. The imported policies may be&lt;br /&gt;
either optional policies or &#039;&#039;private&#039;&#039; policies, located in&lt;br /&gt;
&amp;lt;tt&amp;gt;/usr/share/awall/private&amp;lt;/tt&amp;gt; or &amp;lt;tt&amp;gt;/etc/awall/private&amp;lt;/tt&amp;gt;. By&lt;br /&gt;
default, the policies listed there are processed before the importing&lt;br /&gt;
policy.&lt;br /&gt;
&lt;br /&gt;
The order of the generated iptables rules generally reflects the&lt;br /&gt;
processing order of their corresponding awall policies. The processing&lt;br /&gt;
order of policies can be adjusted by defining top-level attributes&lt;br /&gt;
&#039;&#039;&#039;after&#039;&#039;&#039; and &#039;&#039;&#039;before&#039;&#039;&#039; in policy files. These attributes are&lt;br /&gt;
lists of policies, after or before which the declaring policy shall be&lt;br /&gt;
processed. Putting a policy name to either of these lists does not by&lt;br /&gt;
itself import the policy. The ordering directives are ignored with&lt;br /&gt;
respect to those policies that are not enabled by the user or imported&lt;br /&gt;
by other policies. If not defined, &#039;&#039;&#039;after&#039;&#039;&#039; is assumed to be equal&lt;br /&gt;
to the &#039;&#039;&#039;import&#039;&#039;&#039; definition of the policy.&lt;br /&gt;
&lt;br /&gt;
As the import directive does not require the path name to be&lt;br /&gt;
specified, awall expects policies to have unique names, even if&lt;br /&gt;
located in different directories. It is allowed to import optional&lt;br /&gt;
policies that are not explicitly enabled by the user. Such policies&lt;br /&gt;
show up with the &amp;lt;tt&amp;gt;required&amp;lt;/tt&amp;gt; status in the output of &amp;lt;tt&amp;gt;awall&lt;br /&gt;
list&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
== List Parameters ==&lt;br /&gt;
&lt;br /&gt;
Several awall parameters are defined as lists of values. In order to&lt;br /&gt;
facilitate manual editing of policy files, awall also accepts single&lt;br /&gt;
values in place of lists. Such values are semantically equivalent to&lt;br /&gt;
lists containing one element.&lt;br /&gt;
&lt;br /&gt;
== Variable Expansion ==&lt;br /&gt;
&lt;br /&gt;
Awall allows variable definitions in policy files. The top-level&lt;br /&gt;
attribute &#039;&#039;&#039;variable&#039;&#039;&#039; is a dictionary containing the&lt;br /&gt;
definitions. The value of a variable can be of any type (string,&lt;br /&gt;
integer, list, or dictionary).&lt;br /&gt;
&lt;br /&gt;
A variable is referenced in policy files by a string which equals the&lt;br /&gt;
variable name prepended with the &#039;&#039;&#039;$&#039;&#039;&#039; character. If the value of&lt;br /&gt;
the variable is a string, the reference can be embedded into a longer&lt;br /&gt;
string in order to substitute some part of that string (in shell&lt;br /&gt;
style). Variable references can be used when defining other variables,&lt;br /&gt;
as long as the definitions are not circular.&lt;br /&gt;
&lt;br /&gt;
Policy files can reference variables defined in other policy&lt;br /&gt;
files. Policy files can also override variables defined elsewhere by&lt;br /&gt;
redefining them. In this case, the new definition affects all policy&lt;br /&gt;
files, also those processed before the overriding policy. Awall&lt;br /&gt;
variables are in fact simple macros, since each variable remains&lt;br /&gt;
constant thoughout a single processing round. If multiple files define&lt;br /&gt;
the same variable, the definition in the file processed last takes&lt;br /&gt;
effect.&lt;br /&gt;
&lt;br /&gt;
If defined as an empty string, all non-embedded references to a&lt;br /&gt;
variable evaluate as if the attribute in question was not present in&lt;br /&gt;
the configuration. This is also the case when a string containing&lt;br /&gt;
embedded variable references finally evaluates to an empty string.&lt;br /&gt;
&lt;br /&gt;
== Configuration Objects ==&lt;br /&gt;
&lt;br /&gt;
Configuration objects can be divided into two main types.&lt;br /&gt;
&#039;&#039;Auxiliary objects&#039;&#039; model high-level concepts such as services and&lt;br /&gt;
zones. &#039;&#039;Rule objects&#039;&#039; translate into one or more iptables rules, and&lt;br /&gt;
are often defined with the help of some auxiliary objects.&lt;br /&gt;
&lt;br /&gt;
=== Services ===&lt;br /&gt;
&lt;br /&gt;
A &#039;&#039;service&#039;&#039; represents a set of network protocols. A top-level&lt;br /&gt;
attribute &#039;&#039;&#039;service&#039;&#039;&#039; is a dictionary that maps service names to&lt;br /&gt;
service definition objects, or lists thereof in more complex cases.&lt;br /&gt;
&lt;br /&gt;
A service definition object contains an attribute named &#039;&#039;&#039;proto&#039;&#039;&#039;,&lt;br /&gt;
which corresponds to the &amp;lt;tt&amp;gt;--protocol&amp;lt;/tt&amp;gt; option of iptables. The&lt;br /&gt;
protocol can be defined as a numerical value or string as defined in&lt;br /&gt;
&amp;lt;tt&amp;gt;/etc/protocols&amp;lt;/tt&amp;gt;. If the protocol is &#039;&#039;&#039;tcp&#039;&#039;&#039; or &#039;&#039;&#039;udp&#039;&#039;&#039;,&lt;br /&gt;
the scope of the service definition may be constrained by defining an&lt;br /&gt;
attribute named &#039;&#039;&#039;port&#039;&#039;&#039;, which is a list of TCP or UDP port numbers&lt;br /&gt;
or ranges thereof, separated by the &#039;&#039;&#039;-&#039;&#039;&#039; character. If the protocol&lt;br /&gt;
is &#039;&#039;&#039;icmp&#039;&#039;&#039; or &#039;&#039;&#039;icmpv6&#039;&#039;&#039;, an analogous &#039;&#039;&#039;icmp-type&#039;&#039;&#039; attribute&lt;br /&gt;
may be used. In addition, the scope of the rule is also automatically&lt;br /&gt;
limited to IPv4 or IPv6, respectively.&lt;br /&gt;
&lt;br /&gt;
All rule objects, except for policies, may have an attribute named&lt;br /&gt;
&#039;&#039;&#039;service&#039;&#039;&#039;, constraining the rule&#039;s scope to specific services&lt;br /&gt;
only. This attribute is a list of service names, referring to the keys&lt;br /&gt;
of the top-level service dictionary.&lt;br /&gt;
&lt;br /&gt;
=== Zones ===&lt;br /&gt;
&lt;br /&gt;
A &#039;&#039;zone&#039;&#039; represents a set of network hosts. A top-level attribute &lt;br /&gt;
&#039;&#039;&#039;zone&#039;&#039;&#039; is a dictionary that maps zone names to zone objects. A&lt;br /&gt;
zone object has an attribute named &#039;&#039;&#039;iface&#039;&#039;&#039;, &#039;&#039;&#039;addr&#039;&#039;&#039;, or&lt;br /&gt;
both. &#039;&#039;&#039;iface&#039;&#039;&#039; is a list of network interfaces and &#039;&#039;&#039;addr&#039;&#039;&#039; is a&lt;br /&gt;
list of IPv4/IPv6 host and network addresses (CIDR&lt;br /&gt;
notation). &#039;&#039;&#039;addr&#039;&#039;&#039; may also contain domain names, which are&lt;br /&gt;
expanded to IP addresses using DNS resolution. If not defined,&lt;br /&gt;
&#039;&#039;&#039;addr&#039;&#039;&#039; defaults to the entire address space and &#039;&#039;&#039;iface&#039;&#039;&#039; to all&lt;br /&gt;
interfaces. An empty zone can be defined by setting either &#039;&#039;&#039;addr&#039;&#039;&#039;&lt;br /&gt;
or &#039;&#039;&#039;iface&#039;&#039;&#039; to an empty list.&lt;br /&gt;
&lt;br /&gt;
Rule objects contain two attributes, &#039;&#039;&#039;in&#039;&#039;&#039; and &#039;&#039;&#039;out&#039;&#039;&#039;, which are&lt;br /&gt;
lists of zone names. These attributes control whether a packet matches&lt;br /&gt;
the rule or not. If a particular zone is referenced by the &#039;&#039;&#039;in&#039;&#039;&#039; &lt;br /&gt;
attribute, the rule applies to packets whose ingress interface and&lt;br /&gt;
source address are covered by the zone definition. Correspondingly, if&lt;br /&gt;
a zone is referenced by the &#039;&#039;&#039;out&#039;&#039;&#039; attribute, the rule applies to&lt;br /&gt;
packets whose egress interface and destination address are included in&lt;br /&gt;
the zone. If both &#039;&#039;&#039;in&#039;&#039;&#039; and &#039;&#039;&#039;out&#039;&#039;&#039; are defined, the packet must&lt;br /&gt;
fulfill both criteria in order to match the rule.&lt;br /&gt;
&lt;br /&gt;
The firewall host itself can be referred to using the special value&lt;br /&gt;
&#039;&#039;&#039;_fw&#039;&#039;&#039; as the zone name.&lt;br /&gt;
&lt;br /&gt;
By default, awall does not generate iptables rules with identical&lt;br /&gt;
ingress and egress interfaces. This behavior can be changed per zone&lt;br /&gt;
by setting the optional &#039;&#039;&#039;route-back&#039;&#039;&#039; attribute of the zone to&lt;br /&gt;
&#039;&#039;&#039;true&#039;&#039;&#039;. Note that this attribute can have an effect also in the&lt;br /&gt;
case where &#039;&#039;&#039;in&#039;&#039;&#039; and &#039;&#039;&#039;out&#039;&#039;&#039; attributes of a rule are not equal&lt;br /&gt;
but their definitions overlap. In this case, the &#039;&#039;&#039;route-back&#039;&#039;&#039;&lt;br /&gt;
attribute of the &#039;&#039;&#039;out&#039;&#039;&#039; zone determines the behavior.&lt;br /&gt;
&lt;br /&gt;
=== Logging Classes ===&lt;br /&gt;
&lt;br /&gt;
A &#039;&#039;logging class&#039;&#039; specifies how packets matching certain rules are&lt;br /&gt;
logged. A top-level attribute &#039;&#039;&#039;log&#039;&#039;&#039; is a dictionary that maps&lt;br /&gt;
logging class names to setting objects.&lt;br /&gt;
&lt;br /&gt;
A setting object may have an attribute named &#039;&#039;&#039;mode&#039;&#039;&#039;, which&lt;br /&gt;
specifies which logging facility to use. Allowed values are &#039;&#039;&#039;log&#039;&#039;&#039;,&lt;br /&gt;
&#039;&#039;&#039;nflog&#039;&#039;&#039;, and &#039;&#039;&#039;ulog&#039;&#039;&#039;. The default is &#039;&#039;&#039;log&#039;&#039;&#039;, i.e. in-kernel&lt;br /&gt;
logging.&lt;br /&gt;
&lt;br /&gt;
The following table shows the optional attributes valid for all&lt;br /&gt;
logging modes:&lt;br /&gt;
&lt;br /&gt;
{|&lt;br /&gt;
!Attribute!!Description&lt;br /&gt;
|-&lt;br /&gt;
|&#039;&#039;&#039;every&#039;&#039;&#039;&lt;br /&gt;
|Divide successive packets into groups, the size of which is specified by the value of this attribute, and log only the first packet of each group&lt;br /&gt;
|-&lt;br /&gt;
|&#039;&#039;&#039;limit&#039;&#039;&#039;&lt;br /&gt;
|Maximum number of packets to be logged per second per this rule&lt;br /&gt;
|-&lt;br /&gt;
|&#039;&#039;&#039;prefix&#039;&#039;&#039;&lt;br /&gt;
|String with which the log entries are prefixed&lt;br /&gt;
|-&lt;br /&gt;
|&#039;&#039;&#039;probability&#039;&#039;&#039;&lt;br /&gt;
|Probability for logging an individual packet (default: 1)&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
With the in-kernel log mode &#039;&#039;&#039;log&#039;&#039;&#039;, the level of logging may be&lt;br /&gt;
specified using the &#039;&#039;&#039;level&#039;&#039;&#039; attribute. Log modes &#039;&#039;&#039;nflog&#039;&#039;&#039; and&lt;br /&gt;
&#039;&#039;&#039;ulog&#039;&#039;&#039; are about copying the packets into user space, at least&lt;br /&gt;
partially. The following table shows the additional attributes valid&lt;br /&gt;
with these modes:&lt;br /&gt;
&lt;br /&gt;
{|&lt;br /&gt;
!Attribute!!Description&lt;br /&gt;
|-&lt;br /&gt;
|&#039;&#039;&#039;group&#039;&#039;&#039;&lt;br /&gt;
|Netlink group to be used&lt;br /&gt;
|-&lt;br /&gt;
|&#039;&#039;&#039;range&#039;&#039;&#039;&lt;br /&gt;
|Number of bytes to be copied&lt;br /&gt;
|-&lt;br /&gt;
|&#039;&#039;&#039;threshold&#039;&#039;&#039;&lt;br /&gt;
|Number of packets to queue inside the kernel before copying them&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Filter and policy rules can have an attribute named &#039;&#039;&#039;log&#039;&#039;&#039;. If it&lt;br /&gt;
is a string, it is interpreted as a reference to a logging class, and&lt;br /&gt;
logging is performed according to the definitions. If the value of the&lt;br /&gt;
&#039;&#039;&#039;log&#039;&#039;&#039; attribute is &#039;&#039;&#039;true&#039;&#039;&#039; (boolean), logging is done using&lt;br /&gt;
default settings. If the value is &#039;&#039;&#039;false&#039;&#039;&#039; (boolean), logging is&lt;br /&gt;
disabled for the rule. If &#039;&#039;&#039;log&#039;&#039;&#039; is not defined, logging is done&lt;br /&gt;
using the default settings except for accept rules, for which logging&lt;br /&gt;
is omitted.&lt;br /&gt;
&lt;br /&gt;
Default logging settings can be set by defining a logging class named&lt;br /&gt;
&#039;&#039;&#039;_default&#039;&#039;&#039;. Normally, default logging uses the &#039;&#039;&#039;log&#039;&#039;&#039; mode with&lt;br /&gt;
packets limited to one per second.&lt;br /&gt;
&lt;br /&gt;
=== Rules ===&lt;br /&gt;
&lt;br /&gt;
There are several types of rule objects:&lt;br /&gt;
* Filter rules&lt;br /&gt;
* Policy rules&lt;br /&gt;
* Packet Logging rules&lt;br /&gt;
* NAT rules&lt;br /&gt;
* Packet Marking rules&lt;br /&gt;
* Transparent Proxy rules&lt;br /&gt;
* MSS Clamping rules&lt;br /&gt;
* Connection Tracking Bypass rules&lt;br /&gt;
&lt;br /&gt;
All rule objects can have the &#039;&#039;&#039;in&#039;&#039;&#039; and &#039;&#039;&#039;out&#039;&#039;&#039; attributes&lt;br /&gt;
referring to zones as described in the previous section. In addition,&lt;br /&gt;
the scope of the rule can be further constrained with the following&lt;br /&gt;
attributes:&lt;br /&gt;
&lt;br /&gt;
{|&lt;br /&gt;
!Attribute!!Value format!!Effect&lt;br /&gt;
|-&lt;br /&gt;
|&#039;&#039;&#039;src&#039;&#039;&#039;&lt;br /&gt;
|Similar to &#039;&#039;&#039;addr&#039;&#039;&#039; attribute of zone objects&lt;br /&gt;
|Packet&#039;s source address matches the value&lt;br /&gt;
|-&lt;br /&gt;
|&#039;&#039;&#039;dest&#039;&#039;&#039;&lt;br /&gt;
|Similar to &#039;&#039;&#039;addr&#039;&#039;&#039; attribute of zone objects&lt;br /&gt;
|Packet&#039;s destination address matches the value&lt;br /&gt;
|-&lt;br /&gt;
|&#039;&#039;&#039;ipset&#039;&#039;&#039;&lt;br /&gt;
|Object containing two attributes: &#039;&#039;&#039;name&#039;&#039;&#039; referring to an IP set and &#039;&#039;&#039;args&#039;&#039;&#039;, which is a list of strings &#039;&#039;&#039;in&#039;&#039;&#039; and &#039;&#039;&#039;out&#039;&#039;&#039;&lt;br /&gt;
|Packet matches the IP set referred here when the match arguments are taken from the source (&#039;&#039;&#039;in&#039;&#039;&#039;) and destination (&#039;&#039;&#039;out&#039;&#039;&#039;) address or port in the order specified by &#039;&#039;&#039;args&#039;&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
|&#039;&#039;&#039;ipsec&#039;&#039;&#039;&lt;br /&gt;
|&#039;&#039;&#039;in&#039;&#039;&#039; or &#039;&#039;&#039;out&#039;&#039;&#039;&lt;br /&gt;
|IPsec decapsulation perfomed on ingress (&#039;&#039;&#039;in&#039;&#039;&#039;) or encapsulation performed on egress (&#039;&#039;&#039;out&#039;&#039;&#039;)&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Rule objects are declared in type-specific top-level dictionaries in&lt;br /&gt;
awall policy files. If a packet matches multiple rules, the one&lt;br /&gt;
appearing earlier in the list takes precedence. If the matching rules&lt;br /&gt;
are defined in different policy files, the one that was processed&lt;br /&gt;
earlier takes precedence in the current implementation, but this may&lt;br /&gt;
change in future versions.&lt;br /&gt;
&lt;br /&gt;
==== Filter Rules ====&lt;br /&gt;
&lt;br /&gt;
Filter objects specify an action for packets fulfilling certain&lt;br /&gt;
criteria. The top-level attribute &#039;&#039;&#039;filter&#039;&#039;&#039; is a list of filter&lt;br /&gt;
objects. The precedence rules are similar to those of policy objects.&lt;br /&gt;
&lt;br /&gt;
Filter objects must have an attribute named &#039;&#039;&#039;action&#039;&#039;&#039;, the value of&lt;br /&gt;
which can be one of the following:&lt;br /&gt;
&lt;br /&gt;
{|&lt;br /&gt;
!Value!!Action&lt;br /&gt;
|-&lt;br /&gt;
|&#039;&#039;&#039;accept&#039;&#039;&#039;&lt;br /&gt;
|Accept the packet&lt;br /&gt;
|-&lt;br /&gt;
|&#039;&#039;&#039;reject&#039;&#039;&#039;&lt;br /&gt;
|Reject the packet with an ICMP error message&lt;br /&gt;
|-&lt;br /&gt;
|&#039;&#039;&#039;drop&#039;&#039;&#039;&lt;br /&gt;
|Silently drop the packet&lt;br /&gt;
|-&lt;br /&gt;
|&#039;&#039;&#039;tarpit&#039;&#039;&#039;&lt;br /&gt;
|Put incoming TCP connections into persist state and ignore attempts to close them. Silently drop non-TCP packets. (Connection tracking bypass is automatically enabled for the matching packets.)&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Filter objects, the action of which is &#039;&#039;&#039;accept&#039;&#039;&#039;, may also contain&lt;br /&gt;
limits for packet flow or new connections. These are specified with&lt;br /&gt;
the &#039;&#039;&#039;flow-limit&#039;&#039;&#039; and &#039;&#039;&#039;conn-limit&#039;&#039;&#039; attributes,&lt;br /&gt;
respectively. The values of these attributes are limit objects that&lt;br /&gt;
have two attributes: &#039;&#039;&#039;count&#039;&#039;&#039; and &#039;&#039;&#039;interval&#039;&#039;&#039;. &#039;&#039;&#039;count&#039;&#039;&#039;&lt;br /&gt;
specifies how many new connections or packets are allowed within the&lt;br /&gt;
time frame specified by &#039;&#039;&#039;interval&#039;&#039;&#039; in seconds (default: 1). The&lt;br /&gt;
&#039;&#039;&#039;drop&#039;&#039;&#039; action is applied to the packets exceeding the&lt;br /&gt;
limit. Optionally, the limit object may have an attribute named&lt;br /&gt;
&#039;&#039;&#039;log&#039;&#039;&#039;. It defines how the dropped packets should be logged and is&lt;br /&gt;
semantically similar to the &#039;&#039;&#039;log&#039;&#039;&#039; attribute of rule objects. A&lt;br /&gt;
limit may also be specified by a plain integer, which is interpreted&lt;br /&gt;
as the count while using default interval and log settings.&lt;br /&gt;
&lt;br /&gt;
Filter objects may have an attribute named &#039;&#039;&#039;dnat&#039;&#039;&#039;, the value of&lt;br /&gt;
which is an IPv4 address. If defined, this enables destination NAT for&lt;br /&gt;
all IPv4 packets matching the rule, such that the specified address&lt;br /&gt;
replaces the original destination address. This option has no effect&lt;br /&gt;
on IPv6 packets.&lt;br /&gt;
&lt;br /&gt;
Filter objects may have a boolean attribute named &#039;&#039;&#039;no-track&#039;&#039;&#039;. If&lt;br /&gt;
set to &#039;&#039;&#039;true&#039;&#039;&#039;, connection tracking is bypassed for the matching&lt;br /&gt;
packets. In addition, if &#039;&#039;&#039;action&#039;&#039;&#039; is set to &#039;&#039;&#039;accept&#039;&#039;&#039;, the&lt;br /&gt;
corresponding packets travelling to the reverse direction are also&lt;br /&gt;
allowed.&lt;br /&gt;
&lt;br /&gt;
==== Policy Rules ====&lt;br /&gt;
&lt;br /&gt;
Policy objects describe the default action for packets that did not&lt;br /&gt;
match any filter. The top-level attribute &#039;&#039;&#039;policy&#039;&#039;&#039; is a list of&lt;br /&gt;
policy objects.&lt;br /&gt;
&lt;br /&gt;
Policy objects must have the &#039;&#039;&#039;action&#039;&#039;&#039; attribute defined. The&lt;br /&gt;
possible values and their semantics are the same as in filter objects.&lt;br /&gt;
&lt;br /&gt;
==== Packet Logging Rules ====&lt;br /&gt;
&lt;br /&gt;
Packet logging rules allow packets matching the specified criteria to&lt;br /&gt;
be logged before any filtering takes place. Such rules are contained&lt;br /&gt;
in the top-level list named &#039;&#039;&#039;packet-log&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Logging class may be specified using the &#039;&#039;&#039;log&#039;&#039;&#039;&lt;br /&gt;
attribute. Otherwise, default logging settings are used.&lt;br /&gt;
&lt;br /&gt;
==== NAT Rules ====&lt;br /&gt;
&lt;br /&gt;
NAT rules come in two flavors: &#039;&#039;source NAT rules&#039;&#039; and&lt;br /&gt;
&#039;&#039;destination NAT rules&#039;&#039;. These are contained in two top-level lists&lt;br /&gt;
named &#039;&#039;&#039;snat&#039;&#039;&#039; and &#039;&#039;&#039;dnat&#039;&#039;&#039;, respectively.&lt;br /&gt;
&lt;br /&gt;
Each NAT rule may have an attribute named &#039;&#039;&#039;to-addr&#039;&#039;&#039; that&lt;br /&gt;
specifies the IPv4 address range to which the original source or&lt;br /&gt;
destination address is mapped. The value can be a single IPv4 address&lt;br /&gt;
or a range specified by two addresses, separated with the &#039;&#039;&#039;-&#039;&#039;&#039;&lt;br /&gt;
character. If not defined, it defaults to the primary address of the&lt;br /&gt;
ingress interface in case of destination NAT, or that of the egress&lt;br /&gt;
interface in case of source NAT.&lt;br /&gt;
&lt;br /&gt;
Optionally, a NAT rule can specify the TCP and UDP port range to which&lt;br /&gt;
the original source or destination port is mapped. The attribute is&lt;br /&gt;
named &#039;&#039;&#039;to-port&#039;&#039;&#039;, and the value can be a single port number or a&lt;br /&gt;
range specified by two numbers, separated with the &#039;&#039;&#039;-&#039;&#039;&#039;&lt;br /&gt;
character. If &#039;&#039;&#039;to-port&#039;&#039;&#039; is not specified, the original port number&lt;br /&gt;
is kept intact.&lt;br /&gt;
&lt;br /&gt;
NAT rules may have an &#039;&#039;&#039;action&#039;&#039;&#039; attribute set to value&lt;br /&gt;
&#039;&#039;&#039;accept&#039;&#039;&#039;. In this case, NAT is not performed on the packets&lt;br /&gt;
reaching and matching this rule.&lt;br /&gt;
&lt;br /&gt;
==== Packet Marking Rules ====&lt;br /&gt;
&lt;br /&gt;
Packet marking rules are used to mark incoming packets matching the&lt;br /&gt;
specified criteria. The mark can be used as a basis for the routing&lt;br /&gt;
decision. Each marking rule must specify the mark using the &#039;&#039;&#039;mark&#039;&#039;&#039;&lt;br /&gt;
attribute, which is a 32-bit integer.&lt;br /&gt;
&lt;br /&gt;
Normal marking rules are contained by the top-level list attribute&lt;br /&gt;
named &#039;&#039;&#039;mark&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
There is another top-level list attribute, named &#039;&#039;&#039;route-track&#039;&#039;&#039;,&lt;br /&gt;
which contains route tracking rules. These are special marking rules&lt;br /&gt;
which cause all the subsequent packets related to the same connection&lt;br /&gt;
to be marked according to the rule.&lt;br /&gt;
&lt;br /&gt;
==== Transparent Proxy Rules ====&lt;br /&gt;
&lt;br /&gt;
Transparent proxy rules divert the matching packets to a local proxy&lt;br /&gt;
process without altering their headers. Such rules are contained in&lt;br /&gt;
the top-level list named &#039;&#039;&#039;tproxy&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
In addition to the firewall configuration, using a transparent proxy&lt;br /&gt;
requires a routing configuration where packets marked for proxying are&lt;br /&gt;
diverted to a local process. The &#039;&#039;&#039;awall_tproxy_mark&#039;&#039;&#039; variable can&lt;br /&gt;
be used to specify the mark for such packets, which defaults to 1.&lt;br /&gt;
&lt;br /&gt;
Proxy rules may also have an attribute named &#039;&#039;&#039;to-port&#039;&#039;&#039; for&lt;br /&gt;
specifying the TCP or UDP port of the proxy if it is different from&lt;br /&gt;
the original destination port.&lt;br /&gt;
&lt;br /&gt;
==== MSS Clamping Rules ====&lt;br /&gt;
&lt;br /&gt;
MSS Clamping Rules are used to deal with ISPs that block ICMP&lt;br /&gt;
Fragmentation Needed or ICMPv6 Packet Too Big packets. An MSS clamping&lt;br /&gt;
rule overwrites the MSS option with a value specified with the&lt;br /&gt;
&#039;&#039;&#039;mss&#039;&#039;&#039; attribute for the matching TCP connections. If &#039;&#039;&#039;mss&#039;&#039;&#039; is&lt;br /&gt;
not specified, a suitable value is automatically determined from the&lt;br /&gt;
path MTU. The MSS clamping rules are located in the top-level&lt;br /&gt;
dictionary named &#039;&#039;&#039;clamp-mss&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
==== Connection Tracking Bypass Rules ====&lt;br /&gt;
&lt;br /&gt;
Connection tracking bypass rules are used to disable connection&lt;br /&gt;
tracking for packets matching the specified criteria. The top-level&lt;br /&gt;
attribute &#039;&#039;&#039;no-track&#039;&#039;&#039; is a list of such rules.&lt;br /&gt;
&lt;br /&gt;
Connection tracking bypass rules may have an &#039;&#039;&#039;action&#039;&#039;&#039; attribute&lt;br /&gt;
set to value &#039;&#039;&#039;accept&#039;&#039;&#039;. The effect is similar to corresponding NAT&lt;br /&gt;
rules, i.e. connection tracking is not bypassed for the matching&lt;br /&gt;
packets.&lt;br /&gt;
&lt;br /&gt;
=== IP Sets ===&lt;br /&gt;
&lt;br /&gt;
Any IP set referenced by rule objects should be created by&lt;br /&gt;
awall. Auxiliary &#039;&#039;IP set&#039;&#039; objects are used to defined them in awall&lt;br /&gt;
policy files. The top-level attribute &#039;&#039;&#039;ipset&#039;&#039;&#039; is a dictionary, the&lt;br /&gt;
keys of which are IP set names. The values are IP set objects, which&lt;br /&gt;
have two mandatory attributes. The attribute named &#039;&#039;&#039;type&#039;&#039;&#039; &lt;br /&gt;
corresponds to the type argument of the &amp;lt;tt&amp;gt;ipset create&amp;lt;/tt&amp;gt; &lt;br /&gt;
command. &#039;&#039;&#039;family&#039;&#039;&#039; specifies whether the set is for IPv4 or IPv6&lt;br /&gt;
addresses, and the possible values are &#039;&#039;&#039;inet&#039;&#039;&#039; and &#039;&#039;&#039;inet6&#039;&#039;&#039;,&lt;br /&gt;
correspondingly.&lt;br /&gt;
&lt;br /&gt;
For bitmap-type IP sets, the &#039;&#039;&#039;range&#039;&#039;&#039; attribute specifies the&lt;br /&gt;
range of allowed IPv4 addresses. It may be given as a network&lt;br /&gt;
address or two addresses separated by the &#039;&#039;&#039;-&#039;&#039;&#039; character. It&lt;br /&gt;
is not necessary to specify &#039;&#039;&#039;family&#039;&#039;&#039; for bitmaps, since the&lt;br /&gt;
kernel supports only IPv4 bitmaps.&lt;br /&gt;
&lt;br /&gt;
== Command Line Syntax ==&lt;br /&gt;
&lt;br /&gt;
=== Translating Policy Files to Firewall Configuration Files ===&lt;br /&gt;
&lt;br /&gt;
 &#039;&#039;&#039;awall translate&#039;&#039;&#039; [&#039;&#039;&#039;-o&#039;&#039;&#039;|&#039;&#039;&#039;--output&#039;&#039;&#039; DIRECTORY] [&#039;&#039;&#039;-V&#039;&#039;&#039;|&#039;&#039;&#039;--verify&#039;&#039;&#039;]&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;tt&amp;gt;--verify&amp;lt;/tt&amp;gt; option makes awall verify the configuration&lt;br /&gt;
using the test mode of iptables-restore before overwriting the old&lt;br /&gt;
files.&lt;br /&gt;
&lt;br /&gt;
Specifying the output directory allows testing awall policies without&lt;br /&gt;
overwriting the current iptables and ipset configuration files. By&lt;br /&gt;
default, awall generates the configuration to &amp;lt;tt&amp;gt;/etc/iptables&amp;lt;/tt&amp;gt; &lt;br /&gt;
and &amp;lt;tt&amp;gt;/etc/ipset.d&amp;lt;/tt&amp;gt;, which are read by the init scripts.&lt;br /&gt;
&lt;br /&gt;
=== Run-Time Configuration of Firewall ===&lt;br /&gt;
&lt;br /&gt;
 &#039;&#039;&#039;awall activate&#039;&#039;&#039; [&#039;&#039;&#039;-f&#039;&#039;&#039;|&#039;&#039;&#039;--force&#039;&#039;&#039;]&lt;br /&gt;
&lt;br /&gt;
This command genereates firewall configuration from the policy files&lt;br /&gt;
and enables it. If the user confirms the new configuration by hitting&lt;br /&gt;
the Return key within 10 seconds or the &amp;lt;tt&amp;gt;--force&amp;lt;/tt&amp;gt; option is&lt;br /&gt;
used, the configuration is saved to the files. Otherwise, the old&lt;br /&gt;
configuration is restored.&lt;br /&gt;
&lt;br /&gt;
There is also a command for deleting all firewall rules:&lt;br /&gt;
&lt;br /&gt;
 &#039;&#039;&#039;awall flush&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
This command configures the firewall to drop all packets.&lt;br /&gt;
&lt;br /&gt;
=== Optional Policies ===&lt;br /&gt;
&lt;br /&gt;
Optional policies can be enabled or disabled using this command:&lt;br /&gt;
&lt;br /&gt;
 &#039;&#039;&#039;awall&#039;&#039;&#039; {&#039;&#039;&#039;enable&#039;&#039;&#039;|&#039;&#039;&#039;disable&#039;&#039;&#039;} POLICY...&lt;br /&gt;
&lt;br /&gt;
Optional policies can be listed using this command:&lt;br /&gt;
&lt;br /&gt;
 &#039;&#039;&#039;awall list&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;&#039;enabled&#039;&#039;&#039; status means that the policy has been enabled by the&lt;br /&gt;
user. The &#039;&#039;&#039;disabled&#039;&#039;&#039; status means that the policy is not in&lt;br /&gt;
use. The &#039;&#039;&#039;required&#039;&#039;&#039; status means that the policy has not been&lt;br /&gt;
enabled by the user but is in use because it is required by another&lt;br /&gt;
policy which is in use.&lt;br /&gt;
&lt;br /&gt;
=== Debugging Policies ===&lt;br /&gt;
&lt;br /&gt;
This command can be used to dump variable, zone, and other definitions&lt;br /&gt;
as well as their source policies:&lt;br /&gt;
&lt;br /&gt;
 &#039;&#039;&#039;awall dump&#039;&#039;&#039; [LEVEL]&lt;br /&gt;
&lt;br /&gt;
The level is an integer in range 0&amp;amp;ndash;5 and defaults to 0. More&lt;br /&gt;
information is displayed on higher levels.&lt;br /&gt;
&lt;br /&gt;
[[Category:Networking]]&lt;br /&gt;
[[Category:Security]]&lt;/div&gt;</summary>
		<author><name>Kunkku</name></author>
	</entry>
	<entry>
		<id>https://wiki.alpinelinux.org/w/index.php?title=Alpine_Wall_User%27s_Guide&amp;diff=9021</id>
		<title>Alpine Wall User&#039;s Guide</title>
		<link rel="alternate" type="text/html" href="https://wiki.alpinelinux.org/w/index.php?title=Alpine_Wall_User%27s_Guide&amp;diff=9021"/>
		<updated>2013-02-08T07:33:31Z</updated>

		<summary type="html">&lt;p&gt;Kunkku: /* Configuration File Processing */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Configuration File Processing ==&lt;br /&gt;
&lt;br /&gt;
[[Alpine Wall]] (awall) reads its configuration from multiple&lt;br /&gt;
JSON-formatted files, called &#039;&#039;policy files&#039;&#039;. The files located in&lt;br /&gt;
directory &amp;lt;tt&amp;gt;/usr/share/awall/mandatory&amp;lt;/tt&amp;gt; are &#039;&#039;mandatory&#039;&#039;&lt;br /&gt;
policies shipped with APK packages. In addition, there can be&lt;br /&gt;
installation-specific mandatory policies in &amp;lt;tt&amp;gt;/etc/awall&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
The latter directory may also contain symbolic links to policy files&lt;br /&gt;
located in &amp;lt;tt&amp;gt;/usr/share/awall/optional&amp;lt;/tt&amp;gt; and&lt;br /&gt;
&amp;lt;tt&amp;gt;/etc/awall/optional&amp;lt;/tt&amp;gt;. These are &#039;&#039;optional&#039;&#039; policies, which&lt;br /&gt;
can be enabled on need basis. Such symbolic links are easily created&lt;br /&gt;
and destroyed using the &amp;lt;tt&amp;gt;awall enable&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;awall&lt;br /&gt;
disable&amp;lt;/tt&amp;gt; commands. &amp;lt;tt&amp;gt;awall list&amp;lt;/tt&amp;gt; shows which optional&lt;br /&gt;
policies are enabled and disabled. The command also prints the&lt;br /&gt;
description of the optional policy if defined in the file using a&lt;br /&gt;
top-level attribute named &#039;&#039;&#039;description&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Sometimes a policy file depends on other policy files. In this case,&lt;br /&gt;
the policy file must have a top-level attribute &#039;&#039;&#039;import&#039;&#039;&#039;, the&lt;br /&gt;
value of which is a list of policy names, which correspond to the file&lt;br /&gt;
names without the &amp;lt;tt&amp;gt;.json&amp;lt;/tt&amp;gt; suffix. The imported policies may be&lt;br /&gt;
either optional policies or &#039;&#039;private&#039;&#039; policies, located in&lt;br /&gt;
&amp;lt;tt&amp;gt;/usr/share/awall/private&amp;lt;/tt&amp;gt; or &amp;lt;tt&amp;gt;/etc/awall/private&amp;lt;/tt&amp;gt;. By&lt;br /&gt;
default, the policies listed there are processed before the importing&lt;br /&gt;
policy.&lt;br /&gt;
&lt;br /&gt;
The order of the generated iptables rules generally reflects the&lt;br /&gt;
processing order of their corresponding awall policies. The processing&lt;br /&gt;
order of policies can be adjusted by defining top-level attributes&lt;br /&gt;
&#039;&#039;&#039;after&#039;&#039;&#039; and &#039;&#039;&#039;before&#039;&#039;&#039; in policy files. These attributes are&lt;br /&gt;
lists of policies, after or before which the declaring policy shall be&lt;br /&gt;
processed. Putting a policy name to either of these lists does not by&lt;br /&gt;
itself import the policy. The ordering directives are ignored with&lt;br /&gt;
respect to those policies that are not enabled by the user or imported&lt;br /&gt;
by other policies. If not defined, &#039;&#039;&#039;after&#039;&#039;&#039; is assumed to be equal&lt;br /&gt;
to the &#039;&#039;&#039;import&#039;&#039;&#039; definition of the policy.&lt;br /&gt;
&lt;br /&gt;
As the import directive does not require the path name to be&lt;br /&gt;
specified, awall expects policies to have unique names, even if&lt;br /&gt;
located in different directories. It is allowed to import optional&lt;br /&gt;
policies that are not explicitly enabled by the user. Such policies&lt;br /&gt;
show up with the &amp;lt;tt&amp;gt;required&amp;lt;/tt&amp;gt; status in the output of &amp;lt;tt&amp;gt;awall&lt;br /&gt;
list&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
== List Parameters ==&lt;br /&gt;
&lt;br /&gt;
Several awall parameters are defined as lists of values. In order to&lt;br /&gt;
facilitate manual editing of policy files, awall also accepts single&lt;br /&gt;
values in place of lists. Such values are semantically equivalent to&lt;br /&gt;
lists containing one element.&lt;br /&gt;
&lt;br /&gt;
== Variable Expansion ==&lt;br /&gt;
&lt;br /&gt;
Awall allows variable definitions in policy files. The top-level&lt;br /&gt;
attribute &#039;&#039;&#039;variable&#039;&#039;&#039; is a dictionary containing the&lt;br /&gt;
definitions. The value of a variable can be of any type (string,&lt;br /&gt;
integer, list, or dictionary).&lt;br /&gt;
&lt;br /&gt;
A variable is referenced in policy files by a string which equals the&lt;br /&gt;
variable name prepended with the &#039;&#039;&#039;$&#039;&#039;&#039; character. If the value of&lt;br /&gt;
the variable is a string, the reference can be embedded into a longer&lt;br /&gt;
string in order to substitute some part of that string (in shell&lt;br /&gt;
style). Variable references can be used when defining other variables,&lt;br /&gt;
as long as the definitions are not circular.&lt;br /&gt;
&lt;br /&gt;
Policy files can reference variables defined in other policy&lt;br /&gt;
files. Policy files can also override variables defined elsewhere by&lt;br /&gt;
redefining them. In this case, the new definition affects all policy&lt;br /&gt;
files, also those processed before the overriding policy. Awall&lt;br /&gt;
variables are in fact simple macros, since each variable remains&lt;br /&gt;
constant thoughout a single processing round. If multiple files define&lt;br /&gt;
the same variable, the definition in the file processed last takes&lt;br /&gt;
effect.&lt;br /&gt;
&lt;br /&gt;
If defined as an empty string, all non-embedded references to a&lt;br /&gt;
variable evaluate as if the attribute in question was not present in&lt;br /&gt;
the configuration. This is also the case when a string containing&lt;br /&gt;
embedded variable references finally evaluates to an empty string.&lt;br /&gt;
&lt;br /&gt;
== Configuration Objects ==&lt;br /&gt;
&lt;br /&gt;
Configuration objects can be divided into two main types.&lt;br /&gt;
&#039;&#039;Auxiliary objects&#039;&#039; model high-level concepts such as services and&lt;br /&gt;
zones. &#039;&#039;Rule objects&#039;&#039; translate into one or more iptables rules, and&lt;br /&gt;
are often defined with the help of some auxiliary objects.&lt;br /&gt;
&lt;br /&gt;
=== Services ===&lt;br /&gt;
&lt;br /&gt;
A &#039;&#039;service&#039;&#039; represents a set of network protocols. A top-level&lt;br /&gt;
attribute &#039;&#039;&#039;service&#039;&#039;&#039; is a dictionary that maps service names to&lt;br /&gt;
service definition objects, or lists thereof in more complex cases.&lt;br /&gt;
&lt;br /&gt;
A service definition object contains an attribute named &#039;&#039;&#039;proto&#039;&#039;&#039;,&lt;br /&gt;
which corresponds to the &amp;lt;tt&amp;gt;--protocol&amp;lt;/tt&amp;gt; option of iptables. The&lt;br /&gt;
protocol can be defined as a numerical value or string as defined in&lt;br /&gt;
&amp;lt;tt&amp;gt;/etc/protocols&amp;lt;/tt&amp;gt;. If the protocol is &#039;&#039;&#039;tcp&#039;&#039;&#039; or &#039;&#039;&#039;udp&#039;&#039;&#039;,&lt;br /&gt;
the scope of the service definition may be constrained by defining an&lt;br /&gt;
attribute named &#039;&#039;&#039;port&#039;&#039;&#039;, which is a list of TCP or UDP port numbers&lt;br /&gt;
or ranges thereof, separated by the &#039;&#039;&#039;-&#039;&#039;&#039; character. If the protocol&lt;br /&gt;
is &#039;&#039;&#039;icmp&#039;&#039;&#039; or &#039;&#039;&#039;icmpv6&#039;&#039;&#039;, an analogous &#039;&#039;&#039;icmp-type&#039;&#039;&#039; attribute&lt;br /&gt;
may be used. In addition, the scope of the rule is also automatically&lt;br /&gt;
limited to IPv4 or IPv6, respectively.&lt;br /&gt;
&lt;br /&gt;
All rule objects, except for policies, may have an attribute named&lt;br /&gt;
&#039;&#039;&#039;service&#039;&#039;&#039;, constraining the rule&#039;s scope to specific services&lt;br /&gt;
only. This attribute is a list of service names, referring to the keys&lt;br /&gt;
of the top-level service dictionary.&lt;br /&gt;
&lt;br /&gt;
=== Zones ===&lt;br /&gt;
&lt;br /&gt;
A &#039;&#039;zone&#039;&#039; represents a set of network hosts. A top-level attribute &lt;br /&gt;
&#039;&#039;&#039;zone&#039;&#039;&#039; is a dictionary that maps zone names to zone objects. A&lt;br /&gt;
zone object has an attribute named &#039;&#039;&#039;iface&#039;&#039;&#039;, &#039;&#039;&#039;addr&#039;&#039;&#039;, or&lt;br /&gt;
both. &#039;&#039;&#039;iface&#039;&#039;&#039; is a list of network interfaces and &#039;&#039;&#039;addr&#039;&#039;&#039; is a&lt;br /&gt;
list of IPv4/IPv6 host and network addresses (CIDR&lt;br /&gt;
notation). &#039;&#039;&#039;addr&#039;&#039;&#039; may also contain domain names, which are&lt;br /&gt;
expanded to IP addresses using DNS resolution. If not defined,&lt;br /&gt;
&#039;&#039;&#039;addr&#039;&#039;&#039; defaults to the entire address space and &#039;&#039;&#039;iface&#039;&#039;&#039; to all&lt;br /&gt;
interfaces. An empty zone can be defined by setting either &#039;&#039;&#039;addr&#039;&#039;&#039;&lt;br /&gt;
or &#039;&#039;&#039;iface&#039;&#039;&#039; to an empty list.&lt;br /&gt;
&lt;br /&gt;
Rule objects contain two attributes, &#039;&#039;&#039;in&#039;&#039;&#039; and &#039;&#039;&#039;out&#039;&#039;&#039;, which are&lt;br /&gt;
lists of zone names. These attributes control whether a packet matches&lt;br /&gt;
the rule or not. If a particular zone is referenced by the &#039;&#039;&#039;in&#039;&#039;&#039; &lt;br /&gt;
attribute, the rule applies to packets whose ingress interface and&lt;br /&gt;
source address are covered by the zone definition. Correspondingly, if&lt;br /&gt;
a zone is referenced by the &#039;&#039;&#039;out&#039;&#039;&#039; attribute, the rule applies to&lt;br /&gt;
packets whose egress interface and destination address are included in&lt;br /&gt;
the zone. If both &#039;&#039;&#039;in&#039;&#039;&#039; and &#039;&#039;&#039;out&#039;&#039;&#039; are defined, the packet must&lt;br /&gt;
fulfill both criteria in order to match the rule.&lt;br /&gt;
&lt;br /&gt;
The firewall host itself can be referred to using the special value&lt;br /&gt;
&#039;&#039;&#039;_fw&#039;&#039;&#039; as the zone name.&lt;br /&gt;
&lt;br /&gt;
By default, awall does not generate iptables rules with identical&lt;br /&gt;
ingress and egress interfaces. This behavior can be changed per zone&lt;br /&gt;
by setting the optional &#039;&#039;&#039;route-back&#039;&#039;&#039; attribute of the zone to&lt;br /&gt;
&#039;&#039;&#039;true&#039;&#039;&#039;. Note that this attribute can have an effect also in the&lt;br /&gt;
case where &#039;&#039;&#039;in&#039;&#039;&#039; and &#039;&#039;&#039;out&#039;&#039;&#039; attributes of a rule are not equal&lt;br /&gt;
but their definitions overlap. In this case, the &#039;&#039;&#039;route-back&#039;&#039;&#039;&lt;br /&gt;
attribute of the &#039;&#039;&#039;out&#039;&#039;&#039; zone determines the behavior.&lt;br /&gt;
&lt;br /&gt;
=== Logging Classes ===&lt;br /&gt;
&lt;br /&gt;
A &#039;&#039;logging class&#039;&#039; specifies how packets matching certain rules are&lt;br /&gt;
logged. A top-level attribute &#039;&#039;&#039;log&#039;&#039;&#039; is a dictionary that maps&lt;br /&gt;
logging class names to setting objects.&lt;br /&gt;
&lt;br /&gt;
A setting object may have an attribute named &#039;&#039;&#039;mode&#039;&#039;&#039;, which&lt;br /&gt;
specifies which logging facility to use. Allowed values are &#039;&#039;&#039;log&#039;&#039;&#039;,&lt;br /&gt;
&#039;&#039;&#039;nflog&#039;&#039;&#039;, and &#039;&#039;&#039;ulog&#039;&#039;&#039;. The default is &#039;&#039;&#039;log&#039;&#039;&#039;, i.e. in-kernel&lt;br /&gt;
logging.&lt;br /&gt;
&lt;br /&gt;
The following table shows the optional attributes valid for all&lt;br /&gt;
logging modes:&lt;br /&gt;
&lt;br /&gt;
{|&lt;br /&gt;
!Attribute!!Description&lt;br /&gt;
|-&lt;br /&gt;
|&#039;&#039;&#039;every&#039;&#039;&#039;&lt;br /&gt;
|Divide successive packets into groups, the size of which is specified by the value of this attribute, and log only the first packet of each group&lt;br /&gt;
|-&lt;br /&gt;
|&#039;&#039;&#039;limit&#039;&#039;&#039;&lt;br /&gt;
|Maximum number of packets to be logged per second per this rule&lt;br /&gt;
|-&lt;br /&gt;
|&#039;&#039;&#039;prefix&#039;&#039;&#039;&lt;br /&gt;
|String with which the log entries are prefixed&lt;br /&gt;
|-&lt;br /&gt;
|&#039;&#039;&#039;probability&#039;&#039;&#039;&lt;br /&gt;
|Probability for logging an individual packet (default: 1)&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
With the in-kernel log mode &#039;&#039;&#039;log&#039;&#039;&#039;, the level of logging may be&lt;br /&gt;
specified using the &#039;&#039;&#039;level&#039;&#039;&#039; attribute. Log modes &#039;&#039;&#039;nflog&#039;&#039;&#039; and&lt;br /&gt;
&#039;&#039;&#039;ulog&#039;&#039;&#039; are about copying the packets into user space, at least&lt;br /&gt;
partially. The following table shows the additional attributes valid&lt;br /&gt;
with these modes:&lt;br /&gt;
&lt;br /&gt;
{|&lt;br /&gt;
!Attribute!!Description&lt;br /&gt;
|-&lt;br /&gt;
|&#039;&#039;&#039;group&#039;&#039;&#039;&lt;br /&gt;
|Netlink group to be used&lt;br /&gt;
|-&lt;br /&gt;
|&#039;&#039;&#039;range&#039;&#039;&#039;&lt;br /&gt;
|Number of bytes to be copied&lt;br /&gt;
|-&lt;br /&gt;
|&#039;&#039;&#039;threshold&#039;&#039;&#039;&lt;br /&gt;
|Number of packets to queue inside the kernel before copying them&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Filter and policy rules can have an attribute named &#039;&#039;&#039;log&#039;&#039;&#039;. If it&lt;br /&gt;
is a string, it is interpreted as a reference to a logging class, and&lt;br /&gt;
logging is performed according to the definitions. If the value of the&lt;br /&gt;
&#039;&#039;&#039;log&#039;&#039;&#039; attribute is &#039;&#039;&#039;true&#039;&#039;&#039; (boolean), logging is done using&lt;br /&gt;
default settings. If the value is &#039;&#039;&#039;false&#039;&#039;&#039; (boolean), logging is&lt;br /&gt;
disabled for the rule. If &#039;&#039;&#039;log&#039;&#039;&#039; is not defined, logging is done&lt;br /&gt;
using the default settings except for accept rules, for which logging&lt;br /&gt;
is omitted.&lt;br /&gt;
&lt;br /&gt;
Default logging settings can be set by defining a logging class named&lt;br /&gt;
&#039;&#039;&#039;_default&#039;&#039;&#039;. Normally, default logging uses the &#039;&#039;&#039;log&#039;&#039;&#039; mode with&lt;br /&gt;
packets limited to one per second.&lt;br /&gt;
&lt;br /&gt;
=== Rules ===&lt;br /&gt;
&lt;br /&gt;
There are several types of rule objects:&lt;br /&gt;
* Filter rules&lt;br /&gt;
* Policy rules&lt;br /&gt;
* Packet Logging rules&lt;br /&gt;
* NAT rules&lt;br /&gt;
* Packet Marking rules&lt;br /&gt;
* Transparent Proxy rules&lt;br /&gt;
* MSS Clamping rules&lt;br /&gt;
* Connection Tracking Bypass rules&lt;br /&gt;
&lt;br /&gt;
All rule objects can have the &#039;&#039;&#039;in&#039;&#039;&#039; and &#039;&#039;&#039;out&#039;&#039;&#039; attributes&lt;br /&gt;
referring to zones as described in the previous section. In addition,&lt;br /&gt;
the scope of the rule can be further constrained with the following&lt;br /&gt;
attributes:&lt;br /&gt;
&lt;br /&gt;
{|&lt;br /&gt;
!Attribute!!Value format!!Effect&lt;br /&gt;
|-&lt;br /&gt;
|&#039;&#039;&#039;src&#039;&#039;&#039;&lt;br /&gt;
|Similar to &#039;&#039;&#039;addr&#039;&#039;&#039; attribute of zone objects&lt;br /&gt;
|Packet&#039;s source address matches the value&lt;br /&gt;
|-&lt;br /&gt;
|&#039;&#039;&#039;dest&#039;&#039;&#039;&lt;br /&gt;
|Similar to &#039;&#039;&#039;addr&#039;&#039;&#039; attribute of zone objects&lt;br /&gt;
|Packet&#039;s destination address matches the value&lt;br /&gt;
|-&lt;br /&gt;
|&#039;&#039;&#039;ipset&#039;&#039;&#039;&lt;br /&gt;
|Object containing two attributes: &#039;&#039;&#039;name&#039;&#039;&#039; referring to an IP set and &#039;&#039;&#039;args&#039;&#039;&#039;, which is a list of strings &#039;&#039;&#039;in&#039;&#039;&#039; and &#039;&#039;&#039;out&#039;&#039;&#039;&lt;br /&gt;
|Packet matches the IP set referred here when the match arguments are taken from the source (&#039;&#039;&#039;in&#039;&#039;&#039;) and destination (&#039;&#039;&#039;out&#039;&#039;&#039;) address or port in the order specified by &#039;&#039;&#039;args&#039;&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
|&#039;&#039;&#039;ipsec&#039;&#039;&#039;&lt;br /&gt;
|&#039;&#039;&#039;in&#039;&#039;&#039; or &#039;&#039;&#039;out&#039;&#039;&#039;&lt;br /&gt;
|IPsec decapsulation perfomed on ingress (&#039;&#039;&#039;in&#039;&#039;&#039;) or encapsulation performed on egress (&#039;&#039;&#039;out&#039;&#039;&#039;)&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Rule objects are declared in type-specific top-level dictionaries in&lt;br /&gt;
awall policy files. If a packet matches multiple rules, the one&lt;br /&gt;
appearing earlier in the list takes precedence. If the matching rules&lt;br /&gt;
are defined in different policy files, the one that was processed&lt;br /&gt;
earlier takes precedence in the current implementation, but this may&lt;br /&gt;
change in future versions.&lt;br /&gt;
&lt;br /&gt;
==== Filter Rules ====&lt;br /&gt;
&lt;br /&gt;
Filter objects specify an action for packets fulfilling certain&lt;br /&gt;
criteria. The top-level attribute &#039;&#039;&#039;filter&#039;&#039;&#039; is a list of filter&lt;br /&gt;
objects. The precedence rules are similar to those of policy objects.&lt;br /&gt;
&lt;br /&gt;
Filter objects must have an attribute named &#039;&#039;&#039;action&#039;&#039;&#039;, the value of&lt;br /&gt;
which can be one of the following:&lt;br /&gt;
&lt;br /&gt;
{|&lt;br /&gt;
!Value!!Action&lt;br /&gt;
|-&lt;br /&gt;
|&#039;&#039;&#039;accept&#039;&#039;&#039;&lt;br /&gt;
|Accept the packet&lt;br /&gt;
|-&lt;br /&gt;
|&#039;&#039;&#039;reject&#039;&#039;&#039;&lt;br /&gt;
|Reject the packet with an ICMP error message&lt;br /&gt;
|-&lt;br /&gt;
|&#039;&#039;&#039;drop&#039;&#039;&#039;&lt;br /&gt;
|Silently drop the packet&lt;br /&gt;
|-&lt;br /&gt;
|&#039;&#039;&#039;tarpit&#039;&#039;&#039;&lt;br /&gt;
|Put incoming TCP connections into persist state and ignore attempts to close them. Silently drop non-TCP packets. (Connection tracking bypass is automatically enabled for the matching packets.)&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Filter objects, the action of which is &#039;&#039;&#039;accept&#039;&#039;&#039;, may also contain&lt;br /&gt;
limits for packet flow or new connections. These are specified with&lt;br /&gt;
the &#039;&#039;&#039;flow-limit&#039;&#039;&#039; and &#039;&#039;&#039;conn-limit&#039;&#039;&#039; attributes,&lt;br /&gt;
respectively. The values of these attributes are limit objects that&lt;br /&gt;
have two attributes: &#039;&#039;&#039;count&#039;&#039;&#039; and &#039;&#039;&#039;interval&#039;&#039;&#039;. &#039;&#039;&#039;count&#039;&#039;&#039;&lt;br /&gt;
specifies how many new connections or packets are allowed within the&lt;br /&gt;
time frame specified by &#039;&#039;&#039;interval&#039;&#039;&#039; in seconds (default: 1). The&lt;br /&gt;
&#039;&#039;&#039;drop&#039;&#039;&#039; action is applied to the packets exceeding the&lt;br /&gt;
limit. Optionally, the limit object may have an attribute named&lt;br /&gt;
&#039;&#039;&#039;log&#039;&#039;&#039;. It defines how the dropped packets should be logged and is&lt;br /&gt;
semantically similar to the &#039;&#039;&#039;log&#039;&#039;&#039; attribute of rule objects. A&lt;br /&gt;
limit may also be specified by a plain integer, which is interpreted&lt;br /&gt;
as the count while using default interval and log settings.&lt;br /&gt;
&lt;br /&gt;
Filter objects may have an attribute named &#039;&#039;&#039;dnat&#039;&#039;&#039;, the value of&lt;br /&gt;
which is an IPv4 address. If defined, this enables destination NAT for&lt;br /&gt;
all IPv4 packets matching the rule, such that the specified address&lt;br /&gt;
replaces the original destination address. This option has no effect&lt;br /&gt;
on IPv6 packets.&lt;br /&gt;
&lt;br /&gt;
Filter objects may have a boolean attribute named &#039;&#039;&#039;no-track&#039;&#039;&#039;. If&lt;br /&gt;
set to &#039;&#039;&#039;true&#039;&#039;&#039;, connection tracking is bypassed for the matching&lt;br /&gt;
packets. In addition, if &#039;&#039;&#039;action&#039;&#039;&#039; is set to &#039;&#039;&#039;accept&#039;&#039;&#039;, the&lt;br /&gt;
corresponding packets travelling to the reverse direction are also&lt;br /&gt;
allowed.&lt;br /&gt;
&lt;br /&gt;
==== Policy Rules ====&lt;br /&gt;
&lt;br /&gt;
Policy objects describe the default action for packets that did not&lt;br /&gt;
match any filter. The top-level attribute &#039;&#039;&#039;policy&#039;&#039;&#039; is a list of&lt;br /&gt;
policy objects.&lt;br /&gt;
&lt;br /&gt;
Policy objects must have the &#039;&#039;&#039;action&#039;&#039;&#039; attribute defined. The&lt;br /&gt;
possible values and their semantics are the same as in filter objects.&lt;br /&gt;
&lt;br /&gt;
==== Packet Logging Rules ====&lt;br /&gt;
&lt;br /&gt;
Packet logging rules allow packets matching the specified criteria to&lt;br /&gt;
be logged before any filtering takes place. Such rules are contained&lt;br /&gt;
in the top-level list named &#039;&#039;&#039;packet-log&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Logging class may be specified using the &#039;&#039;&#039;log&#039;&#039;&#039;&lt;br /&gt;
attribute. Otherwise, default logging settings are used.&lt;br /&gt;
&lt;br /&gt;
==== NAT Rules ====&lt;br /&gt;
&lt;br /&gt;
NAT rules come in two flavors: &#039;&#039;source NAT rules&#039;&#039; and&lt;br /&gt;
&#039;&#039;destination NAT rules&#039;&#039;. These are contained in two top-level lists&lt;br /&gt;
named &#039;&#039;&#039;snat&#039;&#039;&#039; and &#039;&#039;&#039;dnat&#039;&#039;&#039;, respectively.&lt;br /&gt;
&lt;br /&gt;
Each NAT rule may have an attribute named &#039;&#039;&#039;to-addr&#039;&#039;&#039; that&lt;br /&gt;
specifies the IPv4 address range to which the original source or&lt;br /&gt;
destination address is mapped. The value can be a single IPv4 address&lt;br /&gt;
or a range specified by two addresses, separated with the &#039;&#039;&#039;-&#039;&#039;&#039;&lt;br /&gt;
character. If not defined, it defaults to the primary address of the&lt;br /&gt;
ingress interface in case of destination NAT, or that of the egress&lt;br /&gt;
interface in case of source NAT.&lt;br /&gt;
&lt;br /&gt;
Optionally, a NAT rule can specify the TCP and UDP port range to which&lt;br /&gt;
the original source or destination port is mapped. The attribute is&lt;br /&gt;
named &#039;&#039;&#039;to-port&#039;&#039;&#039;, and the value can be a single port number or a&lt;br /&gt;
range specified by two numbers, separated with the &#039;&#039;&#039;-&#039;&#039;&#039;&lt;br /&gt;
character. If &#039;&#039;&#039;to-port&#039;&#039;&#039; is not specified, the original port number&lt;br /&gt;
is kept intact.&lt;br /&gt;
&lt;br /&gt;
NAT rules may have an &#039;&#039;&#039;action&#039;&#039;&#039; attribute set to value&lt;br /&gt;
&#039;&#039;&#039;accept&#039;&#039;&#039;. In this case, NAT is not performed on the packets&lt;br /&gt;
reaching and matching this rule.&lt;br /&gt;
&lt;br /&gt;
==== Packet Marking Rules ====&lt;br /&gt;
&lt;br /&gt;
Packet marking rules are used to mark incoming packets matching the&lt;br /&gt;
specified criteria. The mark can be used as a basis for the routing&lt;br /&gt;
decision. Each marking rule must specify the mark using the &#039;&#039;&#039;mark&#039;&#039;&#039;&lt;br /&gt;
attribute, which is a 32-bit integer.&lt;br /&gt;
&lt;br /&gt;
Normal marking rules are contained by the top-level list attribute&lt;br /&gt;
named &#039;&#039;&#039;mark&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
There is another top-level list attribute, named &#039;&#039;&#039;route-track&#039;&#039;&#039;,&lt;br /&gt;
which contains route tracking rules. These are special marking rules&lt;br /&gt;
which cause all the subsequent packets related to the same connection&lt;br /&gt;
to be marked according to the rule.&lt;br /&gt;
&lt;br /&gt;
==== Transparent Proxy Rules ====&lt;br /&gt;
&lt;br /&gt;
Transparent proxy rules divert the matching packets to a local proxy&lt;br /&gt;
process without altering their headers. Such rules are contained in&lt;br /&gt;
the top-level list named &#039;&#039;&#039;tproxy&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
In addition to the firewall configuration, using a transparent proxy&lt;br /&gt;
requires a routing configuration where packets marked for proxying are&lt;br /&gt;
diverted to a local process. The &#039;&#039;&#039;mark&#039;&#039;&#039; attribute of a proxy rule&lt;br /&gt;
specifies the mark to be used.&lt;br /&gt;
&lt;br /&gt;
Proxy rules may also have an attribute named &#039;&#039;&#039;to-port&#039;&#039;&#039; for&lt;br /&gt;
specifying the TCP or UDP port of the proxy if it is different from&lt;br /&gt;
the original destination port.&lt;br /&gt;
&lt;br /&gt;
==== MSS Clamping Rules ====&lt;br /&gt;
&lt;br /&gt;
MSS Clamping Rules are used to deal with ISPs that block ICMP&lt;br /&gt;
Fragmentation Needed or ICMPv6 Packet Too Big packets. An MSS clamping&lt;br /&gt;
rule overwrites the MSS option with a value specified with the&lt;br /&gt;
&#039;&#039;&#039;mss&#039;&#039;&#039; attribute for the matching TCP connections. If &#039;&#039;&#039;mss&#039;&#039;&#039; is&lt;br /&gt;
not specified, a suitable value is automatically determined from the&lt;br /&gt;
path MTU. The MSS clamping rules are located in the top-level&lt;br /&gt;
dictionary named &#039;&#039;&#039;clamp-mss&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
==== Connection Tracking Bypass Rules ====&lt;br /&gt;
&lt;br /&gt;
Connection tracking bypass rules are used to disable connection&lt;br /&gt;
tracking for packets matching the specified criteria. The top-level&lt;br /&gt;
attribute &#039;&#039;&#039;no-track&#039;&#039;&#039; is a list of such rules.&lt;br /&gt;
&lt;br /&gt;
Connection tracking bypass rules may have an &#039;&#039;&#039;action&#039;&#039;&#039; attribute&lt;br /&gt;
set to value &#039;&#039;&#039;accept&#039;&#039;&#039;. The effect is similar to corresponding NAT&lt;br /&gt;
rules, i.e. connection tracking is not bypassed for the matching&lt;br /&gt;
packets.&lt;br /&gt;
&lt;br /&gt;
=== IP Sets ===&lt;br /&gt;
&lt;br /&gt;
Any IP set referenced by rule objects should be created by&lt;br /&gt;
awall. Auxiliary &#039;&#039;IP set&#039;&#039; objects are used to defined them in awall&lt;br /&gt;
policy files. The top-level attribute &#039;&#039;&#039;ipset&#039;&#039;&#039; is a dictionary, the&lt;br /&gt;
keys of which are IP set names. The values are IP set objects, which&lt;br /&gt;
have two mandatory attributes. The attribute named &#039;&#039;&#039;type&#039;&#039;&#039; &lt;br /&gt;
corresponds to the type argument of the &amp;lt;tt&amp;gt;ipset create&amp;lt;/tt&amp;gt; &lt;br /&gt;
command. &#039;&#039;&#039;family&#039;&#039;&#039; specifies whether the set is for IPv4 or IPv6&lt;br /&gt;
addresses, and the possible values are &#039;&#039;&#039;inet&#039;&#039;&#039; and &#039;&#039;&#039;inet6&#039;&#039;&#039;,&lt;br /&gt;
correspondingly.&lt;br /&gt;
&lt;br /&gt;
For bitmap-type IP sets, the &#039;&#039;&#039;range&#039;&#039;&#039; attribute specifies the&lt;br /&gt;
range of allowed IPv4 addresses. It may be given as a network&lt;br /&gt;
address or two addresses separated by the &#039;&#039;&#039;-&#039;&#039;&#039; character. It&lt;br /&gt;
is not necessary to specify &#039;&#039;&#039;family&#039;&#039;&#039; for bitmaps, since the&lt;br /&gt;
kernel supports only IPv4 bitmaps.&lt;br /&gt;
&lt;br /&gt;
== Command Line Syntax ==&lt;br /&gt;
&lt;br /&gt;
=== Translating Policy Files to Firewall Configuration Files ===&lt;br /&gt;
&lt;br /&gt;
 &#039;&#039;&#039;awall translate&#039;&#039;&#039; [&#039;&#039;&#039;-o&#039;&#039;&#039;|&#039;&#039;&#039;--output&#039;&#039;&#039; DIRECTORY] [&#039;&#039;&#039;-V&#039;&#039;&#039;|&#039;&#039;&#039;--verify&#039;&#039;&#039;]&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;tt&amp;gt;--verify&amp;lt;/tt&amp;gt; option makes awall verify the configuration&lt;br /&gt;
using the test mode of iptables-restore before overwriting the old&lt;br /&gt;
files.&lt;br /&gt;
&lt;br /&gt;
Specifying the output directory allows testing awall policies without&lt;br /&gt;
overwriting the current iptables and ipset configuration files. By&lt;br /&gt;
default, awall generates the configuration to &amp;lt;tt&amp;gt;/etc/iptables&amp;lt;/tt&amp;gt; &lt;br /&gt;
and &amp;lt;tt&amp;gt;/etc/ipset.d&amp;lt;/tt&amp;gt;, which are read by the init scripts.&lt;br /&gt;
&lt;br /&gt;
=== Run-Time Configuration of Firewall ===&lt;br /&gt;
&lt;br /&gt;
 &#039;&#039;&#039;awall activate&#039;&#039;&#039; [&#039;&#039;&#039;-f&#039;&#039;&#039;|&#039;&#039;&#039;--force&#039;&#039;&#039;]&lt;br /&gt;
&lt;br /&gt;
This command genereates firewall configuration from the policy files&lt;br /&gt;
and enables it. If the user confirms the new configuration by hitting&lt;br /&gt;
the Return key within 10 seconds or the &amp;lt;tt&amp;gt;--force&amp;lt;/tt&amp;gt; option is&lt;br /&gt;
used, the configuration is saved to the files. Otherwise, the old&lt;br /&gt;
configuration is restored.&lt;br /&gt;
&lt;br /&gt;
There is also a command for deleting all firewall rules:&lt;br /&gt;
&lt;br /&gt;
 &#039;&#039;&#039;awall flush&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
This command configures the firewall to drop all packets.&lt;br /&gt;
&lt;br /&gt;
=== Optional Policies ===&lt;br /&gt;
&lt;br /&gt;
Optional policies can be enabled or disabled using this command:&lt;br /&gt;
&lt;br /&gt;
 &#039;&#039;&#039;awall&#039;&#039;&#039; {&#039;&#039;&#039;enable&#039;&#039;&#039;|&#039;&#039;&#039;disable&#039;&#039;&#039;} POLICY...&lt;br /&gt;
&lt;br /&gt;
Optional policies can be listed using this command:&lt;br /&gt;
&lt;br /&gt;
 &#039;&#039;&#039;awall list&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;&#039;enabled&#039;&#039;&#039; status means that the policy has been enabled by the&lt;br /&gt;
user. The &#039;&#039;&#039;disabled&#039;&#039;&#039; status means that the policy is not in&lt;br /&gt;
use. The &#039;&#039;&#039;required&#039;&#039;&#039; status means that the policy has not been&lt;br /&gt;
enabled by the user but is in use because it is required by another&lt;br /&gt;
policy which is in use.&lt;br /&gt;
&lt;br /&gt;
=== Debugging Policies ===&lt;br /&gt;
&lt;br /&gt;
This command can be used to dump variable, zone, and other definitions&lt;br /&gt;
as well as their source policies:&lt;br /&gt;
&lt;br /&gt;
 &#039;&#039;&#039;awall dump&#039;&#039;&#039; [LEVEL]&lt;br /&gt;
&lt;br /&gt;
The level is an integer in range 0&amp;amp;ndash;5 and defaults to 0. More&lt;br /&gt;
information is displayed on higher levels.&lt;br /&gt;
&lt;br /&gt;
[[Category:Networking]]&lt;br /&gt;
[[Category:Security]]&lt;/div&gt;</summary>
		<author><name>Kunkku</name></author>
	</entry>
	<entry>
		<id>https://wiki.alpinelinux.org/w/index.php?title=Alpine_Wall_User%27s_Guide&amp;diff=9020</id>
		<title>Alpine Wall User&#039;s Guide</title>
		<link rel="alternate" type="text/html" href="https://wiki.alpinelinux.org/w/index.php?title=Alpine_Wall_User%27s_Guide&amp;diff=9020"/>
		<updated>2013-02-08T07:13:28Z</updated>

		<summary type="html">&lt;p&gt;Kunkku: /* Rules */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Configuration File Processing ==&lt;br /&gt;
&lt;br /&gt;
[[Alpine Wall]] (awall) reads its configuration from multiple&lt;br /&gt;
JSON-formatted files, called &#039;&#039;policy files&#039;&#039;. The processing starts&lt;br /&gt;
from directory &amp;lt;tt&amp;gt;/usr/share/awall/mandatory&amp;lt;/tt&amp;gt;, which contains&lt;br /&gt;
mandatory policy files shipped with APK packages. After that,&lt;br /&gt;
installation-specific policy files in &amp;lt;tt&amp;gt;/etc/awall&amp;lt;/tt&amp;gt; are&lt;br /&gt;
processed.&lt;br /&gt;
&lt;br /&gt;
The latter directory may also contain symbolic links to policy files&lt;br /&gt;
located in &amp;lt;tt&amp;gt;/usr/share/awall/optional&amp;lt;/tt&amp;gt; and&lt;br /&gt;
&amp;lt;tt&amp;gt;/etc/awall/optional&amp;lt;/tt&amp;gt;. These are optional policies, which can&lt;br /&gt;
be enabled on need basis. Such symbolic links are easily created and&lt;br /&gt;
destroyed using the &amp;lt;tt&amp;gt;awall enable&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;awall disable&amp;lt;/tt&amp;gt;&lt;br /&gt;
commands. &amp;lt;tt&amp;gt;awall list&amp;lt;/tt&amp;gt; shows which optional policies are&lt;br /&gt;
enabled and disabled. The command also prints the description of the&lt;br /&gt;
optional policy if defined in the file using a top-level attribute&lt;br /&gt;
named &#039;&#039;&#039;description&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Sometimes a policy file depends on other policy files. In this case,&lt;br /&gt;
the policy file must have a top-level attribute &#039;&#039;&#039;import&#039;&#039;&#039;, the&lt;br /&gt;
value of which is a list of policy names, which correspond to the file&lt;br /&gt;
names without the &amp;lt;tt&amp;gt;.json&amp;lt;/tt&amp;gt; suffix. By default, the policies&lt;br /&gt;
listed there are processed before the importing policy.&lt;br /&gt;
&lt;br /&gt;
The order of the generated iptables rules generally reflects the&lt;br /&gt;
processing order of their corresponding awall policies. The processing&lt;br /&gt;
order of policies can be adjusted by defining top-level attributes&lt;br /&gt;
&#039;&#039;&#039;after&#039;&#039;&#039; and &#039;&#039;&#039;before&#039;&#039;&#039; in policy files. These attributes are&lt;br /&gt;
lists of policies, after or before which the declaring policy shall be&lt;br /&gt;
processed. Putting a policy name to either of these lists does not by&lt;br /&gt;
itself import the policy. The ordering directives are ignored with&lt;br /&gt;
respect to those policies that are not enabled by the user or imported&lt;br /&gt;
by other policies. If not defined, &#039;&#039;&#039;after&#039;&#039;&#039; is assumed to be equal&lt;br /&gt;
to the &#039;&#039;&#039;import&#039;&#039;&#039; definition of the policy.&lt;br /&gt;
&lt;br /&gt;
As the import directive does not require the path name to be&lt;br /&gt;
specified, awall expects policies to have unique names, even if&lt;br /&gt;
located in different directories. It is allowed to import optional&lt;br /&gt;
policies that are not explicitly enabled by the user. Such policies&lt;br /&gt;
show up with the &amp;lt;tt&amp;gt;required&amp;lt;/tt&amp;gt; status in the output of &amp;lt;tt&amp;gt;awall&lt;br /&gt;
list&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
== List Parameters ==&lt;br /&gt;
&lt;br /&gt;
Several awall parameters are defined as lists of values. In order to&lt;br /&gt;
facilitate manual editing of policy files, awall also accepts single&lt;br /&gt;
values in place of lists. Such values are semantically equivalent to&lt;br /&gt;
lists containing one element.&lt;br /&gt;
&lt;br /&gt;
== Variable Expansion ==&lt;br /&gt;
&lt;br /&gt;
Awall allows variable definitions in policy files. The top-level&lt;br /&gt;
attribute &#039;&#039;&#039;variable&#039;&#039;&#039; is a dictionary containing the&lt;br /&gt;
definitions. The value of a variable can be of any type (string,&lt;br /&gt;
integer, list, or dictionary).&lt;br /&gt;
&lt;br /&gt;
A variable is referenced in policy files by a string which equals the&lt;br /&gt;
variable name prepended with the &#039;&#039;&#039;$&#039;&#039;&#039; character. If the value of&lt;br /&gt;
the variable is a string, the reference can be embedded into a longer&lt;br /&gt;
string in order to substitute some part of that string (in shell&lt;br /&gt;
style). Variable references can be used when defining other variables,&lt;br /&gt;
as long as the definitions are not circular.&lt;br /&gt;
&lt;br /&gt;
Policy files can reference variables defined in other policy&lt;br /&gt;
files. Policy files can also override variables defined elsewhere by&lt;br /&gt;
redefining them. In this case, the new definition affects all policy&lt;br /&gt;
files, also those processed before the overriding policy. Awall&lt;br /&gt;
variables are in fact simple macros, since each variable remains&lt;br /&gt;
constant thoughout a single processing round. If multiple files define&lt;br /&gt;
the same variable, the definition in the file processed last takes&lt;br /&gt;
effect.&lt;br /&gt;
&lt;br /&gt;
If defined as an empty string, all non-embedded references to a&lt;br /&gt;
variable evaluate as if the attribute in question was not present in&lt;br /&gt;
the configuration. This is also the case when a string containing&lt;br /&gt;
embedded variable references finally evaluates to an empty string.&lt;br /&gt;
&lt;br /&gt;
== Configuration Objects ==&lt;br /&gt;
&lt;br /&gt;
Configuration objects can be divided into two main types.&lt;br /&gt;
&#039;&#039;Auxiliary objects&#039;&#039; model high-level concepts such as services and&lt;br /&gt;
zones. &#039;&#039;Rule objects&#039;&#039; translate into one or more iptables rules, and&lt;br /&gt;
are often defined with the help of some auxiliary objects.&lt;br /&gt;
&lt;br /&gt;
=== Services ===&lt;br /&gt;
&lt;br /&gt;
A &#039;&#039;service&#039;&#039; represents a set of network protocols. A top-level&lt;br /&gt;
attribute &#039;&#039;&#039;service&#039;&#039;&#039; is a dictionary that maps service names to&lt;br /&gt;
service definition objects, or lists thereof in more complex cases.&lt;br /&gt;
&lt;br /&gt;
A service definition object contains an attribute named &#039;&#039;&#039;proto&#039;&#039;&#039;,&lt;br /&gt;
which corresponds to the &amp;lt;tt&amp;gt;--protocol&amp;lt;/tt&amp;gt; option of iptables. The&lt;br /&gt;
protocol can be defined as a numerical value or string as defined in&lt;br /&gt;
&amp;lt;tt&amp;gt;/etc/protocols&amp;lt;/tt&amp;gt;. If the protocol is &#039;&#039;&#039;tcp&#039;&#039;&#039; or &#039;&#039;&#039;udp&#039;&#039;&#039;,&lt;br /&gt;
the scope of the service definition may be constrained by defining an&lt;br /&gt;
attribute named &#039;&#039;&#039;port&#039;&#039;&#039;, which is a list of TCP or UDP port numbers&lt;br /&gt;
or ranges thereof, separated by the &#039;&#039;&#039;-&#039;&#039;&#039; character. If the protocol&lt;br /&gt;
is &#039;&#039;&#039;icmp&#039;&#039;&#039; or &#039;&#039;&#039;icmpv6&#039;&#039;&#039;, an analogous &#039;&#039;&#039;icmp-type&#039;&#039;&#039; attribute&lt;br /&gt;
may be used. In addition, the scope of the rule is also automatically&lt;br /&gt;
limited to IPv4 or IPv6, respectively.&lt;br /&gt;
&lt;br /&gt;
All rule objects, except for policies, may have an attribute named&lt;br /&gt;
&#039;&#039;&#039;service&#039;&#039;&#039;, constraining the rule&#039;s scope to specific services&lt;br /&gt;
only. This attribute is a list of service names, referring to the keys&lt;br /&gt;
of the top-level service dictionary.&lt;br /&gt;
&lt;br /&gt;
=== Zones ===&lt;br /&gt;
&lt;br /&gt;
A &#039;&#039;zone&#039;&#039; represents a set of network hosts. A top-level attribute &lt;br /&gt;
&#039;&#039;&#039;zone&#039;&#039;&#039; is a dictionary that maps zone names to zone objects. A&lt;br /&gt;
zone object has an attribute named &#039;&#039;&#039;iface&#039;&#039;&#039;, &#039;&#039;&#039;addr&#039;&#039;&#039;, or&lt;br /&gt;
both. &#039;&#039;&#039;iface&#039;&#039;&#039; is a list of network interfaces and &#039;&#039;&#039;addr&#039;&#039;&#039; is a&lt;br /&gt;
list of IPv4/IPv6 host and network addresses (CIDR&lt;br /&gt;
notation). &#039;&#039;&#039;addr&#039;&#039;&#039; may also contain domain names, which are&lt;br /&gt;
expanded to IP addresses using DNS resolution. If not defined,&lt;br /&gt;
&#039;&#039;&#039;addr&#039;&#039;&#039; defaults to the entire address space and &#039;&#039;&#039;iface&#039;&#039;&#039; to all&lt;br /&gt;
interfaces. An empty zone can be defined by setting either &#039;&#039;&#039;addr&#039;&#039;&#039;&lt;br /&gt;
or &#039;&#039;&#039;iface&#039;&#039;&#039; to an empty list.&lt;br /&gt;
&lt;br /&gt;
Rule objects contain two attributes, &#039;&#039;&#039;in&#039;&#039;&#039; and &#039;&#039;&#039;out&#039;&#039;&#039;, which are&lt;br /&gt;
lists of zone names. These attributes control whether a packet matches&lt;br /&gt;
the rule or not. If a particular zone is referenced by the &#039;&#039;&#039;in&#039;&#039;&#039; &lt;br /&gt;
attribute, the rule applies to packets whose ingress interface and&lt;br /&gt;
source address are covered by the zone definition. Correspondingly, if&lt;br /&gt;
a zone is referenced by the &#039;&#039;&#039;out&#039;&#039;&#039; attribute, the rule applies to&lt;br /&gt;
packets whose egress interface and destination address are included in&lt;br /&gt;
the zone. If both &#039;&#039;&#039;in&#039;&#039;&#039; and &#039;&#039;&#039;out&#039;&#039;&#039; are defined, the packet must&lt;br /&gt;
fulfill both criteria in order to match the rule.&lt;br /&gt;
&lt;br /&gt;
The firewall host itself can be referred to using the special value&lt;br /&gt;
&#039;&#039;&#039;_fw&#039;&#039;&#039; as the zone name.&lt;br /&gt;
&lt;br /&gt;
By default, awall does not generate iptables rules with identical&lt;br /&gt;
ingress and egress interfaces. This behavior can be changed per zone&lt;br /&gt;
by setting the optional &#039;&#039;&#039;route-back&#039;&#039;&#039; attribute of the zone to&lt;br /&gt;
&#039;&#039;&#039;true&#039;&#039;&#039;. Note that this attribute can have an effect also in the&lt;br /&gt;
case where &#039;&#039;&#039;in&#039;&#039;&#039; and &#039;&#039;&#039;out&#039;&#039;&#039; attributes of a rule are not equal&lt;br /&gt;
but their definitions overlap. In this case, the &#039;&#039;&#039;route-back&#039;&#039;&#039;&lt;br /&gt;
attribute of the &#039;&#039;&#039;out&#039;&#039;&#039; zone determines the behavior.&lt;br /&gt;
&lt;br /&gt;
=== Logging Classes ===&lt;br /&gt;
&lt;br /&gt;
A &#039;&#039;logging class&#039;&#039; specifies how packets matching certain rules are&lt;br /&gt;
logged. A top-level attribute &#039;&#039;&#039;log&#039;&#039;&#039; is a dictionary that maps&lt;br /&gt;
logging class names to setting objects.&lt;br /&gt;
&lt;br /&gt;
A setting object may have an attribute named &#039;&#039;&#039;mode&#039;&#039;&#039;, which&lt;br /&gt;
specifies which logging facility to use. Allowed values are &#039;&#039;&#039;log&#039;&#039;&#039;,&lt;br /&gt;
&#039;&#039;&#039;nflog&#039;&#039;&#039;, and &#039;&#039;&#039;ulog&#039;&#039;&#039;. The default is &#039;&#039;&#039;log&#039;&#039;&#039;, i.e. in-kernel&lt;br /&gt;
logging.&lt;br /&gt;
&lt;br /&gt;
The following table shows the optional attributes valid for all&lt;br /&gt;
logging modes:&lt;br /&gt;
&lt;br /&gt;
{|&lt;br /&gt;
!Attribute!!Description&lt;br /&gt;
|-&lt;br /&gt;
|&#039;&#039;&#039;every&#039;&#039;&#039;&lt;br /&gt;
|Divide successive packets into groups, the size of which is specified by the value of this attribute, and log only the first packet of each group&lt;br /&gt;
|-&lt;br /&gt;
|&#039;&#039;&#039;limit&#039;&#039;&#039;&lt;br /&gt;
|Maximum number of packets to be logged per second per this rule&lt;br /&gt;
|-&lt;br /&gt;
|&#039;&#039;&#039;prefix&#039;&#039;&#039;&lt;br /&gt;
|String with which the log entries are prefixed&lt;br /&gt;
|-&lt;br /&gt;
|&#039;&#039;&#039;probability&#039;&#039;&#039;&lt;br /&gt;
|Probability for logging an individual packet (default: 1)&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
With the in-kernel log mode &#039;&#039;&#039;log&#039;&#039;&#039;, the level of logging may be&lt;br /&gt;
specified using the &#039;&#039;&#039;level&#039;&#039;&#039; attribute. Log modes &#039;&#039;&#039;nflog&#039;&#039;&#039; and&lt;br /&gt;
&#039;&#039;&#039;ulog&#039;&#039;&#039; are about copying the packets into user space, at least&lt;br /&gt;
partially. The following table shows the additional attributes valid&lt;br /&gt;
with these modes:&lt;br /&gt;
&lt;br /&gt;
{|&lt;br /&gt;
!Attribute!!Description&lt;br /&gt;
|-&lt;br /&gt;
|&#039;&#039;&#039;group&#039;&#039;&#039;&lt;br /&gt;
|Netlink group to be used&lt;br /&gt;
|-&lt;br /&gt;
|&#039;&#039;&#039;range&#039;&#039;&#039;&lt;br /&gt;
|Number of bytes to be copied&lt;br /&gt;
|-&lt;br /&gt;
|&#039;&#039;&#039;threshold&#039;&#039;&#039;&lt;br /&gt;
|Number of packets to queue inside the kernel before copying them&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Filter and policy rules can have an attribute named &#039;&#039;&#039;log&#039;&#039;&#039;. If it&lt;br /&gt;
is a string, it is interpreted as a reference to a logging class, and&lt;br /&gt;
logging is performed according to the definitions. If the value of the&lt;br /&gt;
&#039;&#039;&#039;log&#039;&#039;&#039; attribute is &#039;&#039;&#039;true&#039;&#039;&#039; (boolean), logging is done using&lt;br /&gt;
default settings. If the value is &#039;&#039;&#039;false&#039;&#039;&#039; (boolean), logging is&lt;br /&gt;
disabled for the rule. If &#039;&#039;&#039;log&#039;&#039;&#039; is not defined, logging is done&lt;br /&gt;
using the default settings except for accept rules, for which logging&lt;br /&gt;
is omitted.&lt;br /&gt;
&lt;br /&gt;
Default logging settings can be set by defining a logging class named&lt;br /&gt;
&#039;&#039;&#039;_default&#039;&#039;&#039;. Normally, default logging uses the &#039;&#039;&#039;log&#039;&#039;&#039; mode with&lt;br /&gt;
packets limited to one per second.&lt;br /&gt;
&lt;br /&gt;
=== Rules ===&lt;br /&gt;
&lt;br /&gt;
There are several types of rule objects:&lt;br /&gt;
* Filter rules&lt;br /&gt;
* Policy rules&lt;br /&gt;
* Packet Logging rules&lt;br /&gt;
* NAT rules&lt;br /&gt;
* Packet Marking rules&lt;br /&gt;
* Transparent Proxy rules&lt;br /&gt;
* MSS Clamping rules&lt;br /&gt;
* Connection Tracking Bypass rules&lt;br /&gt;
&lt;br /&gt;
All rule objects can have the &#039;&#039;&#039;in&#039;&#039;&#039; and &#039;&#039;&#039;out&#039;&#039;&#039; attributes&lt;br /&gt;
referring to zones as described in the previous section. In addition,&lt;br /&gt;
the scope of the rule can be further constrained with the following&lt;br /&gt;
attributes:&lt;br /&gt;
&lt;br /&gt;
{|&lt;br /&gt;
!Attribute!!Value format!!Effect&lt;br /&gt;
|-&lt;br /&gt;
|&#039;&#039;&#039;src&#039;&#039;&#039;&lt;br /&gt;
|Similar to &#039;&#039;&#039;addr&#039;&#039;&#039; attribute of zone objects&lt;br /&gt;
|Packet&#039;s source address matches the value&lt;br /&gt;
|-&lt;br /&gt;
|&#039;&#039;&#039;dest&#039;&#039;&#039;&lt;br /&gt;
|Similar to &#039;&#039;&#039;addr&#039;&#039;&#039; attribute of zone objects&lt;br /&gt;
|Packet&#039;s destination address matches the value&lt;br /&gt;
|-&lt;br /&gt;
|&#039;&#039;&#039;ipset&#039;&#039;&#039;&lt;br /&gt;
|Object containing two attributes: &#039;&#039;&#039;name&#039;&#039;&#039; referring to an IP set and &#039;&#039;&#039;args&#039;&#039;&#039;, which is a list of strings &#039;&#039;&#039;in&#039;&#039;&#039; and &#039;&#039;&#039;out&#039;&#039;&#039;&lt;br /&gt;
|Packet matches the IP set referred here when the match arguments are taken from the source (&#039;&#039;&#039;in&#039;&#039;&#039;) and destination (&#039;&#039;&#039;out&#039;&#039;&#039;) address or port in the order specified by &#039;&#039;&#039;args&#039;&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
|&#039;&#039;&#039;ipsec&#039;&#039;&#039;&lt;br /&gt;
|&#039;&#039;&#039;in&#039;&#039;&#039; or &#039;&#039;&#039;out&#039;&#039;&#039;&lt;br /&gt;
|IPsec decapsulation perfomed on ingress (&#039;&#039;&#039;in&#039;&#039;&#039;) or encapsulation performed on egress (&#039;&#039;&#039;out&#039;&#039;&#039;)&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Rule objects are declared in type-specific top-level dictionaries in&lt;br /&gt;
awall policy files. If a packet matches multiple rules, the one&lt;br /&gt;
appearing earlier in the list takes precedence. If the matching rules&lt;br /&gt;
are defined in different policy files, the one that was processed&lt;br /&gt;
earlier takes precedence in the current implementation, but this may&lt;br /&gt;
change in future versions.&lt;br /&gt;
&lt;br /&gt;
==== Filter Rules ====&lt;br /&gt;
&lt;br /&gt;
Filter objects specify an action for packets fulfilling certain&lt;br /&gt;
criteria. The top-level attribute &#039;&#039;&#039;filter&#039;&#039;&#039; is a list of filter&lt;br /&gt;
objects. The precedence rules are similar to those of policy objects.&lt;br /&gt;
&lt;br /&gt;
Filter objects must have an attribute named &#039;&#039;&#039;action&#039;&#039;&#039;, the value of&lt;br /&gt;
which can be one of the following:&lt;br /&gt;
&lt;br /&gt;
{|&lt;br /&gt;
!Value!!Action&lt;br /&gt;
|-&lt;br /&gt;
|&#039;&#039;&#039;accept&#039;&#039;&#039;&lt;br /&gt;
|Accept the packet&lt;br /&gt;
|-&lt;br /&gt;
|&#039;&#039;&#039;reject&#039;&#039;&#039;&lt;br /&gt;
|Reject the packet with an ICMP error message&lt;br /&gt;
|-&lt;br /&gt;
|&#039;&#039;&#039;drop&#039;&#039;&#039;&lt;br /&gt;
|Silently drop the packet&lt;br /&gt;
|-&lt;br /&gt;
|&#039;&#039;&#039;tarpit&#039;&#039;&#039;&lt;br /&gt;
|Put incoming TCP connections into persist state and ignore attempts to close them. Silently drop non-TCP packets. (Connection tracking bypass is automatically enabled for the matching packets.)&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Filter objects, the action of which is &#039;&#039;&#039;accept&#039;&#039;&#039;, may also contain&lt;br /&gt;
limits for packet flow or new connections. These are specified with&lt;br /&gt;
the &#039;&#039;&#039;flow-limit&#039;&#039;&#039; and &#039;&#039;&#039;conn-limit&#039;&#039;&#039; attributes,&lt;br /&gt;
respectively. The values of these attributes are limit objects that&lt;br /&gt;
have two attributes: &#039;&#039;&#039;count&#039;&#039;&#039; and &#039;&#039;&#039;interval&#039;&#039;&#039;. &#039;&#039;&#039;count&#039;&#039;&#039;&lt;br /&gt;
specifies how many new connections or packets are allowed within the&lt;br /&gt;
time frame specified by &#039;&#039;&#039;interval&#039;&#039;&#039; in seconds (default: 1). The&lt;br /&gt;
&#039;&#039;&#039;drop&#039;&#039;&#039; action is applied to the packets exceeding the&lt;br /&gt;
limit. Optionally, the limit object may have an attribute named&lt;br /&gt;
&#039;&#039;&#039;log&#039;&#039;&#039;. It defines how the dropped packets should be logged and is&lt;br /&gt;
semantically similar to the &#039;&#039;&#039;log&#039;&#039;&#039; attribute of rule objects. A&lt;br /&gt;
limit may also be specified by a plain integer, which is interpreted&lt;br /&gt;
as the count while using default interval and log settings.&lt;br /&gt;
&lt;br /&gt;
Filter objects may have an attribute named &#039;&#039;&#039;dnat&#039;&#039;&#039;, the value of&lt;br /&gt;
which is an IPv4 address. If defined, this enables destination NAT for&lt;br /&gt;
all IPv4 packets matching the rule, such that the specified address&lt;br /&gt;
replaces the original destination address. This option has no effect&lt;br /&gt;
on IPv6 packets.&lt;br /&gt;
&lt;br /&gt;
Filter objects may have a boolean attribute named &#039;&#039;&#039;no-track&#039;&#039;&#039;. If&lt;br /&gt;
set to &#039;&#039;&#039;true&#039;&#039;&#039;, connection tracking is bypassed for the matching&lt;br /&gt;
packets. In addition, if &#039;&#039;&#039;action&#039;&#039;&#039; is set to &#039;&#039;&#039;accept&#039;&#039;&#039;, the&lt;br /&gt;
corresponding packets travelling to the reverse direction are also&lt;br /&gt;
allowed.&lt;br /&gt;
&lt;br /&gt;
==== Policy Rules ====&lt;br /&gt;
&lt;br /&gt;
Policy objects describe the default action for packets that did not&lt;br /&gt;
match any filter. The top-level attribute &#039;&#039;&#039;policy&#039;&#039;&#039; is a list of&lt;br /&gt;
policy objects.&lt;br /&gt;
&lt;br /&gt;
Policy objects must have the &#039;&#039;&#039;action&#039;&#039;&#039; attribute defined. The&lt;br /&gt;
possible values and their semantics are the same as in filter objects.&lt;br /&gt;
&lt;br /&gt;
==== Packet Logging Rules ====&lt;br /&gt;
&lt;br /&gt;
Packet logging rules allow packets matching the specified criteria to&lt;br /&gt;
be logged before any filtering takes place. Such rules are contained&lt;br /&gt;
in the top-level list named &#039;&#039;&#039;packet-log&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Logging class may be specified using the &#039;&#039;&#039;log&#039;&#039;&#039;&lt;br /&gt;
attribute. Otherwise, default logging settings are used.&lt;br /&gt;
&lt;br /&gt;
==== NAT Rules ====&lt;br /&gt;
&lt;br /&gt;
NAT rules come in two flavors: &#039;&#039;source NAT rules&#039;&#039; and&lt;br /&gt;
&#039;&#039;destination NAT rules&#039;&#039;. These are contained in two top-level lists&lt;br /&gt;
named &#039;&#039;&#039;snat&#039;&#039;&#039; and &#039;&#039;&#039;dnat&#039;&#039;&#039;, respectively.&lt;br /&gt;
&lt;br /&gt;
Each NAT rule may have an attribute named &#039;&#039;&#039;to-addr&#039;&#039;&#039; that&lt;br /&gt;
specifies the IPv4 address range to which the original source or&lt;br /&gt;
destination address is mapped. The value can be a single IPv4 address&lt;br /&gt;
or a range specified by two addresses, separated with the &#039;&#039;&#039;-&#039;&#039;&#039;&lt;br /&gt;
character. If not defined, it defaults to the primary address of the&lt;br /&gt;
ingress interface in case of destination NAT, or that of the egress&lt;br /&gt;
interface in case of source NAT.&lt;br /&gt;
&lt;br /&gt;
Optionally, a NAT rule can specify the TCP and UDP port range to which&lt;br /&gt;
the original source or destination port is mapped. The attribute is&lt;br /&gt;
named &#039;&#039;&#039;to-port&#039;&#039;&#039;, and the value can be a single port number or a&lt;br /&gt;
range specified by two numbers, separated with the &#039;&#039;&#039;-&#039;&#039;&#039;&lt;br /&gt;
character. If &#039;&#039;&#039;to-port&#039;&#039;&#039; is not specified, the original port number&lt;br /&gt;
is kept intact.&lt;br /&gt;
&lt;br /&gt;
NAT rules may have an &#039;&#039;&#039;action&#039;&#039;&#039; attribute set to value&lt;br /&gt;
&#039;&#039;&#039;accept&#039;&#039;&#039;. In this case, NAT is not performed on the packets&lt;br /&gt;
reaching and matching this rule.&lt;br /&gt;
&lt;br /&gt;
==== Packet Marking Rules ====&lt;br /&gt;
&lt;br /&gt;
Packet marking rules are used to mark incoming packets matching the&lt;br /&gt;
specified criteria. The mark can be used as a basis for the routing&lt;br /&gt;
decision. Each marking rule must specify the mark using the &#039;&#039;&#039;mark&#039;&#039;&#039;&lt;br /&gt;
attribute, which is a 32-bit integer.&lt;br /&gt;
&lt;br /&gt;
Normal marking rules are contained by the top-level list attribute&lt;br /&gt;
named &#039;&#039;&#039;mark&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
There is another top-level list attribute, named &#039;&#039;&#039;route-track&#039;&#039;&#039;,&lt;br /&gt;
which contains route tracking rules. These are special marking rules&lt;br /&gt;
which cause all the subsequent packets related to the same connection&lt;br /&gt;
to be marked according to the rule.&lt;br /&gt;
&lt;br /&gt;
==== Transparent Proxy Rules ====&lt;br /&gt;
&lt;br /&gt;
Transparent proxy rules divert the matching packets to a local proxy&lt;br /&gt;
process without altering their headers. Such rules are contained in&lt;br /&gt;
the top-level list named &#039;&#039;&#039;tproxy&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
In addition to the firewall configuration, using a transparent proxy&lt;br /&gt;
requires a routing configuration where packets marked for proxying are&lt;br /&gt;
diverted to a local process. The &#039;&#039;&#039;mark&#039;&#039;&#039; attribute of a proxy rule&lt;br /&gt;
specifies the mark to be used.&lt;br /&gt;
&lt;br /&gt;
Proxy rules may also have an attribute named &#039;&#039;&#039;to-port&#039;&#039;&#039; for&lt;br /&gt;
specifying the TCP or UDP port of the proxy if it is different from&lt;br /&gt;
the original destination port.&lt;br /&gt;
&lt;br /&gt;
==== MSS Clamping Rules ====&lt;br /&gt;
&lt;br /&gt;
MSS Clamping Rules are used to deal with ISPs that block ICMP&lt;br /&gt;
Fragmentation Needed or ICMPv6 Packet Too Big packets. An MSS clamping&lt;br /&gt;
rule overwrites the MSS option with a value specified with the&lt;br /&gt;
&#039;&#039;&#039;mss&#039;&#039;&#039; attribute for the matching TCP connections. If &#039;&#039;&#039;mss&#039;&#039;&#039; is&lt;br /&gt;
not specified, a suitable value is automatically determined from the&lt;br /&gt;
path MTU. The MSS clamping rules are located in the top-level&lt;br /&gt;
dictionary named &#039;&#039;&#039;clamp-mss&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
==== Connection Tracking Bypass Rules ====&lt;br /&gt;
&lt;br /&gt;
Connection tracking bypass rules are used to disable connection&lt;br /&gt;
tracking for packets matching the specified criteria. The top-level&lt;br /&gt;
attribute &#039;&#039;&#039;no-track&#039;&#039;&#039; is a list of such rules.&lt;br /&gt;
&lt;br /&gt;
Connection tracking bypass rules may have an &#039;&#039;&#039;action&#039;&#039;&#039; attribute&lt;br /&gt;
set to value &#039;&#039;&#039;accept&#039;&#039;&#039;. The effect is similar to corresponding NAT&lt;br /&gt;
rules, i.e. connection tracking is not bypassed for the matching&lt;br /&gt;
packets.&lt;br /&gt;
&lt;br /&gt;
=== IP Sets ===&lt;br /&gt;
&lt;br /&gt;
Any IP set referenced by rule objects should be created by&lt;br /&gt;
awall. Auxiliary &#039;&#039;IP set&#039;&#039; objects are used to defined them in awall&lt;br /&gt;
policy files. The top-level attribute &#039;&#039;&#039;ipset&#039;&#039;&#039; is a dictionary, the&lt;br /&gt;
keys of which are IP set names. The values are IP set objects, which&lt;br /&gt;
have two mandatory attributes. The attribute named &#039;&#039;&#039;type&#039;&#039;&#039; &lt;br /&gt;
corresponds to the type argument of the &amp;lt;tt&amp;gt;ipset create&amp;lt;/tt&amp;gt; &lt;br /&gt;
command. &#039;&#039;&#039;family&#039;&#039;&#039; specifies whether the set is for IPv4 or IPv6&lt;br /&gt;
addresses, and the possible values are &#039;&#039;&#039;inet&#039;&#039;&#039; and &#039;&#039;&#039;inet6&#039;&#039;&#039;,&lt;br /&gt;
correspondingly.&lt;br /&gt;
&lt;br /&gt;
For bitmap-type IP sets, the &#039;&#039;&#039;range&#039;&#039;&#039; attribute specifies the&lt;br /&gt;
range of allowed IPv4 addresses. It may be given as a network&lt;br /&gt;
address or two addresses separated by the &#039;&#039;&#039;-&#039;&#039;&#039; character. It&lt;br /&gt;
is not necessary to specify &#039;&#039;&#039;family&#039;&#039;&#039; for bitmaps, since the&lt;br /&gt;
kernel supports only IPv4 bitmaps.&lt;br /&gt;
&lt;br /&gt;
== Command Line Syntax ==&lt;br /&gt;
&lt;br /&gt;
=== Translating Policy Files to Firewall Configuration Files ===&lt;br /&gt;
&lt;br /&gt;
 &#039;&#039;&#039;awall translate&#039;&#039;&#039; [&#039;&#039;&#039;-o&#039;&#039;&#039;|&#039;&#039;&#039;--output&#039;&#039;&#039; DIRECTORY] [&#039;&#039;&#039;-V&#039;&#039;&#039;|&#039;&#039;&#039;--verify&#039;&#039;&#039;]&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;tt&amp;gt;--verify&amp;lt;/tt&amp;gt; option makes awall verify the configuration&lt;br /&gt;
using the test mode of iptables-restore before overwriting the old&lt;br /&gt;
files.&lt;br /&gt;
&lt;br /&gt;
Specifying the output directory allows testing awall policies without&lt;br /&gt;
overwriting the current iptables and ipset configuration files. By&lt;br /&gt;
default, awall generates the configuration to &amp;lt;tt&amp;gt;/etc/iptables&amp;lt;/tt&amp;gt; &lt;br /&gt;
and &amp;lt;tt&amp;gt;/etc/ipset.d&amp;lt;/tt&amp;gt;, which are read by the init scripts.&lt;br /&gt;
&lt;br /&gt;
=== Run-Time Configuration of Firewall ===&lt;br /&gt;
&lt;br /&gt;
 &#039;&#039;&#039;awall activate&#039;&#039;&#039; [&#039;&#039;&#039;-f&#039;&#039;&#039;|&#039;&#039;&#039;--force&#039;&#039;&#039;]&lt;br /&gt;
&lt;br /&gt;
This command genereates firewall configuration from the policy files&lt;br /&gt;
and enables it. If the user confirms the new configuration by hitting&lt;br /&gt;
the Return key within 10 seconds or the &amp;lt;tt&amp;gt;--force&amp;lt;/tt&amp;gt; option is&lt;br /&gt;
used, the configuration is saved to the files. Otherwise, the old&lt;br /&gt;
configuration is restored.&lt;br /&gt;
&lt;br /&gt;
There is also a command for deleting all firewall rules:&lt;br /&gt;
&lt;br /&gt;
 &#039;&#039;&#039;awall flush&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
This command configures the firewall to drop all packets.&lt;br /&gt;
&lt;br /&gt;
=== Optional Policies ===&lt;br /&gt;
&lt;br /&gt;
Optional policies can be enabled or disabled using this command:&lt;br /&gt;
&lt;br /&gt;
 &#039;&#039;&#039;awall&#039;&#039;&#039; {&#039;&#039;&#039;enable&#039;&#039;&#039;|&#039;&#039;&#039;disable&#039;&#039;&#039;} POLICY...&lt;br /&gt;
&lt;br /&gt;
Optional policies can be listed using this command:&lt;br /&gt;
&lt;br /&gt;
 &#039;&#039;&#039;awall list&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;&#039;enabled&#039;&#039;&#039; status means that the policy has been enabled by the&lt;br /&gt;
user. The &#039;&#039;&#039;disabled&#039;&#039;&#039; status means that the policy is not in&lt;br /&gt;
use. The &#039;&#039;&#039;required&#039;&#039;&#039; status means that the policy has not been&lt;br /&gt;
enabled by the user but is in use because it is required by another&lt;br /&gt;
policy which is in use.&lt;br /&gt;
&lt;br /&gt;
=== Debugging Policies ===&lt;br /&gt;
&lt;br /&gt;
This command can be used to dump variable, zone, and other definitions&lt;br /&gt;
as well as their source policies:&lt;br /&gt;
&lt;br /&gt;
 &#039;&#039;&#039;awall dump&#039;&#039;&#039; [LEVEL]&lt;br /&gt;
&lt;br /&gt;
The level is an integer in range 0&amp;amp;ndash;5 and defaults to 0. More&lt;br /&gt;
information is displayed on higher levels.&lt;br /&gt;
&lt;br /&gt;
[[Category:Networking]]&lt;br /&gt;
[[Category:Security]]&lt;/div&gt;</summary>
		<author><name>Kunkku</name></author>
	</entry>
	<entry>
		<id>https://wiki.alpinelinux.org/w/index.php?title=Alpine_Wall_User%27s_Guide&amp;diff=9019</id>
		<title>Alpine Wall User&#039;s Guide</title>
		<link rel="alternate" type="text/html" href="https://wiki.alpinelinux.org/w/index.php?title=Alpine_Wall_User%27s_Guide&amp;diff=9019"/>
		<updated>2013-02-05T16:10:39Z</updated>

		<summary type="html">&lt;p&gt;Kunkku: /* Rules */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Configuration File Processing ==&lt;br /&gt;
&lt;br /&gt;
[[Alpine Wall]] (awall) reads its configuration from multiple&lt;br /&gt;
JSON-formatted files, called &#039;&#039;policy files&#039;&#039;. The processing starts&lt;br /&gt;
from directory &amp;lt;tt&amp;gt;/usr/share/awall/mandatory&amp;lt;/tt&amp;gt;, which contains&lt;br /&gt;
mandatory policy files shipped with APK packages. After that,&lt;br /&gt;
installation-specific policy files in &amp;lt;tt&amp;gt;/etc/awall&amp;lt;/tt&amp;gt; are&lt;br /&gt;
processed.&lt;br /&gt;
&lt;br /&gt;
The latter directory may also contain symbolic links to policy files&lt;br /&gt;
located in &amp;lt;tt&amp;gt;/usr/share/awall/optional&amp;lt;/tt&amp;gt; and&lt;br /&gt;
&amp;lt;tt&amp;gt;/etc/awall/optional&amp;lt;/tt&amp;gt;. These are optional policies, which can&lt;br /&gt;
be enabled on need basis. Such symbolic links are easily created and&lt;br /&gt;
destroyed using the &amp;lt;tt&amp;gt;awall enable&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;awall disable&amp;lt;/tt&amp;gt;&lt;br /&gt;
commands. &amp;lt;tt&amp;gt;awall list&amp;lt;/tt&amp;gt; shows which optional policies are&lt;br /&gt;
enabled and disabled. The command also prints the description of the&lt;br /&gt;
optional policy if defined in the file using a top-level attribute&lt;br /&gt;
named &#039;&#039;&#039;description&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Sometimes a policy file depends on other policy files. In this case,&lt;br /&gt;
the policy file must have a top-level attribute &#039;&#039;&#039;import&#039;&#039;&#039;, the&lt;br /&gt;
value of which is a list of policy names, which correspond to the file&lt;br /&gt;
names without the &amp;lt;tt&amp;gt;.json&amp;lt;/tt&amp;gt; suffix. By default, the policies&lt;br /&gt;
listed there are processed before the importing policy.&lt;br /&gt;
&lt;br /&gt;
The order of the generated iptables rules generally reflects the&lt;br /&gt;
processing order of their corresponding awall policies. The processing&lt;br /&gt;
order of policies can be adjusted by defining top-level attributes&lt;br /&gt;
&#039;&#039;&#039;after&#039;&#039;&#039; and &#039;&#039;&#039;before&#039;&#039;&#039; in policy files. These attributes are&lt;br /&gt;
lists of policies, after or before which the declaring policy shall be&lt;br /&gt;
processed. Putting a policy name to either of these lists does not by&lt;br /&gt;
itself import the policy. The ordering directives are ignored with&lt;br /&gt;
respect to those policies that are not enabled by the user or imported&lt;br /&gt;
by other policies. If not defined, &#039;&#039;&#039;after&#039;&#039;&#039; is assumed to be equal&lt;br /&gt;
to the &#039;&#039;&#039;import&#039;&#039;&#039; definition of the policy.&lt;br /&gt;
&lt;br /&gt;
As the import directive does not require the path name to be&lt;br /&gt;
specified, awall expects policies to have unique names, even if&lt;br /&gt;
located in different directories. It is allowed to import optional&lt;br /&gt;
policies that are not explicitly enabled by the user. Such policies&lt;br /&gt;
show up with the &amp;lt;tt&amp;gt;required&amp;lt;/tt&amp;gt; status in the output of &amp;lt;tt&amp;gt;awall&lt;br /&gt;
list&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
== List Parameters ==&lt;br /&gt;
&lt;br /&gt;
Several awall parameters are defined as lists of values. In order to&lt;br /&gt;
facilitate manual editing of policy files, awall also accepts single&lt;br /&gt;
values in place of lists. Such values are semantically equivalent to&lt;br /&gt;
lists containing one element.&lt;br /&gt;
&lt;br /&gt;
== Variable Expansion ==&lt;br /&gt;
&lt;br /&gt;
Awall allows variable definitions in policy files. The top-level&lt;br /&gt;
attribute &#039;&#039;&#039;variable&#039;&#039;&#039; is a dictionary containing the&lt;br /&gt;
definitions. The value of a variable can be of any type (string,&lt;br /&gt;
integer, list, or dictionary).&lt;br /&gt;
&lt;br /&gt;
A variable is referenced in policy files by a string which equals the&lt;br /&gt;
variable name prepended with the &#039;&#039;&#039;$&#039;&#039;&#039; character. If the value of&lt;br /&gt;
the variable is a string, the reference can be embedded into a longer&lt;br /&gt;
string in order to substitute some part of that string (in shell&lt;br /&gt;
style). Variable references can be used when defining other variables,&lt;br /&gt;
as long as the definitions are not circular.&lt;br /&gt;
&lt;br /&gt;
Policy files can reference variables defined in other policy&lt;br /&gt;
files. Policy files can also override variables defined elsewhere by&lt;br /&gt;
redefining them. In this case, the new definition affects all policy&lt;br /&gt;
files, also those processed before the overriding policy. Awall&lt;br /&gt;
variables are in fact simple macros, since each variable remains&lt;br /&gt;
constant thoughout a single processing round. If multiple files define&lt;br /&gt;
the same variable, the definition in the file processed last takes&lt;br /&gt;
effect.&lt;br /&gt;
&lt;br /&gt;
If defined as an empty string, all non-embedded references to a&lt;br /&gt;
variable evaluate as if the attribute in question was not present in&lt;br /&gt;
the configuration. This is also the case when a string containing&lt;br /&gt;
embedded variable references finally evaluates to an empty string.&lt;br /&gt;
&lt;br /&gt;
== Configuration Objects ==&lt;br /&gt;
&lt;br /&gt;
Configuration objects can be divided into two main types.&lt;br /&gt;
&#039;&#039;Auxiliary objects&#039;&#039; model high-level concepts such as services and&lt;br /&gt;
zones. &#039;&#039;Rule objects&#039;&#039; translate into one or more iptables rules, and&lt;br /&gt;
are often defined with the help of some auxiliary objects.&lt;br /&gt;
&lt;br /&gt;
=== Services ===&lt;br /&gt;
&lt;br /&gt;
A &#039;&#039;service&#039;&#039; represents a set of network protocols. A top-level&lt;br /&gt;
attribute &#039;&#039;&#039;service&#039;&#039;&#039; is a dictionary that maps service names to&lt;br /&gt;
service definition objects, or lists thereof in more complex cases.&lt;br /&gt;
&lt;br /&gt;
A service definition object contains an attribute named &#039;&#039;&#039;proto&#039;&#039;&#039;,&lt;br /&gt;
which corresponds to the &amp;lt;tt&amp;gt;--protocol&amp;lt;/tt&amp;gt; option of iptables. The&lt;br /&gt;
protocol can be defined as a numerical value or string as defined in&lt;br /&gt;
&amp;lt;tt&amp;gt;/etc/protocols&amp;lt;/tt&amp;gt;. If the protocol is &#039;&#039;&#039;tcp&#039;&#039;&#039; or &#039;&#039;&#039;udp&#039;&#039;&#039;,&lt;br /&gt;
the scope of the service definition may be constrained by defining an&lt;br /&gt;
attribute named &#039;&#039;&#039;port&#039;&#039;&#039;, which is a list of TCP or UDP port numbers&lt;br /&gt;
or ranges thereof, separated by the &#039;&#039;&#039;-&#039;&#039;&#039; character. If the protocol&lt;br /&gt;
is &#039;&#039;&#039;icmp&#039;&#039;&#039; or &#039;&#039;&#039;icmpv6&#039;&#039;&#039;, an analogous &#039;&#039;&#039;icmp-type&#039;&#039;&#039; attribute&lt;br /&gt;
may be used. In addition, the scope of the rule is also automatically&lt;br /&gt;
limited to IPv4 or IPv6, respectively.&lt;br /&gt;
&lt;br /&gt;
All rule objects, except for policies, may have an attribute named&lt;br /&gt;
&#039;&#039;&#039;service&#039;&#039;&#039;, constraining the rule&#039;s scope to specific services&lt;br /&gt;
only. This attribute is a list of service names, referring to the keys&lt;br /&gt;
of the top-level service dictionary.&lt;br /&gt;
&lt;br /&gt;
=== Zones ===&lt;br /&gt;
&lt;br /&gt;
A &#039;&#039;zone&#039;&#039; represents a set of network hosts. A top-level attribute &lt;br /&gt;
&#039;&#039;&#039;zone&#039;&#039;&#039; is a dictionary that maps zone names to zone objects. A&lt;br /&gt;
zone object has an attribute named &#039;&#039;&#039;iface&#039;&#039;&#039;, &#039;&#039;&#039;addr&#039;&#039;&#039;, or&lt;br /&gt;
both. &#039;&#039;&#039;iface&#039;&#039;&#039; is a list of network interfaces and &#039;&#039;&#039;addr&#039;&#039;&#039; is a&lt;br /&gt;
list of IPv4/IPv6 host and network addresses (CIDR&lt;br /&gt;
notation). &#039;&#039;&#039;addr&#039;&#039;&#039; may also contain domain names, which are&lt;br /&gt;
expanded to IP addresses using DNS resolution. If not defined,&lt;br /&gt;
&#039;&#039;&#039;addr&#039;&#039;&#039; defaults to the entire address space and &#039;&#039;&#039;iface&#039;&#039;&#039; to all&lt;br /&gt;
interfaces. An empty zone can be defined by setting either &#039;&#039;&#039;addr&#039;&#039;&#039;&lt;br /&gt;
or &#039;&#039;&#039;iface&#039;&#039;&#039; to an empty list.&lt;br /&gt;
&lt;br /&gt;
Rule objects contain two attributes, &#039;&#039;&#039;in&#039;&#039;&#039; and &#039;&#039;&#039;out&#039;&#039;&#039;, which are&lt;br /&gt;
lists of zone names. These attributes control whether a packet matches&lt;br /&gt;
the rule or not. If a particular zone is referenced by the &#039;&#039;&#039;in&#039;&#039;&#039; &lt;br /&gt;
attribute, the rule applies to packets whose ingress interface and&lt;br /&gt;
source address are covered by the zone definition. Correspondingly, if&lt;br /&gt;
a zone is referenced by the &#039;&#039;&#039;out&#039;&#039;&#039; attribute, the rule applies to&lt;br /&gt;
packets whose egress interface and destination address are included in&lt;br /&gt;
the zone. If both &#039;&#039;&#039;in&#039;&#039;&#039; and &#039;&#039;&#039;out&#039;&#039;&#039; are defined, the packet must&lt;br /&gt;
fulfill both criteria in order to match the rule.&lt;br /&gt;
&lt;br /&gt;
The firewall host itself can be referred to using the special value&lt;br /&gt;
&#039;&#039;&#039;_fw&#039;&#039;&#039; as the zone name.&lt;br /&gt;
&lt;br /&gt;
By default, awall does not generate iptables rules with identical&lt;br /&gt;
ingress and egress interfaces. This behavior can be changed per zone&lt;br /&gt;
by setting the optional &#039;&#039;&#039;route-back&#039;&#039;&#039; attribute of the zone to&lt;br /&gt;
&#039;&#039;&#039;true&#039;&#039;&#039;. Note that this attribute can have an effect also in the&lt;br /&gt;
case where &#039;&#039;&#039;in&#039;&#039;&#039; and &#039;&#039;&#039;out&#039;&#039;&#039; attributes of a rule are not equal&lt;br /&gt;
but their definitions overlap. In this case, the &#039;&#039;&#039;route-back&#039;&#039;&#039;&lt;br /&gt;
attribute of the &#039;&#039;&#039;out&#039;&#039;&#039; zone determines the behavior.&lt;br /&gt;
&lt;br /&gt;
=== Logging Classes ===&lt;br /&gt;
&lt;br /&gt;
A &#039;&#039;logging class&#039;&#039; specifies how packets matching certain rules are&lt;br /&gt;
logged. A top-level attribute &#039;&#039;&#039;log&#039;&#039;&#039; is a dictionary that maps&lt;br /&gt;
logging class names to setting objects.&lt;br /&gt;
&lt;br /&gt;
A setting object may have an attribute named &#039;&#039;&#039;mode&#039;&#039;&#039;, which&lt;br /&gt;
specifies which logging facility to use. Allowed values are &#039;&#039;&#039;log&#039;&#039;&#039;,&lt;br /&gt;
&#039;&#039;&#039;nflog&#039;&#039;&#039;, and &#039;&#039;&#039;ulog&#039;&#039;&#039;. The default is &#039;&#039;&#039;log&#039;&#039;&#039;, i.e. in-kernel&lt;br /&gt;
logging.&lt;br /&gt;
&lt;br /&gt;
The following table shows the optional attributes valid for all&lt;br /&gt;
logging modes:&lt;br /&gt;
&lt;br /&gt;
{|&lt;br /&gt;
!Attribute!!Description&lt;br /&gt;
|-&lt;br /&gt;
|&#039;&#039;&#039;every&#039;&#039;&#039;&lt;br /&gt;
|Divide successive packets into groups, the size of which is specified by the value of this attribute, and log only the first packet of each group&lt;br /&gt;
|-&lt;br /&gt;
|&#039;&#039;&#039;limit&#039;&#039;&#039;&lt;br /&gt;
|Maximum number of packets to be logged per second per this rule&lt;br /&gt;
|-&lt;br /&gt;
|&#039;&#039;&#039;prefix&#039;&#039;&#039;&lt;br /&gt;
|String with which the log entries are prefixed&lt;br /&gt;
|-&lt;br /&gt;
|&#039;&#039;&#039;probability&#039;&#039;&#039;&lt;br /&gt;
|Probability for logging an individual packet (default: 1)&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
With the in-kernel log mode &#039;&#039;&#039;log&#039;&#039;&#039;, the level of logging may be&lt;br /&gt;
specified using the &#039;&#039;&#039;level&#039;&#039;&#039; attribute. Log modes &#039;&#039;&#039;nflog&#039;&#039;&#039; and&lt;br /&gt;
&#039;&#039;&#039;ulog&#039;&#039;&#039; are about copying the packets into user space, at least&lt;br /&gt;
partially. The following table shows the additional attributes valid&lt;br /&gt;
with these modes:&lt;br /&gt;
&lt;br /&gt;
{|&lt;br /&gt;
!Attribute!!Description&lt;br /&gt;
|-&lt;br /&gt;
|&#039;&#039;&#039;group&#039;&#039;&#039;&lt;br /&gt;
|Netlink group to be used&lt;br /&gt;
|-&lt;br /&gt;
|&#039;&#039;&#039;range&#039;&#039;&#039;&lt;br /&gt;
|Number of bytes to be copied&lt;br /&gt;
|-&lt;br /&gt;
|&#039;&#039;&#039;threshold&#039;&#039;&#039;&lt;br /&gt;
|Number of packets to queue inside the kernel before copying them&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Filter and policy rules can have an attribute named &#039;&#039;&#039;log&#039;&#039;&#039;. If it&lt;br /&gt;
is a string, it is interpreted as a reference to a logging class, and&lt;br /&gt;
logging is performed according to the definitions. If the value of the&lt;br /&gt;
&#039;&#039;&#039;log&#039;&#039;&#039; attribute is &#039;&#039;&#039;true&#039;&#039;&#039; (boolean), logging is done using&lt;br /&gt;
default settings. If the value is &#039;&#039;&#039;false&#039;&#039;&#039; (boolean), logging is&lt;br /&gt;
disabled for the rule. If &#039;&#039;&#039;log&#039;&#039;&#039; is not defined, logging is done&lt;br /&gt;
using the default settings except for accept rules, for which logging&lt;br /&gt;
is omitted.&lt;br /&gt;
&lt;br /&gt;
Default logging settings can be set by defining a logging class named&lt;br /&gt;
&#039;&#039;&#039;_default&#039;&#039;&#039;. Normally, default logging uses the &#039;&#039;&#039;log&#039;&#039;&#039; mode with&lt;br /&gt;
packets limited to one per second.&lt;br /&gt;
&lt;br /&gt;
=== Rules ===&lt;br /&gt;
&lt;br /&gt;
There are several types of rule objects:&lt;br /&gt;
* Filter rules&lt;br /&gt;
* Policy rules&lt;br /&gt;
* NAT rules&lt;br /&gt;
* Packet Marking rules&lt;br /&gt;
* Transparent Proxy rules&lt;br /&gt;
* MSS Clamping rules&lt;br /&gt;
* Connection Tracking Bypass rules&lt;br /&gt;
&lt;br /&gt;
All rule objects can have the &#039;&#039;&#039;in&#039;&#039;&#039; and &#039;&#039;&#039;out&#039;&#039;&#039; attributes&lt;br /&gt;
referring to zones as described in the previous section. In addition,&lt;br /&gt;
the scope of the rule can be further constrained with the following&lt;br /&gt;
attributes:&lt;br /&gt;
&lt;br /&gt;
{|&lt;br /&gt;
!Attribute!!Value format!!Effect&lt;br /&gt;
|-&lt;br /&gt;
|&#039;&#039;&#039;src&#039;&#039;&#039;&lt;br /&gt;
|Similar to &#039;&#039;&#039;addr&#039;&#039;&#039; attribute of zone objects&lt;br /&gt;
|Packet&#039;s source address matches the value&lt;br /&gt;
|-&lt;br /&gt;
|&#039;&#039;&#039;dest&#039;&#039;&#039;&lt;br /&gt;
|Similar to &#039;&#039;&#039;addr&#039;&#039;&#039; attribute of zone objects&lt;br /&gt;
|Packet&#039;s destination address matches the value&lt;br /&gt;
|-&lt;br /&gt;
|&#039;&#039;&#039;ipset&#039;&#039;&#039;&lt;br /&gt;
|Object containing two attributes: &#039;&#039;&#039;name&#039;&#039;&#039; referring to an IP set and &#039;&#039;&#039;args&#039;&#039;&#039;, which is a list of strings &#039;&#039;&#039;in&#039;&#039;&#039; and &#039;&#039;&#039;out&#039;&#039;&#039;&lt;br /&gt;
|Packet matches the IP set referred here when the match arguments are taken from the source (&#039;&#039;&#039;in&#039;&#039;&#039;) and destination (&#039;&#039;&#039;out&#039;&#039;&#039;) address or port in the order specified by &#039;&#039;&#039;args&#039;&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
|&#039;&#039;&#039;ipsec&#039;&#039;&#039;&lt;br /&gt;
|&#039;&#039;&#039;in&#039;&#039;&#039; or &#039;&#039;&#039;out&#039;&#039;&#039;&lt;br /&gt;
|IPsec decapsulation perfomed on ingress (&#039;&#039;&#039;in&#039;&#039;&#039;) or encapsulation performed on egress (&#039;&#039;&#039;out&#039;&#039;&#039;)&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Rule objects are declared in type-specific top-level dictionaries in&lt;br /&gt;
awall policy files. If a packet matches multiple rules, the one&lt;br /&gt;
appearing earlier in the list takes precedence. If the matching rules&lt;br /&gt;
are defined in different policy files, the one that was processed&lt;br /&gt;
earlier takes precedence in the current implementation, but this may&lt;br /&gt;
change in future versions.&lt;br /&gt;
&lt;br /&gt;
==== Filter Rules ====&lt;br /&gt;
&lt;br /&gt;
Filter objects specify an action for packets fulfilling certain&lt;br /&gt;
criteria. The top-level attribute &#039;&#039;&#039;filter&#039;&#039;&#039; is a list of filter&lt;br /&gt;
objects. The precedence rules are similar to those of policy objects.&lt;br /&gt;
&lt;br /&gt;
Filter objects must have an attribute named &#039;&#039;&#039;action&#039;&#039;&#039;, the value of&lt;br /&gt;
which can be one of the following:&lt;br /&gt;
&lt;br /&gt;
{|&lt;br /&gt;
!Value!!Action&lt;br /&gt;
|-&lt;br /&gt;
|&#039;&#039;&#039;accept&#039;&#039;&#039;&lt;br /&gt;
|Accept the packet&lt;br /&gt;
|-&lt;br /&gt;
|&#039;&#039;&#039;reject&#039;&#039;&#039;&lt;br /&gt;
|Reject the packet with an ICMP error message&lt;br /&gt;
|-&lt;br /&gt;
|&#039;&#039;&#039;drop&#039;&#039;&#039;&lt;br /&gt;
|Silently drop the packet&lt;br /&gt;
|-&lt;br /&gt;
|&#039;&#039;&#039;tarpit&#039;&#039;&#039;&lt;br /&gt;
|Put incoming TCP connections into persist state and ignore attempts to close them. Silently drop non-TCP packets. (Connection tracking bypass is automatically enabled for the matching packets.)&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Filter objects, the action of which is &#039;&#039;&#039;accept&#039;&#039;&#039;, may also contain&lt;br /&gt;
limits for packet flow or new connections. These are specified with&lt;br /&gt;
the &#039;&#039;&#039;flow-limit&#039;&#039;&#039; and &#039;&#039;&#039;conn-limit&#039;&#039;&#039; attributes,&lt;br /&gt;
respectively. The values of these attributes are limit objects that&lt;br /&gt;
have two attributes: &#039;&#039;&#039;count&#039;&#039;&#039; and &#039;&#039;&#039;interval&#039;&#039;&#039;. &#039;&#039;&#039;count&#039;&#039;&#039;&lt;br /&gt;
specifies how many new connections or packets are allowed within the&lt;br /&gt;
time frame specified by &#039;&#039;&#039;interval&#039;&#039;&#039; in seconds (default: 1). The&lt;br /&gt;
&#039;&#039;&#039;drop&#039;&#039;&#039; action is applied to the packets exceeding the&lt;br /&gt;
limit. Optionally, the limit object may have an attribute named&lt;br /&gt;
&#039;&#039;&#039;log&#039;&#039;&#039;. It defines how the dropped packets should be logged and is&lt;br /&gt;
semantically similar to the &#039;&#039;&#039;log&#039;&#039;&#039; attribute of rule objects. A&lt;br /&gt;
limit may also be specified by a plain integer, which is interpreted&lt;br /&gt;
as the count while using default interval and log settings.&lt;br /&gt;
&lt;br /&gt;
Filter objects may have an attribute named &#039;&#039;&#039;dnat&#039;&#039;&#039;, the value of&lt;br /&gt;
which is an IPv4 address. If defined, this enables destination NAT for&lt;br /&gt;
all IPv4 packets matching the rule, such that the specified address&lt;br /&gt;
replaces the original destination address. This option has no effect&lt;br /&gt;
on IPv6 packets.&lt;br /&gt;
&lt;br /&gt;
Filter objects may have a boolean attribute named &#039;&#039;&#039;no-track&#039;&#039;&#039;. If&lt;br /&gt;
set to &#039;&#039;&#039;true&#039;&#039;&#039;, connection tracking is bypassed for the matching&lt;br /&gt;
packets. In addition, if &#039;&#039;&#039;action&#039;&#039;&#039; is set to &#039;&#039;&#039;accept&#039;&#039;&#039;, the&lt;br /&gt;
corresponding packets travelling to the reverse direction are also&lt;br /&gt;
allowed.&lt;br /&gt;
&lt;br /&gt;
==== Policy Rules ====&lt;br /&gt;
&lt;br /&gt;
Policy objects describe the default action for packets that did not&lt;br /&gt;
match any filter. The top-level attribute &#039;&#039;&#039;policy&#039;&#039;&#039; is a list of&lt;br /&gt;
policy objects.&lt;br /&gt;
&lt;br /&gt;
Policy objects must have the &#039;&#039;&#039;action&#039;&#039;&#039; attribute defined. The&lt;br /&gt;
possible values and their semantics are the same as in filter objects.&lt;br /&gt;
&lt;br /&gt;
==== NAT Rules ====&lt;br /&gt;
&lt;br /&gt;
NAT rules come in two flavors: &#039;&#039;source NAT rules&#039;&#039; and&lt;br /&gt;
&#039;&#039;destination NAT rules&#039;&#039;. These are contained in two top-level lists&lt;br /&gt;
named &#039;&#039;&#039;snat&#039;&#039;&#039; and &#039;&#039;&#039;dnat&#039;&#039;&#039;, respectively.&lt;br /&gt;
&lt;br /&gt;
Each NAT rule may have an attribute named &#039;&#039;&#039;to-addr&#039;&#039;&#039; that&lt;br /&gt;
specifies the IPv4 address range to which the original source or&lt;br /&gt;
destination address is mapped. The value can be a single IPv4 address&lt;br /&gt;
or a range specified by two addresses, separated with the &#039;&#039;&#039;-&#039;&#039;&#039;&lt;br /&gt;
character. If not defined, it defaults to the primary address of the&lt;br /&gt;
ingress interface in case of destination NAT, or that of the egress&lt;br /&gt;
interface in case of source NAT.&lt;br /&gt;
&lt;br /&gt;
Optionally, a NAT rule can specify the TCP and UDP port range to which&lt;br /&gt;
the original source or destination port is mapped. The attribute is&lt;br /&gt;
named &#039;&#039;&#039;to-port&#039;&#039;&#039;, and the value can be a single port number or a&lt;br /&gt;
range specified by two numbers, separated with the &#039;&#039;&#039;-&#039;&#039;&#039;&lt;br /&gt;
character. If &#039;&#039;&#039;to-port&#039;&#039;&#039; is not specified, the original port number&lt;br /&gt;
is kept intact.&lt;br /&gt;
&lt;br /&gt;
NAT rules may have an &#039;&#039;&#039;action&#039;&#039;&#039; attribute set to value&lt;br /&gt;
&#039;&#039;&#039;accept&#039;&#039;&#039;. In this case, NAT is not performed on the packets&lt;br /&gt;
reaching and matching this rule.&lt;br /&gt;
&lt;br /&gt;
==== Packet Marking Rules ====&lt;br /&gt;
&lt;br /&gt;
Packet marking rules are used to mark incoming packets matching the&lt;br /&gt;
specified criteria. The mark can be used as a basis for the routing&lt;br /&gt;
decision. Each marking rule must specify the mark using the &#039;&#039;&#039;mark&#039;&#039;&#039;&lt;br /&gt;
attribute, which is a 32-bit integer.&lt;br /&gt;
&lt;br /&gt;
Normal marking rules are contained by the top-level list attribute&lt;br /&gt;
named &#039;&#039;&#039;mark&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
There is another top-level list attribute, named &#039;&#039;&#039;route-track&#039;&#039;&#039;,&lt;br /&gt;
which contains route tracking rules. These are special marking rules&lt;br /&gt;
which cause all the subsequent packets related to the same connection&lt;br /&gt;
to be marked according to the rule.&lt;br /&gt;
&lt;br /&gt;
==== Transparent Proxy Rules ====&lt;br /&gt;
&lt;br /&gt;
Transparent proxy rules divert the matching packets to a local proxy&lt;br /&gt;
process without altering their headers. Such rules are contained in&lt;br /&gt;
the top-level list named &#039;&#039;&#039;tproxy&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
In addition to the firewall configuration, using a transparent proxy&lt;br /&gt;
requires a routing configuration where packets marked for proxying are&lt;br /&gt;
diverted to a local process. The &#039;&#039;&#039;mark&#039;&#039;&#039; attribute of a proxy rule&lt;br /&gt;
specifies the mark to be used.&lt;br /&gt;
&lt;br /&gt;
Proxy rules may also have an attribute named &#039;&#039;&#039;to-port&#039;&#039;&#039; for&lt;br /&gt;
specifying the TCP or UDP port of the proxy if it is different from&lt;br /&gt;
the original destination port.&lt;br /&gt;
&lt;br /&gt;
==== MSS Clamping Rules ====&lt;br /&gt;
&lt;br /&gt;
MSS Clamping Rules are used to deal with ISPs that block ICMP&lt;br /&gt;
Fragmentation Needed or ICMPv6 Packet Too Big packets. An MSS clamping&lt;br /&gt;
rule overwrites the MSS option with a value specified with the&lt;br /&gt;
&#039;&#039;&#039;mss&#039;&#039;&#039; attribute for the matching TCP connections. If &#039;&#039;&#039;mss&#039;&#039;&#039; is&lt;br /&gt;
not specified, a suitable value is automatically determined from the&lt;br /&gt;
path MTU. The MSS clamping rules are located in the top-level&lt;br /&gt;
dictionary named &#039;&#039;&#039;clamp-mss&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
==== Connection Tracking Bypass Rules ====&lt;br /&gt;
&lt;br /&gt;
Connection tracking bypass rules are used to disable connection&lt;br /&gt;
tracking for packets matching the specified criteria. The top-level&lt;br /&gt;
attribute &#039;&#039;&#039;no-track&#039;&#039;&#039; is a list of such rules.&lt;br /&gt;
&lt;br /&gt;
Connection tracking bypass rules may have an &#039;&#039;&#039;action&#039;&#039;&#039; attribute&lt;br /&gt;
set to value &#039;&#039;&#039;accept&#039;&#039;&#039;. The effect is similar to corresponding NAT&lt;br /&gt;
rules, i.e. connection tracking is not bypassed for the matching&lt;br /&gt;
packets.&lt;br /&gt;
&lt;br /&gt;
=== IP Sets ===&lt;br /&gt;
&lt;br /&gt;
Any IP set referenced by rule objects should be created by&lt;br /&gt;
awall. Auxiliary &#039;&#039;IP set&#039;&#039; objects are used to defined them in awall&lt;br /&gt;
policy files. The top-level attribute &#039;&#039;&#039;ipset&#039;&#039;&#039; is a dictionary, the&lt;br /&gt;
keys of which are IP set names. The values are IP set objects, which&lt;br /&gt;
have two mandatory attributes. The attribute named &#039;&#039;&#039;type&#039;&#039;&#039; &lt;br /&gt;
corresponds to the type argument of the &amp;lt;tt&amp;gt;ipset create&amp;lt;/tt&amp;gt; &lt;br /&gt;
command. &#039;&#039;&#039;family&#039;&#039;&#039; specifies whether the set is for IPv4 or IPv6&lt;br /&gt;
addresses, and the possible values are &#039;&#039;&#039;inet&#039;&#039;&#039; and &#039;&#039;&#039;inet6&#039;&#039;&#039;,&lt;br /&gt;
correspondingly.&lt;br /&gt;
&lt;br /&gt;
For bitmap-type IP sets, the &#039;&#039;&#039;range&#039;&#039;&#039; attribute specifies the&lt;br /&gt;
range of allowed IPv4 addresses. It may be given as a network&lt;br /&gt;
address or two addresses separated by the &#039;&#039;&#039;-&#039;&#039;&#039; character. It&lt;br /&gt;
is not necessary to specify &#039;&#039;&#039;family&#039;&#039;&#039; for bitmaps, since the&lt;br /&gt;
kernel supports only IPv4 bitmaps.&lt;br /&gt;
&lt;br /&gt;
== Command Line Syntax ==&lt;br /&gt;
&lt;br /&gt;
=== Translating Policy Files to Firewall Configuration Files ===&lt;br /&gt;
&lt;br /&gt;
 &#039;&#039;&#039;awall translate&#039;&#039;&#039; [&#039;&#039;&#039;-o&#039;&#039;&#039;|&#039;&#039;&#039;--output&#039;&#039;&#039; DIRECTORY] [&#039;&#039;&#039;-V&#039;&#039;&#039;|&#039;&#039;&#039;--verify&#039;&#039;&#039;]&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;tt&amp;gt;--verify&amp;lt;/tt&amp;gt; option makes awall verify the configuration&lt;br /&gt;
using the test mode of iptables-restore before overwriting the old&lt;br /&gt;
files.&lt;br /&gt;
&lt;br /&gt;
Specifying the output directory allows testing awall policies without&lt;br /&gt;
overwriting the current iptables and ipset configuration files. By&lt;br /&gt;
default, awall generates the configuration to &amp;lt;tt&amp;gt;/etc/iptables&amp;lt;/tt&amp;gt; &lt;br /&gt;
and &amp;lt;tt&amp;gt;/etc/ipset.d&amp;lt;/tt&amp;gt;, which are read by the init scripts.&lt;br /&gt;
&lt;br /&gt;
=== Run-Time Configuration of Firewall ===&lt;br /&gt;
&lt;br /&gt;
 &#039;&#039;&#039;awall activate&#039;&#039;&#039; [&#039;&#039;&#039;-f&#039;&#039;&#039;|&#039;&#039;&#039;--force&#039;&#039;&#039;]&lt;br /&gt;
&lt;br /&gt;
This command genereates firewall configuration from the policy files&lt;br /&gt;
and enables it. If the user confirms the new configuration by hitting&lt;br /&gt;
the Return key within 10 seconds or the &amp;lt;tt&amp;gt;--force&amp;lt;/tt&amp;gt; option is&lt;br /&gt;
used, the configuration is saved to the files. Otherwise, the old&lt;br /&gt;
configuration is restored.&lt;br /&gt;
&lt;br /&gt;
There is also a command for deleting all firewall rules:&lt;br /&gt;
&lt;br /&gt;
 &#039;&#039;&#039;awall flush&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
This command configures the firewall to drop all packets.&lt;br /&gt;
&lt;br /&gt;
=== Optional Policies ===&lt;br /&gt;
&lt;br /&gt;
Optional policies can be enabled or disabled using this command:&lt;br /&gt;
&lt;br /&gt;
 &#039;&#039;&#039;awall&#039;&#039;&#039; {&#039;&#039;&#039;enable&#039;&#039;&#039;|&#039;&#039;&#039;disable&#039;&#039;&#039;} POLICY...&lt;br /&gt;
&lt;br /&gt;
Optional policies can be listed using this command:&lt;br /&gt;
&lt;br /&gt;
 &#039;&#039;&#039;awall list&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;&#039;enabled&#039;&#039;&#039; status means that the policy has been enabled by the&lt;br /&gt;
user. The &#039;&#039;&#039;disabled&#039;&#039;&#039; status means that the policy is not in&lt;br /&gt;
use. The &#039;&#039;&#039;required&#039;&#039;&#039; status means that the policy has not been&lt;br /&gt;
enabled by the user but is in use because it is required by another&lt;br /&gt;
policy which is in use.&lt;br /&gt;
&lt;br /&gt;
=== Debugging Policies ===&lt;br /&gt;
&lt;br /&gt;
This command can be used to dump variable, zone, and other definitions&lt;br /&gt;
as well as their source policies:&lt;br /&gt;
&lt;br /&gt;
 &#039;&#039;&#039;awall dump&#039;&#039;&#039; [LEVEL]&lt;br /&gt;
&lt;br /&gt;
The level is an integer in range 0&amp;amp;ndash;5 and defaults to 0. More&lt;br /&gt;
information is displayed on higher levels.&lt;br /&gt;
&lt;br /&gt;
[[Category:Networking]]&lt;br /&gt;
[[Category:Security]]&lt;/div&gt;</summary>
		<author><name>Kunkku</name></author>
	</entry>
	<entry>
		<id>https://wiki.alpinelinux.org/w/index.php?title=Alpine_Wall_User%27s_Guide&amp;diff=9018</id>
		<title>Alpine Wall User&#039;s Guide</title>
		<link rel="alternate" type="text/html" href="https://wiki.alpinelinux.org/w/index.php?title=Alpine_Wall_User%27s_Guide&amp;diff=9018"/>
		<updated>2013-02-05T14:58:40Z</updated>

		<summary type="html">&lt;p&gt;Kunkku: /* Logging Classes */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Configuration File Processing ==&lt;br /&gt;
&lt;br /&gt;
[[Alpine Wall]] (awall) reads its configuration from multiple&lt;br /&gt;
JSON-formatted files, called &#039;&#039;policy files&#039;&#039;. The processing starts&lt;br /&gt;
from directory &amp;lt;tt&amp;gt;/usr/share/awall/mandatory&amp;lt;/tt&amp;gt;, which contains&lt;br /&gt;
mandatory policy files shipped with APK packages. After that,&lt;br /&gt;
installation-specific policy files in &amp;lt;tt&amp;gt;/etc/awall&amp;lt;/tt&amp;gt; are&lt;br /&gt;
processed.&lt;br /&gt;
&lt;br /&gt;
The latter directory may also contain symbolic links to policy files&lt;br /&gt;
located in &amp;lt;tt&amp;gt;/usr/share/awall/optional&amp;lt;/tt&amp;gt; and&lt;br /&gt;
&amp;lt;tt&amp;gt;/etc/awall/optional&amp;lt;/tt&amp;gt;. These are optional policies, which can&lt;br /&gt;
be enabled on need basis. Such symbolic links are easily created and&lt;br /&gt;
destroyed using the &amp;lt;tt&amp;gt;awall enable&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;awall disable&amp;lt;/tt&amp;gt;&lt;br /&gt;
commands. &amp;lt;tt&amp;gt;awall list&amp;lt;/tt&amp;gt; shows which optional policies are&lt;br /&gt;
enabled and disabled. The command also prints the description of the&lt;br /&gt;
optional policy if defined in the file using a top-level attribute&lt;br /&gt;
named &#039;&#039;&#039;description&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Sometimes a policy file depends on other policy files. In this case,&lt;br /&gt;
the policy file must have a top-level attribute &#039;&#039;&#039;import&#039;&#039;&#039;, the&lt;br /&gt;
value of which is a list of policy names, which correspond to the file&lt;br /&gt;
names without the &amp;lt;tt&amp;gt;.json&amp;lt;/tt&amp;gt; suffix. By default, the policies&lt;br /&gt;
listed there are processed before the importing policy.&lt;br /&gt;
&lt;br /&gt;
The order of the generated iptables rules generally reflects the&lt;br /&gt;
processing order of their corresponding awall policies. The processing&lt;br /&gt;
order of policies can be adjusted by defining top-level attributes&lt;br /&gt;
&#039;&#039;&#039;after&#039;&#039;&#039; and &#039;&#039;&#039;before&#039;&#039;&#039; in policy files. These attributes are&lt;br /&gt;
lists of policies, after or before which the declaring policy shall be&lt;br /&gt;
processed. Putting a policy name to either of these lists does not by&lt;br /&gt;
itself import the policy. The ordering directives are ignored with&lt;br /&gt;
respect to those policies that are not enabled by the user or imported&lt;br /&gt;
by other policies. If not defined, &#039;&#039;&#039;after&#039;&#039;&#039; is assumed to be equal&lt;br /&gt;
to the &#039;&#039;&#039;import&#039;&#039;&#039; definition of the policy.&lt;br /&gt;
&lt;br /&gt;
As the import directive does not require the path name to be&lt;br /&gt;
specified, awall expects policies to have unique names, even if&lt;br /&gt;
located in different directories. It is allowed to import optional&lt;br /&gt;
policies that are not explicitly enabled by the user. Such policies&lt;br /&gt;
show up with the &amp;lt;tt&amp;gt;required&amp;lt;/tt&amp;gt; status in the output of &amp;lt;tt&amp;gt;awall&lt;br /&gt;
list&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
== List Parameters ==&lt;br /&gt;
&lt;br /&gt;
Several awall parameters are defined as lists of values. In order to&lt;br /&gt;
facilitate manual editing of policy files, awall also accepts single&lt;br /&gt;
values in place of lists. Such values are semantically equivalent to&lt;br /&gt;
lists containing one element.&lt;br /&gt;
&lt;br /&gt;
== Variable Expansion ==&lt;br /&gt;
&lt;br /&gt;
Awall allows variable definitions in policy files. The top-level&lt;br /&gt;
attribute &#039;&#039;&#039;variable&#039;&#039;&#039; is a dictionary containing the&lt;br /&gt;
definitions. The value of a variable can be of any type (string,&lt;br /&gt;
integer, list, or dictionary).&lt;br /&gt;
&lt;br /&gt;
A variable is referenced in policy files by a string which equals the&lt;br /&gt;
variable name prepended with the &#039;&#039;&#039;$&#039;&#039;&#039; character. If the value of&lt;br /&gt;
the variable is a string, the reference can be embedded into a longer&lt;br /&gt;
string in order to substitute some part of that string (in shell&lt;br /&gt;
style). Variable references can be used when defining other variables,&lt;br /&gt;
as long as the definitions are not circular.&lt;br /&gt;
&lt;br /&gt;
Policy files can reference variables defined in other policy&lt;br /&gt;
files. Policy files can also override variables defined elsewhere by&lt;br /&gt;
redefining them. In this case, the new definition affects all policy&lt;br /&gt;
files, also those processed before the overriding policy. Awall&lt;br /&gt;
variables are in fact simple macros, since each variable remains&lt;br /&gt;
constant thoughout a single processing round. If multiple files define&lt;br /&gt;
the same variable, the definition in the file processed last takes&lt;br /&gt;
effect.&lt;br /&gt;
&lt;br /&gt;
If defined as an empty string, all non-embedded references to a&lt;br /&gt;
variable evaluate as if the attribute in question was not present in&lt;br /&gt;
the configuration. This is also the case when a string containing&lt;br /&gt;
embedded variable references finally evaluates to an empty string.&lt;br /&gt;
&lt;br /&gt;
== Configuration Objects ==&lt;br /&gt;
&lt;br /&gt;
Configuration objects can be divided into two main types.&lt;br /&gt;
&#039;&#039;Auxiliary objects&#039;&#039; model high-level concepts such as services and&lt;br /&gt;
zones. &#039;&#039;Rule objects&#039;&#039; translate into one or more iptables rules, and&lt;br /&gt;
are often defined with the help of some auxiliary objects.&lt;br /&gt;
&lt;br /&gt;
=== Services ===&lt;br /&gt;
&lt;br /&gt;
A &#039;&#039;service&#039;&#039; represents a set of network protocols. A top-level&lt;br /&gt;
attribute &#039;&#039;&#039;service&#039;&#039;&#039; is a dictionary that maps service names to&lt;br /&gt;
service definition objects, or lists thereof in more complex cases.&lt;br /&gt;
&lt;br /&gt;
A service definition object contains an attribute named &#039;&#039;&#039;proto&#039;&#039;&#039;,&lt;br /&gt;
which corresponds to the &amp;lt;tt&amp;gt;--protocol&amp;lt;/tt&amp;gt; option of iptables. The&lt;br /&gt;
protocol can be defined as a numerical value or string as defined in&lt;br /&gt;
&amp;lt;tt&amp;gt;/etc/protocols&amp;lt;/tt&amp;gt;. If the protocol is &#039;&#039;&#039;tcp&#039;&#039;&#039; or &#039;&#039;&#039;udp&#039;&#039;&#039;,&lt;br /&gt;
the scope of the service definition may be constrained by defining an&lt;br /&gt;
attribute named &#039;&#039;&#039;port&#039;&#039;&#039;, which is a list of TCP or UDP port numbers&lt;br /&gt;
or ranges thereof, separated by the &#039;&#039;&#039;-&#039;&#039;&#039; character. If the protocol&lt;br /&gt;
is &#039;&#039;&#039;icmp&#039;&#039;&#039; or &#039;&#039;&#039;icmpv6&#039;&#039;&#039;, an analogous &#039;&#039;&#039;icmp-type&#039;&#039;&#039; attribute&lt;br /&gt;
may be used. In addition, the scope of the rule is also automatically&lt;br /&gt;
limited to IPv4 or IPv6, respectively.&lt;br /&gt;
&lt;br /&gt;
All rule objects, except for policies, may have an attribute named&lt;br /&gt;
&#039;&#039;&#039;service&#039;&#039;&#039;, constraining the rule&#039;s scope to specific services&lt;br /&gt;
only. This attribute is a list of service names, referring to the keys&lt;br /&gt;
of the top-level service dictionary.&lt;br /&gt;
&lt;br /&gt;
=== Zones ===&lt;br /&gt;
&lt;br /&gt;
A &#039;&#039;zone&#039;&#039; represents a set of network hosts. A top-level attribute &lt;br /&gt;
&#039;&#039;&#039;zone&#039;&#039;&#039; is a dictionary that maps zone names to zone objects. A&lt;br /&gt;
zone object has an attribute named &#039;&#039;&#039;iface&#039;&#039;&#039;, &#039;&#039;&#039;addr&#039;&#039;&#039;, or&lt;br /&gt;
both. &#039;&#039;&#039;iface&#039;&#039;&#039; is a list of network interfaces and &#039;&#039;&#039;addr&#039;&#039;&#039; is a&lt;br /&gt;
list of IPv4/IPv6 host and network addresses (CIDR&lt;br /&gt;
notation). &#039;&#039;&#039;addr&#039;&#039;&#039; may also contain domain names, which are&lt;br /&gt;
expanded to IP addresses using DNS resolution. If not defined,&lt;br /&gt;
&#039;&#039;&#039;addr&#039;&#039;&#039; defaults to the entire address space and &#039;&#039;&#039;iface&#039;&#039;&#039; to all&lt;br /&gt;
interfaces. An empty zone can be defined by setting either &#039;&#039;&#039;addr&#039;&#039;&#039;&lt;br /&gt;
or &#039;&#039;&#039;iface&#039;&#039;&#039; to an empty list.&lt;br /&gt;
&lt;br /&gt;
Rule objects contain two attributes, &#039;&#039;&#039;in&#039;&#039;&#039; and &#039;&#039;&#039;out&#039;&#039;&#039;, which are&lt;br /&gt;
lists of zone names. These attributes control whether a packet matches&lt;br /&gt;
the rule or not. If a particular zone is referenced by the &#039;&#039;&#039;in&#039;&#039;&#039; &lt;br /&gt;
attribute, the rule applies to packets whose ingress interface and&lt;br /&gt;
source address are covered by the zone definition. Correspondingly, if&lt;br /&gt;
a zone is referenced by the &#039;&#039;&#039;out&#039;&#039;&#039; attribute, the rule applies to&lt;br /&gt;
packets whose egress interface and destination address are included in&lt;br /&gt;
the zone. If both &#039;&#039;&#039;in&#039;&#039;&#039; and &#039;&#039;&#039;out&#039;&#039;&#039; are defined, the packet must&lt;br /&gt;
fulfill both criteria in order to match the rule.&lt;br /&gt;
&lt;br /&gt;
The firewall host itself can be referred to using the special value&lt;br /&gt;
&#039;&#039;&#039;_fw&#039;&#039;&#039; as the zone name.&lt;br /&gt;
&lt;br /&gt;
By default, awall does not generate iptables rules with identical&lt;br /&gt;
ingress and egress interfaces. This behavior can be changed per zone&lt;br /&gt;
by setting the optional &#039;&#039;&#039;route-back&#039;&#039;&#039; attribute of the zone to&lt;br /&gt;
&#039;&#039;&#039;true&#039;&#039;&#039;. Note that this attribute can have an effect also in the&lt;br /&gt;
case where &#039;&#039;&#039;in&#039;&#039;&#039; and &#039;&#039;&#039;out&#039;&#039;&#039; attributes of a rule are not equal&lt;br /&gt;
but their definitions overlap. In this case, the &#039;&#039;&#039;route-back&#039;&#039;&#039;&lt;br /&gt;
attribute of the &#039;&#039;&#039;out&#039;&#039;&#039; zone determines the behavior.&lt;br /&gt;
&lt;br /&gt;
=== Logging Classes ===&lt;br /&gt;
&lt;br /&gt;
A &#039;&#039;logging class&#039;&#039; specifies how packets matching certain rules are&lt;br /&gt;
logged. A top-level attribute &#039;&#039;&#039;log&#039;&#039;&#039; is a dictionary that maps&lt;br /&gt;
logging class names to setting objects.&lt;br /&gt;
&lt;br /&gt;
A setting object may have an attribute named &#039;&#039;&#039;mode&#039;&#039;&#039;, which&lt;br /&gt;
specifies which logging facility to use. Allowed values are &#039;&#039;&#039;log&#039;&#039;&#039;,&lt;br /&gt;
&#039;&#039;&#039;nflog&#039;&#039;&#039;, and &#039;&#039;&#039;ulog&#039;&#039;&#039;. The default is &#039;&#039;&#039;log&#039;&#039;&#039;, i.e. in-kernel&lt;br /&gt;
logging.&lt;br /&gt;
&lt;br /&gt;
The following table shows the optional attributes valid for all&lt;br /&gt;
logging modes:&lt;br /&gt;
&lt;br /&gt;
{|&lt;br /&gt;
!Attribute!!Description&lt;br /&gt;
|-&lt;br /&gt;
|&#039;&#039;&#039;every&#039;&#039;&#039;&lt;br /&gt;
|Divide successive packets into groups, the size of which is specified by the value of this attribute, and log only the first packet of each group&lt;br /&gt;
|-&lt;br /&gt;
|&#039;&#039;&#039;limit&#039;&#039;&#039;&lt;br /&gt;
|Maximum number of packets to be logged per second per this rule&lt;br /&gt;
|-&lt;br /&gt;
|&#039;&#039;&#039;prefix&#039;&#039;&#039;&lt;br /&gt;
|String with which the log entries are prefixed&lt;br /&gt;
|-&lt;br /&gt;
|&#039;&#039;&#039;probability&#039;&#039;&#039;&lt;br /&gt;
|Probability for logging an individual packet (default: 1)&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
With the in-kernel log mode &#039;&#039;&#039;log&#039;&#039;&#039;, the level of logging may be&lt;br /&gt;
specified using the &#039;&#039;&#039;level&#039;&#039;&#039; attribute. Log modes &#039;&#039;&#039;nflog&#039;&#039;&#039; and&lt;br /&gt;
&#039;&#039;&#039;ulog&#039;&#039;&#039; are about copying the packets into user space, at least&lt;br /&gt;
partially. The following table shows the additional attributes valid&lt;br /&gt;
with these modes:&lt;br /&gt;
&lt;br /&gt;
{|&lt;br /&gt;
!Attribute!!Description&lt;br /&gt;
|-&lt;br /&gt;
|&#039;&#039;&#039;group&#039;&#039;&#039;&lt;br /&gt;
|Netlink group to be used&lt;br /&gt;
|-&lt;br /&gt;
|&#039;&#039;&#039;range&#039;&#039;&#039;&lt;br /&gt;
|Number of bytes to be copied&lt;br /&gt;
|-&lt;br /&gt;
|&#039;&#039;&#039;threshold&#039;&#039;&#039;&lt;br /&gt;
|Number of packets to queue inside the kernel before copying them&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Filter and policy rules can have an attribute named &#039;&#039;&#039;log&#039;&#039;&#039;. If it&lt;br /&gt;
is a string, it is interpreted as a reference to a logging class, and&lt;br /&gt;
logging is performed according to the definitions. If the value of the&lt;br /&gt;
&#039;&#039;&#039;log&#039;&#039;&#039; attribute is &#039;&#039;&#039;true&#039;&#039;&#039; (boolean), logging is done using&lt;br /&gt;
default settings. If the value is &#039;&#039;&#039;false&#039;&#039;&#039; (boolean), logging is&lt;br /&gt;
disabled for the rule. If &#039;&#039;&#039;log&#039;&#039;&#039; is not defined, logging is done&lt;br /&gt;
using the default settings except for accept rules, for which logging&lt;br /&gt;
is omitted.&lt;br /&gt;
&lt;br /&gt;
Default logging settings can be set by defining a logging class named&lt;br /&gt;
&#039;&#039;&#039;_default&#039;&#039;&#039;. Normally, default logging uses the &#039;&#039;&#039;log&#039;&#039;&#039; mode with&lt;br /&gt;
packets limited to one per second.&lt;br /&gt;
&lt;br /&gt;
=== Rules ===&lt;br /&gt;
&lt;br /&gt;
There are six types of rule objects:&lt;br /&gt;
* Filter rules&lt;br /&gt;
* Policy rules&lt;br /&gt;
* NAT rules&lt;br /&gt;
* Packet Marking rules&lt;br /&gt;
* Transparent Proxy rules&lt;br /&gt;
* MSS Clamping rules&lt;br /&gt;
* Connection Tracking Bypass rules&lt;br /&gt;
&lt;br /&gt;
All rule objects can have the &#039;&#039;&#039;in&#039;&#039;&#039; and &#039;&#039;&#039;out&#039;&#039;&#039; attributes&lt;br /&gt;
referring to zones as described in the previous section. In addition,&lt;br /&gt;
the scope of the rule can be further constrained with the following&lt;br /&gt;
attributes:&lt;br /&gt;
&lt;br /&gt;
{|&lt;br /&gt;
!Attribute!!Value format!!Effect&lt;br /&gt;
|-&lt;br /&gt;
|&#039;&#039;&#039;src&#039;&#039;&#039;&lt;br /&gt;
|Similar to &#039;&#039;&#039;addr&#039;&#039;&#039; attribute of zone objects&lt;br /&gt;
|Packet&#039;s source address matches the value&lt;br /&gt;
|-&lt;br /&gt;
|&#039;&#039;&#039;dest&#039;&#039;&#039;&lt;br /&gt;
|Similar to &#039;&#039;&#039;addr&#039;&#039;&#039; attribute of zone objects&lt;br /&gt;
|Packet&#039;s destination address matches the value&lt;br /&gt;
|-&lt;br /&gt;
|&#039;&#039;&#039;ipset&#039;&#039;&#039;&lt;br /&gt;
|Object containing two attributes: &#039;&#039;&#039;name&#039;&#039;&#039; referring to an IP set and &#039;&#039;&#039;args&#039;&#039;&#039;, which is a list of strings &#039;&#039;&#039;in&#039;&#039;&#039; and &#039;&#039;&#039;out&#039;&#039;&#039;&lt;br /&gt;
|Packet matches the IP set referred here when the match arguments are taken from the source (&#039;&#039;&#039;in&#039;&#039;&#039;) and destination (&#039;&#039;&#039;out&#039;&#039;&#039;) address or port in the order specified by &#039;&#039;&#039;args&#039;&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
|&#039;&#039;&#039;ipsec&#039;&#039;&#039;&lt;br /&gt;
|&#039;&#039;&#039;in&#039;&#039;&#039; or &#039;&#039;&#039;out&#039;&#039;&#039;&lt;br /&gt;
|IPsec decapsulation perfomed on ingress (&#039;&#039;&#039;in&#039;&#039;&#039;) or encapsulation performed on egress (&#039;&#039;&#039;out&#039;&#039;&#039;)&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Rule objects are declared in type-specific top-level dictionaries in&lt;br /&gt;
awall policy files. If a packet matches multiple rules, the one&lt;br /&gt;
appearing earlier in the list takes precedence. If the matching rules&lt;br /&gt;
are defined in different policy files, the one that was processed&lt;br /&gt;
earlier takes precedence in the current implementation, but this may&lt;br /&gt;
change in future versions.&lt;br /&gt;
&lt;br /&gt;
==== Filter Rules ====&lt;br /&gt;
&lt;br /&gt;
Filter objects specify an action for packets fulfilling certain&lt;br /&gt;
criteria. The top-level attribute &#039;&#039;&#039;filter&#039;&#039;&#039; is a list of filter&lt;br /&gt;
objects. The precedence rules are similar to those of policy objects.&lt;br /&gt;
&lt;br /&gt;
Filter objects must have an attribute named &#039;&#039;&#039;action&#039;&#039;&#039;, the value of&lt;br /&gt;
which can be one of the following:&lt;br /&gt;
&lt;br /&gt;
{|&lt;br /&gt;
!Value!!Action&lt;br /&gt;
|-&lt;br /&gt;
|&#039;&#039;&#039;accept&#039;&#039;&#039;&lt;br /&gt;
|Accept the packet&lt;br /&gt;
|-&lt;br /&gt;
|&#039;&#039;&#039;reject&#039;&#039;&#039;&lt;br /&gt;
|Reject the packet with an ICMP error message&lt;br /&gt;
|-&lt;br /&gt;
|&#039;&#039;&#039;drop&#039;&#039;&#039;&lt;br /&gt;
|Silently drop the packet&lt;br /&gt;
|-&lt;br /&gt;
|&#039;&#039;&#039;tarpit&#039;&#039;&#039;&lt;br /&gt;
|Put incoming TCP connections into persist state and ignore attempts to close them. Silently drop non-TCP packets. (Connection tracking bypass is automatically enabled for the matching packets.)&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Filter objects, the action of which is &#039;&#039;&#039;accept&#039;&#039;&#039;, may also contain&lt;br /&gt;
limits for packet flow or new connections. These are specified with&lt;br /&gt;
the &#039;&#039;&#039;flow-limit&#039;&#039;&#039; and &#039;&#039;&#039;conn-limit&#039;&#039;&#039; attributes,&lt;br /&gt;
respectively. The values of these attributes are limit objects that&lt;br /&gt;
have two attributes: &#039;&#039;&#039;count&#039;&#039;&#039; and &#039;&#039;&#039;interval&#039;&#039;&#039;. &#039;&#039;&#039;count&#039;&#039;&#039;&lt;br /&gt;
specifies how many new connections or packets are allowed within the&lt;br /&gt;
time frame specified by &#039;&#039;&#039;interval&#039;&#039;&#039; in seconds (default: 1). The&lt;br /&gt;
&#039;&#039;&#039;drop&#039;&#039;&#039; action is applied to the packets exceeding the&lt;br /&gt;
limit. Optionally, the limit object may have an attribute named&lt;br /&gt;
&#039;&#039;&#039;log&#039;&#039;&#039;. It defines how the dropped packets should be logged and is&lt;br /&gt;
semantically similar to the &#039;&#039;&#039;log&#039;&#039;&#039; attribute of rule objects. A&lt;br /&gt;
limit may also be specified by a plain integer, which is interpreted&lt;br /&gt;
as the count while using default interval and log settings.&lt;br /&gt;
&lt;br /&gt;
Filter objects may have an attribute named &#039;&#039;&#039;dnat&#039;&#039;&#039;, the value of&lt;br /&gt;
which is an IPv4 address. If defined, this enables destination NAT for&lt;br /&gt;
all IPv4 packets matching the rule, such that the specified address&lt;br /&gt;
replaces the original destination address. This option has no effect&lt;br /&gt;
on IPv6 packets.&lt;br /&gt;
&lt;br /&gt;
Filter objects may have a boolean attribute named &#039;&#039;&#039;no-track&#039;&#039;&#039;. If&lt;br /&gt;
set to &#039;&#039;&#039;true&#039;&#039;&#039;, connection tracking is bypassed for the matching&lt;br /&gt;
packets. In addition, if &#039;&#039;&#039;action&#039;&#039;&#039; is set to &#039;&#039;&#039;accept&#039;&#039;&#039;, the&lt;br /&gt;
corresponding packets travelling to the reverse direction are also&lt;br /&gt;
allowed.&lt;br /&gt;
&lt;br /&gt;
==== Policy Rules ====&lt;br /&gt;
&lt;br /&gt;
Policy objects describe the default action for packets that did not&lt;br /&gt;
match any filter. The top-level attribute &#039;&#039;&#039;policy&#039;&#039;&#039; is a list of&lt;br /&gt;
policy objects.&lt;br /&gt;
&lt;br /&gt;
Policy objects must have the &#039;&#039;&#039;action&#039;&#039;&#039; attribute defined. The&lt;br /&gt;
possible values and their semantics are the same as in filter objects.&lt;br /&gt;
&lt;br /&gt;
==== NAT Rules ====&lt;br /&gt;
&lt;br /&gt;
NAT rules come in two flavors: &#039;&#039;source NAT rules&#039;&#039; and&lt;br /&gt;
&#039;&#039;destination NAT rules&#039;&#039;. These are contained in two top-level lists&lt;br /&gt;
named &#039;&#039;&#039;snat&#039;&#039;&#039; and &#039;&#039;&#039;dnat&#039;&#039;&#039;, respectively.&lt;br /&gt;
&lt;br /&gt;
Each NAT rule may have an attribute named &#039;&#039;&#039;to-addr&#039;&#039;&#039; that&lt;br /&gt;
specifies the IPv4 address range to which the original source or&lt;br /&gt;
destination address is mapped. The value can be a single IPv4 address&lt;br /&gt;
or a range specified by two addresses, separated with the &#039;&#039;&#039;-&#039;&#039;&#039;&lt;br /&gt;
character. If not defined, it defaults to the primary address of the&lt;br /&gt;
ingress interface in case of destination NAT, or that of the egress&lt;br /&gt;
interface in case of source NAT.&lt;br /&gt;
&lt;br /&gt;
Optionally, a NAT rule can specify the TCP and UDP port range to which&lt;br /&gt;
the original source or destination port is mapped. The attribute is&lt;br /&gt;
named &#039;&#039;&#039;to-port&#039;&#039;&#039;, and the value can be a single port number or a&lt;br /&gt;
range specified by two numbers, separated with the &#039;&#039;&#039;-&#039;&#039;&#039;&lt;br /&gt;
character. If &#039;&#039;&#039;to-port&#039;&#039;&#039; is not specified, the original port number&lt;br /&gt;
is kept intact.&lt;br /&gt;
&lt;br /&gt;
NAT rules may have an &#039;&#039;&#039;action&#039;&#039;&#039; attribute set to value&lt;br /&gt;
&#039;&#039;&#039;accept&#039;&#039;&#039;. In this case, NAT is not performed on the packets&lt;br /&gt;
reaching and matching this rule.&lt;br /&gt;
&lt;br /&gt;
==== Packet Marking Rules ====&lt;br /&gt;
&lt;br /&gt;
Packet marking rules are used to mark incoming packets matching the&lt;br /&gt;
specified criteria. The mark can be used as a basis for the routing&lt;br /&gt;
decision. Each marking rule must specify the mark using the &#039;&#039;&#039;mark&#039;&#039;&#039;&lt;br /&gt;
attribute, which is a 32-bit integer.&lt;br /&gt;
&lt;br /&gt;
Normal marking rules are contained by the top-level list attribute&lt;br /&gt;
named &#039;&#039;&#039;mark&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
There is another top-level list attribute, named &#039;&#039;&#039;route-track&#039;&#039;&#039;,&lt;br /&gt;
which contains route tracking rules. These are special marking rules&lt;br /&gt;
which cause all the subsequent packets related to the same connection&lt;br /&gt;
to be marked according to the rule.&lt;br /&gt;
&lt;br /&gt;
==== Transparent Proxy Rules ====&lt;br /&gt;
&lt;br /&gt;
Transparent proxy rules divert the matching packets to a local proxy&lt;br /&gt;
process without altering their headers. Such rules are contained in&lt;br /&gt;
the top-level list named &#039;&#039;&#039;tproxy&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
In addition to the firewall configuration, using a transparent proxy&lt;br /&gt;
requires a routing configuration where packets marked for proxying are&lt;br /&gt;
diverted to a local process. The &#039;&#039;&#039;mark&#039;&#039;&#039; attribute of a proxy rule&lt;br /&gt;
specifies the mark to be used.&lt;br /&gt;
&lt;br /&gt;
Proxy rules may also have an attribute named &#039;&#039;&#039;to-port&#039;&#039;&#039; for&lt;br /&gt;
specifying the TCP or UDP port of the proxy if it is different from&lt;br /&gt;
the original destination port.&lt;br /&gt;
&lt;br /&gt;
==== MSS Clamping Rules ====&lt;br /&gt;
&lt;br /&gt;
MSS Clamping Rules are used to deal with ISPs that block ICMP&lt;br /&gt;
Fragmentation Needed or ICMPv6 Packet Too Big packets. An MSS clamping&lt;br /&gt;
rule overwrites the MSS option with a value specified with the&lt;br /&gt;
&#039;&#039;&#039;mss&#039;&#039;&#039; attribute for the matching TCP connections. If &#039;&#039;&#039;mss&#039;&#039;&#039; is&lt;br /&gt;
not specified, a suitable value is automatically determined from the&lt;br /&gt;
path MTU. The MSS clamping rules are located in the top-level&lt;br /&gt;
dictionary named &#039;&#039;&#039;clamp-mss&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
==== Connection Tracking Bypass Rules ====&lt;br /&gt;
&lt;br /&gt;
Connection tracking bypass rules are used to disable connection&lt;br /&gt;
tracking for packets matching the specified criteria. The top-level&lt;br /&gt;
attribute &#039;&#039;&#039;no-track&#039;&#039;&#039; is a list of such rules.&lt;br /&gt;
&lt;br /&gt;
Connection tracking bypass rules may have an &#039;&#039;&#039;action&#039;&#039;&#039; attribute&lt;br /&gt;
set to value &#039;&#039;&#039;accept&#039;&#039;&#039;. The effect is similar to corresponding NAT&lt;br /&gt;
rules, i.e. connection tracking is not bypassed for the matching&lt;br /&gt;
packets.&lt;br /&gt;
&lt;br /&gt;
=== IP Sets ===&lt;br /&gt;
&lt;br /&gt;
Any IP set referenced by rule objects should be created by&lt;br /&gt;
awall. Auxiliary &#039;&#039;IP set&#039;&#039; objects are used to defined them in awall&lt;br /&gt;
policy files. The top-level attribute &#039;&#039;&#039;ipset&#039;&#039;&#039; is a dictionary, the&lt;br /&gt;
keys of which are IP set names. The values are IP set objects, which&lt;br /&gt;
have two mandatory attributes. The attribute named &#039;&#039;&#039;type&#039;&#039;&#039; &lt;br /&gt;
corresponds to the type argument of the &amp;lt;tt&amp;gt;ipset create&amp;lt;/tt&amp;gt; &lt;br /&gt;
command. &#039;&#039;&#039;family&#039;&#039;&#039; specifies whether the set is for IPv4 or IPv6&lt;br /&gt;
addresses, and the possible values are &#039;&#039;&#039;inet&#039;&#039;&#039; and &#039;&#039;&#039;inet6&#039;&#039;&#039;,&lt;br /&gt;
correspondingly.&lt;br /&gt;
&lt;br /&gt;
For bitmap-type IP sets, the &#039;&#039;&#039;range&#039;&#039;&#039; attribute specifies the&lt;br /&gt;
range of allowed IPv4 addresses. It may be given as a network&lt;br /&gt;
address or two addresses separated by the &#039;&#039;&#039;-&#039;&#039;&#039; character. It&lt;br /&gt;
is not necessary to specify &#039;&#039;&#039;family&#039;&#039;&#039; for bitmaps, since the&lt;br /&gt;
kernel supports only IPv4 bitmaps.&lt;br /&gt;
&lt;br /&gt;
== Command Line Syntax ==&lt;br /&gt;
&lt;br /&gt;
=== Translating Policy Files to Firewall Configuration Files ===&lt;br /&gt;
&lt;br /&gt;
 &#039;&#039;&#039;awall translate&#039;&#039;&#039; [&#039;&#039;&#039;-o&#039;&#039;&#039;|&#039;&#039;&#039;--output&#039;&#039;&#039; DIRECTORY] [&#039;&#039;&#039;-V&#039;&#039;&#039;|&#039;&#039;&#039;--verify&#039;&#039;&#039;]&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;tt&amp;gt;--verify&amp;lt;/tt&amp;gt; option makes awall verify the configuration&lt;br /&gt;
using the test mode of iptables-restore before overwriting the old&lt;br /&gt;
files.&lt;br /&gt;
&lt;br /&gt;
Specifying the output directory allows testing awall policies without&lt;br /&gt;
overwriting the current iptables and ipset configuration files. By&lt;br /&gt;
default, awall generates the configuration to &amp;lt;tt&amp;gt;/etc/iptables&amp;lt;/tt&amp;gt; &lt;br /&gt;
and &amp;lt;tt&amp;gt;/etc/ipset.d&amp;lt;/tt&amp;gt;, which are read by the init scripts.&lt;br /&gt;
&lt;br /&gt;
=== Run-Time Configuration of Firewall ===&lt;br /&gt;
&lt;br /&gt;
 &#039;&#039;&#039;awall activate&#039;&#039;&#039; [&#039;&#039;&#039;-f&#039;&#039;&#039;|&#039;&#039;&#039;--force&#039;&#039;&#039;]&lt;br /&gt;
&lt;br /&gt;
This command genereates firewall configuration from the policy files&lt;br /&gt;
and enables it. If the user confirms the new configuration by hitting&lt;br /&gt;
the Return key within 10 seconds or the &amp;lt;tt&amp;gt;--force&amp;lt;/tt&amp;gt; option is&lt;br /&gt;
used, the configuration is saved to the files. Otherwise, the old&lt;br /&gt;
configuration is restored.&lt;br /&gt;
&lt;br /&gt;
There is also a command for deleting all firewall rules:&lt;br /&gt;
&lt;br /&gt;
 &#039;&#039;&#039;awall flush&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
This command configures the firewall to drop all packets.&lt;br /&gt;
&lt;br /&gt;
=== Optional Policies ===&lt;br /&gt;
&lt;br /&gt;
Optional policies can be enabled or disabled using this command:&lt;br /&gt;
&lt;br /&gt;
 &#039;&#039;&#039;awall&#039;&#039;&#039; {&#039;&#039;&#039;enable&#039;&#039;&#039;|&#039;&#039;&#039;disable&#039;&#039;&#039;} POLICY...&lt;br /&gt;
&lt;br /&gt;
Optional policies can be listed using this command:&lt;br /&gt;
&lt;br /&gt;
 &#039;&#039;&#039;awall list&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;&#039;enabled&#039;&#039;&#039; status means that the policy has been enabled by the&lt;br /&gt;
user. The &#039;&#039;&#039;disabled&#039;&#039;&#039; status means that the policy is not in&lt;br /&gt;
use. The &#039;&#039;&#039;required&#039;&#039;&#039; status means that the policy has not been&lt;br /&gt;
enabled by the user but is in use because it is required by another&lt;br /&gt;
policy which is in use.&lt;br /&gt;
&lt;br /&gt;
=== Debugging Policies ===&lt;br /&gt;
&lt;br /&gt;
This command can be used to dump variable, zone, and other definitions&lt;br /&gt;
as well as their source policies:&lt;br /&gt;
&lt;br /&gt;
 &#039;&#039;&#039;awall dump&#039;&#039;&#039; [LEVEL]&lt;br /&gt;
&lt;br /&gt;
The level is an integer in range 0&amp;amp;ndash;5 and defaults to 0. More&lt;br /&gt;
information is displayed on higher levels.&lt;br /&gt;
&lt;br /&gt;
[[Category:Networking]]&lt;br /&gt;
[[Category:Security]]&lt;/div&gt;</summary>
		<author><name>Kunkku</name></author>
	</entry>
	<entry>
		<id>https://wiki.alpinelinux.org/w/index.php?title=Alpine_Wall_User%27s_Guide&amp;diff=9010</id>
		<title>Alpine Wall User&#039;s Guide</title>
		<link rel="alternate" type="text/html" href="https://wiki.alpinelinux.org/w/index.php?title=Alpine_Wall_User%27s_Guide&amp;diff=9010"/>
		<updated>2013-01-30T08:23:54Z</updated>

		<summary type="html">&lt;p&gt;Kunkku: /* Filter Rules */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Configuration File Processing ==&lt;br /&gt;
&lt;br /&gt;
[[Alpine Wall]] (awall) reads its configuration from multiple&lt;br /&gt;
JSON-formatted files, called &#039;&#039;policy files&#039;&#039;. The processing starts&lt;br /&gt;
from directory &amp;lt;tt&amp;gt;/usr/share/awall/mandatory&amp;lt;/tt&amp;gt;, which contains&lt;br /&gt;
mandatory policy files shipped with APK packages. After that,&lt;br /&gt;
installation-specific policy files in &amp;lt;tt&amp;gt;/etc/awall&amp;lt;/tt&amp;gt; are&lt;br /&gt;
processed.&lt;br /&gt;
&lt;br /&gt;
The latter directory may also contain symbolic links to policy files&lt;br /&gt;
located in &amp;lt;tt&amp;gt;/usr/share/awall/optional&amp;lt;/tt&amp;gt; and&lt;br /&gt;
&amp;lt;tt&amp;gt;/etc/awall/optional&amp;lt;/tt&amp;gt;. These are optional policies, which can&lt;br /&gt;
be enabled on need basis. Such symbolic links are easily created and&lt;br /&gt;
destroyed using the &amp;lt;tt&amp;gt;awall enable&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;awall disable&amp;lt;/tt&amp;gt;&lt;br /&gt;
commands. &amp;lt;tt&amp;gt;awall list&amp;lt;/tt&amp;gt; shows which optional policies are&lt;br /&gt;
enabled and disabled. The command also prints the description of the&lt;br /&gt;
optional policy if defined in the file using a top-level attribute&lt;br /&gt;
named &#039;&#039;&#039;description&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Sometimes a policy file depends on other policy files. In this case,&lt;br /&gt;
the policy file must have a top-level attribute &#039;&#039;&#039;import&#039;&#039;&#039;, the&lt;br /&gt;
value of which is a list of policy names, which correspond to the file&lt;br /&gt;
names without the &amp;lt;tt&amp;gt;.json&amp;lt;/tt&amp;gt; suffix. By default, the policies&lt;br /&gt;
listed there are processed before the importing policy.&lt;br /&gt;
&lt;br /&gt;
The order of the generated iptables rules generally reflects the&lt;br /&gt;
processing order of their corresponding awall policies. The processing&lt;br /&gt;
order of policies can be adjusted by defining top-level attributes&lt;br /&gt;
&#039;&#039;&#039;after&#039;&#039;&#039; and &#039;&#039;&#039;before&#039;&#039;&#039; in policy files. These attributes are&lt;br /&gt;
lists of policies, after or before which the declaring policy shall be&lt;br /&gt;
processed. Putting a policy name to either of these lists does not by&lt;br /&gt;
itself import the policy. The ordering directives are ignored with&lt;br /&gt;
respect to those policies that are not enabled by the user or imported&lt;br /&gt;
by other policies. If not defined, &#039;&#039;&#039;after&#039;&#039;&#039; is assumed to be equal&lt;br /&gt;
to the &#039;&#039;&#039;import&#039;&#039;&#039; definition of the policy.&lt;br /&gt;
&lt;br /&gt;
As the import directive does not require the path name to be&lt;br /&gt;
specified, awall expects policies to have unique names, even if&lt;br /&gt;
located in different directories. It is allowed to import optional&lt;br /&gt;
policies that are not explicitly enabled by the user. Such policies&lt;br /&gt;
show up with the &amp;lt;tt&amp;gt;required&amp;lt;/tt&amp;gt; status in the output of &amp;lt;tt&amp;gt;awall&lt;br /&gt;
list&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
== List Parameters ==&lt;br /&gt;
&lt;br /&gt;
Several awall parameters are defined as lists of values. In order to&lt;br /&gt;
facilitate manual editing of policy files, awall also accepts single&lt;br /&gt;
values in place of lists. Such values are semantically equivalent to&lt;br /&gt;
lists containing one element.&lt;br /&gt;
&lt;br /&gt;
== Variable Expansion ==&lt;br /&gt;
&lt;br /&gt;
Awall allows variable definitions in policy files. The top-level&lt;br /&gt;
attribute &#039;&#039;&#039;variable&#039;&#039;&#039; is a dictionary containing the&lt;br /&gt;
definitions. The value of a variable can be of any type (string,&lt;br /&gt;
integer, list, or dictionary).&lt;br /&gt;
&lt;br /&gt;
A variable is referenced in policy files by a string which equals the&lt;br /&gt;
variable name prepended with the &#039;&#039;&#039;$&#039;&#039;&#039; character. If the value of&lt;br /&gt;
the variable is a string, the reference can be embedded into a longer&lt;br /&gt;
string in order to substitute some part of that string (in shell&lt;br /&gt;
style). Variable references can be used when defining other variables,&lt;br /&gt;
as long as the definitions are not circular.&lt;br /&gt;
&lt;br /&gt;
Policy files can reference variables defined in other policy&lt;br /&gt;
files. Policy files can also override variables defined elsewhere by&lt;br /&gt;
redefining them. In this case, the new definition affects all policy&lt;br /&gt;
files, also those processed before the overriding policy. Awall&lt;br /&gt;
variables are in fact simple macros, since each variable remains&lt;br /&gt;
constant thoughout a single processing round. If multiple files define&lt;br /&gt;
the same variable, the definition in the file processed last takes&lt;br /&gt;
effect.&lt;br /&gt;
&lt;br /&gt;
If defined as an empty string, all non-embedded references to a&lt;br /&gt;
variable evaluate as if the attribute in question was not present in&lt;br /&gt;
the configuration. This is also the case when a string containing&lt;br /&gt;
embedded variable references finally evaluates to an empty string.&lt;br /&gt;
&lt;br /&gt;
== Configuration Objects ==&lt;br /&gt;
&lt;br /&gt;
Configuration objects can be divided into two main types.&lt;br /&gt;
&#039;&#039;Auxiliary objects&#039;&#039; model high-level concepts such as services and&lt;br /&gt;
zones. &#039;&#039;Rule objects&#039;&#039; translate into one or more iptables rules, and&lt;br /&gt;
are often defined with the help of some auxiliary objects.&lt;br /&gt;
&lt;br /&gt;
=== Services ===&lt;br /&gt;
&lt;br /&gt;
A &#039;&#039;service&#039;&#039; represents a set of network protocols. A top-level&lt;br /&gt;
attribute &#039;&#039;&#039;service&#039;&#039;&#039; is a dictionary that maps service names to&lt;br /&gt;
service definition objects, or lists thereof in more complex cases.&lt;br /&gt;
&lt;br /&gt;
A service definition object contains an attribute named &#039;&#039;&#039;proto&#039;&#039;&#039;,&lt;br /&gt;
which corresponds to the &amp;lt;tt&amp;gt;--protocol&amp;lt;/tt&amp;gt; option of iptables. The&lt;br /&gt;
protocol can be defined as a numerical value or string as defined in&lt;br /&gt;
&amp;lt;tt&amp;gt;/etc/protocols&amp;lt;/tt&amp;gt;. If the protocol is &#039;&#039;&#039;tcp&#039;&#039;&#039; or &#039;&#039;&#039;udp&#039;&#039;&#039;,&lt;br /&gt;
the scope of the service definition may be constrained by defining an&lt;br /&gt;
attribute named &#039;&#039;&#039;port&#039;&#039;&#039;, which is a list of TCP or UDP port numbers&lt;br /&gt;
or ranges thereof, separated by the &#039;&#039;&#039;-&#039;&#039;&#039; character. If the protocol&lt;br /&gt;
is &#039;&#039;&#039;icmp&#039;&#039;&#039; or &#039;&#039;&#039;icmpv6&#039;&#039;&#039;, an analogous &#039;&#039;&#039;icmp-type&#039;&#039;&#039; attribute&lt;br /&gt;
may be used. In addition, the scope of the rule is also automatically&lt;br /&gt;
limited to IPv4 or IPv6, respectively.&lt;br /&gt;
&lt;br /&gt;
All rule objects, except for policies, may have an attribute named&lt;br /&gt;
&#039;&#039;&#039;service&#039;&#039;&#039;, constraining the rule&#039;s scope to specific services&lt;br /&gt;
only. This attribute is a list of service names, referring to the keys&lt;br /&gt;
of the top-level service dictionary.&lt;br /&gt;
&lt;br /&gt;
=== Zones ===&lt;br /&gt;
&lt;br /&gt;
A &#039;&#039;zone&#039;&#039; represents a set of network hosts. A top-level attribute &lt;br /&gt;
&#039;&#039;&#039;zone&#039;&#039;&#039; is a dictionary that maps zone names to zone objects. A&lt;br /&gt;
zone object has an attribute named &#039;&#039;&#039;iface&#039;&#039;&#039;, &#039;&#039;&#039;addr&#039;&#039;&#039;, or&lt;br /&gt;
both. &#039;&#039;&#039;iface&#039;&#039;&#039; is a list of network interfaces and &#039;&#039;&#039;addr&#039;&#039;&#039; is a&lt;br /&gt;
list of IPv4/IPv6 host and network addresses (CIDR&lt;br /&gt;
notation). &#039;&#039;&#039;addr&#039;&#039;&#039; may also contain domain names, which are&lt;br /&gt;
expanded to IP addresses using DNS resolution. If not defined,&lt;br /&gt;
&#039;&#039;&#039;addr&#039;&#039;&#039; defaults to the entire address space and &#039;&#039;&#039;iface&#039;&#039;&#039; to all&lt;br /&gt;
interfaces. An empty zone can be defined by setting either &#039;&#039;&#039;addr&#039;&#039;&#039;&lt;br /&gt;
or &#039;&#039;&#039;iface&#039;&#039;&#039; to an empty list.&lt;br /&gt;
&lt;br /&gt;
Rule objects contain two attributes, &#039;&#039;&#039;in&#039;&#039;&#039; and &#039;&#039;&#039;out&#039;&#039;&#039;, which are&lt;br /&gt;
lists of zone names. These attributes control whether a packet matches&lt;br /&gt;
the rule or not. If a particular zone is referenced by the &#039;&#039;&#039;in&#039;&#039;&#039; &lt;br /&gt;
attribute, the rule applies to packets whose ingress interface and&lt;br /&gt;
source address are covered by the zone definition. Correspondingly, if&lt;br /&gt;
a zone is referenced by the &#039;&#039;&#039;out&#039;&#039;&#039; attribute, the rule applies to&lt;br /&gt;
packets whose egress interface and destination address are included in&lt;br /&gt;
the zone. If both &#039;&#039;&#039;in&#039;&#039;&#039; and &#039;&#039;&#039;out&#039;&#039;&#039; are defined, the packet must&lt;br /&gt;
fulfill both criteria in order to match the rule.&lt;br /&gt;
&lt;br /&gt;
The firewall host itself can be referred to using the special value&lt;br /&gt;
&#039;&#039;&#039;_fw&#039;&#039;&#039; as the zone name.&lt;br /&gt;
&lt;br /&gt;
By default, awall does not generate iptables rules with identical&lt;br /&gt;
ingress and egress interfaces. This behavior can be changed per zone&lt;br /&gt;
by setting the optional &#039;&#039;&#039;route-back&#039;&#039;&#039; attribute of the zone to&lt;br /&gt;
&#039;&#039;&#039;true&#039;&#039;&#039;. Note that this attribute can have an effect also in the&lt;br /&gt;
case where &#039;&#039;&#039;in&#039;&#039;&#039; and &#039;&#039;&#039;out&#039;&#039;&#039; attributes of a rule are not equal&lt;br /&gt;
but their definitions overlap. In this case, the &#039;&#039;&#039;route-back&#039;&#039;&#039;&lt;br /&gt;
attribute of the &#039;&#039;&#039;out&#039;&#039;&#039; zone determines the behavior.&lt;br /&gt;
&lt;br /&gt;
=== Logging Classes ===&lt;br /&gt;
&lt;br /&gt;
A &#039;&#039;logging class&#039;&#039; specifies how packets matching certain rules are&lt;br /&gt;
logged. A top-level attribute &#039;&#039;&#039;log&#039;&#039;&#039; is a dictionary that maps&lt;br /&gt;
logging class names to setting objects.&lt;br /&gt;
&lt;br /&gt;
A setting object may have an attribute named &#039;&#039;&#039;mode&#039;&#039;&#039;, which&lt;br /&gt;
specifies which logging facility to use. Allowed values are &#039;&#039;&#039;log&#039;&#039;&#039;,&lt;br /&gt;
&#039;&#039;&#039;nflog&#039;&#039;&#039;, and &#039;&#039;&#039;ulog&#039;&#039;&#039;. The default is &#039;&#039;&#039;log&#039;&#039;&#039;, i.e. in-kernel&lt;br /&gt;
logging. The object may also have a &#039;&#039;&#039;limit&#039;&#039;&#039; attribute, which is an&lt;br /&gt;
integer specifying the maximum number of matching packets to be logged&lt;br /&gt;
per second per rule. Optionally, the log entries are prefixed with a&lt;br /&gt;
string configured using the &#039;&#039;&#039;prefix&#039;&#039;&#039; attribute.&lt;br /&gt;
&lt;br /&gt;
Filter and policy rules can have an attribute named &#039;&#039;&#039;log&#039;&#039;&#039;. If it&lt;br /&gt;
is a string, it is interpreted as a reference to a logging class, and&lt;br /&gt;
logging is performed according to the definitions. If the value of the&lt;br /&gt;
&#039;&#039;&#039;log&#039;&#039;&#039; attribute is &#039;&#039;&#039;true&#039;&#039;&#039; (boolean), logging is done using&lt;br /&gt;
default settings. If the value is &#039;&#039;&#039;false&#039;&#039;&#039; (boolean), logging is&lt;br /&gt;
disabled for the rule. If &#039;&#039;&#039;log&#039;&#039;&#039; is not defined, logging is done&lt;br /&gt;
using the default settings except for accept rules, for which logging&lt;br /&gt;
is omitted.&lt;br /&gt;
&lt;br /&gt;
Default logging settings can be set by defining a logging class named&lt;br /&gt;
&#039;&#039;&#039;_default&#039;&#039;&#039;. Normally, default logging uses the &#039;&#039;&#039;log&#039;&#039;&#039; mode with&lt;br /&gt;
packets limited to one per second.&lt;br /&gt;
&lt;br /&gt;
=== Rules ===&lt;br /&gt;
&lt;br /&gt;
There are six types of rule objects:&lt;br /&gt;
* Filter rules&lt;br /&gt;
* Policy rules&lt;br /&gt;
* NAT rules&lt;br /&gt;
* Packet Marking rules&lt;br /&gt;
* Transparent Proxy rules&lt;br /&gt;
* MSS Clamping rules&lt;br /&gt;
* Connection Tracking Bypass rules&lt;br /&gt;
&lt;br /&gt;
All rule objects can have the &#039;&#039;&#039;in&#039;&#039;&#039; and &#039;&#039;&#039;out&#039;&#039;&#039; attributes&lt;br /&gt;
referring to zones as described in the previous section. In addition,&lt;br /&gt;
the scope of the rule can be further constrained with the following&lt;br /&gt;
attributes:&lt;br /&gt;
&lt;br /&gt;
{|&lt;br /&gt;
!Attribute!!Value format!!Effect&lt;br /&gt;
|-&lt;br /&gt;
|&#039;&#039;&#039;src&#039;&#039;&#039;&lt;br /&gt;
|Similar to &#039;&#039;&#039;addr&#039;&#039;&#039; attribute of zone objects&lt;br /&gt;
|Packet&#039;s source address matches the value&lt;br /&gt;
|-&lt;br /&gt;
|&#039;&#039;&#039;dest&#039;&#039;&#039;&lt;br /&gt;
|Similar to &#039;&#039;&#039;addr&#039;&#039;&#039; attribute of zone objects&lt;br /&gt;
|Packet&#039;s destination address matches the value&lt;br /&gt;
|-&lt;br /&gt;
|&#039;&#039;&#039;ipset&#039;&#039;&#039;&lt;br /&gt;
|Object containing two attributes: &#039;&#039;&#039;name&#039;&#039;&#039; referring to an IP set and &#039;&#039;&#039;args&#039;&#039;&#039;, which is a list of strings &#039;&#039;&#039;in&#039;&#039;&#039; and &#039;&#039;&#039;out&#039;&#039;&#039;&lt;br /&gt;
|Packet matches the IP set referred here when the match arguments are taken from the source (&#039;&#039;&#039;in&#039;&#039;&#039;) and destination (&#039;&#039;&#039;out&#039;&#039;&#039;) address or port in the order specified by &#039;&#039;&#039;args&#039;&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
|&#039;&#039;&#039;ipsec&#039;&#039;&#039;&lt;br /&gt;
|&#039;&#039;&#039;in&#039;&#039;&#039; or &#039;&#039;&#039;out&#039;&#039;&#039;&lt;br /&gt;
|IPsec decapsulation perfomed on ingress (&#039;&#039;&#039;in&#039;&#039;&#039;) or encapsulation performed on egress (&#039;&#039;&#039;out&#039;&#039;&#039;)&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Rule objects are declared in type-specific top-level dictionaries in&lt;br /&gt;
awall policy files. If a packet matches multiple rules, the one&lt;br /&gt;
appearing earlier in the list takes precedence. If the matching rules&lt;br /&gt;
are defined in different policy files, the one that was processed&lt;br /&gt;
earlier takes precedence in the current implementation, but this may&lt;br /&gt;
change in future versions.&lt;br /&gt;
&lt;br /&gt;
==== Filter Rules ====&lt;br /&gt;
&lt;br /&gt;
Filter objects specify an action for packets fulfilling certain&lt;br /&gt;
criteria. The top-level attribute &#039;&#039;&#039;filter&#039;&#039;&#039; is a list of filter&lt;br /&gt;
objects. The precedence rules are similar to those of policy objects.&lt;br /&gt;
&lt;br /&gt;
Filter objects must have an attribute named &#039;&#039;&#039;action&#039;&#039;&#039;, the value of&lt;br /&gt;
which can be one of the following:&lt;br /&gt;
&lt;br /&gt;
{|&lt;br /&gt;
!Value!!Action&lt;br /&gt;
|-&lt;br /&gt;
|&#039;&#039;&#039;accept&#039;&#039;&#039;&lt;br /&gt;
|Accept the packet&lt;br /&gt;
|-&lt;br /&gt;
|&#039;&#039;&#039;reject&#039;&#039;&#039;&lt;br /&gt;
|Reject the packet with an ICMP error message&lt;br /&gt;
|-&lt;br /&gt;
|&#039;&#039;&#039;drop&#039;&#039;&#039;&lt;br /&gt;
|Silently drop the packet&lt;br /&gt;
|-&lt;br /&gt;
|&#039;&#039;&#039;tarpit&#039;&#039;&#039;&lt;br /&gt;
|Put incoming TCP connections into persist state and ignore attempts to close them. Silently drop non-TCP packets. (Connection tracking bypass is automatically enabled for the matching packets.)&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Filter objects, the action of which is &#039;&#039;&#039;accept&#039;&#039;&#039;, may also contain&lt;br /&gt;
limits for packet flow or new connections. These are specified with&lt;br /&gt;
the &#039;&#039;&#039;flow-limit&#039;&#039;&#039; and &#039;&#039;&#039;conn-limit&#039;&#039;&#039; attributes,&lt;br /&gt;
respectively. The values of these attributes are limit objects that&lt;br /&gt;
have two attributes: &#039;&#039;&#039;count&#039;&#039;&#039; and &#039;&#039;&#039;interval&#039;&#039;&#039;. &#039;&#039;&#039;count&#039;&#039;&#039;&lt;br /&gt;
specifies how many new connections or packets are allowed within the&lt;br /&gt;
time frame specified by &#039;&#039;&#039;interval&#039;&#039;&#039; in seconds (default: 1). The&lt;br /&gt;
&#039;&#039;&#039;drop&#039;&#039;&#039; action is applied to the packets exceeding the&lt;br /&gt;
limit. Optionally, the limit object may have an attribute named&lt;br /&gt;
&#039;&#039;&#039;log&#039;&#039;&#039;. It defines how the dropped packets should be logged and is&lt;br /&gt;
semantically similar to the &#039;&#039;&#039;log&#039;&#039;&#039; attribute of rule objects. A&lt;br /&gt;
limit may also be specified by a plain integer, which is interpreted&lt;br /&gt;
as the count while using default interval and log settings.&lt;br /&gt;
&lt;br /&gt;
Filter objects may have an attribute named &#039;&#039;&#039;dnat&#039;&#039;&#039;, the value of&lt;br /&gt;
which is an IPv4 address. If defined, this enables destination NAT for&lt;br /&gt;
all IPv4 packets matching the rule, such that the specified address&lt;br /&gt;
replaces the original destination address. This option has no effect&lt;br /&gt;
on IPv6 packets.&lt;br /&gt;
&lt;br /&gt;
Filter objects may have a boolean attribute named &#039;&#039;&#039;no-track&#039;&#039;&#039;. If&lt;br /&gt;
set to &#039;&#039;&#039;true&#039;&#039;&#039;, connection tracking is bypassed for the matching&lt;br /&gt;
packets. In addition, if &#039;&#039;&#039;action&#039;&#039;&#039; is set to &#039;&#039;&#039;accept&#039;&#039;&#039;, the&lt;br /&gt;
corresponding packets travelling to the reverse direction are also&lt;br /&gt;
allowed.&lt;br /&gt;
&lt;br /&gt;
==== Policy Rules ====&lt;br /&gt;
&lt;br /&gt;
Policy objects describe the default action for packets that did not&lt;br /&gt;
match any filter. The top-level attribute &#039;&#039;&#039;policy&#039;&#039;&#039; is a list of&lt;br /&gt;
policy objects.&lt;br /&gt;
&lt;br /&gt;
Policy objects must have the &#039;&#039;&#039;action&#039;&#039;&#039; attribute defined. The&lt;br /&gt;
possible values and their semantics are the same as in filter objects.&lt;br /&gt;
&lt;br /&gt;
==== NAT Rules ====&lt;br /&gt;
&lt;br /&gt;
NAT rules come in two flavors: &#039;&#039;source NAT rules&#039;&#039; and&lt;br /&gt;
&#039;&#039;destination NAT rules&#039;&#039;. These are contained in two top-level lists&lt;br /&gt;
named &#039;&#039;&#039;snat&#039;&#039;&#039; and &#039;&#039;&#039;dnat&#039;&#039;&#039;, respectively.&lt;br /&gt;
&lt;br /&gt;
Each NAT rule may have an attribute named &#039;&#039;&#039;to-addr&#039;&#039;&#039; that&lt;br /&gt;
specifies the IPv4 address range to which the original source or&lt;br /&gt;
destination address is mapped. The value can be a single IPv4 address&lt;br /&gt;
or a range specified by two addresses, separated with the &#039;&#039;&#039;-&#039;&#039;&#039;&lt;br /&gt;
character. If not defined, it defaults to the primary address of the&lt;br /&gt;
ingress interface in case of destination NAT, or that of the egress&lt;br /&gt;
interface in case of source NAT.&lt;br /&gt;
&lt;br /&gt;
Optionally, a NAT rule can specify the TCP and UDP port range to which&lt;br /&gt;
the original source or destination port is mapped. The attribute is&lt;br /&gt;
named &#039;&#039;&#039;to-port&#039;&#039;&#039;, and the value can be a single port number or a&lt;br /&gt;
range specified by two numbers, separated with the &#039;&#039;&#039;-&#039;&#039;&#039;&lt;br /&gt;
character. If &#039;&#039;&#039;to-port&#039;&#039;&#039; is not specified, the original port number&lt;br /&gt;
is kept intact.&lt;br /&gt;
&lt;br /&gt;
NAT rules may have an &#039;&#039;&#039;action&#039;&#039;&#039; attribute set to value&lt;br /&gt;
&#039;&#039;&#039;accept&#039;&#039;&#039;. In this case, NAT is not performed on the packets&lt;br /&gt;
reaching and matching this rule.&lt;br /&gt;
&lt;br /&gt;
==== Packet Marking Rules ====&lt;br /&gt;
&lt;br /&gt;
Packet marking rules are used to mark incoming packets matching the&lt;br /&gt;
specified criteria. The mark can be used as a basis for the routing&lt;br /&gt;
decision. Each marking rule must specify the mark using the &#039;&#039;&#039;mark&#039;&#039;&#039;&lt;br /&gt;
attribute, which is a 32-bit integer.&lt;br /&gt;
&lt;br /&gt;
Normal marking rules are contained by the top-level list attribute&lt;br /&gt;
named &#039;&#039;&#039;mark&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
There is another top-level list attribute, named &#039;&#039;&#039;route-track&#039;&#039;&#039;,&lt;br /&gt;
which contains route tracking rules. These are special marking rules&lt;br /&gt;
which cause all the subsequent packets related to the same connection&lt;br /&gt;
to be marked according to the rule.&lt;br /&gt;
&lt;br /&gt;
==== Transparent Proxy Rules ====&lt;br /&gt;
&lt;br /&gt;
Transparent proxy rules divert the matching packets to a local proxy&lt;br /&gt;
process without altering their headers. Such rules are contained in&lt;br /&gt;
the top-level list named &#039;&#039;&#039;tproxy&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
In addition to the firewall configuration, using a transparent proxy&lt;br /&gt;
requires a routing configuration where packets marked for proxying are&lt;br /&gt;
diverted to a local process. The &#039;&#039;&#039;mark&#039;&#039;&#039; attribute of a proxy rule&lt;br /&gt;
specifies the mark to be used.&lt;br /&gt;
&lt;br /&gt;
Proxy rules may also have an attribute named &#039;&#039;&#039;to-port&#039;&#039;&#039; for&lt;br /&gt;
specifying the TCP or UDP port of the proxy if it is different from&lt;br /&gt;
the original destination port.&lt;br /&gt;
&lt;br /&gt;
==== MSS Clamping Rules ====&lt;br /&gt;
&lt;br /&gt;
MSS Clamping Rules are used to deal with ISPs that block ICMP&lt;br /&gt;
Fragmentation Needed or ICMPv6 Packet Too Big packets. An MSS clamping&lt;br /&gt;
rule overwrites the MSS option with a value specified with the&lt;br /&gt;
&#039;&#039;&#039;mss&#039;&#039;&#039; attribute for the matching TCP connections. If &#039;&#039;&#039;mss&#039;&#039;&#039; is&lt;br /&gt;
not specified, a suitable value is automatically determined from the&lt;br /&gt;
path MTU. The MSS clamping rules are located in the top-level&lt;br /&gt;
dictionary named &#039;&#039;&#039;clamp-mss&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
==== Connection Tracking Bypass Rules ====&lt;br /&gt;
&lt;br /&gt;
Connection tracking bypass rules are used to disable connection&lt;br /&gt;
tracking for packets matching the specified criteria. The top-level&lt;br /&gt;
attribute &#039;&#039;&#039;no-track&#039;&#039;&#039; is a list of such rules.&lt;br /&gt;
&lt;br /&gt;
Connection tracking bypass rules may have an &#039;&#039;&#039;action&#039;&#039;&#039; attribute&lt;br /&gt;
set to value &#039;&#039;&#039;accept&#039;&#039;&#039;. The effect is similar to corresponding NAT&lt;br /&gt;
rules, i.e. connection tracking is not bypassed for the matching&lt;br /&gt;
packets.&lt;br /&gt;
&lt;br /&gt;
=== IP Sets ===&lt;br /&gt;
&lt;br /&gt;
Any IP set referenced by rule objects should be created by&lt;br /&gt;
awall. Auxiliary &#039;&#039;IP set&#039;&#039; objects are used to defined them in awall&lt;br /&gt;
policy files. The top-level attribute &#039;&#039;&#039;ipset&#039;&#039;&#039; is a dictionary, the&lt;br /&gt;
keys of which are IP set names. The values are IP set objects, which&lt;br /&gt;
have two mandatory attributes. The attribute named &#039;&#039;&#039;type&#039;&#039;&#039; &lt;br /&gt;
corresponds to the type argument of the &amp;lt;tt&amp;gt;ipset create&amp;lt;/tt&amp;gt; &lt;br /&gt;
command. &#039;&#039;&#039;family&#039;&#039;&#039; specifies whether the set is for IPv4 or IPv6&lt;br /&gt;
addresses, and the possible values are &#039;&#039;&#039;inet&#039;&#039;&#039; and &#039;&#039;&#039;inet6&#039;&#039;&#039;,&lt;br /&gt;
correspondingly.&lt;br /&gt;
&lt;br /&gt;
For bitmap-type IP sets, the &#039;&#039;&#039;range&#039;&#039;&#039; attribute specifies the&lt;br /&gt;
range of allowed IPv4 addresses. It may be given as a network&lt;br /&gt;
address or two addresses separated by the &#039;&#039;&#039;-&#039;&#039;&#039; character. It&lt;br /&gt;
is not necessary to specify &#039;&#039;&#039;family&#039;&#039;&#039; for bitmaps, since the&lt;br /&gt;
kernel supports only IPv4 bitmaps.&lt;br /&gt;
&lt;br /&gt;
== Command Line Syntax ==&lt;br /&gt;
&lt;br /&gt;
=== Translating Policy Files to Firewall Configuration Files ===&lt;br /&gt;
&lt;br /&gt;
 &#039;&#039;&#039;awall translate&#039;&#039;&#039; [&#039;&#039;&#039;-o&#039;&#039;&#039;|&#039;&#039;&#039;--output&#039;&#039;&#039; DIRECTORY] [&#039;&#039;&#039;-V&#039;&#039;&#039;|&#039;&#039;&#039;--verify&#039;&#039;&#039;]&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;tt&amp;gt;--verify&amp;lt;/tt&amp;gt; option makes awall verify the configuration&lt;br /&gt;
using the test mode of iptables-restore before overwriting the old&lt;br /&gt;
files.&lt;br /&gt;
&lt;br /&gt;
Specifying the output directory allows testing awall policies without&lt;br /&gt;
overwriting the current iptables and ipset configuration files. By&lt;br /&gt;
default, awall generates the configuration to &amp;lt;tt&amp;gt;/etc/iptables&amp;lt;/tt&amp;gt; &lt;br /&gt;
and &amp;lt;tt&amp;gt;/etc/ipset.d&amp;lt;/tt&amp;gt;, which are read by the init scripts.&lt;br /&gt;
&lt;br /&gt;
=== Run-Time Configuration of Firewall ===&lt;br /&gt;
&lt;br /&gt;
 &#039;&#039;&#039;awall activate&#039;&#039;&#039; [&#039;&#039;&#039;-f&#039;&#039;&#039;|&#039;&#039;&#039;--force&#039;&#039;&#039;]&lt;br /&gt;
&lt;br /&gt;
This command genereates firewall configuration from the policy files&lt;br /&gt;
and enables it. If the user confirms the new configuration by hitting&lt;br /&gt;
the Return key within 10 seconds or the &amp;lt;tt&amp;gt;--force&amp;lt;/tt&amp;gt; option is&lt;br /&gt;
used, the configuration is saved to the files. Otherwise, the old&lt;br /&gt;
configuration is restored.&lt;br /&gt;
&lt;br /&gt;
There is also a command for deleting all firewall rules:&lt;br /&gt;
&lt;br /&gt;
 &#039;&#039;&#039;awall flush&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
This command configures the firewall to drop all packets.&lt;br /&gt;
&lt;br /&gt;
=== Optional Policies ===&lt;br /&gt;
&lt;br /&gt;
Optional policies can be enabled or disabled using this command:&lt;br /&gt;
&lt;br /&gt;
 &#039;&#039;&#039;awall&#039;&#039;&#039; {&#039;&#039;&#039;enable&#039;&#039;&#039;|&#039;&#039;&#039;disable&#039;&#039;&#039;} POLICY...&lt;br /&gt;
&lt;br /&gt;
Optional policies can be listed using this command:&lt;br /&gt;
&lt;br /&gt;
 &#039;&#039;&#039;awall list&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;&#039;enabled&#039;&#039;&#039; status means that the policy has been enabled by the&lt;br /&gt;
user. The &#039;&#039;&#039;disabled&#039;&#039;&#039; status means that the policy is not in&lt;br /&gt;
use. The &#039;&#039;&#039;required&#039;&#039;&#039; status means that the policy has not been&lt;br /&gt;
enabled by the user but is in use because it is required by another&lt;br /&gt;
policy which is in use.&lt;br /&gt;
&lt;br /&gt;
=== Debugging Policies ===&lt;br /&gt;
&lt;br /&gt;
This command can be used to dump variable, zone, and other definitions&lt;br /&gt;
as well as their source policies:&lt;br /&gt;
&lt;br /&gt;
 &#039;&#039;&#039;awall dump&#039;&#039;&#039; [LEVEL]&lt;br /&gt;
&lt;br /&gt;
The level is an integer in range 0&amp;amp;ndash;5 and defaults to 0. More&lt;br /&gt;
information is displayed on higher levels.&lt;br /&gt;
&lt;br /&gt;
[[Category:Networking]]&lt;br /&gt;
[[Category:Security]]&lt;/div&gt;</summary>
		<author><name>Kunkku</name></author>
	</entry>
	<entry>
		<id>https://wiki.alpinelinux.org/w/index.php?title=Alpine_Wall_User%27s_Guide&amp;diff=9009</id>
		<title>Alpine Wall User&#039;s Guide</title>
		<link rel="alternate" type="text/html" href="https://wiki.alpinelinux.org/w/index.php?title=Alpine_Wall_User%27s_Guide&amp;diff=9009"/>
		<updated>2013-01-29T11:21:42Z</updated>

		<summary type="html">&lt;p&gt;Kunkku: /* Configuration Objects */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Configuration File Processing ==&lt;br /&gt;
&lt;br /&gt;
[[Alpine Wall]] (awall) reads its configuration from multiple&lt;br /&gt;
JSON-formatted files, called &#039;&#039;policy files&#039;&#039;. The processing starts&lt;br /&gt;
from directory &amp;lt;tt&amp;gt;/usr/share/awall/mandatory&amp;lt;/tt&amp;gt;, which contains&lt;br /&gt;
mandatory policy files shipped with APK packages. After that,&lt;br /&gt;
installation-specific policy files in &amp;lt;tt&amp;gt;/etc/awall&amp;lt;/tt&amp;gt; are&lt;br /&gt;
processed.&lt;br /&gt;
&lt;br /&gt;
The latter directory may also contain symbolic links to policy files&lt;br /&gt;
located in &amp;lt;tt&amp;gt;/usr/share/awall/optional&amp;lt;/tt&amp;gt; and&lt;br /&gt;
&amp;lt;tt&amp;gt;/etc/awall/optional&amp;lt;/tt&amp;gt;. These are optional policies, which can&lt;br /&gt;
be enabled on need basis. Such symbolic links are easily created and&lt;br /&gt;
destroyed using the &amp;lt;tt&amp;gt;awall enable&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;awall disable&amp;lt;/tt&amp;gt;&lt;br /&gt;
commands. &amp;lt;tt&amp;gt;awall list&amp;lt;/tt&amp;gt; shows which optional policies are&lt;br /&gt;
enabled and disabled. The command also prints the description of the&lt;br /&gt;
optional policy if defined in the file using a top-level attribute&lt;br /&gt;
named &#039;&#039;&#039;description&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Sometimes a policy file depends on other policy files. In this case,&lt;br /&gt;
the policy file must have a top-level attribute &#039;&#039;&#039;import&#039;&#039;&#039;, the&lt;br /&gt;
value of which is a list of policy names, which correspond to the file&lt;br /&gt;
names without the &amp;lt;tt&amp;gt;.json&amp;lt;/tt&amp;gt; suffix. By default, the policies&lt;br /&gt;
listed there are processed before the importing policy.&lt;br /&gt;
&lt;br /&gt;
The order of the generated iptables rules generally reflects the&lt;br /&gt;
processing order of their corresponding awall policies. The processing&lt;br /&gt;
order of policies can be adjusted by defining top-level attributes&lt;br /&gt;
&#039;&#039;&#039;after&#039;&#039;&#039; and &#039;&#039;&#039;before&#039;&#039;&#039; in policy files. These attributes are&lt;br /&gt;
lists of policies, after or before which the declaring policy shall be&lt;br /&gt;
processed. Putting a policy name to either of these lists does not by&lt;br /&gt;
itself import the policy. The ordering directives are ignored with&lt;br /&gt;
respect to those policies that are not enabled by the user or imported&lt;br /&gt;
by other policies. If not defined, &#039;&#039;&#039;after&#039;&#039;&#039; is assumed to be equal&lt;br /&gt;
to the &#039;&#039;&#039;import&#039;&#039;&#039; definition of the policy.&lt;br /&gt;
&lt;br /&gt;
As the import directive does not require the path name to be&lt;br /&gt;
specified, awall expects policies to have unique names, even if&lt;br /&gt;
located in different directories. It is allowed to import optional&lt;br /&gt;
policies that are not explicitly enabled by the user. Such policies&lt;br /&gt;
show up with the &amp;lt;tt&amp;gt;required&amp;lt;/tt&amp;gt; status in the output of &amp;lt;tt&amp;gt;awall&lt;br /&gt;
list&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
== List Parameters ==&lt;br /&gt;
&lt;br /&gt;
Several awall parameters are defined as lists of values. In order to&lt;br /&gt;
facilitate manual editing of policy files, awall also accepts single&lt;br /&gt;
values in place of lists. Such values are semantically equivalent to&lt;br /&gt;
lists containing one element.&lt;br /&gt;
&lt;br /&gt;
== Variable Expansion ==&lt;br /&gt;
&lt;br /&gt;
Awall allows variable definitions in policy files. The top-level&lt;br /&gt;
attribute &#039;&#039;&#039;variable&#039;&#039;&#039; is a dictionary containing the&lt;br /&gt;
definitions. The value of a variable can be of any type (string,&lt;br /&gt;
integer, list, or dictionary).&lt;br /&gt;
&lt;br /&gt;
A variable is referenced in policy files by a string which equals the&lt;br /&gt;
variable name prepended with the &#039;&#039;&#039;$&#039;&#039;&#039; character. If the value of&lt;br /&gt;
the variable is a string, the reference can be embedded into a longer&lt;br /&gt;
string in order to substitute some part of that string (in shell&lt;br /&gt;
style). Variable references can be used when defining other variables,&lt;br /&gt;
as long as the definitions are not circular.&lt;br /&gt;
&lt;br /&gt;
Policy files can reference variables defined in other policy&lt;br /&gt;
files. Policy files can also override variables defined elsewhere by&lt;br /&gt;
redefining them. In this case, the new definition affects all policy&lt;br /&gt;
files, also those processed before the overriding policy. Awall&lt;br /&gt;
variables are in fact simple macros, since each variable remains&lt;br /&gt;
constant thoughout a single processing round. If multiple files define&lt;br /&gt;
the same variable, the definition in the file processed last takes&lt;br /&gt;
effect.&lt;br /&gt;
&lt;br /&gt;
If defined as an empty string, all non-embedded references to a&lt;br /&gt;
variable evaluate as if the attribute in question was not present in&lt;br /&gt;
the configuration. This is also the case when a string containing&lt;br /&gt;
embedded variable references finally evaluates to an empty string.&lt;br /&gt;
&lt;br /&gt;
== Configuration Objects ==&lt;br /&gt;
&lt;br /&gt;
Configuration objects can be divided into two main types.&lt;br /&gt;
&#039;&#039;Auxiliary objects&#039;&#039; model high-level concepts such as services and&lt;br /&gt;
zones. &#039;&#039;Rule objects&#039;&#039; translate into one or more iptables rules, and&lt;br /&gt;
are often defined with the help of some auxiliary objects.&lt;br /&gt;
&lt;br /&gt;
=== Services ===&lt;br /&gt;
&lt;br /&gt;
A &#039;&#039;service&#039;&#039; represents a set of network protocols. A top-level&lt;br /&gt;
attribute &#039;&#039;&#039;service&#039;&#039;&#039; is a dictionary that maps service names to&lt;br /&gt;
service definition objects, or lists thereof in more complex cases.&lt;br /&gt;
&lt;br /&gt;
A service definition object contains an attribute named &#039;&#039;&#039;proto&#039;&#039;&#039;,&lt;br /&gt;
which corresponds to the &amp;lt;tt&amp;gt;--protocol&amp;lt;/tt&amp;gt; option of iptables. The&lt;br /&gt;
protocol can be defined as a numerical value or string as defined in&lt;br /&gt;
&amp;lt;tt&amp;gt;/etc/protocols&amp;lt;/tt&amp;gt;. If the protocol is &#039;&#039;&#039;tcp&#039;&#039;&#039; or &#039;&#039;&#039;udp&#039;&#039;&#039;,&lt;br /&gt;
the scope of the service definition may be constrained by defining an&lt;br /&gt;
attribute named &#039;&#039;&#039;port&#039;&#039;&#039;, which is a list of TCP or UDP port numbers&lt;br /&gt;
or ranges thereof, separated by the &#039;&#039;&#039;-&#039;&#039;&#039; character. If the protocol&lt;br /&gt;
is &#039;&#039;&#039;icmp&#039;&#039;&#039; or &#039;&#039;&#039;icmpv6&#039;&#039;&#039;, an analogous &#039;&#039;&#039;icmp-type&#039;&#039;&#039; attribute&lt;br /&gt;
may be used. In addition, the scope of the rule is also automatically&lt;br /&gt;
limited to IPv4 or IPv6, respectively.&lt;br /&gt;
&lt;br /&gt;
All rule objects, except for policies, may have an attribute named&lt;br /&gt;
&#039;&#039;&#039;service&#039;&#039;&#039;, constraining the rule&#039;s scope to specific services&lt;br /&gt;
only. This attribute is a list of service names, referring to the keys&lt;br /&gt;
of the top-level service dictionary.&lt;br /&gt;
&lt;br /&gt;
=== Zones ===&lt;br /&gt;
&lt;br /&gt;
A &#039;&#039;zone&#039;&#039; represents a set of network hosts. A top-level attribute &lt;br /&gt;
&#039;&#039;&#039;zone&#039;&#039;&#039; is a dictionary that maps zone names to zone objects. A&lt;br /&gt;
zone object has an attribute named &#039;&#039;&#039;iface&#039;&#039;&#039;, &#039;&#039;&#039;addr&#039;&#039;&#039;, or&lt;br /&gt;
both. &#039;&#039;&#039;iface&#039;&#039;&#039; is a list of network interfaces and &#039;&#039;&#039;addr&#039;&#039;&#039; is a&lt;br /&gt;
list of IPv4/IPv6 host and network addresses (CIDR&lt;br /&gt;
notation). &#039;&#039;&#039;addr&#039;&#039;&#039; may also contain domain names, which are&lt;br /&gt;
expanded to IP addresses using DNS resolution. If not defined,&lt;br /&gt;
&#039;&#039;&#039;addr&#039;&#039;&#039; defaults to the entire address space and &#039;&#039;&#039;iface&#039;&#039;&#039; to all&lt;br /&gt;
interfaces. An empty zone can be defined by setting either &#039;&#039;&#039;addr&#039;&#039;&#039;&lt;br /&gt;
or &#039;&#039;&#039;iface&#039;&#039;&#039; to an empty list.&lt;br /&gt;
&lt;br /&gt;
Rule objects contain two attributes, &#039;&#039;&#039;in&#039;&#039;&#039; and &#039;&#039;&#039;out&#039;&#039;&#039;, which are&lt;br /&gt;
lists of zone names. These attributes control whether a packet matches&lt;br /&gt;
the rule or not. If a particular zone is referenced by the &#039;&#039;&#039;in&#039;&#039;&#039; &lt;br /&gt;
attribute, the rule applies to packets whose ingress interface and&lt;br /&gt;
source address are covered by the zone definition. Correspondingly, if&lt;br /&gt;
a zone is referenced by the &#039;&#039;&#039;out&#039;&#039;&#039; attribute, the rule applies to&lt;br /&gt;
packets whose egress interface and destination address are included in&lt;br /&gt;
the zone. If both &#039;&#039;&#039;in&#039;&#039;&#039; and &#039;&#039;&#039;out&#039;&#039;&#039; are defined, the packet must&lt;br /&gt;
fulfill both criteria in order to match the rule.&lt;br /&gt;
&lt;br /&gt;
The firewall host itself can be referred to using the special value&lt;br /&gt;
&#039;&#039;&#039;_fw&#039;&#039;&#039; as the zone name.&lt;br /&gt;
&lt;br /&gt;
By default, awall does not generate iptables rules with identical&lt;br /&gt;
ingress and egress interfaces. This behavior can be changed per zone&lt;br /&gt;
by setting the optional &#039;&#039;&#039;route-back&#039;&#039;&#039; attribute of the zone to&lt;br /&gt;
&#039;&#039;&#039;true&#039;&#039;&#039;. Note that this attribute can have an effect also in the&lt;br /&gt;
case where &#039;&#039;&#039;in&#039;&#039;&#039; and &#039;&#039;&#039;out&#039;&#039;&#039; attributes of a rule are not equal&lt;br /&gt;
but their definitions overlap. In this case, the &#039;&#039;&#039;route-back&#039;&#039;&#039;&lt;br /&gt;
attribute of the &#039;&#039;&#039;out&#039;&#039;&#039; zone determines the behavior.&lt;br /&gt;
&lt;br /&gt;
=== Logging Classes ===&lt;br /&gt;
&lt;br /&gt;
A &#039;&#039;logging class&#039;&#039; specifies how packets matching certain rules are&lt;br /&gt;
logged. A top-level attribute &#039;&#039;&#039;log&#039;&#039;&#039; is a dictionary that maps&lt;br /&gt;
logging class names to setting objects.&lt;br /&gt;
&lt;br /&gt;
A setting object may have an attribute named &#039;&#039;&#039;mode&#039;&#039;&#039;, which&lt;br /&gt;
specifies which logging facility to use. Allowed values are &#039;&#039;&#039;log&#039;&#039;&#039;,&lt;br /&gt;
&#039;&#039;&#039;nflog&#039;&#039;&#039;, and &#039;&#039;&#039;ulog&#039;&#039;&#039;. The default is &#039;&#039;&#039;log&#039;&#039;&#039;, i.e. in-kernel&lt;br /&gt;
logging. The object may also have a &#039;&#039;&#039;limit&#039;&#039;&#039; attribute, which is an&lt;br /&gt;
integer specifying the maximum number of matching packets to be logged&lt;br /&gt;
per second per rule. Optionally, the log entries are prefixed with a&lt;br /&gt;
string configured using the &#039;&#039;&#039;prefix&#039;&#039;&#039; attribute.&lt;br /&gt;
&lt;br /&gt;
Filter and policy rules can have an attribute named &#039;&#039;&#039;log&#039;&#039;&#039;. If it&lt;br /&gt;
is a string, it is interpreted as a reference to a logging class, and&lt;br /&gt;
logging is performed according to the definitions. If the value of the&lt;br /&gt;
&#039;&#039;&#039;log&#039;&#039;&#039; attribute is &#039;&#039;&#039;true&#039;&#039;&#039; (boolean), logging is done using&lt;br /&gt;
default settings. If the value is &#039;&#039;&#039;false&#039;&#039;&#039; (boolean), logging is&lt;br /&gt;
disabled for the rule. If &#039;&#039;&#039;log&#039;&#039;&#039; is not defined, logging is done&lt;br /&gt;
using the default settings except for accept rules, for which logging&lt;br /&gt;
is omitted.&lt;br /&gt;
&lt;br /&gt;
Default logging settings can be set by defining a logging class named&lt;br /&gt;
&#039;&#039;&#039;_default&#039;&#039;&#039;. Normally, default logging uses the &#039;&#039;&#039;log&#039;&#039;&#039; mode with&lt;br /&gt;
packets limited to one per second.&lt;br /&gt;
&lt;br /&gt;
=== Rules ===&lt;br /&gt;
&lt;br /&gt;
There are six types of rule objects:&lt;br /&gt;
* Filter rules&lt;br /&gt;
* Policy rules&lt;br /&gt;
* NAT rules&lt;br /&gt;
* Packet Marking rules&lt;br /&gt;
* Transparent Proxy rules&lt;br /&gt;
* MSS Clamping rules&lt;br /&gt;
* Connection Tracking Bypass rules&lt;br /&gt;
&lt;br /&gt;
All rule objects can have the &#039;&#039;&#039;in&#039;&#039;&#039; and &#039;&#039;&#039;out&#039;&#039;&#039; attributes&lt;br /&gt;
referring to zones as described in the previous section. In addition,&lt;br /&gt;
the scope of the rule can be further constrained with the following&lt;br /&gt;
attributes:&lt;br /&gt;
&lt;br /&gt;
{|&lt;br /&gt;
!Attribute!!Value format!!Effect&lt;br /&gt;
|-&lt;br /&gt;
|&#039;&#039;&#039;src&#039;&#039;&#039;&lt;br /&gt;
|Similar to &#039;&#039;&#039;addr&#039;&#039;&#039; attribute of zone objects&lt;br /&gt;
|Packet&#039;s source address matches the value&lt;br /&gt;
|-&lt;br /&gt;
|&#039;&#039;&#039;dest&#039;&#039;&#039;&lt;br /&gt;
|Similar to &#039;&#039;&#039;addr&#039;&#039;&#039; attribute of zone objects&lt;br /&gt;
|Packet&#039;s destination address matches the value&lt;br /&gt;
|-&lt;br /&gt;
|&#039;&#039;&#039;ipset&#039;&#039;&#039;&lt;br /&gt;
|Object containing two attributes: &#039;&#039;&#039;name&#039;&#039;&#039; referring to an IP set and &#039;&#039;&#039;args&#039;&#039;&#039;, which is a list of strings &#039;&#039;&#039;in&#039;&#039;&#039; and &#039;&#039;&#039;out&#039;&#039;&#039;&lt;br /&gt;
|Packet matches the IP set referred here when the match arguments are taken from the source (&#039;&#039;&#039;in&#039;&#039;&#039;) and destination (&#039;&#039;&#039;out&#039;&#039;&#039;) address or port in the order specified by &#039;&#039;&#039;args&#039;&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
|&#039;&#039;&#039;ipsec&#039;&#039;&#039;&lt;br /&gt;
|&#039;&#039;&#039;in&#039;&#039;&#039; or &#039;&#039;&#039;out&#039;&#039;&#039;&lt;br /&gt;
|IPsec decapsulation perfomed on ingress (&#039;&#039;&#039;in&#039;&#039;&#039;) or encapsulation performed on egress (&#039;&#039;&#039;out&#039;&#039;&#039;)&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Rule objects are declared in type-specific top-level dictionaries in&lt;br /&gt;
awall policy files. If a packet matches multiple rules, the one&lt;br /&gt;
appearing earlier in the list takes precedence. If the matching rules&lt;br /&gt;
are defined in different policy files, the one that was processed&lt;br /&gt;
earlier takes precedence in the current implementation, but this may&lt;br /&gt;
change in future versions.&lt;br /&gt;
&lt;br /&gt;
==== Filter Rules ====&lt;br /&gt;
&lt;br /&gt;
Filter objects specify an action for packets fulfilling certain&lt;br /&gt;
criteria. The top-level attribute &#039;&#039;&#039;filter&#039;&#039;&#039; is a list of filter&lt;br /&gt;
objects. The precedence rules are similar to those of policy objects.&lt;br /&gt;
&lt;br /&gt;
Filter objects must have an attribute named &#039;&#039;&#039;action&#039;&#039;&#039;, the value of&lt;br /&gt;
which can be one of the following:&lt;br /&gt;
&lt;br /&gt;
{|&lt;br /&gt;
!Value!!Action&lt;br /&gt;
|-&lt;br /&gt;
|&#039;&#039;&#039;accept&#039;&#039;&#039;&lt;br /&gt;
|Accept the packet&lt;br /&gt;
|-&lt;br /&gt;
|&#039;&#039;&#039;reject&#039;&#039;&#039;&lt;br /&gt;
|Reject the packet with an ICMP error message&lt;br /&gt;
|-&lt;br /&gt;
|&#039;&#039;&#039;drop&#039;&#039;&#039;&lt;br /&gt;
|Silently drop the packet&lt;br /&gt;
|-&lt;br /&gt;
|&#039;&#039;&#039;tarpit&#039;&#039;&#039;&lt;br /&gt;
|Put incoming TCP connections into persist state and ignore attempts to close them. Silently drop non-TCP packets. (Connection tracking bypass is automatically enabled for the matching packets.)&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Filter objects, the action of which is &#039;&#039;&#039;accept&#039;&#039;&#039;, may also contain&lt;br /&gt;
limits for packet flow or new connections. These are specified with&lt;br /&gt;
the &#039;&#039;&#039;flow-limit&#039;&#039;&#039; and &#039;&#039;&#039;conn-limit&#039;&#039;&#039; attributes,&lt;br /&gt;
respectively. The values of these attributes are limit objects that&lt;br /&gt;
have two attributes: &#039;&#039;&#039;count&#039;&#039;&#039; and &#039;&#039;&#039;interval&#039;&#039;&#039;. &#039;&#039;&#039;count&#039;&#039;&#039;&lt;br /&gt;
specifies how many new connections or packets are allowed within the&lt;br /&gt;
time frame specified by &#039;&#039;&#039;interval&#039;&#039;&#039; (in seconds). The &#039;&#039;&#039;drop&#039;&#039;&#039;&lt;br /&gt;
action is applied to the packets exceeding the limit. Optionally, the&lt;br /&gt;
limit object may have an attribute named &#039;&#039;&#039;log&#039;&#039;&#039;. It defines how the&lt;br /&gt;
dropped packets should be logged and is semantically similar to the&lt;br /&gt;
&#039;&#039;&#039;log&#039;&#039;&#039; attribute of rule objects.&lt;br /&gt;
&lt;br /&gt;
Filter objects may have an attribute named &#039;&#039;&#039;dnat&#039;&#039;&#039;, the value of&lt;br /&gt;
which is an IPv4 address. If defined, this enables destination NAT for&lt;br /&gt;
all IPv4 packets matching the rule, such that the specified address&lt;br /&gt;
replaces the original destination address. This option has no effect&lt;br /&gt;
on IPv6 packets.&lt;br /&gt;
&lt;br /&gt;
Filter objects may have a boolean attribute named &#039;&#039;&#039;no-track&#039;&#039;&#039;. If&lt;br /&gt;
set to &#039;&#039;&#039;true&#039;&#039;&#039;, connection tracking is bypassed for the matching&lt;br /&gt;
packets. In addition, if &#039;&#039;&#039;action&#039;&#039;&#039; is set to &#039;&#039;&#039;accept&#039;&#039;&#039;, the&lt;br /&gt;
corresponding packets travelling to the reverse direction are also&lt;br /&gt;
allowed.&lt;br /&gt;
&lt;br /&gt;
==== Policy Rules ====&lt;br /&gt;
&lt;br /&gt;
Policy objects describe the default action for packets that did not&lt;br /&gt;
match any filter. The top-level attribute &#039;&#039;&#039;policy&#039;&#039;&#039; is a list of&lt;br /&gt;
policy objects.&lt;br /&gt;
&lt;br /&gt;
Policy objects must have the &#039;&#039;&#039;action&#039;&#039;&#039; attribute defined. The&lt;br /&gt;
possible values and their semantics are the same as in filter objects.&lt;br /&gt;
&lt;br /&gt;
==== NAT Rules ====&lt;br /&gt;
&lt;br /&gt;
NAT rules come in two flavors: &#039;&#039;source NAT rules&#039;&#039; and&lt;br /&gt;
&#039;&#039;destination NAT rules&#039;&#039;. These are contained in two top-level lists&lt;br /&gt;
named &#039;&#039;&#039;snat&#039;&#039;&#039; and &#039;&#039;&#039;dnat&#039;&#039;&#039;, respectively.&lt;br /&gt;
&lt;br /&gt;
Each NAT rule may have an attribute named &#039;&#039;&#039;to-addr&#039;&#039;&#039; that&lt;br /&gt;
specifies the IPv4 address range to which the original source or&lt;br /&gt;
destination address is mapped. The value can be a single IPv4 address&lt;br /&gt;
or a range specified by two addresses, separated with the &#039;&#039;&#039;-&#039;&#039;&#039;&lt;br /&gt;
character. If not defined, it defaults to the primary address of the&lt;br /&gt;
ingress interface in case of destination NAT, or that of the egress&lt;br /&gt;
interface in case of source NAT.&lt;br /&gt;
&lt;br /&gt;
Optionally, a NAT rule can specify the TCP and UDP port range to which&lt;br /&gt;
the original source or destination port is mapped. The attribute is&lt;br /&gt;
named &#039;&#039;&#039;to-port&#039;&#039;&#039;, and the value can be a single port number or a&lt;br /&gt;
range specified by two numbers, separated with the &#039;&#039;&#039;-&#039;&#039;&#039;&lt;br /&gt;
character. If &#039;&#039;&#039;to-port&#039;&#039;&#039; is not specified, the original port number&lt;br /&gt;
is kept intact.&lt;br /&gt;
&lt;br /&gt;
NAT rules may have an &#039;&#039;&#039;action&#039;&#039;&#039; attribute set to value&lt;br /&gt;
&#039;&#039;&#039;accept&#039;&#039;&#039;. In this case, NAT is not performed on the packets&lt;br /&gt;
reaching and matching this rule.&lt;br /&gt;
&lt;br /&gt;
==== Packet Marking Rules ====&lt;br /&gt;
&lt;br /&gt;
Packet marking rules are used to mark incoming packets matching the&lt;br /&gt;
specified criteria. The mark can be used as a basis for the routing&lt;br /&gt;
decision. Each marking rule must specify the mark using the &#039;&#039;&#039;mark&#039;&#039;&#039;&lt;br /&gt;
attribute, which is a 32-bit integer.&lt;br /&gt;
&lt;br /&gt;
Normal marking rules are contained by the top-level list attribute&lt;br /&gt;
named &#039;&#039;&#039;mark&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
There is another top-level list attribute, named &#039;&#039;&#039;route-track&#039;&#039;&#039;,&lt;br /&gt;
which contains route tracking rules. These are special marking rules&lt;br /&gt;
which cause all the subsequent packets related to the same connection&lt;br /&gt;
to be marked according to the rule.&lt;br /&gt;
&lt;br /&gt;
==== Transparent Proxy Rules ====&lt;br /&gt;
&lt;br /&gt;
Transparent proxy rules divert the matching packets to a local proxy&lt;br /&gt;
process without altering their headers. Such rules are contained in&lt;br /&gt;
the top-level list named &#039;&#039;&#039;tproxy&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
In addition to the firewall configuration, using a transparent proxy&lt;br /&gt;
requires a routing configuration where packets marked for proxying are&lt;br /&gt;
diverted to a local process. The &#039;&#039;&#039;mark&#039;&#039;&#039; attribute of a proxy rule&lt;br /&gt;
specifies the mark to be used.&lt;br /&gt;
&lt;br /&gt;
Proxy rules may also have an attribute named &#039;&#039;&#039;to-port&#039;&#039;&#039; for&lt;br /&gt;
specifying the TCP or UDP port of the proxy if it is different from&lt;br /&gt;
the original destination port.&lt;br /&gt;
&lt;br /&gt;
==== MSS Clamping Rules ====&lt;br /&gt;
&lt;br /&gt;
MSS Clamping Rules are used to deal with ISPs that block ICMP&lt;br /&gt;
Fragmentation Needed or ICMPv6 Packet Too Big packets. An MSS clamping&lt;br /&gt;
rule overwrites the MSS option with a value specified with the&lt;br /&gt;
&#039;&#039;&#039;mss&#039;&#039;&#039; attribute for the matching TCP connections. If &#039;&#039;&#039;mss&#039;&#039;&#039; is&lt;br /&gt;
not specified, a suitable value is automatically determined from the&lt;br /&gt;
path MTU. The MSS clamping rules are located in the top-level&lt;br /&gt;
dictionary named &#039;&#039;&#039;clamp-mss&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
==== Connection Tracking Bypass Rules ====&lt;br /&gt;
&lt;br /&gt;
Connection tracking bypass rules are used to disable connection&lt;br /&gt;
tracking for packets matching the specified criteria. The top-level&lt;br /&gt;
attribute &#039;&#039;&#039;no-track&#039;&#039;&#039; is a list of such rules.&lt;br /&gt;
&lt;br /&gt;
Connection tracking bypass rules may have an &#039;&#039;&#039;action&#039;&#039;&#039; attribute&lt;br /&gt;
set to value &#039;&#039;&#039;accept&#039;&#039;&#039;. The effect is similar to corresponding NAT&lt;br /&gt;
rules, i.e. connection tracking is not bypassed for the matching&lt;br /&gt;
packets.&lt;br /&gt;
&lt;br /&gt;
=== IP Sets ===&lt;br /&gt;
&lt;br /&gt;
Any IP set referenced by rule objects should be created by&lt;br /&gt;
awall. Auxiliary &#039;&#039;IP set&#039;&#039; objects are used to defined them in awall&lt;br /&gt;
policy files. The top-level attribute &#039;&#039;&#039;ipset&#039;&#039;&#039; is a dictionary, the&lt;br /&gt;
keys of which are IP set names. The values are IP set objects, which&lt;br /&gt;
have two mandatory attributes. The attribute named &#039;&#039;&#039;type&#039;&#039;&#039; &lt;br /&gt;
corresponds to the type argument of the &amp;lt;tt&amp;gt;ipset create&amp;lt;/tt&amp;gt; &lt;br /&gt;
command. &#039;&#039;&#039;family&#039;&#039;&#039; specifies whether the set is for IPv4 or IPv6&lt;br /&gt;
addresses, and the possible values are &#039;&#039;&#039;inet&#039;&#039;&#039; and &#039;&#039;&#039;inet6&#039;&#039;&#039;,&lt;br /&gt;
correspondingly.&lt;br /&gt;
&lt;br /&gt;
For bitmap-type IP sets, the &#039;&#039;&#039;range&#039;&#039;&#039; attribute specifies the&lt;br /&gt;
range of allowed IPv4 addresses. It may be given as a network&lt;br /&gt;
address or two addresses separated by the &#039;&#039;&#039;-&#039;&#039;&#039; character. It&lt;br /&gt;
is not necessary to specify &#039;&#039;&#039;family&#039;&#039;&#039; for bitmaps, since the&lt;br /&gt;
kernel supports only IPv4 bitmaps.&lt;br /&gt;
&lt;br /&gt;
== Command Line Syntax ==&lt;br /&gt;
&lt;br /&gt;
=== Translating Policy Files to Firewall Configuration Files ===&lt;br /&gt;
&lt;br /&gt;
 &#039;&#039;&#039;awall translate&#039;&#039;&#039; [&#039;&#039;&#039;-o&#039;&#039;&#039;|&#039;&#039;&#039;--output&#039;&#039;&#039; DIRECTORY] [&#039;&#039;&#039;-V&#039;&#039;&#039;|&#039;&#039;&#039;--verify&#039;&#039;&#039;]&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;tt&amp;gt;--verify&amp;lt;/tt&amp;gt; option makes awall verify the configuration&lt;br /&gt;
using the test mode of iptables-restore before overwriting the old&lt;br /&gt;
files.&lt;br /&gt;
&lt;br /&gt;
Specifying the output directory allows testing awall policies without&lt;br /&gt;
overwriting the current iptables and ipset configuration files. By&lt;br /&gt;
default, awall generates the configuration to &amp;lt;tt&amp;gt;/etc/iptables&amp;lt;/tt&amp;gt; &lt;br /&gt;
and &amp;lt;tt&amp;gt;/etc/ipset.d&amp;lt;/tt&amp;gt;, which are read by the init scripts.&lt;br /&gt;
&lt;br /&gt;
=== Run-Time Configuration of Firewall ===&lt;br /&gt;
&lt;br /&gt;
 &#039;&#039;&#039;awall activate&#039;&#039;&#039; [&#039;&#039;&#039;-f&#039;&#039;&#039;|&#039;&#039;&#039;--force&#039;&#039;&#039;]&lt;br /&gt;
&lt;br /&gt;
This command genereates firewall configuration from the policy files&lt;br /&gt;
and enables it. If the user confirms the new configuration by hitting&lt;br /&gt;
the Return key within 10 seconds or the &amp;lt;tt&amp;gt;--force&amp;lt;/tt&amp;gt; option is&lt;br /&gt;
used, the configuration is saved to the files. Otherwise, the old&lt;br /&gt;
configuration is restored.&lt;br /&gt;
&lt;br /&gt;
There is also a command for deleting all firewall rules:&lt;br /&gt;
&lt;br /&gt;
 &#039;&#039;&#039;awall flush&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
This command configures the firewall to drop all packets.&lt;br /&gt;
&lt;br /&gt;
=== Optional Policies ===&lt;br /&gt;
&lt;br /&gt;
Optional policies can be enabled or disabled using this command:&lt;br /&gt;
&lt;br /&gt;
 &#039;&#039;&#039;awall&#039;&#039;&#039; {&#039;&#039;&#039;enable&#039;&#039;&#039;|&#039;&#039;&#039;disable&#039;&#039;&#039;} POLICY...&lt;br /&gt;
&lt;br /&gt;
Optional policies can be listed using this command:&lt;br /&gt;
&lt;br /&gt;
 &#039;&#039;&#039;awall list&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;&#039;enabled&#039;&#039;&#039; status means that the policy has been enabled by the&lt;br /&gt;
user. The &#039;&#039;&#039;disabled&#039;&#039;&#039; status means that the policy is not in&lt;br /&gt;
use. The &#039;&#039;&#039;required&#039;&#039;&#039; status means that the policy has not been&lt;br /&gt;
enabled by the user but is in use because it is required by another&lt;br /&gt;
policy which is in use.&lt;br /&gt;
&lt;br /&gt;
=== Debugging Policies ===&lt;br /&gt;
&lt;br /&gt;
This command can be used to dump variable, zone, and other definitions&lt;br /&gt;
as well as their source policies:&lt;br /&gt;
&lt;br /&gt;
 &#039;&#039;&#039;awall dump&#039;&#039;&#039; [LEVEL]&lt;br /&gt;
&lt;br /&gt;
The level is an integer in range 0&amp;amp;ndash;5 and defaults to 0. More&lt;br /&gt;
information is displayed on higher levels.&lt;br /&gt;
&lt;br /&gt;
[[Category:Networking]]&lt;br /&gt;
[[Category:Security]]&lt;/div&gt;</summary>
		<author><name>Kunkku</name></author>
	</entry>
	<entry>
		<id>https://wiki.alpinelinux.org/w/index.php?title=Alpine_Wall_User%27s_Guide&amp;diff=8950</id>
		<title>Alpine Wall User&#039;s Guide</title>
		<link rel="alternate" type="text/html" href="https://wiki.alpinelinux.org/w/index.php?title=Alpine_Wall_User%27s_Guide&amp;diff=8950"/>
		<updated>2013-01-18T17:27:34Z</updated>

		<summary type="html">&lt;p&gt;Kunkku: /* IP Sets */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Configuration File Processing ==&lt;br /&gt;
&lt;br /&gt;
[[Alpine Wall]] (awall) reads its configuration from multiple&lt;br /&gt;
JSON-formatted files, called &#039;&#039;policy files&#039;&#039;. The processing starts&lt;br /&gt;
from directory &amp;lt;tt&amp;gt;/usr/share/awall/mandatory&amp;lt;/tt&amp;gt;, which contains&lt;br /&gt;
mandatory policy files shipped with APK packages. After that,&lt;br /&gt;
installation-specific policy files in &amp;lt;tt&amp;gt;/etc/awall&amp;lt;/tt&amp;gt; are&lt;br /&gt;
processed.&lt;br /&gt;
&lt;br /&gt;
The latter directory may also contain symbolic links to policy files&lt;br /&gt;
located in &amp;lt;tt&amp;gt;/usr/share/awall/optional&amp;lt;/tt&amp;gt; and&lt;br /&gt;
&amp;lt;tt&amp;gt;/etc/awall/optional&amp;lt;/tt&amp;gt;. These are optional policies, which can&lt;br /&gt;
be enabled on need basis. Such symbolic links are easily created and&lt;br /&gt;
destroyed using the &amp;lt;tt&amp;gt;awall enable&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;awall disable&amp;lt;/tt&amp;gt;&lt;br /&gt;
commands. &amp;lt;tt&amp;gt;awall list&amp;lt;/tt&amp;gt; shows which optional policies are&lt;br /&gt;
enabled and disabled. The command also prints the description of the&lt;br /&gt;
optional policy if defined in the file using a top-level attribute&lt;br /&gt;
named &#039;&#039;&#039;description&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Sometimes a policy file depends on other policy files. In this case,&lt;br /&gt;
the policy file must have a top-level attribute &#039;&#039;&#039;import&#039;&#039;&#039;, the&lt;br /&gt;
value of which is a list of policy names, which correspond to the file&lt;br /&gt;
names without the &amp;lt;tt&amp;gt;.json&amp;lt;/tt&amp;gt; suffix. By default, the policies&lt;br /&gt;
listed there are processed before the importing policy.&lt;br /&gt;
&lt;br /&gt;
The order of the generated iptables rules generally reflects the&lt;br /&gt;
processing order of their corresponding awall policies. The processing&lt;br /&gt;
order of policies can be adjusted by defining top-level attributes&lt;br /&gt;
&#039;&#039;&#039;after&#039;&#039;&#039; and &#039;&#039;&#039;before&#039;&#039;&#039; in policy files. These attributes are&lt;br /&gt;
lists of policies, after or before which the declaring policy shall be&lt;br /&gt;
processed. Putting a policy name to either of these lists does not by&lt;br /&gt;
itself import the policy. The ordering directives are ignored with&lt;br /&gt;
respect to those policies that are not enabled by the user or imported&lt;br /&gt;
by other policies. If not defined, &#039;&#039;&#039;after&#039;&#039;&#039; is assumed to be equal&lt;br /&gt;
to the &#039;&#039;&#039;import&#039;&#039;&#039; definition of the policy.&lt;br /&gt;
&lt;br /&gt;
As the import directive does not require the path name to be&lt;br /&gt;
specified, awall expects policies to have unique names, even if&lt;br /&gt;
located in different directories. It is allowed to import optional&lt;br /&gt;
policies that are not explicitly enabled by the user. Such policies&lt;br /&gt;
show up with the &amp;lt;tt&amp;gt;required&amp;lt;/tt&amp;gt; status in the output of &amp;lt;tt&amp;gt;awall&lt;br /&gt;
list&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
== List Parameters ==&lt;br /&gt;
&lt;br /&gt;
Several awall parameters are defined as lists of values. In order to&lt;br /&gt;
facilitate manual editing of policy files, awall also accepts single&lt;br /&gt;
values in place of lists. Such values are semantically equivalent to&lt;br /&gt;
lists containing one element.&lt;br /&gt;
&lt;br /&gt;
== Variable Expansion ==&lt;br /&gt;
&lt;br /&gt;
Awall allows variable definitions in policy files. The top-level&lt;br /&gt;
attribute &#039;&#039;&#039;variable&#039;&#039;&#039; is a dictionary containing the&lt;br /&gt;
definitions. The value of a variable can be of any type (string,&lt;br /&gt;
integer, list, or dictionary).&lt;br /&gt;
&lt;br /&gt;
A variable is referenced in policy files by a string which equals the&lt;br /&gt;
variable name prepended with the &#039;&#039;&#039;$&#039;&#039;&#039; character. If the value of&lt;br /&gt;
the variable is a string, the reference can be embedded into a longer&lt;br /&gt;
string in order to substitute some part of that string (in shell&lt;br /&gt;
style). Variable references can be used when defining other variables,&lt;br /&gt;
as long as the definitions are not circular.&lt;br /&gt;
&lt;br /&gt;
Policy files can reference variables defined in other policy&lt;br /&gt;
files. Policy files can also override variables defined elsewhere by&lt;br /&gt;
redefining them. In this case, the new definition affects all policy&lt;br /&gt;
files, also those processed before the overriding policy. Awall&lt;br /&gt;
variables are in fact simple macros, since each variable remains&lt;br /&gt;
constant thoughout a single processing round. If multiple files define&lt;br /&gt;
the same variable, the definition in the file processed last takes&lt;br /&gt;
effect.&lt;br /&gt;
&lt;br /&gt;
If defined as an empty string, all non-embedded references to a&lt;br /&gt;
variable evaluate as if the attribute in question was not present in&lt;br /&gt;
the configuration. This is also the case when a string containing&lt;br /&gt;
embedded variable references finally evaluates to an empty string.&lt;br /&gt;
&lt;br /&gt;
== Configuration Objects ==&lt;br /&gt;
&lt;br /&gt;
Configuration objects can be divided into two main types.&lt;br /&gt;
&#039;&#039;Auxiliary objects&#039;&#039; model high-level concepts such as services and&lt;br /&gt;
zones. &#039;&#039;Rule objects&#039;&#039; translate into one or more iptables rules, and&lt;br /&gt;
are often defined with the help of some auxiliary objects.&lt;br /&gt;
&lt;br /&gt;
=== Services ===&lt;br /&gt;
&lt;br /&gt;
A &#039;&#039;service&#039;&#039; represents a set of network protocols. A top-level&lt;br /&gt;
attribute &#039;&#039;&#039;service&#039;&#039;&#039; is a dictionary that maps service names to&lt;br /&gt;
service definition objects, or lists thereof in more complex cases.&lt;br /&gt;
&lt;br /&gt;
A service definition object contains an attribute named &#039;&#039;&#039;proto&#039;&#039;&#039;,&lt;br /&gt;
which corresponds to the &amp;lt;tt&amp;gt;--protocol&amp;lt;/tt&amp;gt; option of iptables. The&lt;br /&gt;
protocol can be defined as a numerical value or string as defined in&lt;br /&gt;
&amp;lt;tt&amp;gt;/etc/protocols&amp;lt;/tt&amp;gt;. If the protocol is &#039;&#039;&#039;tcp&#039;&#039;&#039; or &#039;&#039;&#039;udp&#039;&#039;&#039;,&lt;br /&gt;
the scope of the service definition may be constrained by defining an&lt;br /&gt;
attribute named &#039;&#039;&#039;port&#039;&#039;&#039;, which is a list of TCP or UDP port numbers&lt;br /&gt;
or ranges thereof, separated by the &#039;&#039;&#039;-&#039;&#039;&#039; character. If the protocol&lt;br /&gt;
is &#039;&#039;&#039;icmp&#039;&#039;&#039; or &#039;&#039;&#039;icmpv6&#039;&#039;&#039;, an analogous &#039;&#039;&#039;icmp-type&#039;&#039;&#039; attribute&lt;br /&gt;
may be used. In addition, the scope of the rule is also automatically&lt;br /&gt;
limited to IPv4 or IPv6, respectively.&lt;br /&gt;
&lt;br /&gt;
=== Zones ===&lt;br /&gt;
&lt;br /&gt;
A &#039;&#039;zone&#039;&#039; represents a set of network hosts. A top-level attribute &lt;br /&gt;
&#039;&#039;&#039;zone&#039;&#039;&#039; is a dictionary that maps zone names to zone objects. A&lt;br /&gt;
zone object has an attribute named &#039;&#039;&#039;iface&#039;&#039;&#039;, &#039;&#039;&#039;addr&#039;&#039;&#039;, or&lt;br /&gt;
both. &#039;&#039;&#039;iface&#039;&#039;&#039; is a list of network interfaces and &#039;&#039;&#039;addr&#039;&#039;&#039; is a&lt;br /&gt;
list of IPv4/IPv6 host and network addresses (CIDR&lt;br /&gt;
notation). &#039;&#039;&#039;addr&#039;&#039;&#039; may also contain domain names, which are&lt;br /&gt;
expanded to IP addresses using DNS resolution. If not defined,&lt;br /&gt;
&#039;&#039;&#039;addr&#039;&#039;&#039; defaults to the entire address space and &#039;&#039;&#039;iface&#039;&#039;&#039; to all&lt;br /&gt;
interfaces. An empty zone can be defined by setting either &#039;&#039;&#039;addr&#039;&#039;&#039;&lt;br /&gt;
or &#039;&#039;&#039;iface&#039;&#039;&#039; to an empty list.&lt;br /&gt;
&lt;br /&gt;
Rule objects contain two attributes, &#039;&#039;&#039;in&#039;&#039;&#039; and &#039;&#039;&#039;out&#039;&#039;&#039;, which are&lt;br /&gt;
lists of zone names. These attributes control whether a packet matches&lt;br /&gt;
the rule or not. If a particular zone is referenced by the &#039;&#039;&#039;in&#039;&#039;&#039; &lt;br /&gt;
attribute, the rule applies to packets whose ingress interface and&lt;br /&gt;
source address are covered by the zone definition. Correspondingly, if&lt;br /&gt;
a zone is referenced by the &#039;&#039;&#039;out&#039;&#039;&#039; attribute, the rule applies to&lt;br /&gt;
packets whose egress interface and destination address are included in&lt;br /&gt;
the zone. If both &#039;&#039;&#039;in&#039;&#039;&#039; and &#039;&#039;&#039;out&#039;&#039;&#039; are defined, the packet must&lt;br /&gt;
fulfill both criteria in order to match the rule.&lt;br /&gt;
&lt;br /&gt;
The firewall host itself can be referred to using the special value&lt;br /&gt;
&#039;&#039;&#039;_fw&#039;&#039;&#039; as the zone name.&lt;br /&gt;
&lt;br /&gt;
By default, awall does not generate iptables rules with identical&lt;br /&gt;
ingress and egress interfaces. This behavior can be changed per zone&lt;br /&gt;
by setting the optional &#039;&#039;&#039;route-back&#039;&#039;&#039; attribute of the zone to&lt;br /&gt;
&#039;&#039;&#039;true&#039;&#039;&#039;. Note that this attribute can have an effect also in the&lt;br /&gt;
case where &#039;&#039;&#039;in&#039;&#039;&#039; and &#039;&#039;&#039;out&#039;&#039;&#039; attributes of a rule are not equal&lt;br /&gt;
but their definitions overlap. In this case, the &#039;&#039;&#039;route-back&#039;&#039;&#039;&lt;br /&gt;
attribute of the &#039;&#039;&#039;out&#039;&#039;&#039; zone determines the behavior.&lt;br /&gt;
&lt;br /&gt;
=== Logging Classes ===&lt;br /&gt;
&lt;br /&gt;
A &#039;&#039;logging class&#039;&#039; specifies how packets matching certain rules are&lt;br /&gt;
logged. A top-level attribute &#039;&#039;&#039;log&#039;&#039;&#039; is a dictionary that maps&lt;br /&gt;
logging class names to setting objects.&lt;br /&gt;
&lt;br /&gt;
A setting object may have an attribute named &#039;&#039;&#039;mode&#039;&#039;&#039;, which&lt;br /&gt;
specifies which logging facility to use. Allowed values are &#039;&#039;&#039;log&#039;&#039;&#039;,&lt;br /&gt;
&#039;&#039;&#039;nflog&#039;&#039;&#039;, and &#039;&#039;&#039;ulog&#039;&#039;&#039;. The default is &#039;&#039;&#039;log&#039;&#039;&#039;, i.e. in-kernel&lt;br /&gt;
logging. The object may also have a &#039;&#039;&#039;limit&#039;&#039;&#039; attribute, which is an&lt;br /&gt;
integer specifying the maximum number of matching packets to be logged&lt;br /&gt;
per second per rule. Optionally, the log entries are prefixed with a&lt;br /&gt;
string configured using the &#039;&#039;&#039;prefix&#039;&#039;&#039; attribute.&lt;br /&gt;
&lt;br /&gt;
Filter and policy rules can have an attribute named &#039;&#039;&#039;log&#039;&#039;&#039;. If it&lt;br /&gt;
is a string, it is interpreted as a reference to a logging class, and&lt;br /&gt;
logging is performed according to the definitions. If the value of the&lt;br /&gt;
&#039;&#039;&#039;log&#039;&#039;&#039; attribute is &#039;&#039;&#039;true&#039;&#039;&#039; (boolean), logging is done using&lt;br /&gt;
default settings. If the value is &#039;&#039;&#039;false&#039;&#039;&#039; (boolean), logging is&lt;br /&gt;
disabled for the rule. If &#039;&#039;&#039;log&#039;&#039;&#039; is not defined, logging is done&lt;br /&gt;
using the default settings except for accept rules, for which logging&lt;br /&gt;
is omitted.&lt;br /&gt;
&lt;br /&gt;
Default logging settings can be set by defining a logging class named&lt;br /&gt;
&#039;&#039;&#039;_default&#039;&#039;&#039;. Normally, default logging uses the &#039;&#039;&#039;log&#039;&#039;&#039; mode with&lt;br /&gt;
packets limited to one per second.&lt;br /&gt;
&lt;br /&gt;
=== Rules ===&lt;br /&gt;
&lt;br /&gt;
There are six types of rule objects:&lt;br /&gt;
* Filters rules&lt;br /&gt;
* Policies rules&lt;br /&gt;
* NAT rules&lt;br /&gt;
* Packet Marking rules&lt;br /&gt;
* MSS Clamping rules&lt;br /&gt;
* Connection Tracking Bypass rules&lt;br /&gt;
&lt;br /&gt;
All rule objects can have the &#039;&#039;&#039;in&#039;&#039;&#039; and &#039;&#039;&#039;out&#039;&#039;&#039; attributes&lt;br /&gt;
referring to zones as described in the previous section. In addition,&lt;br /&gt;
the scope of the rule can be further constrained with the following&lt;br /&gt;
attributes:&lt;br /&gt;
&lt;br /&gt;
{|&lt;br /&gt;
!Attribute!!Value format!!Effect&lt;br /&gt;
|-&lt;br /&gt;
|&#039;&#039;&#039;src&#039;&#039;&#039;&lt;br /&gt;
|Similar to &#039;&#039;&#039;addr&#039;&#039;&#039; attribute of zone objects&lt;br /&gt;
|Packet&#039;s source address matches the value&lt;br /&gt;
|-&lt;br /&gt;
|&#039;&#039;&#039;dest&#039;&#039;&#039;&lt;br /&gt;
|Similar to &#039;&#039;&#039;addr&#039;&#039;&#039; attribute of zone objects&lt;br /&gt;
|Packet&#039;s destination address matches the value&lt;br /&gt;
|-&lt;br /&gt;
|&#039;&#039;&#039;ipset&#039;&#039;&#039;&lt;br /&gt;
|Object containing two attributes: &#039;&#039;&#039;name&#039;&#039;&#039; referring to an IP set and &#039;&#039;&#039;args&#039;&#039;&#039;, which is a list of strings &#039;&#039;&#039;in&#039;&#039;&#039; and &#039;&#039;&#039;out&#039;&#039;&#039;&lt;br /&gt;
|Packet matches the IP set referred here when the match arguments are taken from the source (&#039;&#039;&#039;in&#039;&#039;&#039;) and destination (&#039;&#039;&#039;out&#039;&#039;&#039;) address or port in the order specified by &#039;&#039;&#039;args&#039;&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
|&#039;&#039;&#039;ipsec&#039;&#039;&#039;&lt;br /&gt;
|&#039;&#039;&#039;in&#039;&#039;&#039; or &#039;&#039;&#039;out&#039;&#039;&#039;&lt;br /&gt;
|IPsec decapsulation perfomed on ingress (&#039;&#039;&#039;in&#039;&#039;&#039;) or encapsulation performed on egress (&#039;&#039;&#039;out&#039;&#039;&#039;)&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Rule objects are declared in type-specific top-level dictionaries in&lt;br /&gt;
awall policy files. If a packet matches multiple rules, the one&lt;br /&gt;
appearing earlier in the list takes precedence. If the matching rules&lt;br /&gt;
are defined in different policy files, the one that was processed&lt;br /&gt;
earlier takes precedence in the current implementation, but this may&lt;br /&gt;
change in future versions.&lt;br /&gt;
&lt;br /&gt;
==== Filters Rules ====&lt;br /&gt;
&lt;br /&gt;
Filter objects specify an action for packets fulfilling certain&lt;br /&gt;
criteria. The top-level attribute &#039;&#039;&#039;filter&#039;&#039;&#039; is a list of filter&lt;br /&gt;
objects. The precedence rules are similar to those of policy objects.&lt;br /&gt;
&lt;br /&gt;
In addition to the common rule attributes, filter objects can have a &lt;br /&gt;
&#039;&#039;&#039;service&#039;&#039;&#039; attribute constraining the scope to specific services&lt;br /&gt;
only. This attribute is a list of service names, referring to the&lt;br /&gt;
keys of the top-level &#039;&#039;&#039;service&#039;&#039;&#039; dictionary.&lt;br /&gt;
&lt;br /&gt;
Filter objects must have an attribute named &#039;&#039;&#039;action&#039;&#039;&#039;, the value of&lt;br /&gt;
which can be one of the following:&lt;br /&gt;
&lt;br /&gt;
{|&lt;br /&gt;
!Value!!Action&lt;br /&gt;
|-&lt;br /&gt;
|&#039;&#039;&#039;accept&#039;&#039;&#039;&lt;br /&gt;
|Accept the packet&lt;br /&gt;
|-&lt;br /&gt;
|&#039;&#039;&#039;reject&#039;&#039;&#039;&lt;br /&gt;
|Reject the packet with an ICMP error message&lt;br /&gt;
|-&lt;br /&gt;
|&#039;&#039;&#039;drop&#039;&#039;&#039;&lt;br /&gt;
|Silently drop the packet&lt;br /&gt;
|-&lt;br /&gt;
|&#039;&#039;&#039;tarpit&#039;&#039;&#039;&lt;br /&gt;
|Put incoming TCP connections into persist state and ignore attempts to close them. Silently drop non-TCP packets. (Connection tracking bypass is automatically enabled for the matching packets.)&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Filter objects, the action of which is &#039;&#039;&#039;accept&#039;&#039;&#039;, may also contain&lt;br /&gt;
limits for packet flow or new connections. These are specified with&lt;br /&gt;
the &#039;&#039;&#039;flow-limit&#039;&#039;&#039; and &#039;&#039;&#039;conn-limit&#039;&#039;&#039; attributes,&lt;br /&gt;
respectively. The values of these attributes are limit objects that&lt;br /&gt;
have two attributes: &#039;&#039;&#039;count&#039;&#039;&#039; and &#039;&#039;&#039;interval&#039;&#039;&#039;. &#039;&#039;&#039;count&#039;&#039;&#039;&lt;br /&gt;
specifies how many new connections or packets are allowed within the&lt;br /&gt;
time frame specified by &#039;&#039;&#039;interval&#039;&#039;&#039; (in seconds). The &#039;&#039;&#039;drop&#039;&#039;&#039;&lt;br /&gt;
action is applied to the packets exceeding the limit. Optionally, the&lt;br /&gt;
limit object may have an attribute named &#039;&#039;&#039;log&#039;&#039;&#039;. It defines how the&lt;br /&gt;
dropped packets should be logged and is semantically similar to the&lt;br /&gt;
&#039;&#039;&#039;log&#039;&#039;&#039; attribute of rule objects.&lt;br /&gt;
&lt;br /&gt;
Filter objects may have an attribute named &#039;&#039;&#039;dnat&#039;&#039;&#039;, the value of&lt;br /&gt;
which is an IPv4 address. If defined, this enables destination NAT for&lt;br /&gt;
all IPv4 packets matching the rule, such that the specified address&lt;br /&gt;
replaces the original destination address. This option has no effect&lt;br /&gt;
on IPv6 packets.&lt;br /&gt;
&lt;br /&gt;
Filter objects may have a boolean attribute named &#039;&#039;&#039;no-track&#039;&#039;&#039;. If&lt;br /&gt;
set to &#039;&#039;&#039;true&#039;&#039;&#039;, connection tracking is bypassed for the matching&lt;br /&gt;
packets. In addition, if &#039;&#039;&#039;action&#039;&#039;&#039; is set to &#039;&#039;&#039;accept&#039;&#039;&#039;, the&lt;br /&gt;
corresponding packets travelling to the reverse direction are also&lt;br /&gt;
allowed.&lt;br /&gt;
&lt;br /&gt;
==== Policies Rules ====&lt;br /&gt;
&lt;br /&gt;
Policy objects describe the default action for packets that did not&lt;br /&gt;
match any filter. The top-level attribute &#039;&#039;&#039;policy&#039;&#039;&#039; is a list of&lt;br /&gt;
policy objects.&lt;br /&gt;
&lt;br /&gt;
Policy objects must have the &#039;&#039;&#039;action&#039;&#039;&#039; attribute defined. The&lt;br /&gt;
possible values and their semantics are the same as in filter objects.&lt;br /&gt;
&lt;br /&gt;
==== NAT Rules ====&lt;br /&gt;
&lt;br /&gt;
NAT rules come in two flavors: &#039;&#039;source NAT rules&#039;&#039; and&lt;br /&gt;
&#039;&#039;destination NAT rules&#039;&#039;. These are contained in two top-level lists&lt;br /&gt;
named &#039;&#039;&#039;snat&#039;&#039;&#039; and &#039;&#039;&#039;dnat&#039;&#039;&#039;, respectively.&lt;br /&gt;
&lt;br /&gt;
Each NAT rule may have an attribute named &#039;&#039;&#039;to-addr&#039;&#039;&#039; that&lt;br /&gt;
specifies the IPv4 address range to which the original source or&lt;br /&gt;
destination address is mapped. The value can be a single IPv4 address&lt;br /&gt;
or a range specified by two addresses, separated with the &#039;&#039;&#039;-&#039;&#039;&#039;&lt;br /&gt;
character. If not defined, it defaults to the primary address of the&lt;br /&gt;
ingress interface in case of destination NAT, or that of the egress&lt;br /&gt;
interface in case of source NAT.&lt;br /&gt;
&lt;br /&gt;
Optionally, a NAT rule can specify the TCP and UDP port range to which&lt;br /&gt;
the original source or destination port is mapped. The attribute is&lt;br /&gt;
named &#039;&#039;&#039;to-port&#039;&#039;&#039;, and the value can be a single port number or a&lt;br /&gt;
range specified by two numbers, separated with the &#039;&#039;&#039;-&#039;&#039;&#039;&lt;br /&gt;
character. If &#039;&#039;&#039;to-port&#039;&#039;&#039; is not specified, the original port number&lt;br /&gt;
is kept intact.&lt;br /&gt;
&lt;br /&gt;
Like filters, NAT rules can have a &#039;&#039;&#039;service&#039;&#039;&#039; attribute&lt;br /&gt;
constraining their scope to specific services.&lt;br /&gt;
&lt;br /&gt;
NAT rules may have an &#039;&#039;&#039;action&#039;&#039;&#039; attribute set to value&lt;br /&gt;
&#039;&#039;&#039;accept&#039;&#039;&#039;. In this case, NAT is not performed on the packets&lt;br /&gt;
reaching and matching this rule.&lt;br /&gt;
&lt;br /&gt;
==== Packet Marking Rules ====&lt;br /&gt;
&lt;br /&gt;
Packet marking rules are used to mark incoming packets matching the&lt;br /&gt;
specified criteria. The mark can be used as a basis for the routing&lt;br /&gt;
decision. Each marking rule must specify the mark using the &#039;&#039;&#039;mark&#039;&#039;&#039;&lt;br /&gt;
attribute, which is a 32-bit integer.&lt;br /&gt;
&lt;br /&gt;
Normal marking rules are contained by the top-level list attribute&lt;br /&gt;
named &#039;&#039;&#039;mark&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
There is another top-level list attribute, named &#039;&#039;&#039;route-track&#039;&#039;&#039;,&lt;br /&gt;
which contains route tracking rules. These are special marking rules&lt;br /&gt;
which cause all the subsequent packets related to the same connection&lt;br /&gt;
to be marked according to the rule.&lt;br /&gt;
&lt;br /&gt;
==== MSS Clamping Rules ====&lt;br /&gt;
&lt;br /&gt;
MSS Clamping Rules are used to deal with ISPs that block ICMP&lt;br /&gt;
Fragmentation Needed or ICMPv6 Packet Too Big packets. An MSS clamping&lt;br /&gt;
rule overwrites the MSS option with a value specified with the&lt;br /&gt;
&#039;&#039;&#039;mss&#039;&#039;&#039; attribute for the matching TCP connections. If &#039;&#039;&#039;mss&#039;&#039;&#039; is&lt;br /&gt;
not specified, a suitable value is automatically determined from the&lt;br /&gt;
path MTU. The MSS clamping rules are located in the top-level&lt;br /&gt;
dictionary named &#039;&#039;&#039;clamp-mss&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
==== Connection Tracking Bypass Rules ====&lt;br /&gt;
&lt;br /&gt;
Connection tracking bypass rules are used to disable connection&lt;br /&gt;
tracking for packets matching the specified criteria. The top-level&lt;br /&gt;
attribute &#039;&#039;&#039;no-track&#039;&#039;&#039; is a list of such rules.&lt;br /&gt;
&lt;br /&gt;
Connection tracking bypass rules may have an &#039;&#039;&#039;action&#039;&#039;&#039; attribute&lt;br /&gt;
set to value &#039;&#039;&#039;accept&#039;&#039;&#039;. The effect is similar to corresponding NAT&lt;br /&gt;
rules, i.e. connection tracking is not bypassed for the matching&lt;br /&gt;
packets.&lt;br /&gt;
&lt;br /&gt;
=== IP Sets ===&lt;br /&gt;
&lt;br /&gt;
Any IP set referenced by rule objects should be created by&lt;br /&gt;
awall. Auxiliary &#039;&#039;IP set&#039;&#039; objects are used to defined them in awall&lt;br /&gt;
policy files. The top-level attribute &#039;&#039;&#039;ipset&#039;&#039;&#039; is a dictionary, the&lt;br /&gt;
keys of which are IP set names. The values are IP set objects, which&lt;br /&gt;
have two mandatory attributes. The attribute named &#039;&#039;&#039;type&#039;&#039;&#039; &lt;br /&gt;
corresponds to the type argument of the &amp;lt;tt&amp;gt;ipset create&amp;lt;/tt&amp;gt; &lt;br /&gt;
command. &#039;&#039;&#039;family&#039;&#039;&#039; specifies whether the set is for IPv4 or IPv6&lt;br /&gt;
addresses, and the possible values are &#039;&#039;&#039;inet&#039;&#039;&#039; and &#039;&#039;&#039;inet6&#039;&#039;&#039;,&lt;br /&gt;
correspondingly.&lt;br /&gt;
&lt;br /&gt;
For bitmap-type IP sets, the &#039;&#039;&#039;range&#039;&#039;&#039; attribute specifies the&lt;br /&gt;
range of allowed IPv4 addresses. It may be given as a network&lt;br /&gt;
address or two addresses separated by the &#039;&#039;&#039;-&#039;&#039;&#039; character. It&lt;br /&gt;
is not necessary to specify &#039;&#039;&#039;family&#039;&#039;&#039; for bitmaps, since the&lt;br /&gt;
kernel supports only IPv4 bitmaps.&lt;br /&gt;
&lt;br /&gt;
== Command Line Syntax ==&lt;br /&gt;
&lt;br /&gt;
=== Translating Policy Files to Firewall Configuration Files ===&lt;br /&gt;
&lt;br /&gt;
 &#039;&#039;&#039;awall translate&#039;&#039;&#039; [&#039;&#039;&#039;-o&#039;&#039;&#039;|&#039;&#039;&#039;--output&#039;&#039;&#039; DIRECTORY] [&#039;&#039;&#039;-V&#039;&#039;&#039;|&#039;&#039;&#039;--verify&#039;&#039;&#039;]&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;tt&amp;gt;--verify&amp;lt;/tt&amp;gt; option makes awall verify the configuration&lt;br /&gt;
using the test mode of iptables-restore before overwriting the old&lt;br /&gt;
files.&lt;br /&gt;
&lt;br /&gt;
Specifying the output directory allows testing awall policies without&lt;br /&gt;
overwriting the current iptables and ipset configuration files. By&lt;br /&gt;
default, awall generates the configuration to &amp;lt;tt&amp;gt;/etc/iptables&amp;lt;/tt&amp;gt; &lt;br /&gt;
and &amp;lt;tt&amp;gt;/etc/ipset.d&amp;lt;/tt&amp;gt;, which are read by the init scripts.&lt;br /&gt;
&lt;br /&gt;
=== Run-Time Configuration of Firewall ===&lt;br /&gt;
&lt;br /&gt;
 &#039;&#039;&#039;awall activate&#039;&#039;&#039; [&#039;&#039;&#039;-f&#039;&#039;&#039;|&#039;&#039;&#039;--force&#039;&#039;&#039;]&lt;br /&gt;
&lt;br /&gt;
This command genereates firewall configuration from the policy files&lt;br /&gt;
and enables it. If the user confirms the new configuration by hitting&lt;br /&gt;
the Return key within 10 seconds or the &amp;lt;tt&amp;gt;--force&amp;lt;/tt&amp;gt; option is&lt;br /&gt;
used, the configuration is saved to the files. Otherwise, the old&lt;br /&gt;
configuration is restored.&lt;br /&gt;
&lt;br /&gt;
There is also a command for deleting all firewall rules:&lt;br /&gt;
&lt;br /&gt;
 &#039;&#039;&#039;awall flush&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
This command configures the firewall to drop all packets.&lt;br /&gt;
&lt;br /&gt;
=== Optional Policies ===&lt;br /&gt;
&lt;br /&gt;
Optional policies can be enabled or disabled using this command:&lt;br /&gt;
&lt;br /&gt;
 &#039;&#039;&#039;awall&#039;&#039;&#039; {&#039;&#039;&#039;enable&#039;&#039;&#039;|&#039;&#039;&#039;disable&#039;&#039;&#039;} POLICY...&lt;br /&gt;
&lt;br /&gt;
Optional policies can be listed using this command:&lt;br /&gt;
&lt;br /&gt;
 &#039;&#039;&#039;awall list&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;&#039;enabled&#039;&#039;&#039; status means that the policy has been enabled by the&lt;br /&gt;
user. The &#039;&#039;&#039;disabled&#039;&#039;&#039; status means that the policy is not in&lt;br /&gt;
use. The &#039;&#039;&#039;required&#039;&#039;&#039; status means that the policy has not been&lt;br /&gt;
enabled by the user but is in use because it is required by another&lt;br /&gt;
policy which is in use.&lt;br /&gt;
&lt;br /&gt;
=== Debugging Policies ===&lt;br /&gt;
&lt;br /&gt;
This command can be used to dump variable, zone, and other definitions&lt;br /&gt;
as well as their source policies:&lt;br /&gt;
&lt;br /&gt;
 &#039;&#039;&#039;awall dump&#039;&#039;&#039; [LEVEL]&lt;br /&gt;
&lt;br /&gt;
The level is an integer in range 0&amp;amp;ndash;5 and defaults to 0. More&lt;br /&gt;
information is displayed on higher levels.&lt;br /&gt;
&lt;br /&gt;
[[Category:Networking]]&lt;br /&gt;
[[Category:Security]]&lt;/div&gt;</summary>
		<author><name>Kunkku</name></author>
	</entry>
	<entry>
		<id>https://wiki.alpinelinux.org/w/index.php?title=Alpine_Wall_User%27s_Guide&amp;diff=8595</id>
		<title>Alpine Wall User&#039;s Guide</title>
		<link rel="alternate" type="text/html" href="https://wiki.alpinelinux.org/w/index.php?title=Alpine_Wall_User%27s_Guide&amp;diff=8595"/>
		<updated>2012-10-23T11:23:56Z</updated>

		<summary type="html">&lt;p&gt;Kunkku: /* Configuration File Processing */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Configuration File Processing ==&lt;br /&gt;
&lt;br /&gt;
[[Alpine Wall]] (awall) reads its configuration from multiple&lt;br /&gt;
JSON-formatted files, called &#039;&#039;policy files&#039;&#039;. The processing starts&lt;br /&gt;
from directory &amp;lt;tt&amp;gt;/usr/share/awall/mandatory&amp;lt;/tt&amp;gt;, which contains&lt;br /&gt;
mandatory policy files shipped with APK packages. After that,&lt;br /&gt;
installation-specific policy files in &amp;lt;tt&amp;gt;/etc/awall&amp;lt;/tt&amp;gt; are&lt;br /&gt;
processed.&lt;br /&gt;
&lt;br /&gt;
The latter directory may also contain symbolic links to policy files&lt;br /&gt;
located in &amp;lt;tt&amp;gt;/usr/share/awall/optional&amp;lt;/tt&amp;gt; and&lt;br /&gt;
&amp;lt;tt&amp;gt;/etc/awall/optional&amp;lt;/tt&amp;gt;. These are optional policies, which can&lt;br /&gt;
be enabled on need basis. Such symbolic links are easily created and&lt;br /&gt;
destroyed using the &amp;lt;tt&amp;gt;awall enable&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;awall disable&amp;lt;/tt&amp;gt;&lt;br /&gt;
commands. &amp;lt;tt&amp;gt;awall list&amp;lt;/tt&amp;gt; shows which optional policies are&lt;br /&gt;
enabled and disabled. The command also prints the description of the&lt;br /&gt;
optional policy if defined in the file using a top-level attribute&lt;br /&gt;
named &#039;&#039;&#039;description&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Sometimes a policy file depends on other policy files. In this case,&lt;br /&gt;
the policy file must have a top-level attribute &#039;&#039;&#039;import&#039;&#039;&#039;, the&lt;br /&gt;
value of which is a list of policy names, which correspond to the file&lt;br /&gt;
names without the &amp;lt;tt&amp;gt;.json&amp;lt;/tt&amp;gt; suffix. By default, the policies&lt;br /&gt;
listed there are processed before the importing policy.&lt;br /&gt;
&lt;br /&gt;
The order of the generated iptables rules generally reflects the&lt;br /&gt;
processing order of their corresponding awall policies. The processing&lt;br /&gt;
order of policies can be adjusted by defining top-level attributes&lt;br /&gt;
&#039;&#039;&#039;after&#039;&#039;&#039; and &#039;&#039;&#039;before&#039;&#039;&#039; in policy files. These attributes are&lt;br /&gt;
lists of policies, after or before which the declaring policy shall be&lt;br /&gt;
processed. Putting a policy name to either of these lists does not by&lt;br /&gt;
itself import the policy. The ordering directives are ignored with&lt;br /&gt;
respect to those policies that are not enabled by the user or imported&lt;br /&gt;
by other policies. If not defined, &#039;&#039;&#039;after&#039;&#039;&#039; is assumed to be equal&lt;br /&gt;
to the &#039;&#039;&#039;import&#039;&#039;&#039; definition of the policy.&lt;br /&gt;
&lt;br /&gt;
As the import directive does not require the path name to be&lt;br /&gt;
specified, awall expects policies to have unique names, even if&lt;br /&gt;
located in different directories. It is allowed to import optional&lt;br /&gt;
policies that are not explicitly enabled by the user. Such policies&lt;br /&gt;
show up with the &amp;lt;tt&amp;gt;required&amp;lt;/tt&amp;gt; status in the output of &amp;lt;tt&amp;gt;awall&lt;br /&gt;
list&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
== List Parameters ==&lt;br /&gt;
&lt;br /&gt;
Several awall parameters are defined as lists of values. In order to&lt;br /&gt;
facilitate manual editing of policy files, awall also accepts single&lt;br /&gt;
values in place of lists. Such values are semantically equivalent to&lt;br /&gt;
lists containing one element.&lt;br /&gt;
&lt;br /&gt;
== Variable Expansion ==&lt;br /&gt;
&lt;br /&gt;
Awall allows variable definitions in policy files. The top-level&lt;br /&gt;
attribute &#039;&#039;&#039;variable&#039;&#039;&#039; is a dictionary containing the&lt;br /&gt;
definitions. The value of a variable can be of any type (string,&lt;br /&gt;
integer, list, or dictionary).&lt;br /&gt;
&lt;br /&gt;
A variable is referenced in policy files by a string which equals the&lt;br /&gt;
variable name prepended with the &#039;&#039;&#039;$&#039;&#039;&#039; character. If the value of&lt;br /&gt;
the variable is a string, the reference can be embedded into a longer&lt;br /&gt;
string in order to substitute some part of that string (in shell&lt;br /&gt;
style). Variable references can be used when defining other variables,&lt;br /&gt;
as long as the definitions are not circular.&lt;br /&gt;
&lt;br /&gt;
Policy files can reference variables defined in other policy&lt;br /&gt;
files. Policy files can also override variables defined elsewhere by&lt;br /&gt;
redefining them. In this case, the new definition affects all policy&lt;br /&gt;
files, also those processed before the overriding policy. Awall&lt;br /&gt;
variables are in fact simple macros, since each variable remains&lt;br /&gt;
constant thoughout a single processing round. If multiple files define&lt;br /&gt;
the same variable, the definition in the file processed last takes&lt;br /&gt;
effect.&lt;br /&gt;
&lt;br /&gt;
If defined as an empty string, all non-embedded references to a&lt;br /&gt;
variable evaluate as if the attribute in question was not present in&lt;br /&gt;
the configuration. This is also the case when a string containing&lt;br /&gt;
embedded variable references finally evaluates to an empty string.&lt;br /&gt;
&lt;br /&gt;
== Configuration Objects ==&lt;br /&gt;
&lt;br /&gt;
Configuration objects can be divided into two main types.&lt;br /&gt;
&#039;&#039;Auxiliary objects&#039;&#039; model high-level concepts such as services and&lt;br /&gt;
zones. &#039;&#039;Rule objects&#039;&#039; translate into one or more iptables rules, and&lt;br /&gt;
are often defined with the help of some auxiliary objects.&lt;br /&gt;
&lt;br /&gt;
=== Services ===&lt;br /&gt;
&lt;br /&gt;
A &#039;&#039;service&#039;&#039; represents a set of network protocols. A top-level&lt;br /&gt;
attribute &#039;&#039;&#039;service&#039;&#039;&#039; is a dictionary that maps service names to&lt;br /&gt;
service definition objects, or lists thereof in more complex cases.&lt;br /&gt;
&lt;br /&gt;
A service definition object contains an attribute named &#039;&#039;&#039;proto&#039;&#039;&#039;,&lt;br /&gt;
which corresponds to the &amp;lt;tt&amp;gt;--protocol&amp;lt;/tt&amp;gt; option of iptables. The&lt;br /&gt;
protocol can be defined as a numerical value or string as defined in&lt;br /&gt;
&amp;lt;tt&amp;gt;/etc/protocols&amp;lt;/tt&amp;gt;. If the protocol is &#039;&#039;&#039;tcp&#039;&#039;&#039; or &#039;&#039;&#039;udp&#039;&#039;&#039;,&lt;br /&gt;
the scope of the service definition may be constrained by defining an&lt;br /&gt;
attribute named &#039;&#039;&#039;port&#039;&#039;&#039;, which is a list of TCP or UDP port numbers&lt;br /&gt;
or ranges thereof, separated by the &#039;&#039;&#039;-&#039;&#039;&#039; character. If the protocol&lt;br /&gt;
is &#039;&#039;&#039;icmp&#039;&#039;&#039; or &#039;&#039;&#039;icmpv6&#039;&#039;&#039;, an analogous &#039;&#039;&#039;icmp-type&#039;&#039;&#039; attribute&lt;br /&gt;
may be used. In addition, the scope of the rule is also automatically&lt;br /&gt;
limited to IPv4 or IPv6, respectively.&lt;br /&gt;
&lt;br /&gt;
=== Zones ===&lt;br /&gt;
&lt;br /&gt;
A &#039;&#039;zone&#039;&#039; represents a set of network hosts. A top-level attribute &lt;br /&gt;
&#039;&#039;&#039;zone&#039;&#039;&#039; is a dictionary that maps zone names to zone objects. A&lt;br /&gt;
zone object has an attribute named &#039;&#039;&#039;iface&#039;&#039;&#039;, &#039;&#039;&#039;addr&#039;&#039;&#039;, or&lt;br /&gt;
both. &#039;&#039;&#039;iface&#039;&#039;&#039; is a list of network interfaces and &#039;&#039;&#039;addr&#039;&#039;&#039; is a&lt;br /&gt;
list of IPv4/IPv6 host and network addresses (CIDR&lt;br /&gt;
notation). &#039;&#039;&#039;addr&#039;&#039;&#039; may also contain domain names, which are&lt;br /&gt;
expanded to IP addresses using DNS resolution. If not defined,&lt;br /&gt;
&#039;&#039;&#039;addr&#039;&#039;&#039; defaults to the entire address space and &#039;&#039;&#039;iface&#039;&#039;&#039; to all&lt;br /&gt;
interfaces. An empty zone can be defined by setting either &#039;&#039;&#039;addr&#039;&#039;&#039;&lt;br /&gt;
or &#039;&#039;&#039;iface&#039;&#039;&#039; to an empty list.&lt;br /&gt;
&lt;br /&gt;
Rule objects contain two attributes, &#039;&#039;&#039;in&#039;&#039;&#039; and &#039;&#039;&#039;out&#039;&#039;&#039;, which are&lt;br /&gt;
lists of zone names. These attributes control whether a packet matches&lt;br /&gt;
the rule or not. If a particular zone is referenced by the &#039;&#039;&#039;in&#039;&#039;&#039; &lt;br /&gt;
attribute, the rule applies to packets whose ingress interface and&lt;br /&gt;
source address are covered by the zone definition. Correspondingly, if&lt;br /&gt;
a zone is referenced by the &#039;&#039;&#039;out&#039;&#039;&#039; attribute, the rule applies to&lt;br /&gt;
packets whose egress interface and destination address are included in&lt;br /&gt;
the zone. If both &#039;&#039;&#039;in&#039;&#039;&#039; and &#039;&#039;&#039;out&#039;&#039;&#039; are defined, the packet must&lt;br /&gt;
fulfill both criteria in order to match the rule.&lt;br /&gt;
&lt;br /&gt;
The firewall host itself can be referred to using the special value&lt;br /&gt;
&#039;&#039;&#039;_fw&#039;&#039;&#039; as the zone name.&lt;br /&gt;
&lt;br /&gt;
By default, awall does not generate iptables rules with identical&lt;br /&gt;
ingress and egress interfaces. This behavior can be changed per zone&lt;br /&gt;
by setting the optional &#039;&#039;&#039;route-back&#039;&#039;&#039; attribute of the zone to&lt;br /&gt;
&#039;&#039;&#039;true&#039;&#039;&#039;. Note that this attribute can have an effect also in the&lt;br /&gt;
case where &#039;&#039;&#039;in&#039;&#039;&#039; and &#039;&#039;&#039;out&#039;&#039;&#039; attributes of a rule are not equal&lt;br /&gt;
but their definitions overlap. In this case, the &#039;&#039;&#039;route-back&#039;&#039;&#039;&lt;br /&gt;
attribute of the &#039;&#039;&#039;out&#039;&#039;&#039; zone determines the behavior.&lt;br /&gt;
&lt;br /&gt;
=== Logging Classes ===&lt;br /&gt;
&lt;br /&gt;
A &#039;&#039;logging class&#039;&#039; specifies how packets matching certain rules are&lt;br /&gt;
logged. A top-level attribute &#039;&#039;&#039;log&#039;&#039;&#039; is a dictionary that maps&lt;br /&gt;
logging class names to setting objects.&lt;br /&gt;
&lt;br /&gt;
A setting object may have an attribute named &#039;&#039;&#039;mode&#039;&#039;&#039;, which&lt;br /&gt;
specifies which logging facility to use. Allowed values are &#039;&#039;&#039;log&#039;&#039;&#039;,&lt;br /&gt;
&#039;&#039;&#039;nflog&#039;&#039;&#039;, and &#039;&#039;&#039;ulog&#039;&#039;&#039;. The default is &#039;&#039;&#039;log&#039;&#039;&#039;, i.e. in-kernel&lt;br /&gt;
logging. The object may also have a &#039;&#039;&#039;limit&#039;&#039;&#039; attribute, which is an&lt;br /&gt;
integer specifying the maximum number of matching packets to be logged&lt;br /&gt;
per second per rule. Optionally, the log entries are prefixed with a&lt;br /&gt;
string configured using the &#039;&#039;&#039;prefix&#039;&#039;&#039; attribute.&lt;br /&gt;
&lt;br /&gt;
Filter and policy rules can have an attribute named &#039;&#039;&#039;log&#039;&#039;&#039;. If it&lt;br /&gt;
is a string, it is interpreted as a reference to a logging class, and&lt;br /&gt;
logging is performed according to the definitions. If the value of the&lt;br /&gt;
&#039;&#039;&#039;log&#039;&#039;&#039; attribute is &#039;&#039;&#039;true&#039;&#039;&#039; (boolean), logging is done using&lt;br /&gt;
default settings. If the value is &#039;&#039;&#039;false&#039;&#039;&#039; (boolean), logging is&lt;br /&gt;
disabled for the rule. If &#039;&#039;&#039;log&#039;&#039;&#039; is not defined, logging is done&lt;br /&gt;
using the default settings except for accept rules, for which logging&lt;br /&gt;
is omitted.&lt;br /&gt;
&lt;br /&gt;
Default logging settings can be set by defining a logging class named&lt;br /&gt;
&#039;&#039;&#039;_default&#039;&#039;&#039;. Normally, default logging uses the &#039;&#039;&#039;log&#039;&#039;&#039; mode with&lt;br /&gt;
packets limited to one per second.&lt;br /&gt;
&lt;br /&gt;
=== Rules ===&lt;br /&gt;
&lt;br /&gt;
There are six types of rule objects:&lt;br /&gt;
* Filters rules&lt;br /&gt;
* Policies rules&lt;br /&gt;
* NAT rules&lt;br /&gt;
* Packet Marking rules&lt;br /&gt;
* MSS Clamping rules&lt;br /&gt;
* Connection Tracking Bypass rules&lt;br /&gt;
&lt;br /&gt;
All rule objects can have the &#039;&#039;&#039;in&#039;&#039;&#039; and &#039;&#039;&#039;out&#039;&#039;&#039; attributes&lt;br /&gt;
referring to zones as described in the previous section. In addition,&lt;br /&gt;
the scope of the rule can be further constrained with the following&lt;br /&gt;
attributes:&lt;br /&gt;
&lt;br /&gt;
{|&lt;br /&gt;
!Attribute!!Value format!!Effect&lt;br /&gt;
|-&lt;br /&gt;
|&#039;&#039;&#039;src&#039;&#039;&#039;&lt;br /&gt;
|Similar to &#039;&#039;&#039;addr&#039;&#039;&#039; attribute of zone objects&lt;br /&gt;
|Packet&#039;s source address matches the value&lt;br /&gt;
|-&lt;br /&gt;
|&#039;&#039;&#039;dest&#039;&#039;&#039;&lt;br /&gt;
|Similar to &#039;&#039;&#039;addr&#039;&#039;&#039; attribute of zone objects&lt;br /&gt;
|Packet&#039;s destination address matches the value&lt;br /&gt;
|-&lt;br /&gt;
|&#039;&#039;&#039;ipset&#039;&#039;&#039;&lt;br /&gt;
|Object containing two attributes: &#039;&#039;&#039;name&#039;&#039;&#039; referring to an IP set and &#039;&#039;&#039;args&#039;&#039;&#039;, which is a list of strings &#039;&#039;&#039;in&#039;&#039;&#039; and &#039;&#039;&#039;out&#039;&#039;&#039;&lt;br /&gt;
|Packet matches the IP set referred here when the match arguments are taken from the source (&#039;&#039;&#039;in&#039;&#039;&#039;) and destination (&#039;&#039;&#039;out&#039;&#039;&#039;) address or port in the order specified by &#039;&#039;&#039;args&#039;&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
|&#039;&#039;&#039;ipsec&#039;&#039;&#039;&lt;br /&gt;
|&#039;&#039;&#039;in&#039;&#039;&#039; or &#039;&#039;&#039;out&#039;&#039;&#039;&lt;br /&gt;
|IPsec decapsulation perfomed on ingress (&#039;&#039;&#039;in&#039;&#039;&#039;) or encapsulation performed on egress (&#039;&#039;&#039;out&#039;&#039;&#039;)&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Rule objects are declared in type-specific top-level dictionaries in&lt;br /&gt;
awall policy files. If a packet matches multiple rules, the one&lt;br /&gt;
appearing earlier in the list takes precedence. If the matching rules&lt;br /&gt;
are defined in different policy files, the one that was processed&lt;br /&gt;
earlier takes precedence in the current implementation, but this may&lt;br /&gt;
change in future versions.&lt;br /&gt;
&lt;br /&gt;
==== Filters Rules ====&lt;br /&gt;
&lt;br /&gt;
Filter objects specify an action for packets fulfilling certain&lt;br /&gt;
criteria. The top-level attribute &#039;&#039;&#039;filter&#039;&#039;&#039; is a list of filter&lt;br /&gt;
objects. The precedence rules are similar to those of policy objects.&lt;br /&gt;
&lt;br /&gt;
In addition to the common rule attributes, filter objects can have a &lt;br /&gt;
&#039;&#039;&#039;service&#039;&#039;&#039; attribute constraining the scope to specific services&lt;br /&gt;
only. This attribute is a list of service names, referring to the&lt;br /&gt;
keys of the top-level &#039;&#039;&#039;service&#039;&#039;&#039; dictionary.&lt;br /&gt;
&lt;br /&gt;
Filter objects must have an attribute named &#039;&#039;&#039;action&#039;&#039;&#039;, the value of&lt;br /&gt;
which can be one of the following:&lt;br /&gt;
&lt;br /&gt;
{|&lt;br /&gt;
!Value!!Action&lt;br /&gt;
|-&lt;br /&gt;
|&#039;&#039;&#039;accept&#039;&#039;&#039;&lt;br /&gt;
|Accept the packet&lt;br /&gt;
|-&lt;br /&gt;
|&#039;&#039;&#039;reject&#039;&#039;&#039;&lt;br /&gt;
|Reject the packet with an ICMP error message&lt;br /&gt;
|-&lt;br /&gt;
|&#039;&#039;&#039;drop&#039;&#039;&#039;&lt;br /&gt;
|Silently drop the packet&lt;br /&gt;
|-&lt;br /&gt;
|&#039;&#039;&#039;tarpit&#039;&#039;&#039;&lt;br /&gt;
|Put incoming TCP connections into persist state and ignore attempts to close them. Silently drop non-TCP packets. (Connection tracking bypass is automatically enabled for the matching packets.)&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Filter objects, the action of which is &#039;&#039;&#039;accept&#039;&#039;&#039;, may also contain&lt;br /&gt;
limits for packet flow or new connections. These are specified with&lt;br /&gt;
the &#039;&#039;&#039;flow-limit&#039;&#039;&#039; and &#039;&#039;&#039;conn-limit&#039;&#039;&#039; attributes,&lt;br /&gt;
respectively. The values of these attributes are limit objects that&lt;br /&gt;
have two attributes: &#039;&#039;&#039;count&#039;&#039;&#039; and &#039;&#039;&#039;interval&#039;&#039;&#039;. &#039;&#039;&#039;count&#039;&#039;&#039;&lt;br /&gt;
specifies how many new connections or packets are allowed within the&lt;br /&gt;
time frame specified by &#039;&#039;&#039;interval&#039;&#039;&#039; (in seconds). The &#039;&#039;&#039;drop&#039;&#039;&#039;&lt;br /&gt;
action is applied to the packets exceeding the limit. Optionally, the&lt;br /&gt;
limit object may have an attribute named &#039;&#039;&#039;log&#039;&#039;&#039;. It defines how the&lt;br /&gt;
dropped packets should be logged and is semantically similar to the&lt;br /&gt;
&#039;&#039;&#039;log&#039;&#039;&#039; attribute of rule objects.&lt;br /&gt;
&lt;br /&gt;
Filter objects may have an attribute named &#039;&#039;&#039;dnat&#039;&#039;&#039;, the value of&lt;br /&gt;
which is an IPv4 address. If defined, this enables destination NAT for&lt;br /&gt;
all IPv4 packets matching the rule, such that the specified address&lt;br /&gt;
replaces the original destination address. This option has no effect&lt;br /&gt;
on IPv6 packets.&lt;br /&gt;
&lt;br /&gt;
Filter objects may have a boolean attribute named &#039;&#039;&#039;no-track&#039;&#039;&#039;. If&lt;br /&gt;
set to &#039;&#039;&#039;true&#039;&#039;&#039;, connection tracking is bypassed for the matching&lt;br /&gt;
packets. In addition, if &#039;&#039;&#039;action&#039;&#039;&#039; is set to &#039;&#039;&#039;accept&#039;&#039;&#039;, the&lt;br /&gt;
corresponding packets travelling to the reverse direction are also&lt;br /&gt;
allowed.&lt;br /&gt;
&lt;br /&gt;
==== Policies Rules ====&lt;br /&gt;
&lt;br /&gt;
Policy objects describe the default action for packets that did not&lt;br /&gt;
match any filter. The top-level attribute &#039;&#039;&#039;policy&#039;&#039;&#039; is a list of&lt;br /&gt;
policy objects.&lt;br /&gt;
&lt;br /&gt;
Policy objects must have the &#039;&#039;&#039;action&#039;&#039;&#039; attribute defined. The&lt;br /&gt;
possible values and their semantics are the same as in filter objects.&lt;br /&gt;
&lt;br /&gt;
==== NAT Rules ====&lt;br /&gt;
&lt;br /&gt;
NAT rules come in two flavors: &#039;&#039;source NAT rules&#039;&#039; and&lt;br /&gt;
&#039;&#039;destination NAT rules&#039;&#039;. These are contained in two top-level lists&lt;br /&gt;
named &#039;&#039;&#039;snat&#039;&#039;&#039; and &#039;&#039;&#039;dnat&#039;&#039;&#039;, respectively.&lt;br /&gt;
&lt;br /&gt;
Each NAT rule may have an attribute named &#039;&#039;&#039;to-addr&#039;&#039;&#039; that&lt;br /&gt;
specifies the IPv4 address range to which the original source or&lt;br /&gt;
destination address is mapped. The value can be a single IPv4 address&lt;br /&gt;
or a range specified by two addresses, separated with the &#039;&#039;&#039;-&#039;&#039;&#039;&lt;br /&gt;
character. If not defined, it defaults to the primary address of the&lt;br /&gt;
ingress interface in case of destination NAT, or that of the egress&lt;br /&gt;
interface in case of source NAT.&lt;br /&gt;
&lt;br /&gt;
Optionally, a NAT rule can specify the TCP and UDP port range to which&lt;br /&gt;
the original source or destination port is mapped. The attribute is&lt;br /&gt;
named &#039;&#039;&#039;to-port&#039;&#039;&#039;, and the value can be a single port number or a&lt;br /&gt;
range specified by two numbers, separated with the &#039;&#039;&#039;-&#039;&#039;&#039;&lt;br /&gt;
character. If &#039;&#039;&#039;to-port&#039;&#039;&#039; is not specified, the original port number&lt;br /&gt;
is kept intact.&lt;br /&gt;
&lt;br /&gt;
Like filters, NAT rules can have a &#039;&#039;&#039;service&#039;&#039;&#039; attribute&lt;br /&gt;
constraining their scope to specific services.&lt;br /&gt;
&lt;br /&gt;
NAT rules may have an &#039;&#039;&#039;action&#039;&#039;&#039; attribute set to value&lt;br /&gt;
&#039;&#039;&#039;accept&#039;&#039;&#039;. In this case, NAT is not performed on the packets&lt;br /&gt;
reaching and matching this rule.&lt;br /&gt;
&lt;br /&gt;
==== Packet Marking Rules ====&lt;br /&gt;
&lt;br /&gt;
Packet marking rules are used to mark incoming packets matching the&lt;br /&gt;
specified criteria. The mark can be used as a basis for the routing&lt;br /&gt;
decision. Each marking rule must specify the mark using the &#039;&#039;&#039;mark&#039;&#039;&#039;&lt;br /&gt;
attribute, which is a 32-bit integer.&lt;br /&gt;
&lt;br /&gt;
Normal marking rules are contained by the top-level list attribute&lt;br /&gt;
named &#039;&#039;&#039;mark&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
There is another top-level list attribute, named &#039;&#039;&#039;route-track&#039;&#039;&#039;,&lt;br /&gt;
which contains route tracking rules. These are special marking rules&lt;br /&gt;
which cause all the subsequent packets related to the same connection&lt;br /&gt;
to be marked according to the rule.&lt;br /&gt;
&lt;br /&gt;
==== MSS Clamping Rules ====&lt;br /&gt;
&lt;br /&gt;
MSS Clamping Rules are used to deal with ISPs that block ICMP&lt;br /&gt;
Fragmentation Needed or ICMPv6 Packet Too Big packets. An MSS clamping&lt;br /&gt;
rule overwrites the MSS option with a value specified with the&lt;br /&gt;
&#039;&#039;&#039;mss&#039;&#039;&#039; attribute for the matching TCP connections. If &#039;&#039;&#039;mss&#039;&#039;&#039; is&lt;br /&gt;
not specified, a suitable value is automatically determined from the&lt;br /&gt;
path MTU. The MSS clamping rules are located in the top-level&lt;br /&gt;
dictionary named &#039;&#039;&#039;clamp-mss&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
==== Connection Tracking Bypass Rules ====&lt;br /&gt;
&lt;br /&gt;
Connection tracking bypass rules are used to disable connection&lt;br /&gt;
tracking for packets matching the specified criteria. The top-level&lt;br /&gt;
attribute &#039;&#039;&#039;no-track&#039;&#039;&#039; is a list of such rules.&lt;br /&gt;
&lt;br /&gt;
Connection tracking bypass rules may have an &#039;&#039;&#039;action&#039;&#039;&#039; attribute&lt;br /&gt;
set to value &#039;&#039;&#039;accept&#039;&#039;&#039;. The effect is similar to corresponding NAT&lt;br /&gt;
rules, i.e. connection tracking is not bypassed for the matching&lt;br /&gt;
packets.&lt;br /&gt;
&lt;br /&gt;
=== IP Sets ===&lt;br /&gt;
&lt;br /&gt;
Any IP set referenced by rule objects should be created by&lt;br /&gt;
awall. Auxiliary &#039;&#039;IP set&#039;&#039; objects are used to defined them in awall&lt;br /&gt;
policy files. The top-level attribute &#039;&#039;&#039;ipset&#039;&#039;&#039; is a dictionary, the&lt;br /&gt;
keys of which are IP set names. The values are IP set objects, which&lt;br /&gt;
have two mandatory attributes. The attribute named &#039;&#039;&#039;type&#039;&#039;&#039; &lt;br /&gt;
corresponds to the type argument of the &amp;lt;tt&amp;gt;ipset create&amp;lt;/tt&amp;gt; &lt;br /&gt;
command. &#039;&#039;&#039;family&#039;&#039;&#039; specifies whether the set is for IPv4 or IPv6&lt;br /&gt;
addresses, and the possible values are &#039;&#039;&#039;inet&#039;&#039;&#039; and &#039;&#039;&#039;inet6&#039;&#039;&#039;,&lt;br /&gt;
correspondingly.&lt;br /&gt;
&lt;br /&gt;
== Command Line Syntax ==&lt;br /&gt;
&lt;br /&gt;
=== Translating Policy Files to Firewall Configuration Files ===&lt;br /&gt;
&lt;br /&gt;
 &#039;&#039;&#039;awall translate&#039;&#039;&#039; [&#039;&#039;&#039;-o&#039;&#039;&#039;|&#039;&#039;&#039;--output&#039;&#039;&#039; DIRECTORY] [&#039;&#039;&#039;-V&#039;&#039;&#039;|&#039;&#039;&#039;--verify&#039;&#039;&#039;]&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;tt&amp;gt;--verify&amp;lt;/tt&amp;gt; option makes awall verify the configuration&lt;br /&gt;
using the test mode of iptables-restore before overwriting the old&lt;br /&gt;
files.&lt;br /&gt;
&lt;br /&gt;
Specifying the output directory allows testing awall policies without&lt;br /&gt;
overwriting the current iptables and ipset configuration files. By&lt;br /&gt;
default, awall generates the configuration to &amp;lt;tt&amp;gt;/etc/iptables&amp;lt;/tt&amp;gt; &lt;br /&gt;
and &amp;lt;tt&amp;gt;/etc/ipset.d&amp;lt;/tt&amp;gt;, which are read by the init scripts.&lt;br /&gt;
&lt;br /&gt;
=== Run-Time Configuration of Firewall ===&lt;br /&gt;
&lt;br /&gt;
 &#039;&#039;&#039;awall activate&#039;&#039;&#039; [&#039;&#039;&#039;-f&#039;&#039;&#039;|&#039;&#039;&#039;--force&#039;&#039;&#039;]&lt;br /&gt;
&lt;br /&gt;
This command genereates firewall configuration from the policy files&lt;br /&gt;
and enables it. If the user confirms the new configuration by hitting&lt;br /&gt;
the Return key within 10 seconds or the &amp;lt;tt&amp;gt;--force&amp;lt;/tt&amp;gt; option is&lt;br /&gt;
used, the configuration is saved to the files. Otherwise, the old&lt;br /&gt;
configuration is restored.&lt;br /&gt;
&lt;br /&gt;
There is also a command for deleting all firewall rules:&lt;br /&gt;
&lt;br /&gt;
 &#039;&#039;&#039;awall flush&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
This command configures the firewall to drop all packets.&lt;br /&gt;
&lt;br /&gt;
=== Optional Policies ===&lt;br /&gt;
&lt;br /&gt;
Optional policies can be enabled or disabled using this command:&lt;br /&gt;
&lt;br /&gt;
 &#039;&#039;&#039;awall&#039;&#039;&#039; {&#039;&#039;&#039;enable&#039;&#039;&#039;|&#039;&#039;&#039;disable&#039;&#039;&#039;} POLICY...&lt;br /&gt;
&lt;br /&gt;
Optional policies can be listed using this command:&lt;br /&gt;
&lt;br /&gt;
 &#039;&#039;&#039;awall list&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;&#039;enabled&#039;&#039;&#039; status means that the policy has been enabled by the&lt;br /&gt;
user. The &#039;&#039;&#039;disabled&#039;&#039;&#039; status means that the policy is not in&lt;br /&gt;
use. The &#039;&#039;&#039;required&#039;&#039;&#039; status means that the policy has not been&lt;br /&gt;
enabled by the user but is in use because it is required by another&lt;br /&gt;
policy which is in use.&lt;br /&gt;
&lt;br /&gt;
=== Debugging Policies ===&lt;br /&gt;
&lt;br /&gt;
This command can be used to dump variable, zone, and other definitions&lt;br /&gt;
as well as their source policies:&lt;br /&gt;
&lt;br /&gt;
 &#039;&#039;&#039;awall dump&#039;&#039;&#039; [LEVEL]&lt;br /&gt;
&lt;br /&gt;
The level is an integer in range 0&amp;amp;ndash;5 and defaults to 0. More&lt;br /&gt;
information is displayed on higher levels.&lt;br /&gt;
&lt;br /&gt;
[[Category:Networking]]&lt;br /&gt;
[[Category:Security]]&lt;/div&gt;</summary>
		<author><name>Kunkku</name></author>
	</entry>
	<entry>
		<id>https://wiki.alpinelinux.org/w/index.php?title=Alpine_Wall_User%27s_Guide&amp;diff=8593</id>
		<title>Alpine Wall User&#039;s Guide</title>
		<link rel="alternate" type="text/html" href="https://wiki.alpinelinux.org/w/index.php?title=Alpine_Wall_User%27s_Guide&amp;diff=8593"/>
		<updated>2012-10-23T07:03:18Z</updated>

		<summary type="html">&lt;p&gt;Kunkku: /* Filters Rules */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Configuration File Processing ==&lt;br /&gt;
&lt;br /&gt;
[[Alpine Wall]] (awall) reads its configuration from multiple&lt;br /&gt;
JSON-formatted files, called &#039;&#039;policy files&#039;&#039;. The processing starts&lt;br /&gt;
from directory &amp;lt;tt&amp;gt;/usr/share/awall/mandatory&amp;lt;/tt&amp;gt;, which contains&lt;br /&gt;
mandatory policy files shipped with APK packages. After that,&lt;br /&gt;
installation-specific policy files in &amp;lt;tt&amp;gt;/etc/awall&amp;lt;/tt&amp;gt; are&lt;br /&gt;
processed.&lt;br /&gt;
&lt;br /&gt;
The latter directory may also contain symbolic links to policy files&lt;br /&gt;
located in &amp;lt;tt&amp;gt;/usr/share/awall/optional&amp;lt;/tt&amp;gt;. These are optional&lt;br /&gt;
policies, which can be enabled on need basis. Such symbolic links are&lt;br /&gt;
easily created and destroyed using the &amp;lt;tt&amp;gt;awall enable&amp;lt;/tt&amp;gt; and &lt;br /&gt;
&amp;lt;tt&amp;gt;awall disable&amp;lt;/tt&amp;gt; commands. &amp;lt;tt&amp;gt;awall list&amp;lt;/tt&amp;gt; shows which&lt;br /&gt;
optional policies are enabled and disabled. The command also prints&lt;br /&gt;
the description of the optional policy if defined in the file using&lt;br /&gt;
a top-level attribute named &#039;&#039;&#039;description&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Sometimes a policy file depends on other policy files. In this case,&lt;br /&gt;
the policy file must have a top-level attribute &#039;&#039;&#039;import&#039;&#039;&#039;, the&lt;br /&gt;
value of which is a list of policy names, which correspond to the file&lt;br /&gt;
names without the &amp;lt;tt&amp;gt;.json&amp;lt;/tt&amp;gt; suffix. By default, the policies&lt;br /&gt;
listed there are processed before the importing policy.&lt;br /&gt;
&lt;br /&gt;
The order of the generated iptables rules generally reflects the&lt;br /&gt;
processing order of their corresponding awall policies. The processing&lt;br /&gt;
order of policies can be adjusted by defining top-level attributes&lt;br /&gt;
&#039;&#039;&#039;after&#039;&#039;&#039; and &#039;&#039;&#039;before&#039;&#039;&#039; in policy files. These attributes are&lt;br /&gt;
lists of policies, after or before which the declaring policy shall be&lt;br /&gt;
processed. Putting a policy name to either of these lists does not by&lt;br /&gt;
itself import the policy. The ordering directives are ignored with&lt;br /&gt;
respect to those policies that are not enabled by the user or imported&lt;br /&gt;
by other policies. If not defined, &#039;&#039;&#039;after&#039;&#039;&#039; is assumed to be equal&lt;br /&gt;
to the &#039;&#039;&#039;import&#039;&#039;&#039; definition of the policy.&lt;br /&gt;
&lt;br /&gt;
As the import directive does not require the path name to be&lt;br /&gt;
specified, awall expects policies to have unique names, even if&lt;br /&gt;
located in different directories. It is allowed to import optional&lt;br /&gt;
policies that are not explicitly enabled by the user. Such policies&lt;br /&gt;
show up with the &amp;lt;tt&amp;gt;required&amp;lt;/tt&amp;gt; status in the output of &amp;lt;tt&amp;gt;awall&lt;br /&gt;
list&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
== List Parameters ==&lt;br /&gt;
&lt;br /&gt;
Several awall parameters are defined as lists of values. In order to&lt;br /&gt;
facilitate manual editing of policy files, awall also accepts single&lt;br /&gt;
values in place of lists. Such values are semantically equivalent to&lt;br /&gt;
lists containing one element.&lt;br /&gt;
&lt;br /&gt;
== Variable Expansion ==&lt;br /&gt;
&lt;br /&gt;
Awall allows variable definitions in policy files. The top-level&lt;br /&gt;
attribute &#039;&#039;&#039;variable&#039;&#039;&#039; is a dictionary containing the&lt;br /&gt;
definitions. The value of a variable can be of any type (string,&lt;br /&gt;
integer, list, or dictionary).&lt;br /&gt;
&lt;br /&gt;
A variable is referenced in policy files by a string which equals the&lt;br /&gt;
variable name prepended with the &#039;&#039;&#039;$&#039;&#039;&#039; character. If the value of&lt;br /&gt;
the variable is a string, the reference can be embedded into a longer&lt;br /&gt;
string in order to substitute some part of that string (in shell&lt;br /&gt;
style). Variable references can be used when defining other variables,&lt;br /&gt;
as long as the definitions are not circular.&lt;br /&gt;
&lt;br /&gt;
Policy files can reference variables defined in other policy&lt;br /&gt;
files. Policy files can also override variables defined elsewhere by&lt;br /&gt;
redefining them. In this case, the new definition affects all policy&lt;br /&gt;
files, also those processed before the overriding policy. Awall&lt;br /&gt;
variables are in fact simple macros, since each variable remains&lt;br /&gt;
constant thoughout a single processing round. If multiple files define&lt;br /&gt;
the same variable, the definition in the file processed last takes&lt;br /&gt;
effect.&lt;br /&gt;
&lt;br /&gt;
If defined as an empty string, all non-embedded references to a&lt;br /&gt;
variable evaluate as if the attribute in question was not present in&lt;br /&gt;
the configuration. This is also the case when a string containing&lt;br /&gt;
embedded variable references finally evaluates to an empty string.&lt;br /&gt;
&lt;br /&gt;
== Configuration Objects ==&lt;br /&gt;
&lt;br /&gt;
Configuration objects can be divided into two main types.&lt;br /&gt;
&#039;&#039;Auxiliary objects&#039;&#039; model high-level concepts such as services and&lt;br /&gt;
zones. &#039;&#039;Rule objects&#039;&#039; translate into one or more iptables rules, and&lt;br /&gt;
are often defined with the help of some auxiliary objects.&lt;br /&gt;
&lt;br /&gt;
=== Services ===&lt;br /&gt;
&lt;br /&gt;
A &#039;&#039;service&#039;&#039; represents a set of network protocols. A top-level&lt;br /&gt;
attribute &#039;&#039;&#039;service&#039;&#039;&#039; is a dictionary that maps service names to&lt;br /&gt;
service definition objects, or lists thereof in more complex cases.&lt;br /&gt;
&lt;br /&gt;
A service definition object contains an attribute named &#039;&#039;&#039;proto&#039;&#039;&#039;,&lt;br /&gt;
which corresponds to the &amp;lt;tt&amp;gt;--protocol&amp;lt;/tt&amp;gt; option of iptables. The&lt;br /&gt;
protocol can be defined as a numerical value or string as defined in&lt;br /&gt;
&amp;lt;tt&amp;gt;/etc/protocols&amp;lt;/tt&amp;gt;. If the protocol is &#039;&#039;&#039;tcp&#039;&#039;&#039; or &#039;&#039;&#039;udp&#039;&#039;&#039;,&lt;br /&gt;
the scope of the service definition may be constrained by defining an&lt;br /&gt;
attribute named &#039;&#039;&#039;port&#039;&#039;&#039;, which is a list of TCP or UDP port numbers&lt;br /&gt;
or ranges thereof, separated by the &#039;&#039;&#039;-&#039;&#039;&#039; character. If the protocol&lt;br /&gt;
is &#039;&#039;&#039;icmp&#039;&#039;&#039; or &#039;&#039;&#039;icmpv6&#039;&#039;&#039;, an analogous &#039;&#039;&#039;icmp-type&#039;&#039;&#039; attribute&lt;br /&gt;
may be used. In addition, the scope of the rule is also automatically&lt;br /&gt;
limited to IPv4 or IPv6, respectively.&lt;br /&gt;
&lt;br /&gt;
=== Zones ===&lt;br /&gt;
&lt;br /&gt;
A &#039;&#039;zone&#039;&#039; represents a set of network hosts. A top-level attribute &lt;br /&gt;
&#039;&#039;&#039;zone&#039;&#039;&#039; is a dictionary that maps zone names to zone objects. A&lt;br /&gt;
zone object has an attribute named &#039;&#039;&#039;iface&#039;&#039;&#039;, &#039;&#039;&#039;addr&#039;&#039;&#039;, or&lt;br /&gt;
both. &#039;&#039;&#039;iface&#039;&#039;&#039; is a list of network interfaces and &#039;&#039;&#039;addr&#039;&#039;&#039; is a&lt;br /&gt;
list of IPv4/IPv6 host and network addresses (CIDR&lt;br /&gt;
notation). &#039;&#039;&#039;addr&#039;&#039;&#039; may also contain domain names, which are&lt;br /&gt;
expanded to IP addresses using DNS resolution. If not defined,&lt;br /&gt;
&#039;&#039;&#039;addr&#039;&#039;&#039; defaults to the entire address space and &#039;&#039;&#039;iface&#039;&#039;&#039; to all&lt;br /&gt;
interfaces. An empty zone can be defined by setting either &#039;&#039;&#039;addr&#039;&#039;&#039;&lt;br /&gt;
or &#039;&#039;&#039;iface&#039;&#039;&#039; to an empty list.&lt;br /&gt;
&lt;br /&gt;
Rule objects contain two attributes, &#039;&#039;&#039;in&#039;&#039;&#039; and &#039;&#039;&#039;out&#039;&#039;&#039;, which are&lt;br /&gt;
lists of zone names. These attributes control whether a packet matches&lt;br /&gt;
the rule or not. If a particular zone is referenced by the &#039;&#039;&#039;in&#039;&#039;&#039; &lt;br /&gt;
attribute, the rule applies to packets whose ingress interface and&lt;br /&gt;
source address are covered by the zone definition. Correspondingly, if&lt;br /&gt;
a zone is referenced by the &#039;&#039;&#039;out&#039;&#039;&#039; attribute, the rule applies to&lt;br /&gt;
packets whose egress interface and destination address are included in&lt;br /&gt;
the zone. If both &#039;&#039;&#039;in&#039;&#039;&#039; and &#039;&#039;&#039;out&#039;&#039;&#039; are defined, the packet must&lt;br /&gt;
fulfill both criteria in order to match the rule.&lt;br /&gt;
&lt;br /&gt;
The firewall host itself can be referred to using the special value&lt;br /&gt;
&#039;&#039;&#039;_fw&#039;&#039;&#039; as the zone name.&lt;br /&gt;
&lt;br /&gt;
By default, awall does not generate iptables rules with identical&lt;br /&gt;
ingress and egress interfaces. This behavior can be changed per zone&lt;br /&gt;
by setting the optional &#039;&#039;&#039;route-back&#039;&#039;&#039; attribute of the zone to&lt;br /&gt;
&#039;&#039;&#039;true&#039;&#039;&#039;. Note that this attribute can have an effect also in the&lt;br /&gt;
case where &#039;&#039;&#039;in&#039;&#039;&#039; and &#039;&#039;&#039;out&#039;&#039;&#039; attributes of a rule are not equal&lt;br /&gt;
but their definitions overlap. In this case, the &#039;&#039;&#039;route-back&#039;&#039;&#039;&lt;br /&gt;
attribute of the &#039;&#039;&#039;out&#039;&#039;&#039; zone determines the behavior.&lt;br /&gt;
&lt;br /&gt;
=== Logging Classes ===&lt;br /&gt;
&lt;br /&gt;
A &#039;&#039;logging class&#039;&#039; specifies how packets matching certain rules are&lt;br /&gt;
logged. A top-level attribute &#039;&#039;&#039;log&#039;&#039;&#039; is a dictionary that maps&lt;br /&gt;
logging class names to setting objects.&lt;br /&gt;
&lt;br /&gt;
A setting object may have an attribute named &#039;&#039;&#039;mode&#039;&#039;&#039;, which&lt;br /&gt;
specifies which logging facility to use. Allowed values are &#039;&#039;&#039;log&#039;&#039;&#039;,&lt;br /&gt;
&#039;&#039;&#039;nflog&#039;&#039;&#039;, and &#039;&#039;&#039;ulog&#039;&#039;&#039;. The default is &#039;&#039;&#039;log&#039;&#039;&#039;, i.e. in-kernel&lt;br /&gt;
logging. The object may also have a &#039;&#039;&#039;limit&#039;&#039;&#039; attribute, which is an&lt;br /&gt;
integer specifying the maximum number of matching packets to be logged&lt;br /&gt;
per second per rule. Optionally, the log entries are prefixed with a&lt;br /&gt;
string configured using the &#039;&#039;&#039;prefix&#039;&#039;&#039; attribute.&lt;br /&gt;
&lt;br /&gt;
Filter and policy rules can have an attribute named &#039;&#039;&#039;log&#039;&#039;&#039;. If it&lt;br /&gt;
is a string, it is interpreted as a reference to a logging class, and&lt;br /&gt;
logging is performed according to the definitions. If the value of the&lt;br /&gt;
&#039;&#039;&#039;log&#039;&#039;&#039; attribute is &#039;&#039;&#039;true&#039;&#039;&#039; (boolean), logging is done using&lt;br /&gt;
default settings. If the value is &#039;&#039;&#039;false&#039;&#039;&#039; (boolean), logging is&lt;br /&gt;
disabled for the rule. If &#039;&#039;&#039;log&#039;&#039;&#039; is not defined, logging is done&lt;br /&gt;
using the default settings except for accept rules, for which logging&lt;br /&gt;
is omitted.&lt;br /&gt;
&lt;br /&gt;
Default logging settings can be set by defining a logging class named&lt;br /&gt;
&#039;&#039;&#039;_default&#039;&#039;&#039;. Normally, default logging uses the &#039;&#039;&#039;log&#039;&#039;&#039; mode with&lt;br /&gt;
packets limited to one per second.&lt;br /&gt;
&lt;br /&gt;
=== Rules ===&lt;br /&gt;
&lt;br /&gt;
There are six types of rule objects:&lt;br /&gt;
* Filters rules&lt;br /&gt;
* Policies rules&lt;br /&gt;
* NAT rules&lt;br /&gt;
* Packet Marking rules&lt;br /&gt;
* MSS Clamping rules&lt;br /&gt;
* Connection Tracking Bypass rules&lt;br /&gt;
&lt;br /&gt;
All rule objects can have the &#039;&#039;&#039;in&#039;&#039;&#039; and &#039;&#039;&#039;out&#039;&#039;&#039; attributes&lt;br /&gt;
referring to zones as described in the previous section. In addition,&lt;br /&gt;
the scope of the rule can be further constrained with the following&lt;br /&gt;
attributes:&lt;br /&gt;
&lt;br /&gt;
{|&lt;br /&gt;
!Attribute!!Value format!!Effect&lt;br /&gt;
|-&lt;br /&gt;
|&#039;&#039;&#039;src&#039;&#039;&#039;&lt;br /&gt;
|Similar to &#039;&#039;&#039;addr&#039;&#039;&#039; attribute of zone objects&lt;br /&gt;
|Packet&#039;s source address matches the value&lt;br /&gt;
|-&lt;br /&gt;
|&#039;&#039;&#039;dest&#039;&#039;&#039;&lt;br /&gt;
|Similar to &#039;&#039;&#039;addr&#039;&#039;&#039; attribute of zone objects&lt;br /&gt;
|Packet&#039;s destination address matches the value&lt;br /&gt;
|-&lt;br /&gt;
|&#039;&#039;&#039;ipset&#039;&#039;&#039;&lt;br /&gt;
|Object containing two attributes: &#039;&#039;&#039;name&#039;&#039;&#039; referring to an IP set and &#039;&#039;&#039;args&#039;&#039;&#039;, which is a list of strings &#039;&#039;&#039;in&#039;&#039;&#039; and &#039;&#039;&#039;out&#039;&#039;&#039;&lt;br /&gt;
|Packet matches the IP set referred here when the match arguments are taken from the source (&#039;&#039;&#039;in&#039;&#039;&#039;) and destination (&#039;&#039;&#039;out&#039;&#039;&#039;) address or port in the order specified by &#039;&#039;&#039;args&#039;&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
|&#039;&#039;&#039;ipsec&#039;&#039;&#039;&lt;br /&gt;
|&#039;&#039;&#039;in&#039;&#039;&#039; or &#039;&#039;&#039;out&#039;&#039;&#039;&lt;br /&gt;
|IPsec decapsulation perfomed on ingress (&#039;&#039;&#039;in&#039;&#039;&#039;) or encapsulation performed on egress (&#039;&#039;&#039;out&#039;&#039;&#039;)&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Rule objects are declared in type-specific top-level dictionaries in&lt;br /&gt;
awall policy files. If a packet matches multiple rules, the one&lt;br /&gt;
appearing earlier in the list takes precedence. If the matching rules&lt;br /&gt;
are defined in different policy files, the one that was processed&lt;br /&gt;
earlier takes precedence in the current implementation, but this may&lt;br /&gt;
change in future versions.&lt;br /&gt;
&lt;br /&gt;
==== Filters Rules ====&lt;br /&gt;
&lt;br /&gt;
Filter objects specify an action for packets fulfilling certain&lt;br /&gt;
criteria. The top-level attribute &#039;&#039;&#039;filter&#039;&#039;&#039; is a list of filter&lt;br /&gt;
objects. The precedence rules are similar to those of policy objects.&lt;br /&gt;
&lt;br /&gt;
In addition to the common rule attributes, filter objects can have a &lt;br /&gt;
&#039;&#039;&#039;service&#039;&#039;&#039; attribute constraining the scope to specific services&lt;br /&gt;
only. This attribute is a list of service names, referring to the&lt;br /&gt;
keys of the top-level &#039;&#039;&#039;service&#039;&#039;&#039; dictionary.&lt;br /&gt;
&lt;br /&gt;
Filter objects must have an attribute named &#039;&#039;&#039;action&#039;&#039;&#039;, the value of&lt;br /&gt;
which can be one of the following:&lt;br /&gt;
&lt;br /&gt;
{|&lt;br /&gt;
!Value!!Action&lt;br /&gt;
|-&lt;br /&gt;
|&#039;&#039;&#039;accept&#039;&#039;&#039;&lt;br /&gt;
|Accept the packet&lt;br /&gt;
|-&lt;br /&gt;
|&#039;&#039;&#039;reject&#039;&#039;&#039;&lt;br /&gt;
|Reject the packet with an ICMP error message&lt;br /&gt;
|-&lt;br /&gt;
|&#039;&#039;&#039;drop&#039;&#039;&#039;&lt;br /&gt;
|Silently drop the packet&lt;br /&gt;
|-&lt;br /&gt;
|&#039;&#039;&#039;tarpit&#039;&#039;&#039;&lt;br /&gt;
|Put incoming TCP connections into persist state and ignore attempts to close them. Silently drop non-TCP packets. (Connection tracking bypass is automatically enabled for the matching packets.)&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Filter objects, the action of which is &#039;&#039;&#039;accept&#039;&#039;&#039;, may also contain&lt;br /&gt;
limits for packet flow or new connections. These are specified with&lt;br /&gt;
the &#039;&#039;&#039;flow-limit&#039;&#039;&#039; and &#039;&#039;&#039;conn-limit&#039;&#039;&#039; attributes,&lt;br /&gt;
respectively. The values of these attributes are limit objects that&lt;br /&gt;
have two attributes: &#039;&#039;&#039;count&#039;&#039;&#039; and &#039;&#039;&#039;interval&#039;&#039;&#039;. &#039;&#039;&#039;count&#039;&#039;&#039;&lt;br /&gt;
specifies how many new connections or packets are allowed within the&lt;br /&gt;
time frame specified by &#039;&#039;&#039;interval&#039;&#039;&#039; (in seconds). The &#039;&#039;&#039;drop&#039;&#039;&#039;&lt;br /&gt;
action is applied to the packets exceeding the limit. Optionally, the&lt;br /&gt;
limit object may have an attribute named &#039;&#039;&#039;log&#039;&#039;&#039;. It defines how the&lt;br /&gt;
dropped packets should be logged and is semantically similar to the&lt;br /&gt;
&#039;&#039;&#039;log&#039;&#039;&#039; attribute of rule objects.&lt;br /&gt;
&lt;br /&gt;
Filter objects may have an attribute named &#039;&#039;&#039;dnat&#039;&#039;&#039;, the value of&lt;br /&gt;
which is an IPv4 address. If defined, this enables destination NAT for&lt;br /&gt;
all IPv4 packets matching the rule, such that the specified address&lt;br /&gt;
replaces the original destination address. This option has no effect&lt;br /&gt;
on IPv6 packets.&lt;br /&gt;
&lt;br /&gt;
Filter objects may have a boolean attribute named &#039;&#039;&#039;no-track&#039;&#039;&#039;. If&lt;br /&gt;
set to &#039;&#039;&#039;true&#039;&#039;&#039;, connection tracking is bypassed for the matching&lt;br /&gt;
packets. In addition, if &#039;&#039;&#039;action&#039;&#039;&#039; is set to &#039;&#039;&#039;accept&#039;&#039;&#039;, the&lt;br /&gt;
corresponding packets travelling to the reverse direction are also&lt;br /&gt;
allowed.&lt;br /&gt;
&lt;br /&gt;
==== Policies Rules ====&lt;br /&gt;
&lt;br /&gt;
Policy objects describe the default action for packets that did not&lt;br /&gt;
match any filter. The top-level attribute &#039;&#039;&#039;policy&#039;&#039;&#039; is a list of&lt;br /&gt;
policy objects.&lt;br /&gt;
&lt;br /&gt;
Policy objects must have the &#039;&#039;&#039;action&#039;&#039;&#039; attribute defined. The&lt;br /&gt;
possible values and their semantics are the same as in filter objects.&lt;br /&gt;
&lt;br /&gt;
==== NAT Rules ====&lt;br /&gt;
&lt;br /&gt;
NAT rules come in two flavors: &#039;&#039;source NAT rules&#039;&#039; and&lt;br /&gt;
&#039;&#039;destination NAT rules&#039;&#039;. These are contained in two top-level lists&lt;br /&gt;
named &#039;&#039;&#039;snat&#039;&#039;&#039; and &#039;&#039;&#039;dnat&#039;&#039;&#039;, respectively.&lt;br /&gt;
&lt;br /&gt;
Each NAT rule may have an attribute named &#039;&#039;&#039;to-addr&#039;&#039;&#039; that&lt;br /&gt;
specifies the IPv4 address range to which the original source or&lt;br /&gt;
destination address is mapped. The value can be a single IPv4 address&lt;br /&gt;
or a range specified by two addresses, separated with the &#039;&#039;&#039;-&#039;&#039;&#039;&lt;br /&gt;
character. If not defined, it defaults to the primary address of the&lt;br /&gt;
ingress interface in case of destination NAT, or that of the egress&lt;br /&gt;
interface in case of source NAT.&lt;br /&gt;
&lt;br /&gt;
Optionally, a NAT rule can specify the TCP and UDP port range to which&lt;br /&gt;
the original source or destination port is mapped. The attribute is&lt;br /&gt;
named &#039;&#039;&#039;to-port&#039;&#039;&#039;, and the value can be a single port number or a&lt;br /&gt;
range specified by two numbers, separated with the &#039;&#039;&#039;-&#039;&#039;&#039;&lt;br /&gt;
character. If &#039;&#039;&#039;to-port&#039;&#039;&#039; is not specified, the original port number&lt;br /&gt;
is kept intact.&lt;br /&gt;
&lt;br /&gt;
Like filters, NAT rules can have a &#039;&#039;&#039;service&#039;&#039;&#039; attribute&lt;br /&gt;
constraining their scope to specific services.&lt;br /&gt;
&lt;br /&gt;
NAT rules may have an &#039;&#039;&#039;action&#039;&#039;&#039; attribute set to value&lt;br /&gt;
&#039;&#039;&#039;accept&#039;&#039;&#039;. In this case, NAT is not performed on the packets&lt;br /&gt;
reaching and matching this rule.&lt;br /&gt;
&lt;br /&gt;
==== Packet Marking Rules ====&lt;br /&gt;
&lt;br /&gt;
Packet marking rules are used to mark incoming packets matching the&lt;br /&gt;
specified criteria. The mark can be used as a basis for the routing&lt;br /&gt;
decision. Each marking rule must specify the mark using the &#039;&#039;&#039;mark&#039;&#039;&#039;&lt;br /&gt;
attribute, which is a 32-bit integer.&lt;br /&gt;
&lt;br /&gt;
Normal marking rules are contained by the top-level list attribute&lt;br /&gt;
named &#039;&#039;&#039;mark&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
There is another top-level list attribute, named &#039;&#039;&#039;route-track&#039;&#039;&#039;,&lt;br /&gt;
which contains route tracking rules. These are special marking rules&lt;br /&gt;
which cause all the subsequent packets related to the same connection&lt;br /&gt;
to be marked according to the rule.&lt;br /&gt;
&lt;br /&gt;
==== MSS Clamping Rules ====&lt;br /&gt;
&lt;br /&gt;
MSS Clamping Rules are used to deal with ISPs that block ICMP&lt;br /&gt;
Fragmentation Needed or ICMPv6 Packet Too Big packets. An MSS clamping&lt;br /&gt;
rule overwrites the MSS option with a value specified with the&lt;br /&gt;
&#039;&#039;&#039;mss&#039;&#039;&#039; attribute for the matching TCP connections. If &#039;&#039;&#039;mss&#039;&#039;&#039; is&lt;br /&gt;
not specified, a suitable value is automatically determined from the&lt;br /&gt;
path MTU. The MSS clamping rules are located in the top-level&lt;br /&gt;
dictionary named &#039;&#039;&#039;clamp-mss&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
==== Connection Tracking Bypass Rules ====&lt;br /&gt;
&lt;br /&gt;
Connection tracking bypass rules are used to disable connection&lt;br /&gt;
tracking for packets matching the specified criteria. The top-level&lt;br /&gt;
attribute &#039;&#039;&#039;no-track&#039;&#039;&#039; is a list of such rules.&lt;br /&gt;
&lt;br /&gt;
Connection tracking bypass rules may have an &#039;&#039;&#039;action&#039;&#039;&#039; attribute&lt;br /&gt;
set to value &#039;&#039;&#039;accept&#039;&#039;&#039;. The effect is similar to corresponding NAT&lt;br /&gt;
rules, i.e. connection tracking is not bypassed for the matching&lt;br /&gt;
packets.&lt;br /&gt;
&lt;br /&gt;
=== IP Sets ===&lt;br /&gt;
&lt;br /&gt;
Any IP set referenced by rule objects should be created by&lt;br /&gt;
awall. Auxiliary &#039;&#039;IP set&#039;&#039; objects are used to defined them in awall&lt;br /&gt;
policy files. The top-level attribute &#039;&#039;&#039;ipset&#039;&#039;&#039; is a dictionary, the&lt;br /&gt;
keys of which are IP set names. The values are IP set objects, which&lt;br /&gt;
have two mandatory attributes. The attribute named &#039;&#039;&#039;type&#039;&#039;&#039; &lt;br /&gt;
corresponds to the type argument of the &amp;lt;tt&amp;gt;ipset create&amp;lt;/tt&amp;gt; &lt;br /&gt;
command. &#039;&#039;&#039;family&#039;&#039;&#039; specifies whether the set is for IPv4 or IPv6&lt;br /&gt;
addresses, and the possible values are &#039;&#039;&#039;inet&#039;&#039;&#039; and &#039;&#039;&#039;inet6&#039;&#039;&#039;,&lt;br /&gt;
correspondingly.&lt;br /&gt;
&lt;br /&gt;
== Command Line Syntax ==&lt;br /&gt;
&lt;br /&gt;
=== Translating Policy Files to Firewall Configuration Files ===&lt;br /&gt;
&lt;br /&gt;
 &#039;&#039;&#039;awall translate&#039;&#039;&#039; [&#039;&#039;&#039;-o&#039;&#039;&#039;|&#039;&#039;&#039;--output&#039;&#039;&#039; DIRECTORY] [&#039;&#039;&#039;-V&#039;&#039;&#039;|&#039;&#039;&#039;--verify&#039;&#039;&#039;]&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;tt&amp;gt;--verify&amp;lt;/tt&amp;gt; option makes awall verify the configuration&lt;br /&gt;
using the test mode of iptables-restore before overwriting the old&lt;br /&gt;
files.&lt;br /&gt;
&lt;br /&gt;
Specifying the output directory allows testing awall policies without&lt;br /&gt;
overwriting the current iptables and ipset configuration files. By&lt;br /&gt;
default, awall generates the configuration to &amp;lt;tt&amp;gt;/etc/iptables&amp;lt;/tt&amp;gt; &lt;br /&gt;
and &amp;lt;tt&amp;gt;/etc/ipset.d&amp;lt;/tt&amp;gt;, which are read by the init scripts.&lt;br /&gt;
&lt;br /&gt;
=== Run-Time Configuration of Firewall ===&lt;br /&gt;
&lt;br /&gt;
 &#039;&#039;&#039;awall activate&#039;&#039;&#039; [&#039;&#039;&#039;-f&#039;&#039;&#039;|&#039;&#039;&#039;--force&#039;&#039;&#039;]&lt;br /&gt;
&lt;br /&gt;
This command genereates firewall configuration from the policy files&lt;br /&gt;
and enables it. If the user confirms the new configuration by hitting&lt;br /&gt;
the Return key within 10 seconds or the &amp;lt;tt&amp;gt;--force&amp;lt;/tt&amp;gt; option is&lt;br /&gt;
used, the configuration is saved to the files. Otherwise, the old&lt;br /&gt;
configuration is restored.&lt;br /&gt;
&lt;br /&gt;
There is also a command for deleting all firewall rules:&lt;br /&gt;
&lt;br /&gt;
 &#039;&#039;&#039;awall flush&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
This command configures the firewall to drop all packets.&lt;br /&gt;
&lt;br /&gt;
=== Optional Policies ===&lt;br /&gt;
&lt;br /&gt;
Optional policies can be enabled or disabled using this command:&lt;br /&gt;
&lt;br /&gt;
 &#039;&#039;&#039;awall&#039;&#039;&#039; {&#039;&#039;&#039;enable&#039;&#039;&#039;|&#039;&#039;&#039;disable&#039;&#039;&#039;} POLICY...&lt;br /&gt;
&lt;br /&gt;
Optional policies can be listed using this command:&lt;br /&gt;
&lt;br /&gt;
 &#039;&#039;&#039;awall list&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;&#039;enabled&#039;&#039;&#039; status means that the policy has been enabled by the&lt;br /&gt;
user. The &#039;&#039;&#039;disabled&#039;&#039;&#039; status means that the policy is not in&lt;br /&gt;
use. The &#039;&#039;&#039;required&#039;&#039;&#039; status means that the policy has not been&lt;br /&gt;
enabled by the user but is in use because it is required by another&lt;br /&gt;
policy which is in use.&lt;br /&gt;
&lt;br /&gt;
=== Debugging Policies ===&lt;br /&gt;
&lt;br /&gt;
This command can be used to dump variable, zone, and other definitions&lt;br /&gt;
as well as their source policies:&lt;br /&gt;
&lt;br /&gt;
 &#039;&#039;&#039;awall dump&#039;&#039;&#039; [LEVEL]&lt;br /&gt;
&lt;br /&gt;
The level is an integer in range 0&amp;amp;ndash;5 and defaults to 0. More&lt;br /&gt;
information is displayed on higher levels.&lt;br /&gt;
&lt;br /&gt;
[[Category:Networking]]&lt;br /&gt;
[[Category:Security]]&lt;/div&gt;</summary>
		<author><name>Kunkku</name></author>
	</entry>
	<entry>
		<id>https://wiki.alpinelinux.org/w/index.php?title=Alpine_Wall_User%27s_Guide&amp;diff=8485</id>
		<title>Alpine Wall User&#039;s Guide</title>
		<link rel="alternate" type="text/html" href="https://wiki.alpinelinux.org/w/index.php?title=Alpine_Wall_User%27s_Guide&amp;diff=8485"/>
		<updated>2012-10-17T13:16:15Z</updated>

		<summary type="html">&lt;p&gt;Kunkku: /* MSS Clamping Rules */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Configuration File Processing ==&lt;br /&gt;
&lt;br /&gt;
[[Alpine Wall]] (awall) reads its configuration from multiple&lt;br /&gt;
JSON-formatted files, called &#039;&#039;policy files&#039;&#039;. The processing starts&lt;br /&gt;
from directory &amp;lt;tt&amp;gt;/usr/share/awall/mandatory&amp;lt;/tt&amp;gt;, which contains&lt;br /&gt;
mandatory policy files shipped with APK packages. After that,&lt;br /&gt;
installation-specific policy files in &amp;lt;tt&amp;gt;/etc/awall&amp;lt;/tt&amp;gt; are&lt;br /&gt;
processed.&lt;br /&gt;
&lt;br /&gt;
The latter directory may also contain symbolic links to policy files&lt;br /&gt;
located in &amp;lt;tt&amp;gt;/usr/share/awall/optional&amp;lt;/tt&amp;gt;. These are optional&lt;br /&gt;
policies, which can be enabled on need basis. Such symbolic links are&lt;br /&gt;
easily created and destroyed using the &amp;lt;tt&amp;gt;awall enable&amp;lt;/tt&amp;gt; and &lt;br /&gt;
&amp;lt;tt&amp;gt;awall disable&amp;lt;/tt&amp;gt; commands. &amp;lt;tt&amp;gt;awall list&amp;lt;/tt&amp;gt; shows which&lt;br /&gt;
optional policies are enabled and disabled. The command also prints&lt;br /&gt;
the description of the optional policy if defined in the file using&lt;br /&gt;
a top-level attribute named &#039;&#039;&#039;description&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Sometimes a policy file depends on other policy files. In this case,&lt;br /&gt;
the policy file must have a top-level attribute &#039;&#039;&#039;import&#039;&#039;&#039;, the&lt;br /&gt;
value of which is a list of policy names, which correspond to the file&lt;br /&gt;
names without the &amp;lt;tt&amp;gt;.json&amp;lt;/tt&amp;gt; suffix. By default, the policies&lt;br /&gt;
listed there are processed before the importing policy.&lt;br /&gt;
&lt;br /&gt;
The order of the generated iptables rules generally reflects the&lt;br /&gt;
processing order of their corresponding awall policies. The processing&lt;br /&gt;
order of policies can be adjusted by defining top-level attributes&lt;br /&gt;
&#039;&#039;&#039;after&#039;&#039;&#039; and &#039;&#039;&#039;before&#039;&#039;&#039; in policy files. These attributes are&lt;br /&gt;
lists of policies, after or before which the declaring policy shall be&lt;br /&gt;
processed. Putting a policy name to either of these lists does not by&lt;br /&gt;
itself import the policy. The ordering directives are ignored with&lt;br /&gt;
respect to those policies that are not enabled by the user or imported&lt;br /&gt;
by other policies. If not defined, &#039;&#039;&#039;after&#039;&#039;&#039; is assumed to be equal&lt;br /&gt;
to the &#039;&#039;&#039;import&#039;&#039;&#039; definition of the policy.&lt;br /&gt;
&lt;br /&gt;
As the import directive does not require the path name to be&lt;br /&gt;
specified, awall expects policies to have unique names, even if&lt;br /&gt;
located in different directories. It is allowed to import optional&lt;br /&gt;
policies that are not explicitly enabled by the user. Such policies&lt;br /&gt;
show up with the &amp;lt;tt&amp;gt;required&amp;lt;/tt&amp;gt; status in the output of &amp;lt;tt&amp;gt;awall&lt;br /&gt;
list&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
== List Parameters ==&lt;br /&gt;
&lt;br /&gt;
Several awall parameters are defined as lists of values. In order to&lt;br /&gt;
facilitate manual editing of policy files, awall also accepts single&lt;br /&gt;
values in place of lists. Such values are semantically equivalent to&lt;br /&gt;
lists containing one element.&lt;br /&gt;
&lt;br /&gt;
== Variable Expansion ==&lt;br /&gt;
&lt;br /&gt;
Awall allows variable definitions in policy files. The top-level&lt;br /&gt;
attribute &#039;&#039;&#039;variable&#039;&#039;&#039; is a dictionary containing the&lt;br /&gt;
definitions. The value of a variable can be of any type (string,&lt;br /&gt;
integer, list, or dictionary).&lt;br /&gt;
&lt;br /&gt;
A variable is referenced in policy files by a string which equals the&lt;br /&gt;
variable name prepended with the &#039;&#039;&#039;$&#039;&#039;&#039; character. If the value of&lt;br /&gt;
the variable is a string, the reference can be embedded into a longer&lt;br /&gt;
string in order to substitute some part of that string (in shell&lt;br /&gt;
style). Variable references can be used when defining other variables,&lt;br /&gt;
as long as the definitions are not circular.&lt;br /&gt;
&lt;br /&gt;
Policy files can reference variables defined in other policy&lt;br /&gt;
files. Policy files can also override variables defined elsewhere by&lt;br /&gt;
redefining them. In this case, the new definition affects all policy&lt;br /&gt;
files, also those processed before the overriding policy. Awall&lt;br /&gt;
variables are in fact simple macros, since each variable remains&lt;br /&gt;
constant thoughout a single processing round. If multiple files define&lt;br /&gt;
the same variable, the definition in the file processed last takes&lt;br /&gt;
effect.&lt;br /&gt;
&lt;br /&gt;
If defined as an empty string, all non-embedded references to a&lt;br /&gt;
variable evaluate as if the attribute in question was not present in&lt;br /&gt;
the configuration. This is also the case when a string containing&lt;br /&gt;
embedded variable references finally evaluates to an empty string.&lt;br /&gt;
&lt;br /&gt;
== Configuration Objects ==&lt;br /&gt;
&lt;br /&gt;
Configuration objects can be divided into two main types.&lt;br /&gt;
&#039;&#039;Auxiliary objects&#039;&#039; model high-level concepts such as services and&lt;br /&gt;
zones. &#039;&#039;Rule objects&#039;&#039; translate into one or more iptables rules, and&lt;br /&gt;
are often defined with the help of some auxiliary objects.&lt;br /&gt;
&lt;br /&gt;
=== Services ===&lt;br /&gt;
&lt;br /&gt;
A &#039;&#039;service&#039;&#039; represents a set of network protocols. A top-level&lt;br /&gt;
attribute &#039;&#039;&#039;service&#039;&#039;&#039; is a dictionary that maps service names to&lt;br /&gt;
service definition objects, or lists thereof in more complex cases.&lt;br /&gt;
&lt;br /&gt;
A service definition object contains an attribute named &#039;&#039;&#039;proto&#039;&#039;&#039;,&lt;br /&gt;
which corresponds to the &amp;lt;tt&amp;gt;--protocol&amp;lt;/tt&amp;gt; option of iptables. The&lt;br /&gt;
protocol can be defined as a numerical value or string as defined in&lt;br /&gt;
&amp;lt;tt&amp;gt;/etc/protocols&amp;lt;/tt&amp;gt;. If the protocol is &#039;&#039;&#039;tcp&#039;&#039;&#039; or &#039;&#039;&#039;udp&#039;&#039;&#039;,&lt;br /&gt;
the scope of the service definition may be constrained by defining an&lt;br /&gt;
attribute named &#039;&#039;&#039;port&#039;&#039;&#039;, which is a list of TCP or UDP port numbers&lt;br /&gt;
or ranges thereof, separated by the &#039;&#039;&#039;-&#039;&#039;&#039; character. If the protocol&lt;br /&gt;
is &#039;&#039;&#039;icmp&#039;&#039;&#039; or &#039;&#039;&#039;icmpv6&#039;&#039;&#039;, an analogous &#039;&#039;&#039;icmp-type&#039;&#039;&#039; attribute&lt;br /&gt;
may be used. In addition, the scope of the rule is also automatically&lt;br /&gt;
limited to IPv4 or IPv6, respectively.&lt;br /&gt;
&lt;br /&gt;
=== Zones ===&lt;br /&gt;
&lt;br /&gt;
A &#039;&#039;zone&#039;&#039; represents a set of network hosts. A top-level attribute &lt;br /&gt;
&#039;&#039;&#039;zone&#039;&#039;&#039; is a dictionary that maps zone names to zone objects. A&lt;br /&gt;
zone object has an attribute named &#039;&#039;&#039;iface&#039;&#039;&#039;, &#039;&#039;&#039;addr&#039;&#039;&#039;, or&lt;br /&gt;
both. &#039;&#039;&#039;iface&#039;&#039;&#039; is a list of network interfaces and &#039;&#039;&#039;addr&#039;&#039;&#039; is a&lt;br /&gt;
list of IPv4/IPv6 host and network addresses (CIDR&lt;br /&gt;
notation). &#039;&#039;&#039;addr&#039;&#039;&#039; may also contain domain names, which are&lt;br /&gt;
expanded to IP addresses using DNS resolution. If not defined,&lt;br /&gt;
&#039;&#039;&#039;addr&#039;&#039;&#039; defaults to the entire address space and &#039;&#039;&#039;iface&#039;&#039;&#039; to all&lt;br /&gt;
interfaces. An empty zone can be defined by setting either &#039;&#039;&#039;addr&#039;&#039;&#039;&lt;br /&gt;
or &#039;&#039;&#039;iface&#039;&#039;&#039; to an empty list.&lt;br /&gt;
&lt;br /&gt;
Rule objects contain two attributes, &#039;&#039;&#039;in&#039;&#039;&#039; and &#039;&#039;&#039;out&#039;&#039;&#039;, which are&lt;br /&gt;
lists of zone names. These attributes control whether a packet matches&lt;br /&gt;
the rule or not. If a particular zone is referenced by the &#039;&#039;&#039;in&#039;&#039;&#039; &lt;br /&gt;
attribute, the rule applies to packets whose ingress interface and&lt;br /&gt;
source address are covered by the zone definition. Correspondingly, if&lt;br /&gt;
a zone is referenced by the &#039;&#039;&#039;out&#039;&#039;&#039; attribute, the rule applies to&lt;br /&gt;
packets whose egress interface and destination address are included in&lt;br /&gt;
the zone. If both &#039;&#039;&#039;in&#039;&#039;&#039; and &#039;&#039;&#039;out&#039;&#039;&#039; are defined, the packet must&lt;br /&gt;
fulfill both criteria in order to match the rule.&lt;br /&gt;
&lt;br /&gt;
The firewall host itself can be referred to using the special value&lt;br /&gt;
&#039;&#039;&#039;_fw&#039;&#039;&#039; as the zone name.&lt;br /&gt;
&lt;br /&gt;
By default, awall does not generate iptables rules with identical&lt;br /&gt;
ingress and egress interfaces. This behavior can be changed per zone&lt;br /&gt;
by setting the optional &#039;&#039;&#039;route-back&#039;&#039;&#039; attribute of the zone to&lt;br /&gt;
&#039;&#039;&#039;true&#039;&#039;&#039;. Note that this attribute can have an effect also in the&lt;br /&gt;
case where &#039;&#039;&#039;in&#039;&#039;&#039; and &#039;&#039;&#039;out&#039;&#039;&#039; attributes of a rule are not equal&lt;br /&gt;
but their definitions overlap. In this case, the &#039;&#039;&#039;route-back&#039;&#039;&#039;&lt;br /&gt;
attribute of the &#039;&#039;&#039;out&#039;&#039;&#039; zone determines the behavior.&lt;br /&gt;
&lt;br /&gt;
=== Logging Classes ===&lt;br /&gt;
&lt;br /&gt;
A &#039;&#039;logging class&#039;&#039; specifies how packets matching certain rules are&lt;br /&gt;
logged. A top-level attribute &#039;&#039;&#039;log&#039;&#039;&#039; is a dictionary that maps&lt;br /&gt;
logging class names to setting objects.&lt;br /&gt;
&lt;br /&gt;
A setting object may have an attribute named &#039;&#039;&#039;mode&#039;&#039;&#039;, which&lt;br /&gt;
specifies which logging facility to use. Allowed values are &#039;&#039;&#039;log&#039;&#039;&#039;,&lt;br /&gt;
&#039;&#039;&#039;nflog&#039;&#039;&#039;, and &#039;&#039;&#039;ulog&#039;&#039;&#039;. The default is &#039;&#039;&#039;log&#039;&#039;&#039;, i.e. in-kernel&lt;br /&gt;
logging. The object may also have a &#039;&#039;&#039;limit&#039;&#039;&#039; attribute, which is an&lt;br /&gt;
integer specifying the maximum number of matching packets to be logged&lt;br /&gt;
per second per rule. Optionally, the log entries are prefixed with a&lt;br /&gt;
string configured using the &#039;&#039;&#039;prefix&#039;&#039;&#039; attribute.&lt;br /&gt;
&lt;br /&gt;
Filter and policy rules can have an attribute named &#039;&#039;&#039;log&#039;&#039;&#039;. If it&lt;br /&gt;
is a string, it is interpreted as a reference to a logging class, and&lt;br /&gt;
logging is performed according to the definitions. If the value of the&lt;br /&gt;
&#039;&#039;&#039;log&#039;&#039;&#039; attribute is &#039;&#039;&#039;true&#039;&#039;&#039; (boolean), logging is done using&lt;br /&gt;
default settings. If the value is &#039;&#039;&#039;false&#039;&#039;&#039; (boolean), logging is&lt;br /&gt;
disabled for the rule. If &#039;&#039;&#039;log&#039;&#039;&#039; is not defined, logging is done&lt;br /&gt;
using the default settings except for accept rules, for which logging&lt;br /&gt;
is omitted.&lt;br /&gt;
&lt;br /&gt;
Default logging settings can be set by defining a logging class named&lt;br /&gt;
&#039;&#039;&#039;_default&#039;&#039;&#039;. Normally, default logging uses the &#039;&#039;&#039;log&#039;&#039;&#039; mode with&lt;br /&gt;
packets limited to one per second.&lt;br /&gt;
&lt;br /&gt;
=== Rules ===&lt;br /&gt;
&lt;br /&gt;
There are six types of rule objects:&lt;br /&gt;
* Filters rules&lt;br /&gt;
* Policies rules&lt;br /&gt;
* NAT rules&lt;br /&gt;
* Packet Marking rules&lt;br /&gt;
* MSS Clamping rules&lt;br /&gt;
* Connection Tracking Bypass rules&lt;br /&gt;
&lt;br /&gt;
All rule objects can have the &#039;&#039;&#039;in&#039;&#039;&#039; and &#039;&#039;&#039;out&#039;&#039;&#039; attributes&lt;br /&gt;
referring to zones as described in the previous section. In addition,&lt;br /&gt;
the scope of the rule can be further constrained with the following&lt;br /&gt;
attributes:&lt;br /&gt;
&lt;br /&gt;
{|&lt;br /&gt;
!Attribute!!Value format!!Effect&lt;br /&gt;
|-&lt;br /&gt;
|&#039;&#039;&#039;src&#039;&#039;&#039;&lt;br /&gt;
|Similar to &#039;&#039;&#039;addr&#039;&#039;&#039; attribute of zone objects&lt;br /&gt;
|Packet&#039;s source address matches the value&lt;br /&gt;
|-&lt;br /&gt;
|&#039;&#039;&#039;dest&#039;&#039;&#039;&lt;br /&gt;
|Similar to &#039;&#039;&#039;addr&#039;&#039;&#039; attribute of zone objects&lt;br /&gt;
|Packet&#039;s destination address matches the value&lt;br /&gt;
|-&lt;br /&gt;
|&#039;&#039;&#039;ipset&#039;&#039;&#039;&lt;br /&gt;
|Object containing two attributes: &#039;&#039;&#039;name&#039;&#039;&#039; referring to an IP set and &#039;&#039;&#039;args&#039;&#039;&#039;, which is a list of strings &#039;&#039;&#039;in&#039;&#039;&#039; and &#039;&#039;&#039;out&#039;&#039;&#039;&lt;br /&gt;
|Packet matches the IP set referred here when the match arguments are taken from the source (&#039;&#039;&#039;in&#039;&#039;&#039;) and destination (&#039;&#039;&#039;out&#039;&#039;&#039;) address or port in the order specified by &#039;&#039;&#039;args&#039;&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
|&#039;&#039;&#039;ipsec&#039;&#039;&#039;&lt;br /&gt;
|&#039;&#039;&#039;in&#039;&#039;&#039; or &#039;&#039;&#039;out&#039;&#039;&#039;&lt;br /&gt;
|IPsec decapsulation perfomed on ingress (&#039;&#039;&#039;in&#039;&#039;&#039;) or encapsulation performed on egress (&#039;&#039;&#039;out&#039;&#039;&#039;)&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Rule objects are declared in type-specific top-level dictionaries in&lt;br /&gt;
awall policy files. If a packet matches multiple rules, the one&lt;br /&gt;
appearing earlier in the list takes precedence. If the matching rules&lt;br /&gt;
are defined in different policy files, the one that was processed&lt;br /&gt;
earlier takes precedence in the current implementation, but this may&lt;br /&gt;
change in future versions.&lt;br /&gt;
&lt;br /&gt;
==== Filters Rules ====&lt;br /&gt;
&lt;br /&gt;
Filter objects specify an action for packets fulfilling certain&lt;br /&gt;
criteria. The top-level attribute &#039;&#039;&#039;filter&#039;&#039;&#039; is a list of filter&lt;br /&gt;
objects. The precedence rules are similar to those of policy objects.&lt;br /&gt;
&lt;br /&gt;
In addition to the common rule attributes, filter objects can have a &lt;br /&gt;
&#039;&#039;&#039;service&#039;&#039;&#039; attribute constraining the scope to specific services&lt;br /&gt;
only. This attribute is a list of service names, referring to the&lt;br /&gt;
keys of the top-level &#039;&#039;&#039;service&#039;&#039;&#039; dictionary.&lt;br /&gt;
&lt;br /&gt;
Filter objects must have an attribute named &#039;&#039;&#039;action&#039;&#039;&#039;, the value of&lt;br /&gt;
which can be one of the following:&lt;br /&gt;
&lt;br /&gt;
{|&lt;br /&gt;
!Value!!Action&lt;br /&gt;
|-&lt;br /&gt;
|&#039;&#039;&#039;accept&#039;&#039;&#039;&lt;br /&gt;
|Accept the packet&lt;br /&gt;
|-&lt;br /&gt;
|&#039;&#039;&#039;reject&#039;&#039;&#039;&lt;br /&gt;
|Reject the packet with an ICMP error message&lt;br /&gt;
|-&lt;br /&gt;
|&#039;&#039;&#039;drop&#039;&#039;&#039;&lt;br /&gt;
|Silently drop the packet&lt;br /&gt;
|-&lt;br /&gt;
|&#039;&#039;&#039;tarpit&#039;&#039;&#039;&lt;br /&gt;
|Put incoming TCP connections into persist state and ignore attempts to close them. Silently drop non-TCP packets. (Connection tracking bypass is automatically enabled for the matching packets.)&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Filter objects, the action of which is &#039;&#039;&#039;accept&#039;&#039;&#039;, may also contain&lt;br /&gt;
limits for packet flow or new connections. These are specified with&lt;br /&gt;
the &#039;&#039;&#039;flow-limit&#039;&#039;&#039; and &#039;&#039;&#039;conn-limit&#039;&#039;&#039; attributes,&lt;br /&gt;
respectively. The values of these attributes are limit objects that&lt;br /&gt;
have two attributes: &#039;&#039;&#039;count&#039;&#039;&#039; and &#039;&#039;&#039;interval&#039;&#039;&#039;. &#039;&#039;&#039;count&#039;&#039;&#039;&lt;br /&gt;
specifies how many new connections or packets are allowed within the&lt;br /&gt;
time frame specified by &#039;&#039;&#039;interval&#039;&#039;&#039; (in seconds). The &#039;&#039;&#039;drop&#039;&#039;&#039;&lt;br /&gt;
action is applied to the packets exceeding the limit.&lt;br /&gt;
&lt;br /&gt;
Filter objects may have an attribute named &#039;&#039;&#039;dnat&#039;&#039;&#039;, the value of&lt;br /&gt;
which is an IPv4 address. If defined, this enables destination NAT for&lt;br /&gt;
all IPv4 packets matching the rule, such that the specified address&lt;br /&gt;
replaces the original destination address. This option has no effect&lt;br /&gt;
on IPv6 packets.&lt;br /&gt;
&lt;br /&gt;
Filter objects may have a boolean attribute named &#039;&#039;&#039;no-track&#039;&#039;&#039;. If&lt;br /&gt;
set to &#039;&#039;&#039;true&#039;&#039;&#039;, connection tracking is bypassed for the matching&lt;br /&gt;
packets. In addition, if &#039;&#039;&#039;action&#039;&#039;&#039; is set to &#039;&#039;&#039;accept&#039;&#039;&#039;, the&lt;br /&gt;
corresponding packets travelling to the reverse direction are also&lt;br /&gt;
allowed.&lt;br /&gt;
&lt;br /&gt;
==== Policies Rules ====&lt;br /&gt;
&lt;br /&gt;
Policy objects describe the default action for packets that did not&lt;br /&gt;
match any filter. The top-level attribute &#039;&#039;&#039;policy&#039;&#039;&#039; is a list of&lt;br /&gt;
policy objects.&lt;br /&gt;
&lt;br /&gt;
Policy objects must have the &#039;&#039;&#039;action&#039;&#039;&#039; attribute defined. The&lt;br /&gt;
possible values and their semantics are the same as in filter objects.&lt;br /&gt;
&lt;br /&gt;
==== NAT Rules ====&lt;br /&gt;
&lt;br /&gt;
NAT rules come in two flavors: &#039;&#039;source NAT rules&#039;&#039; and&lt;br /&gt;
&#039;&#039;destination NAT rules&#039;&#039;. These are contained in two top-level lists&lt;br /&gt;
named &#039;&#039;&#039;snat&#039;&#039;&#039; and &#039;&#039;&#039;dnat&#039;&#039;&#039;, respectively.&lt;br /&gt;
&lt;br /&gt;
Each NAT rule may have an attribute named &#039;&#039;&#039;to-addr&#039;&#039;&#039; that&lt;br /&gt;
specifies the IPv4 address range to which the original source or&lt;br /&gt;
destination address is mapped. The value can be a single IPv4 address&lt;br /&gt;
or a range specified by two addresses, separated with the &#039;&#039;&#039;-&#039;&#039;&#039;&lt;br /&gt;
character. If not defined, it defaults to the primary address of the&lt;br /&gt;
ingress interface in case of destination NAT, or that of the egress&lt;br /&gt;
interface in case of source NAT.&lt;br /&gt;
&lt;br /&gt;
Optionally, a NAT rule can specify the TCP and UDP port range to which&lt;br /&gt;
the original source or destination port is mapped. The attribute is&lt;br /&gt;
named &#039;&#039;&#039;to-port&#039;&#039;&#039;, and the value can be a single port number or a&lt;br /&gt;
range specified by two numbers, separated with the &#039;&#039;&#039;-&#039;&#039;&#039;&lt;br /&gt;
character. If &#039;&#039;&#039;to-port&#039;&#039;&#039; is not specified, the original port number&lt;br /&gt;
is kept intact.&lt;br /&gt;
&lt;br /&gt;
Like filters, NAT rules can have a &#039;&#039;&#039;service&#039;&#039;&#039; attribute&lt;br /&gt;
constraining their scope to specific services.&lt;br /&gt;
&lt;br /&gt;
NAT rules may have an &#039;&#039;&#039;action&#039;&#039;&#039; attribute set to value&lt;br /&gt;
&#039;&#039;&#039;accept&#039;&#039;&#039;. In this case, NAT is not performed on the packets&lt;br /&gt;
reaching and matching this rule.&lt;br /&gt;
&lt;br /&gt;
==== Packet Marking Rules ====&lt;br /&gt;
&lt;br /&gt;
Packet marking rules are used to mark incoming packets matching the&lt;br /&gt;
specified criteria. The mark can be used as a basis for the routing&lt;br /&gt;
decision. Each marking rule must specify the mark using the &#039;&#039;&#039;mark&#039;&#039;&#039;&lt;br /&gt;
attribute, which is a 32-bit integer.&lt;br /&gt;
&lt;br /&gt;
Normal marking rules are contained by the top-level list attribute&lt;br /&gt;
named &#039;&#039;&#039;mark&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
There is another top-level list attribute, named &#039;&#039;&#039;route-track&#039;&#039;&#039;,&lt;br /&gt;
which contains route tracking rules. These are special marking rules&lt;br /&gt;
which cause all the subsequent packets related to the same connection&lt;br /&gt;
to be marked according to the rule.&lt;br /&gt;
&lt;br /&gt;
==== MSS Clamping Rules ====&lt;br /&gt;
&lt;br /&gt;
MSS Clamping Rules are used to deal with ISPs that block ICMP&lt;br /&gt;
Fragmentation Needed or ICMPv6 Packet Too Big packets. An MSS clamping&lt;br /&gt;
rule overwrites the MSS option with a value specified with the&lt;br /&gt;
&#039;&#039;&#039;mss&#039;&#039;&#039; attribute for the matching TCP connections. If &#039;&#039;&#039;mss&#039;&#039;&#039; is&lt;br /&gt;
not specified, a suitable value is automatically determined from the&lt;br /&gt;
path MTU. The MSS clamping rules are located in the top-level&lt;br /&gt;
dictionary named &#039;&#039;&#039;clamp-mss&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
==== Connection Tracking Bypass Rules ====&lt;br /&gt;
&lt;br /&gt;
Connection tracking bypass rules are used to disable connection&lt;br /&gt;
tracking for packets matching the specified criteria. The top-level&lt;br /&gt;
attribute &#039;&#039;&#039;no-track&#039;&#039;&#039; is a list of such rules.&lt;br /&gt;
&lt;br /&gt;
Connection tracking bypass rules may have an &#039;&#039;&#039;action&#039;&#039;&#039; attribute&lt;br /&gt;
set to value &#039;&#039;&#039;accept&#039;&#039;&#039;. The effect is similar to corresponding NAT&lt;br /&gt;
rules, i.e. connection tracking is not bypassed for the matching&lt;br /&gt;
packets.&lt;br /&gt;
&lt;br /&gt;
=== IP Sets ===&lt;br /&gt;
&lt;br /&gt;
Any IP set referenced by rule objects should be created by&lt;br /&gt;
awall. Auxiliary &#039;&#039;IP set&#039;&#039; objects are used to defined them in awall&lt;br /&gt;
policy files. The top-level attribute &#039;&#039;&#039;ipset&#039;&#039;&#039; is a dictionary, the&lt;br /&gt;
keys of which are IP set names. The values are IP set objects, which&lt;br /&gt;
have two mandatory attributes. The attribute named &#039;&#039;&#039;type&#039;&#039;&#039; &lt;br /&gt;
corresponds to the type argument of the &amp;lt;tt&amp;gt;ipset create&amp;lt;/tt&amp;gt; &lt;br /&gt;
command. &#039;&#039;&#039;family&#039;&#039;&#039; specifies whether the set is for IPv4 or IPv6&lt;br /&gt;
addresses, and the possible values are &#039;&#039;&#039;inet&#039;&#039;&#039; and &#039;&#039;&#039;inet6&#039;&#039;&#039;,&lt;br /&gt;
correspondingly.&lt;br /&gt;
&lt;br /&gt;
== Command Line Syntax ==&lt;br /&gt;
&lt;br /&gt;
=== Translating Policy Files to Firewall Configuration Files ===&lt;br /&gt;
&lt;br /&gt;
 &#039;&#039;&#039;awall translate&#039;&#039;&#039; [&#039;&#039;&#039;-o&#039;&#039;&#039;|&#039;&#039;&#039;--output&#039;&#039;&#039; DIRECTORY] [&#039;&#039;&#039;-V&#039;&#039;&#039;|&#039;&#039;&#039;--verify&#039;&#039;&#039;]&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;tt&amp;gt;--verify&amp;lt;/tt&amp;gt; option makes awall verify the configuration&lt;br /&gt;
using the test mode of iptables-restore before overwriting the old&lt;br /&gt;
files.&lt;br /&gt;
&lt;br /&gt;
Specifying the output directory allows testing awall policies without&lt;br /&gt;
overwriting the current iptables and ipset configuration files. By&lt;br /&gt;
default, awall generates the configuration to &amp;lt;tt&amp;gt;/etc/iptables&amp;lt;/tt&amp;gt; &lt;br /&gt;
and &amp;lt;tt&amp;gt;/etc/ipset.d&amp;lt;/tt&amp;gt;, which are read by the init scripts.&lt;br /&gt;
&lt;br /&gt;
=== Run-Time Configuration of Firewall ===&lt;br /&gt;
&lt;br /&gt;
 &#039;&#039;&#039;awall activate&#039;&#039;&#039; [&#039;&#039;&#039;-f&#039;&#039;&#039;|&#039;&#039;&#039;--force&#039;&#039;&#039;]&lt;br /&gt;
&lt;br /&gt;
This command genereates firewall configuration from the policy files&lt;br /&gt;
and enables it. If the user confirms the new configuration by hitting&lt;br /&gt;
the Return key within 10 seconds or the &amp;lt;tt&amp;gt;--force&amp;lt;/tt&amp;gt; option is&lt;br /&gt;
used, the configuration is saved to the files. Otherwise, the old&lt;br /&gt;
configuration is restored.&lt;br /&gt;
&lt;br /&gt;
There is also a command for deleting all firewall rules:&lt;br /&gt;
&lt;br /&gt;
 &#039;&#039;&#039;awall flush&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
This command configures the firewall to drop all packets.&lt;br /&gt;
&lt;br /&gt;
=== Optional Policies ===&lt;br /&gt;
&lt;br /&gt;
Optional policies can be enabled or disabled using this command:&lt;br /&gt;
&lt;br /&gt;
 &#039;&#039;&#039;awall&#039;&#039;&#039; {&#039;&#039;&#039;enable&#039;&#039;&#039;|&#039;&#039;&#039;disable&#039;&#039;&#039;} POLICY...&lt;br /&gt;
&lt;br /&gt;
Optional policies can be listed using this command:&lt;br /&gt;
&lt;br /&gt;
 &#039;&#039;&#039;awall list&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;&#039;enabled&#039;&#039;&#039; status means that the policy has been enabled by the&lt;br /&gt;
user. The &#039;&#039;&#039;disabled&#039;&#039;&#039; status means that the policy is not in&lt;br /&gt;
use. The &#039;&#039;&#039;required&#039;&#039;&#039; status means that the policy has not been&lt;br /&gt;
enabled by the user but is in use because it is required by another&lt;br /&gt;
policy which is in use.&lt;br /&gt;
&lt;br /&gt;
=== Debugging Policies ===&lt;br /&gt;
&lt;br /&gt;
This command can be used to dump variable, zone, and other definitions&lt;br /&gt;
as well as their source policies:&lt;br /&gt;
&lt;br /&gt;
 &#039;&#039;&#039;awall dump&#039;&#039;&#039; [LEVEL]&lt;br /&gt;
&lt;br /&gt;
The level is an integer in range 0&amp;amp;ndash;5 and defaults to 0. More&lt;br /&gt;
information is displayed on higher levels.&lt;br /&gt;
&lt;br /&gt;
[[Category:Networking]]&lt;br /&gt;
[[Category:Security]]&lt;/div&gt;</summary>
		<author><name>Kunkku</name></author>
	</entry>
	<entry>
		<id>https://wiki.alpinelinux.org/w/index.php?title=Alpine_Wall_User%27s_Guide&amp;diff=8484</id>
		<title>Alpine Wall User&#039;s Guide</title>
		<link rel="alternate" type="text/html" href="https://wiki.alpinelinux.org/w/index.php?title=Alpine_Wall_User%27s_Guide&amp;diff=8484"/>
		<updated>2012-10-17T13:04:07Z</updated>

		<summary type="html">&lt;p&gt;Kunkku: /* Filters Rules */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Configuration File Processing ==&lt;br /&gt;
&lt;br /&gt;
[[Alpine Wall]] (awall) reads its configuration from multiple&lt;br /&gt;
JSON-formatted files, called &#039;&#039;policy files&#039;&#039;. The processing starts&lt;br /&gt;
from directory &amp;lt;tt&amp;gt;/usr/share/awall/mandatory&amp;lt;/tt&amp;gt;, which contains&lt;br /&gt;
mandatory policy files shipped with APK packages. After that,&lt;br /&gt;
installation-specific policy files in &amp;lt;tt&amp;gt;/etc/awall&amp;lt;/tt&amp;gt; are&lt;br /&gt;
processed.&lt;br /&gt;
&lt;br /&gt;
The latter directory may also contain symbolic links to policy files&lt;br /&gt;
located in &amp;lt;tt&amp;gt;/usr/share/awall/optional&amp;lt;/tt&amp;gt;. These are optional&lt;br /&gt;
policies, which can be enabled on need basis. Such symbolic links are&lt;br /&gt;
easily created and destroyed using the &amp;lt;tt&amp;gt;awall enable&amp;lt;/tt&amp;gt; and &lt;br /&gt;
&amp;lt;tt&amp;gt;awall disable&amp;lt;/tt&amp;gt; commands. &amp;lt;tt&amp;gt;awall list&amp;lt;/tt&amp;gt; shows which&lt;br /&gt;
optional policies are enabled and disabled. The command also prints&lt;br /&gt;
the description of the optional policy if defined in the file using&lt;br /&gt;
a top-level attribute named &#039;&#039;&#039;description&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Sometimes a policy file depends on other policy files. In this case,&lt;br /&gt;
the policy file must have a top-level attribute &#039;&#039;&#039;import&#039;&#039;&#039;, the&lt;br /&gt;
value of which is a list of policy names, which correspond to the file&lt;br /&gt;
names without the &amp;lt;tt&amp;gt;.json&amp;lt;/tt&amp;gt; suffix. By default, the policies&lt;br /&gt;
listed there are processed before the importing policy.&lt;br /&gt;
&lt;br /&gt;
The order of the generated iptables rules generally reflects the&lt;br /&gt;
processing order of their corresponding awall policies. The processing&lt;br /&gt;
order of policies can be adjusted by defining top-level attributes&lt;br /&gt;
&#039;&#039;&#039;after&#039;&#039;&#039; and &#039;&#039;&#039;before&#039;&#039;&#039; in policy files. These attributes are&lt;br /&gt;
lists of policies, after or before which the declaring policy shall be&lt;br /&gt;
processed. Putting a policy name to either of these lists does not by&lt;br /&gt;
itself import the policy. The ordering directives are ignored with&lt;br /&gt;
respect to those policies that are not enabled by the user or imported&lt;br /&gt;
by other policies. If not defined, &#039;&#039;&#039;after&#039;&#039;&#039; is assumed to be equal&lt;br /&gt;
to the &#039;&#039;&#039;import&#039;&#039;&#039; definition of the policy.&lt;br /&gt;
&lt;br /&gt;
As the import directive does not require the path name to be&lt;br /&gt;
specified, awall expects policies to have unique names, even if&lt;br /&gt;
located in different directories. It is allowed to import optional&lt;br /&gt;
policies that are not explicitly enabled by the user. Such policies&lt;br /&gt;
show up with the &amp;lt;tt&amp;gt;required&amp;lt;/tt&amp;gt; status in the output of &amp;lt;tt&amp;gt;awall&lt;br /&gt;
list&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
== List Parameters ==&lt;br /&gt;
&lt;br /&gt;
Several awall parameters are defined as lists of values. In order to&lt;br /&gt;
facilitate manual editing of policy files, awall also accepts single&lt;br /&gt;
values in place of lists. Such values are semantically equivalent to&lt;br /&gt;
lists containing one element.&lt;br /&gt;
&lt;br /&gt;
== Variable Expansion ==&lt;br /&gt;
&lt;br /&gt;
Awall allows variable definitions in policy files. The top-level&lt;br /&gt;
attribute &#039;&#039;&#039;variable&#039;&#039;&#039; is a dictionary containing the&lt;br /&gt;
definitions. The value of a variable can be of any type (string,&lt;br /&gt;
integer, list, or dictionary).&lt;br /&gt;
&lt;br /&gt;
A variable is referenced in policy files by a string which equals the&lt;br /&gt;
variable name prepended with the &#039;&#039;&#039;$&#039;&#039;&#039; character. If the value of&lt;br /&gt;
the variable is a string, the reference can be embedded into a longer&lt;br /&gt;
string in order to substitute some part of that string (in shell&lt;br /&gt;
style). Variable references can be used when defining other variables,&lt;br /&gt;
as long as the definitions are not circular.&lt;br /&gt;
&lt;br /&gt;
Policy files can reference variables defined in other policy&lt;br /&gt;
files. Policy files can also override variables defined elsewhere by&lt;br /&gt;
redefining them. In this case, the new definition affects all policy&lt;br /&gt;
files, also those processed before the overriding policy. Awall&lt;br /&gt;
variables are in fact simple macros, since each variable remains&lt;br /&gt;
constant thoughout a single processing round. If multiple files define&lt;br /&gt;
the same variable, the definition in the file processed last takes&lt;br /&gt;
effect.&lt;br /&gt;
&lt;br /&gt;
If defined as an empty string, all non-embedded references to a&lt;br /&gt;
variable evaluate as if the attribute in question was not present in&lt;br /&gt;
the configuration. This is also the case when a string containing&lt;br /&gt;
embedded variable references finally evaluates to an empty string.&lt;br /&gt;
&lt;br /&gt;
== Configuration Objects ==&lt;br /&gt;
&lt;br /&gt;
Configuration objects can be divided into two main types.&lt;br /&gt;
&#039;&#039;Auxiliary objects&#039;&#039; model high-level concepts such as services and&lt;br /&gt;
zones. &#039;&#039;Rule objects&#039;&#039; translate into one or more iptables rules, and&lt;br /&gt;
are often defined with the help of some auxiliary objects.&lt;br /&gt;
&lt;br /&gt;
=== Services ===&lt;br /&gt;
&lt;br /&gt;
A &#039;&#039;service&#039;&#039; represents a set of network protocols. A top-level&lt;br /&gt;
attribute &#039;&#039;&#039;service&#039;&#039;&#039; is a dictionary that maps service names to&lt;br /&gt;
service definition objects, or lists thereof in more complex cases.&lt;br /&gt;
&lt;br /&gt;
A service definition object contains an attribute named &#039;&#039;&#039;proto&#039;&#039;&#039;,&lt;br /&gt;
which corresponds to the &amp;lt;tt&amp;gt;--protocol&amp;lt;/tt&amp;gt; option of iptables. The&lt;br /&gt;
protocol can be defined as a numerical value or string as defined in&lt;br /&gt;
&amp;lt;tt&amp;gt;/etc/protocols&amp;lt;/tt&amp;gt;. If the protocol is &#039;&#039;&#039;tcp&#039;&#039;&#039; or &#039;&#039;&#039;udp&#039;&#039;&#039;,&lt;br /&gt;
the scope of the service definition may be constrained by defining an&lt;br /&gt;
attribute named &#039;&#039;&#039;port&#039;&#039;&#039;, which is a list of TCP or UDP port numbers&lt;br /&gt;
or ranges thereof, separated by the &#039;&#039;&#039;-&#039;&#039;&#039; character. If the protocol&lt;br /&gt;
is &#039;&#039;&#039;icmp&#039;&#039;&#039; or &#039;&#039;&#039;icmpv6&#039;&#039;&#039;, an analogous &#039;&#039;&#039;icmp-type&#039;&#039;&#039; attribute&lt;br /&gt;
may be used. In addition, the scope of the rule is also automatically&lt;br /&gt;
limited to IPv4 or IPv6, respectively.&lt;br /&gt;
&lt;br /&gt;
=== Zones ===&lt;br /&gt;
&lt;br /&gt;
A &#039;&#039;zone&#039;&#039; represents a set of network hosts. A top-level attribute &lt;br /&gt;
&#039;&#039;&#039;zone&#039;&#039;&#039; is a dictionary that maps zone names to zone objects. A&lt;br /&gt;
zone object has an attribute named &#039;&#039;&#039;iface&#039;&#039;&#039;, &#039;&#039;&#039;addr&#039;&#039;&#039;, or&lt;br /&gt;
both. &#039;&#039;&#039;iface&#039;&#039;&#039; is a list of network interfaces and &#039;&#039;&#039;addr&#039;&#039;&#039; is a&lt;br /&gt;
list of IPv4/IPv6 host and network addresses (CIDR&lt;br /&gt;
notation). &#039;&#039;&#039;addr&#039;&#039;&#039; may also contain domain names, which are&lt;br /&gt;
expanded to IP addresses using DNS resolution. If not defined,&lt;br /&gt;
&#039;&#039;&#039;addr&#039;&#039;&#039; defaults to the entire address space and &#039;&#039;&#039;iface&#039;&#039;&#039; to all&lt;br /&gt;
interfaces. An empty zone can be defined by setting either &#039;&#039;&#039;addr&#039;&#039;&#039;&lt;br /&gt;
or &#039;&#039;&#039;iface&#039;&#039;&#039; to an empty list.&lt;br /&gt;
&lt;br /&gt;
Rule objects contain two attributes, &#039;&#039;&#039;in&#039;&#039;&#039; and &#039;&#039;&#039;out&#039;&#039;&#039;, which are&lt;br /&gt;
lists of zone names. These attributes control whether a packet matches&lt;br /&gt;
the rule or not. If a particular zone is referenced by the &#039;&#039;&#039;in&#039;&#039;&#039; &lt;br /&gt;
attribute, the rule applies to packets whose ingress interface and&lt;br /&gt;
source address are covered by the zone definition. Correspondingly, if&lt;br /&gt;
a zone is referenced by the &#039;&#039;&#039;out&#039;&#039;&#039; attribute, the rule applies to&lt;br /&gt;
packets whose egress interface and destination address are included in&lt;br /&gt;
the zone. If both &#039;&#039;&#039;in&#039;&#039;&#039; and &#039;&#039;&#039;out&#039;&#039;&#039; are defined, the packet must&lt;br /&gt;
fulfill both criteria in order to match the rule.&lt;br /&gt;
&lt;br /&gt;
The firewall host itself can be referred to using the special value&lt;br /&gt;
&#039;&#039;&#039;_fw&#039;&#039;&#039; as the zone name.&lt;br /&gt;
&lt;br /&gt;
By default, awall does not generate iptables rules with identical&lt;br /&gt;
ingress and egress interfaces. This behavior can be changed per zone&lt;br /&gt;
by setting the optional &#039;&#039;&#039;route-back&#039;&#039;&#039; attribute of the zone to&lt;br /&gt;
&#039;&#039;&#039;true&#039;&#039;&#039;. Note that this attribute can have an effect also in the&lt;br /&gt;
case where &#039;&#039;&#039;in&#039;&#039;&#039; and &#039;&#039;&#039;out&#039;&#039;&#039; attributes of a rule are not equal&lt;br /&gt;
but their definitions overlap. In this case, the &#039;&#039;&#039;route-back&#039;&#039;&#039;&lt;br /&gt;
attribute of the &#039;&#039;&#039;out&#039;&#039;&#039; zone determines the behavior.&lt;br /&gt;
&lt;br /&gt;
=== Logging Classes ===&lt;br /&gt;
&lt;br /&gt;
A &#039;&#039;logging class&#039;&#039; specifies how packets matching certain rules are&lt;br /&gt;
logged. A top-level attribute &#039;&#039;&#039;log&#039;&#039;&#039; is a dictionary that maps&lt;br /&gt;
logging class names to setting objects.&lt;br /&gt;
&lt;br /&gt;
A setting object may have an attribute named &#039;&#039;&#039;mode&#039;&#039;&#039;, which&lt;br /&gt;
specifies which logging facility to use. Allowed values are &#039;&#039;&#039;log&#039;&#039;&#039;,&lt;br /&gt;
&#039;&#039;&#039;nflog&#039;&#039;&#039;, and &#039;&#039;&#039;ulog&#039;&#039;&#039;. The default is &#039;&#039;&#039;log&#039;&#039;&#039;, i.e. in-kernel&lt;br /&gt;
logging. The object may also have a &#039;&#039;&#039;limit&#039;&#039;&#039; attribute, which is an&lt;br /&gt;
integer specifying the maximum number of matching packets to be logged&lt;br /&gt;
per second per rule. Optionally, the log entries are prefixed with a&lt;br /&gt;
string configured using the &#039;&#039;&#039;prefix&#039;&#039;&#039; attribute.&lt;br /&gt;
&lt;br /&gt;
Filter and policy rules can have an attribute named &#039;&#039;&#039;log&#039;&#039;&#039;. If it&lt;br /&gt;
is a string, it is interpreted as a reference to a logging class, and&lt;br /&gt;
logging is performed according to the definitions. If the value of the&lt;br /&gt;
&#039;&#039;&#039;log&#039;&#039;&#039; attribute is &#039;&#039;&#039;true&#039;&#039;&#039; (boolean), logging is done using&lt;br /&gt;
default settings. If the value is &#039;&#039;&#039;false&#039;&#039;&#039; (boolean), logging is&lt;br /&gt;
disabled for the rule. If &#039;&#039;&#039;log&#039;&#039;&#039; is not defined, logging is done&lt;br /&gt;
using the default settings except for accept rules, for which logging&lt;br /&gt;
is omitted.&lt;br /&gt;
&lt;br /&gt;
Default logging settings can be set by defining a logging class named&lt;br /&gt;
&#039;&#039;&#039;_default&#039;&#039;&#039;. Normally, default logging uses the &#039;&#039;&#039;log&#039;&#039;&#039; mode with&lt;br /&gt;
packets limited to one per second.&lt;br /&gt;
&lt;br /&gt;
=== Rules ===&lt;br /&gt;
&lt;br /&gt;
There are six types of rule objects:&lt;br /&gt;
* Filters rules&lt;br /&gt;
* Policies rules&lt;br /&gt;
* NAT rules&lt;br /&gt;
* Packet Marking rules&lt;br /&gt;
* MSS Clamping rules&lt;br /&gt;
* Connection Tracking Bypass rules&lt;br /&gt;
&lt;br /&gt;
All rule objects can have the &#039;&#039;&#039;in&#039;&#039;&#039; and &#039;&#039;&#039;out&#039;&#039;&#039; attributes&lt;br /&gt;
referring to zones as described in the previous section. In addition,&lt;br /&gt;
the scope of the rule can be further constrained with the following&lt;br /&gt;
attributes:&lt;br /&gt;
&lt;br /&gt;
{|&lt;br /&gt;
!Attribute!!Value format!!Effect&lt;br /&gt;
|-&lt;br /&gt;
|&#039;&#039;&#039;src&#039;&#039;&#039;&lt;br /&gt;
|Similar to &#039;&#039;&#039;addr&#039;&#039;&#039; attribute of zone objects&lt;br /&gt;
|Packet&#039;s source address matches the value&lt;br /&gt;
|-&lt;br /&gt;
|&#039;&#039;&#039;dest&#039;&#039;&#039;&lt;br /&gt;
|Similar to &#039;&#039;&#039;addr&#039;&#039;&#039; attribute of zone objects&lt;br /&gt;
|Packet&#039;s destination address matches the value&lt;br /&gt;
|-&lt;br /&gt;
|&#039;&#039;&#039;ipset&#039;&#039;&#039;&lt;br /&gt;
|Object containing two attributes: &#039;&#039;&#039;name&#039;&#039;&#039; referring to an IP set and &#039;&#039;&#039;args&#039;&#039;&#039;, which is a list of strings &#039;&#039;&#039;in&#039;&#039;&#039; and &#039;&#039;&#039;out&#039;&#039;&#039;&lt;br /&gt;
|Packet matches the IP set referred here when the match arguments are taken from the source (&#039;&#039;&#039;in&#039;&#039;&#039;) and destination (&#039;&#039;&#039;out&#039;&#039;&#039;) address or port in the order specified by &#039;&#039;&#039;args&#039;&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
|&#039;&#039;&#039;ipsec&#039;&#039;&#039;&lt;br /&gt;
|&#039;&#039;&#039;in&#039;&#039;&#039; or &#039;&#039;&#039;out&#039;&#039;&#039;&lt;br /&gt;
|IPsec decapsulation perfomed on ingress (&#039;&#039;&#039;in&#039;&#039;&#039;) or encapsulation performed on egress (&#039;&#039;&#039;out&#039;&#039;&#039;)&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Rule objects are declared in type-specific top-level dictionaries in&lt;br /&gt;
awall policy files. If a packet matches multiple rules, the one&lt;br /&gt;
appearing earlier in the list takes precedence. If the matching rules&lt;br /&gt;
are defined in different policy files, the one that was processed&lt;br /&gt;
earlier takes precedence in the current implementation, but this may&lt;br /&gt;
change in future versions.&lt;br /&gt;
&lt;br /&gt;
==== Filters Rules ====&lt;br /&gt;
&lt;br /&gt;
Filter objects specify an action for packets fulfilling certain&lt;br /&gt;
criteria. The top-level attribute &#039;&#039;&#039;filter&#039;&#039;&#039; is a list of filter&lt;br /&gt;
objects. The precedence rules are similar to those of policy objects.&lt;br /&gt;
&lt;br /&gt;
In addition to the common rule attributes, filter objects can have a &lt;br /&gt;
&#039;&#039;&#039;service&#039;&#039;&#039; attribute constraining the scope to specific services&lt;br /&gt;
only. This attribute is a list of service names, referring to the&lt;br /&gt;
keys of the top-level &#039;&#039;&#039;service&#039;&#039;&#039; dictionary.&lt;br /&gt;
&lt;br /&gt;
Filter objects must have an attribute named &#039;&#039;&#039;action&#039;&#039;&#039;, the value of&lt;br /&gt;
which can be one of the following:&lt;br /&gt;
&lt;br /&gt;
{|&lt;br /&gt;
!Value!!Action&lt;br /&gt;
|-&lt;br /&gt;
|&#039;&#039;&#039;accept&#039;&#039;&#039;&lt;br /&gt;
|Accept the packet&lt;br /&gt;
|-&lt;br /&gt;
|&#039;&#039;&#039;reject&#039;&#039;&#039;&lt;br /&gt;
|Reject the packet with an ICMP error message&lt;br /&gt;
|-&lt;br /&gt;
|&#039;&#039;&#039;drop&#039;&#039;&#039;&lt;br /&gt;
|Silently drop the packet&lt;br /&gt;
|-&lt;br /&gt;
|&#039;&#039;&#039;tarpit&#039;&#039;&#039;&lt;br /&gt;
|Put incoming TCP connections into persist state and ignore attempts to close them. Silently drop non-TCP packets. (Connection tracking bypass is automatically enabled for the matching packets.)&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Filter objects, the action of which is &#039;&#039;&#039;accept&#039;&#039;&#039;, may also contain&lt;br /&gt;
limits for packet flow or new connections. These are specified with&lt;br /&gt;
the &#039;&#039;&#039;flow-limit&#039;&#039;&#039; and &#039;&#039;&#039;conn-limit&#039;&#039;&#039; attributes,&lt;br /&gt;
respectively. The values of these attributes are limit objects that&lt;br /&gt;
have two attributes: &#039;&#039;&#039;count&#039;&#039;&#039; and &#039;&#039;&#039;interval&#039;&#039;&#039;. &#039;&#039;&#039;count&#039;&#039;&#039;&lt;br /&gt;
specifies how many new connections or packets are allowed within the&lt;br /&gt;
time frame specified by &#039;&#039;&#039;interval&#039;&#039;&#039; (in seconds). The &#039;&#039;&#039;drop&#039;&#039;&#039;&lt;br /&gt;
action is applied to the packets exceeding the limit.&lt;br /&gt;
&lt;br /&gt;
Filter objects may have an attribute named &#039;&#039;&#039;dnat&#039;&#039;&#039;, the value of&lt;br /&gt;
which is an IPv4 address. If defined, this enables destination NAT for&lt;br /&gt;
all IPv4 packets matching the rule, such that the specified address&lt;br /&gt;
replaces the original destination address. This option has no effect&lt;br /&gt;
on IPv6 packets.&lt;br /&gt;
&lt;br /&gt;
Filter objects may have a boolean attribute named &#039;&#039;&#039;no-track&#039;&#039;&#039;. If&lt;br /&gt;
set to &#039;&#039;&#039;true&#039;&#039;&#039;, connection tracking is bypassed for the matching&lt;br /&gt;
packets. In addition, if &#039;&#039;&#039;action&#039;&#039;&#039; is set to &#039;&#039;&#039;accept&#039;&#039;&#039;, the&lt;br /&gt;
corresponding packets travelling to the reverse direction are also&lt;br /&gt;
allowed.&lt;br /&gt;
&lt;br /&gt;
==== Policies Rules ====&lt;br /&gt;
&lt;br /&gt;
Policy objects describe the default action for packets that did not&lt;br /&gt;
match any filter. The top-level attribute &#039;&#039;&#039;policy&#039;&#039;&#039; is a list of&lt;br /&gt;
policy objects.&lt;br /&gt;
&lt;br /&gt;
Policy objects must have the &#039;&#039;&#039;action&#039;&#039;&#039; attribute defined. The&lt;br /&gt;
possible values and their semantics are the same as in filter objects.&lt;br /&gt;
&lt;br /&gt;
==== NAT Rules ====&lt;br /&gt;
&lt;br /&gt;
NAT rules come in two flavors: &#039;&#039;source NAT rules&#039;&#039; and&lt;br /&gt;
&#039;&#039;destination NAT rules&#039;&#039;. These are contained in two top-level lists&lt;br /&gt;
named &#039;&#039;&#039;snat&#039;&#039;&#039; and &#039;&#039;&#039;dnat&#039;&#039;&#039;, respectively.&lt;br /&gt;
&lt;br /&gt;
Each NAT rule may have an attribute named &#039;&#039;&#039;to-addr&#039;&#039;&#039; that&lt;br /&gt;
specifies the IPv4 address range to which the original source or&lt;br /&gt;
destination address is mapped. The value can be a single IPv4 address&lt;br /&gt;
or a range specified by two addresses, separated with the &#039;&#039;&#039;-&#039;&#039;&#039;&lt;br /&gt;
character. If not defined, it defaults to the primary address of the&lt;br /&gt;
ingress interface in case of destination NAT, or that of the egress&lt;br /&gt;
interface in case of source NAT.&lt;br /&gt;
&lt;br /&gt;
Optionally, a NAT rule can specify the TCP and UDP port range to which&lt;br /&gt;
the original source or destination port is mapped. The attribute is&lt;br /&gt;
named &#039;&#039;&#039;to-port&#039;&#039;&#039;, and the value can be a single port number or a&lt;br /&gt;
range specified by two numbers, separated with the &#039;&#039;&#039;-&#039;&#039;&#039;&lt;br /&gt;
character. If &#039;&#039;&#039;to-port&#039;&#039;&#039; is not specified, the original port number&lt;br /&gt;
is kept intact.&lt;br /&gt;
&lt;br /&gt;
Like filters, NAT rules can have a &#039;&#039;&#039;service&#039;&#039;&#039; attribute&lt;br /&gt;
constraining their scope to specific services.&lt;br /&gt;
&lt;br /&gt;
NAT rules may have an &#039;&#039;&#039;action&#039;&#039;&#039; attribute set to value&lt;br /&gt;
&#039;&#039;&#039;accept&#039;&#039;&#039;. In this case, NAT is not performed on the packets&lt;br /&gt;
reaching and matching this rule.&lt;br /&gt;
&lt;br /&gt;
==== Packet Marking Rules ====&lt;br /&gt;
&lt;br /&gt;
Packet marking rules are used to mark incoming packets matching the&lt;br /&gt;
specified criteria. The mark can be used as a basis for the routing&lt;br /&gt;
decision. Each marking rule must specify the mark using the &#039;&#039;&#039;mark&#039;&#039;&#039;&lt;br /&gt;
attribute, which is a 32-bit integer.&lt;br /&gt;
&lt;br /&gt;
Normal marking rules are contained by the top-level list attribute&lt;br /&gt;
named &#039;&#039;&#039;mark&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
There is another top-level list attribute, named &#039;&#039;&#039;route-track&#039;&#039;&#039;,&lt;br /&gt;
which contains route tracking rules. These are special marking rules&lt;br /&gt;
which cause all the subsequent packets related to the same connection&lt;br /&gt;
to be marked according to the rule.&lt;br /&gt;
&lt;br /&gt;
==== MSS Clamping Rules ====&lt;br /&gt;
&lt;br /&gt;
MSS Clamping Rules are used to deal with ISPs that block ICMP&lt;br /&gt;
Fragmentation Needed or ICMPv6 Packet Too Big packets. An MSS clamping&lt;br /&gt;
rule overwrites the MSS option with a value specified with the&lt;br /&gt;
&#039;&#039;&#039;mss&#039;&#039;&#039; attribute for the matching TCP connections. If &#039;&#039;&#039;mss&#039;&#039;&#039; is&lt;br /&gt;
not specified, a suitable value is automatically determined from the&lt;br /&gt;
path MTU.&lt;br /&gt;
&lt;br /&gt;
==== Connection Tracking Bypass Rules ====&lt;br /&gt;
&lt;br /&gt;
Connection tracking bypass rules are used to disable connection&lt;br /&gt;
tracking for packets matching the specified criteria. The top-level&lt;br /&gt;
attribute &#039;&#039;&#039;no-track&#039;&#039;&#039; is a list of such rules.&lt;br /&gt;
&lt;br /&gt;
Connection tracking bypass rules may have an &#039;&#039;&#039;action&#039;&#039;&#039; attribute&lt;br /&gt;
set to value &#039;&#039;&#039;accept&#039;&#039;&#039;. The effect is similar to corresponding NAT&lt;br /&gt;
rules, i.e. connection tracking is not bypassed for the matching&lt;br /&gt;
packets.&lt;br /&gt;
&lt;br /&gt;
=== IP Sets ===&lt;br /&gt;
&lt;br /&gt;
Any IP set referenced by rule objects should be created by&lt;br /&gt;
awall. Auxiliary &#039;&#039;IP set&#039;&#039; objects are used to defined them in awall&lt;br /&gt;
policy files. The top-level attribute &#039;&#039;&#039;ipset&#039;&#039;&#039; is a dictionary, the&lt;br /&gt;
keys of which are IP set names. The values are IP set objects, which&lt;br /&gt;
have two mandatory attributes. The attribute named &#039;&#039;&#039;type&#039;&#039;&#039; &lt;br /&gt;
corresponds to the type argument of the &amp;lt;tt&amp;gt;ipset create&amp;lt;/tt&amp;gt; &lt;br /&gt;
command. &#039;&#039;&#039;family&#039;&#039;&#039; specifies whether the set is for IPv4 or IPv6&lt;br /&gt;
addresses, and the possible values are &#039;&#039;&#039;inet&#039;&#039;&#039; and &#039;&#039;&#039;inet6&#039;&#039;&#039;,&lt;br /&gt;
correspondingly.&lt;br /&gt;
&lt;br /&gt;
== Command Line Syntax ==&lt;br /&gt;
&lt;br /&gt;
=== Translating Policy Files to Firewall Configuration Files ===&lt;br /&gt;
&lt;br /&gt;
 &#039;&#039;&#039;awall translate&#039;&#039;&#039; [&#039;&#039;&#039;-o&#039;&#039;&#039;|&#039;&#039;&#039;--output&#039;&#039;&#039; DIRECTORY] [&#039;&#039;&#039;-V&#039;&#039;&#039;|&#039;&#039;&#039;--verify&#039;&#039;&#039;]&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;tt&amp;gt;--verify&amp;lt;/tt&amp;gt; option makes awall verify the configuration&lt;br /&gt;
using the test mode of iptables-restore before overwriting the old&lt;br /&gt;
files.&lt;br /&gt;
&lt;br /&gt;
Specifying the output directory allows testing awall policies without&lt;br /&gt;
overwriting the current iptables and ipset configuration files. By&lt;br /&gt;
default, awall generates the configuration to &amp;lt;tt&amp;gt;/etc/iptables&amp;lt;/tt&amp;gt; &lt;br /&gt;
and &amp;lt;tt&amp;gt;/etc/ipset.d&amp;lt;/tt&amp;gt;, which are read by the init scripts.&lt;br /&gt;
&lt;br /&gt;
=== Run-Time Configuration of Firewall ===&lt;br /&gt;
&lt;br /&gt;
 &#039;&#039;&#039;awall activate&#039;&#039;&#039; [&#039;&#039;&#039;-f&#039;&#039;&#039;|&#039;&#039;&#039;--force&#039;&#039;&#039;]&lt;br /&gt;
&lt;br /&gt;
This command genereates firewall configuration from the policy files&lt;br /&gt;
and enables it. If the user confirms the new configuration by hitting&lt;br /&gt;
the Return key within 10 seconds or the &amp;lt;tt&amp;gt;--force&amp;lt;/tt&amp;gt; option is&lt;br /&gt;
used, the configuration is saved to the files. Otherwise, the old&lt;br /&gt;
configuration is restored.&lt;br /&gt;
&lt;br /&gt;
There is also a command for deleting all firewall rules:&lt;br /&gt;
&lt;br /&gt;
 &#039;&#039;&#039;awall flush&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
This command configures the firewall to drop all packets.&lt;br /&gt;
&lt;br /&gt;
=== Optional Policies ===&lt;br /&gt;
&lt;br /&gt;
Optional policies can be enabled or disabled using this command:&lt;br /&gt;
&lt;br /&gt;
 &#039;&#039;&#039;awall&#039;&#039;&#039; {&#039;&#039;&#039;enable&#039;&#039;&#039;|&#039;&#039;&#039;disable&#039;&#039;&#039;} POLICY...&lt;br /&gt;
&lt;br /&gt;
Optional policies can be listed using this command:&lt;br /&gt;
&lt;br /&gt;
 &#039;&#039;&#039;awall list&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;&#039;enabled&#039;&#039;&#039; status means that the policy has been enabled by the&lt;br /&gt;
user. The &#039;&#039;&#039;disabled&#039;&#039;&#039; status means that the policy is not in&lt;br /&gt;
use. The &#039;&#039;&#039;required&#039;&#039;&#039; status means that the policy has not been&lt;br /&gt;
enabled by the user but is in use because it is required by another&lt;br /&gt;
policy which is in use.&lt;br /&gt;
&lt;br /&gt;
=== Debugging Policies ===&lt;br /&gt;
&lt;br /&gt;
This command can be used to dump variable, zone, and other definitions&lt;br /&gt;
as well as their source policies:&lt;br /&gt;
&lt;br /&gt;
 &#039;&#039;&#039;awall dump&#039;&#039;&#039; [LEVEL]&lt;br /&gt;
&lt;br /&gt;
The level is an integer in range 0&amp;amp;ndash;5 and defaults to 0. More&lt;br /&gt;
information is displayed on higher levels.&lt;br /&gt;
&lt;br /&gt;
[[Category:Networking]]&lt;br /&gt;
[[Category:Security]]&lt;/div&gt;</summary>
		<author><name>Kunkku</name></author>
	</entry>
	<entry>
		<id>https://wiki.alpinelinux.org/w/index.php?title=Alpine_Wall_User%27s_Guide&amp;diff=8438</id>
		<title>Alpine Wall User&#039;s Guide</title>
		<link rel="alternate" type="text/html" href="https://wiki.alpinelinux.org/w/index.php?title=Alpine_Wall_User%27s_Guide&amp;diff=8438"/>
		<updated>2012-10-03T07:31:00Z</updated>

		<summary type="html">&lt;p&gt;Kunkku: /* Zones */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Configuration File Processing ==&lt;br /&gt;
&lt;br /&gt;
[[Alpine Wall]] (awall) reads its configuration from multiple&lt;br /&gt;
JSON-formatted files, called &#039;&#039;policy files&#039;&#039;. The processing starts&lt;br /&gt;
from directory &amp;lt;tt&amp;gt;/usr/share/awall/mandatory&amp;lt;/tt&amp;gt;, which contains&lt;br /&gt;
mandatory policy files shipped with APK packages. After that,&lt;br /&gt;
installation-specific policy files in &amp;lt;tt&amp;gt;/etc/awall&amp;lt;/tt&amp;gt; are&lt;br /&gt;
processed.&lt;br /&gt;
&lt;br /&gt;
The latter directory may also contain symbolic links to policy files&lt;br /&gt;
located in &amp;lt;tt&amp;gt;/usr/share/awall/optional&amp;lt;/tt&amp;gt;. These are optional&lt;br /&gt;
policies, which can be enabled on need basis. Such symbolic links are&lt;br /&gt;
easily created and destroyed using the &amp;lt;tt&amp;gt;awall enable&amp;lt;/tt&amp;gt; and &lt;br /&gt;
&amp;lt;tt&amp;gt;awall disable&amp;lt;/tt&amp;gt; commands. &amp;lt;tt&amp;gt;awall list&amp;lt;/tt&amp;gt; shows which&lt;br /&gt;
optional policies are enabled and disabled. The command also prints&lt;br /&gt;
the description of the optional policy if defined in the file using&lt;br /&gt;
a top-level attribute named &#039;&#039;&#039;description&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Sometimes a policy file depends on other policy files. In this case,&lt;br /&gt;
the policy file must have a top-level attribute &#039;&#039;&#039;import&#039;&#039;&#039;, the&lt;br /&gt;
value of which is a list of policy names, which correspond to the file&lt;br /&gt;
names without the &amp;lt;tt&amp;gt;.json&amp;lt;/tt&amp;gt; suffix. By default, the policies&lt;br /&gt;
listed there are processed before the importing policy.&lt;br /&gt;
&lt;br /&gt;
The order of the generated iptables rules generally reflects the&lt;br /&gt;
processing order of their corresponding awall policies. The processing&lt;br /&gt;
order of policies can be adjusted by defining top-level attributes&lt;br /&gt;
&#039;&#039;&#039;after&#039;&#039;&#039; and &#039;&#039;&#039;before&#039;&#039;&#039; in policy files. These attributes are&lt;br /&gt;
lists of policies, after or before which the declaring policy shall be&lt;br /&gt;
processed. Putting a policy name to either of these lists does not by&lt;br /&gt;
itself import the policy. The ordering directives are ignored with&lt;br /&gt;
respect to those policies that are not enabled by the user or imported&lt;br /&gt;
by other policies. If not defined, &#039;&#039;&#039;after&#039;&#039;&#039; is assumed to be equal&lt;br /&gt;
to the &#039;&#039;&#039;import&#039;&#039;&#039; definition of the policy.&lt;br /&gt;
&lt;br /&gt;
As the import directive does not require the path name to be&lt;br /&gt;
specified, awall expects policies to have unique names, even if&lt;br /&gt;
located in different directories. It is allowed to import optional&lt;br /&gt;
policies that are not explicitly enabled by the user. Such policies&lt;br /&gt;
show up with the &amp;lt;tt&amp;gt;required&amp;lt;/tt&amp;gt; status in the output of &amp;lt;tt&amp;gt;awall&lt;br /&gt;
list&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
== List Parameters ==&lt;br /&gt;
&lt;br /&gt;
Several awall parameters are defined as lists of values. In order to&lt;br /&gt;
facilitate manual editing of policy files, awall also accepts single&lt;br /&gt;
values in place of lists. Such values are semantically equivalent to&lt;br /&gt;
lists containing one element.&lt;br /&gt;
&lt;br /&gt;
== Variable Expansion ==&lt;br /&gt;
&lt;br /&gt;
Awall allows variable definitions in policy files. The top-level&lt;br /&gt;
attribute &#039;&#039;&#039;variable&#039;&#039;&#039; is a dictionary containing the&lt;br /&gt;
definitions. The value of a variable can be of any type (string,&lt;br /&gt;
integer, list, or dictionary).&lt;br /&gt;
&lt;br /&gt;
A variable is referenced in policy files by a string which equals the&lt;br /&gt;
variable name prepended with the &#039;&#039;&#039;$&#039;&#039;&#039; character. If the value of&lt;br /&gt;
the variable is a string, the reference can be embedded into a longer&lt;br /&gt;
string in order to substitute some part of that string (in shell&lt;br /&gt;
style). Variable references can be used when defining other variables,&lt;br /&gt;
as long as the definitions are not circular.&lt;br /&gt;
&lt;br /&gt;
Policy files can reference variables defined in other policy&lt;br /&gt;
files. Policy files can also override variables defined elsewhere by&lt;br /&gt;
redefining them. In this case, the new definition affects all policy&lt;br /&gt;
files, also those processed before the overriding policy. Awall&lt;br /&gt;
variables are in fact simple macros, since each variable remains&lt;br /&gt;
constant thoughout a single processing round. If multiple files define&lt;br /&gt;
the same variable, the definition in the file processed last takes&lt;br /&gt;
effect.&lt;br /&gt;
&lt;br /&gt;
If defined as an empty string, all non-embedded references to a&lt;br /&gt;
variable evaluate as if the attribute in question was not present in&lt;br /&gt;
the configuration. This is also the case when a string containing&lt;br /&gt;
embedded variable references finally evaluates to an empty string.&lt;br /&gt;
&lt;br /&gt;
== Configuration Objects ==&lt;br /&gt;
&lt;br /&gt;
Configuration objects can be divided into two main types.&lt;br /&gt;
&#039;&#039;Auxiliary objects&#039;&#039; model high-level concepts such as services and&lt;br /&gt;
zones. &#039;&#039;Rule objects&#039;&#039; translate into one or more iptables rules, and&lt;br /&gt;
are often defined with the help of some auxiliary objects.&lt;br /&gt;
&lt;br /&gt;
=== Services ===&lt;br /&gt;
&lt;br /&gt;
A &#039;&#039;service&#039;&#039; represents a set of network protocols. A top-level&lt;br /&gt;
attribute &#039;&#039;&#039;service&#039;&#039;&#039; is a dictionary that maps service names to&lt;br /&gt;
service definition objects, or lists thereof in more complex cases.&lt;br /&gt;
&lt;br /&gt;
A service definition object contains an attribute named &#039;&#039;&#039;proto&#039;&#039;&#039;,&lt;br /&gt;
which corresponds to the &amp;lt;tt&amp;gt;--protocol&amp;lt;/tt&amp;gt; option of iptables. The&lt;br /&gt;
protocol can be defined as a numerical value or string as defined in&lt;br /&gt;
&amp;lt;tt&amp;gt;/etc/protocols&amp;lt;/tt&amp;gt;. If the protocol is &#039;&#039;&#039;tcp&#039;&#039;&#039; or &#039;&#039;&#039;udp&#039;&#039;&#039;,&lt;br /&gt;
the scope of the service definition may be constrained by defining an&lt;br /&gt;
attribute named &#039;&#039;&#039;port&#039;&#039;&#039;, which is a list of TCP or UDP port numbers&lt;br /&gt;
or ranges thereof, separated by the &#039;&#039;&#039;-&#039;&#039;&#039; character. If the protocol&lt;br /&gt;
is &#039;&#039;&#039;icmp&#039;&#039;&#039; or &#039;&#039;&#039;icmpv6&#039;&#039;&#039;, an analogous &#039;&#039;&#039;icmp-type&#039;&#039;&#039; attribute&lt;br /&gt;
may be used. In addition, the scope of the rule is also automatically&lt;br /&gt;
limited to IPv4 or IPv6, respectively.&lt;br /&gt;
&lt;br /&gt;
=== Zones ===&lt;br /&gt;
&lt;br /&gt;
A &#039;&#039;zone&#039;&#039; represents a set of network hosts. A top-level attribute &lt;br /&gt;
&#039;&#039;&#039;zone&#039;&#039;&#039; is a dictionary that maps zone names to zone objects. A&lt;br /&gt;
zone object has an attribute named &#039;&#039;&#039;iface&#039;&#039;&#039;, &#039;&#039;&#039;addr&#039;&#039;&#039;, or&lt;br /&gt;
both. &#039;&#039;&#039;iface&#039;&#039;&#039; is a list of network interfaces and &#039;&#039;&#039;addr&#039;&#039;&#039; is a&lt;br /&gt;
list of IPv4/IPv6 host and network addresses (CIDR&lt;br /&gt;
notation). &#039;&#039;&#039;addr&#039;&#039;&#039; may also contain domain names, which are&lt;br /&gt;
expanded to IP addresses using DNS resolution. If not defined,&lt;br /&gt;
&#039;&#039;&#039;addr&#039;&#039;&#039; defaults to the entire address space and &#039;&#039;&#039;iface&#039;&#039;&#039; to all&lt;br /&gt;
interfaces. An empty zone can be defined by setting either &#039;&#039;&#039;addr&#039;&#039;&#039;&lt;br /&gt;
or &#039;&#039;&#039;iface&#039;&#039;&#039; to an empty list.&lt;br /&gt;
&lt;br /&gt;
Rule objects contain two attributes, &#039;&#039;&#039;in&#039;&#039;&#039; and &#039;&#039;&#039;out&#039;&#039;&#039;, which are&lt;br /&gt;
lists of zone names. These attributes control whether a packet matches&lt;br /&gt;
the rule or not. If a particular zone is referenced by the &#039;&#039;&#039;in&#039;&#039;&#039; &lt;br /&gt;
attribute, the rule applies to packets whose ingress interface and&lt;br /&gt;
source address are covered by the zone definition. Correspondingly, if&lt;br /&gt;
a zone is referenced by the &#039;&#039;&#039;out&#039;&#039;&#039; attribute, the rule applies to&lt;br /&gt;
packets whose egress interface and destination address are included in&lt;br /&gt;
the zone. If both &#039;&#039;&#039;in&#039;&#039;&#039; and &#039;&#039;&#039;out&#039;&#039;&#039; are defined, the packet must&lt;br /&gt;
fulfill both criteria in order to match the rule.&lt;br /&gt;
&lt;br /&gt;
The firewall host itself can be referred to using the special value&lt;br /&gt;
&#039;&#039;&#039;_fw&#039;&#039;&#039; as the zone name.&lt;br /&gt;
&lt;br /&gt;
By default, awall does not generate iptables rules with identical&lt;br /&gt;
ingress and egress interfaces. This behavior can be changed per zone&lt;br /&gt;
by setting the optional &#039;&#039;&#039;route-back&#039;&#039;&#039; attribute of the zone to&lt;br /&gt;
&#039;&#039;&#039;true&#039;&#039;&#039;. Note that this attribute can have an effect also in the&lt;br /&gt;
case where &#039;&#039;&#039;in&#039;&#039;&#039; and &#039;&#039;&#039;out&#039;&#039;&#039; attributes of a rule are not equal&lt;br /&gt;
but their definitions overlap. In this case, the &#039;&#039;&#039;route-back&#039;&#039;&#039;&lt;br /&gt;
attribute of the &#039;&#039;&#039;out&#039;&#039;&#039; zone determines the behavior.&lt;br /&gt;
&lt;br /&gt;
=== Logging Classes ===&lt;br /&gt;
&lt;br /&gt;
A &#039;&#039;logging class&#039;&#039; specifies how packets matching certain rules are&lt;br /&gt;
logged. A top-level attribute &#039;&#039;&#039;log&#039;&#039;&#039; is a dictionary that maps&lt;br /&gt;
logging class names to setting objects.&lt;br /&gt;
&lt;br /&gt;
A setting object may have an attribute named &#039;&#039;&#039;mode&#039;&#039;&#039;, which&lt;br /&gt;
specifies which logging facility to use. Allowed values are &#039;&#039;&#039;log&#039;&#039;&#039;,&lt;br /&gt;
&#039;&#039;&#039;nflog&#039;&#039;&#039;, and &#039;&#039;&#039;ulog&#039;&#039;&#039;. The default is &#039;&#039;&#039;log&#039;&#039;&#039;, i.e. in-kernel&lt;br /&gt;
logging. The object may also have a &#039;&#039;&#039;limit&#039;&#039;&#039; attribute, which is an&lt;br /&gt;
integer specifying the maximum number of matching packets to be logged&lt;br /&gt;
per second per rule. Optionally, the log entries are prefixed with a&lt;br /&gt;
string configured using the &#039;&#039;&#039;prefix&#039;&#039;&#039; attribute.&lt;br /&gt;
&lt;br /&gt;
Filter and policy rules can have an attribute named &#039;&#039;&#039;log&#039;&#039;&#039;. If it&lt;br /&gt;
is a string, it is interpreted as a reference to a logging class, and&lt;br /&gt;
logging is performed according to the definitions. If the value of the&lt;br /&gt;
&#039;&#039;&#039;log&#039;&#039;&#039; attribute is &#039;&#039;&#039;true&#039;&#039;&#039; (boolean), logging is done using&lt;br /&gt;
default settings. If the value is &#039;&#039;&#039;false&#039;&#039;&#039; (boolean), logging is&lt;br /&gt;
disabled for the rule. If &#039;&#039;&#039;log&#039;&#039;&#039; is not defined, logging is done&lt;br /&gt;
using the default settings except for accept rules, for which logging&lt;br /&gt;
is omitted.&lt;br /&gt;
&lt;br /&gt;
Default logging settings can be set by defining a logging class named&lt;br /&gt;
&#039;&#039;&#039;_default&#039;&#039;&#039;. Normally, default logging uses the &#039;&#039;&#039;log&#039;&#039;&#039; mode with&lt;br /&gt;
packets limited to one per second.&lt;br /&gt;
&lt;br /&gt;
=== Rules ===&lt;br /&gt;
&lt;br /&gt;
There are six types of rule objects:&lt;br /&gt;
* Filters rules&lt;br /&gt;
* Policies rules&lt;br /&gt;
* NAT rules&lt;br /&gt;
* Packet Marking rules&lt;br /&gt;
* MSS Clamping rules&lt;br /&gt;
* Connection Tracking Bypass rules&lt;br /&gt;
&lt;br /&gt;
All rule objects can have the &#039;&#039;&#039;in&#039;&#039;&#039; and &#039;&#039;&#039;out&#039;&#039;&#039; attributes&lt;br /&gt;
referring to zones as described in the previous section. In addition,&lt;br /&gt;
the scope of the rule can be further constrained with the following&lt;br /&gt;
attributes:&lt;br /&gt;
&lt;br /&gt;
{|&lt;br /&gt;
!Attribute!!Value format!!Effect&lt;br /&gt;
|-&lt;br /&gt;
|&#039;&#039;&#039;src&#039;&#039;&#039;&lt;br /&gt;
|Similar to &#039;&#039;&#039;addr&#039;&#039;&#039; attribute of zone objects&lt;br /&gt;
|Packet&#039;s source address matches the value&lt;br /&gt;
|-&lt;br /&gt;
|&#039;&#039;&#039;dest&#039;&#039;&#039;&lt;br /&gt;
|Similar to &#039;&#039;&#039;addr&#039;&#039;&#039; attribute of zone objects&lt;br /&gt;
|Packet&#039;s destination address matches the value&lt;br /&gt;
|-&lt;br /&gt;
|&#039;&#039;&#039;ipset&#039;&#039;&#039;&lt;br /&gt;
|Object containing two attributes: &#039;&#039;&#039;name&#039;&#039;&#039; referring to an IP set and &#039;&#039;&#039;args&#039;&#039;&#039;, which is a list of strings &#039;&#039;&#039;in&#039;&#039;&#039; and &#039;&#039;&#039;out&#039;&#039;&#039;&lt;br /&gt;
|Packet matches the IP set referred here when the match arguments are taken from the source (&#039;&#039;&#039;in&#039;&#039;&#039;) and destination (&#039;&#039;&#039;out&#039;&#039;&#039;) address or port in the order specified by &#039;&#039;&#039;args&#039;&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
|&#039;&#039;&#039;ipsec&#039;&#039;&#039;&lt;br /&gt;
|&#039;&#039;&#039;in&#039;&#039;&#039; or &#039;&#039;&#039;out&#039;&#039;&#039;&lt;br /&gt;
|IPsec decapsulation perfomed on ingress (&#039;&#039;&#039;in&#039;&#039;&#039;) or encapsulation performed on egress (&#039;&#039;&#039;out&#039;&#039;&#039;)&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Rule objects are declared in type-specific top-level dictionaries in&lt;br /&gt;
awall policy files. If a packet matches multiple rules, the one&lt;br /&gt;
appearing earlier in the list takes precedence. If the matching rules&lt;br /&gt;
are defined in different policy files, the one that was processed&lt;br /&gt;
earlier takes precedence in the current implementation, but this may&lt;br /&gt;
change in future versions.&lt;br /&gt;
&lt;br /&gt;
==== Filters Rules ====&lt;br /&gt;
&lt;br /&gt;
Filter objects specify an action for packets fulfilling certain&lt;br /&gt;
criteria. The top-level attribute &#039;&#039;&#039;filter&#039;&#039;&#039; is a list of filter&lt;br /&gt;
objects. The precedence rules are similar to those of policy objects.&lt;br /&gt;
&lt;br /&gt;
In addition to the common rule attributes, filter objects can have a &lt;br /&gt;
&#039;&#039;&#039;service&#039;&#039;&#039; attribute constraining the scope to specific services&lt;br /&gt;
only. This attribute is a list of service names, referring to the&lt;br /&gt;
keys of the top-level &#039;&#039;&#039;service&#039;&#039;&#039; dictionary.&lt;br /&gt;
&lt;br /&gt;
Filter objects must have an attribute named &#039;&#039;&#039;action&#039;&#039;&#039;, the value of&lt;br /&gt;
which can be one of the following:&lt;br /&gt;
&lt;br /&gt;
{|&lt;br /&gt;
!Value!!Action&lt;br /&gt;
|-&lt;br /&gt;
|&#039;&#039;&#039;accept&#039;&#039;&#039;&lt;br /&gt;
|Accept the packet&lt;br /&gt;
|-&lt;br /&gt;
|&#039;&#039;&#039;reject&#039;&#039;&#039;&lt;br /&gt;
|Reject the packet with an ICMP error message&lt;br /&gt;
|-&lt;br /&gt;
|&#039;&#039;&#039;drop&#039;&#039;&#039;&lt;br /&gt;
|Silently drop the packet&lt;br /&gt;
|-&lt;br /&gt;
|&#039;&#039;&#039;tarpit&#039;&#039;&#039;&lt;br /&gt;
|Put incoming TCP connections into persist state and ignore attempts to close them. Silently drop non-TCP packets. (Connection tracking bypass is automatically enabled for the matching packets.)&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Filter objects, the action of which is &#039;&#039;&#039;accept&#039;&#039;&#039;, may also contain&lt;br /&gt;
limits for packet flow or new connections. These are specified with&lt;br /&gt;
the &#039;&#039;&#039;flow-limit&#039;&#039;&#039; and &#039;&#039;&#039;conn-limit&#039;&#039;&#039; attributes,&lt;br /&gt;
respectively. The values of these attributes are limit objects that&lt;br /&gt;
have two attributes: &#039;&#039;&#039;count&#039;&#039;&#039; and &#039;&#039;&#039;interval&#039;&#039;&#039;. &#039;&#039;&#039;count&#039;&#039;&#039;&lt;br /&gt;
specifies how many new connections or packets are allowed within the&lt;br /&gt;
time frame specified by &#039;&#039;&#039;interval&#039;&#039;&#039; (in seconds). The &#039;&#039;&#039;logdrop&#039;&#039;&#039;&lt;br /&gt;
action is applied to the packets exceeding the limit.&lt;br /&gt;
&lt;br /&gt;
Filter objects may have an attribute named &#039;&#039;&#039;dnat&#039;&#039;&#039;, the value of&lt;br /&gt;
which is an IPv4 address. If defined, this enables destination NAT for&lt;br /&gt;
all IPv4 packets matching the rule, such that the specified address&lt;br /&gt;
replaces the original destination address. This option has no effect&lt;br /&gt;
on IPv6 packets.&lt;br /&gt;
&lt;br /&gt;
Filter objects may have a boolean attribute named &#039;&#039;&#039;no-track&#039;&#039;&#039;. If&lt;br /&gt;
set to &#039;&#039;&#039;true&#039;&#039;&#039;, connection tracking is bypassed for the matching&lt;br /&gt;
packets. In addition, if &#039;&#039;&#039;action&#039;&#039;&#039; is set to &#039;&#039;&#039;accept&#039;&#039;&#039;, the&lt;br /&gt;
corresponding packets travelling to the reverse direction are also&lt;br /&gt;
allowed.&lt;br /&gt;
&lt;br /&gt;
==== Policies Rules ====&lt;br /&gt;
&lt;br /&gt;
Policy objects describe the default action for packets that did not&lt;br /&gt;
match any filter. The top-level attribute &#039;&#039;&#039;policy&#039;&#039;&#039; is a list of&lt;br /&gt;
policy objects.&lt;br /&gt;
&lt;br /&gt;
Policy objects must have the &#039;&#039;&#039;action&#039;&#039;&#039; attribute defined. The&lt;br /&gt;
possible values and their semantics are the same as in filter objects.&lt;br /&gt;
&lt;br /&gt;
==== NAT Rules ====&lt;br /&gt;
&lt;br /&gt;
NAT rules come in two flavors: &#039;&#039;source NAT rules&#039;&#039; and&lt;br /&gt;
&#039;&#039;destination NAT rules&#039;&#039;. These are contained in two top-level lists&lt;br /&gt;
named &#039;&#039;&#039;snat&#039;&#039;&#039; and &#039;&#039;&#039;dnat&#039;&#039;&#039;, respectively.&lt;br /&gt;
&lt;br /&gt;
Each NAT rule may have an attribute named &#039;&#039;&#039;to-addr&#039;&#039;&#039; that&lt;br /&gt;
specifies the IPv4 address range to which the original source or&lt;br /&gt;
destination address is mapped. The value can be a single IPv4 address&lt;br /&gt;
or a range specified by two addresses, separated with the &#039;&#039;&#039;-&#039;&#039;&#039;&lt;br /&gt;
character. If not defined, it defaults to the primary address of the&lt;br /&gt;
ingress interface in case of destination NAT, or that of the egress&lt;br /&gt;
interface in case of source NAT.&lt;br /&gt;
&lt;br /&gt;
Optionally, a NAT rule can specify the TCP and UDP port range to which&lt;br /&gt;
the original source or destination port is mapped. The attribute is&lt;br /&gt;
named &#039;&#039;&#039;to-port&#039;&#039;&#039;, and the value can be a single port number or a&lt;br /&gt;
range specified by two numbers, separated with the &#039;&#039;&#039;-&#039;&#039;&#039;&lt;br /&gt;
character. If &#039;&#039;&#039;to-port&#039;&#039;&#039; is not specified, the original port number&lt;br /&gt;
is kept intact.&lt;br /&gt;
&lt;br /&gt;
Like filters, NAT rules can have a &#039;&#039;&#039;service&#039;&#039;&#039; attribute&lt;br /&gt;
constraining their scope to specific services.&lt;br /&gt;
&lt;br /&gt;
NAT rules may have an &#039;&#039;&#039;action&#039;&#039;&#039; attribute set to value&lt;br /&gt;
&#039;&#039;&#039;accept&#039;&#039;&#039;. In this case, NAT is not performed on the packets&lt;br /&gt;
reaching and matching this rule.&lt;br /&gt;
&lt;br /&gt;
==== Packet Marking Rules ====&lt;br /&gt;
&lt;br /&gt;
Packet marking rules are used to mark incoming packets matching the&lt;br /&gt;
specified criteria. The mark can be used as a basis for the routing&lt;br /&gt;
decision. Each marking rule must specify the mark using the &#039;&#039;&#039;mark&#039;&#039;&#039;&lt;br /&gt;
attribute, which is a 32-bit integer.&lt;br /&gt;
&lt;br /&gt;
Normal marking rules are contained by the top-level list attribute&lt;br /&gt;
named &#039;&#039;&#039;mark&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
There is another top-level list attribute, named &#039;&#039;&#039;route-track&#039;&#039;&#039;,&lt;br /&gt;
which contains route tracking rules. These are special marking rules&lt;br /&gt;
which cause all the subsequent packets related to the same connection&lt;br /&gt;
to be marked according to the rule.&lt;br /&gt;
&lt;br /&gt;
==== MSS Clamping Rules ====&lt;br /&gt;
&lt;br /&gt;
MSS Clamping Rules are used to deal with ISPs that block ICMP&lt;br /&gt;
Fragmentation Needed or ICMPv6 Packet Too Big packets. An MSS clamping&lt;br /&gt;
rule overwrites the MSS option with a value specified with the&lt;br /&gt;
&#039;&#039;&#039;mss&#039;&#039;&#039; attribute for the matching TCP connections. If &#039;&#039;&#039;mss&#039;&#039;&#039; is&lt;br /&gt;
not specified, a suitable value is automatically determined from the&lt;br /&gt;
path MTU.&lt;br /&gt;
&lt;br /&gt;
==== Connection Tracking Bypass Rules ====&lt;br /&gt;
&lt;br /&gt;
Connection tracking bypass rules are used to disable connection&lt;br /&gt;
tracking for packets matching the specified criteria. The top-level&lt;br /&gt;
attribute &#039;&#039;&#039;no-track&#039;&#039;&#039; is a list of such rules.&lt;br /&gt;
&lt;br /&gt;
Connection tracking bypass rules may have an &#039;&#039;&#039;action&#039;&#039;&#039; attribute&lt;br /&gt;
set to value &#039;&#039;&#039;accept&#039;&#039;&#039;. The effect is similar to corresponding NAT&lt;br /&gt;
rules, i.e. connection tracking is not bypassed for the matching&lt;br /&gt;
packets.&lt;br /&gt;
&lt;br /&gt;
=== IP Sets ===&lt;br /&gt;
&lt;br /&gt;
Any IP set referenced by rule objects should be created by&lt;br /&gt;
awall. Auxiliary &#039;&#039;IP set&#039;&#039; objects are used to defined them in awall&lt;br /&gt;
policy files. The top-level attribute &#039;&#039;&#039;ipset&#039;&#039;&#039; is a dictionary, the&lt;br /&gt;
keys of which are IP set names. The values are IP set objects, which&lt;br /&gt;
have two mandatory attributes. The attribute named &#039;&#039;&#039;type&#039;&#039;&#039; &lt;br /&gt;
corresponds to the type argument of the &amp;lt;tt&amp;gt;ipset create&amp;lt;/tt&amp;gt; &lt;br /&gt;
command. &#039;&#039;&#039;family&#039;&#039;&#039; specifies whether the set is for IPv4 or IPv6&lt;br /&gt;
addresses, and the possible values are &#039;&#039;&#039;inet&#039;&#039;&#039; and &#039;&#039;&#039;inet6&#039;&#039;&#039;,&lt;br /&gt;
correspondingly.&lt;br /&gt;
&lt;br /&gt;
== Command Line Syntax ==&lt;br /&gt;
&lt;br /&gt;
=== Translating Policy Files to Firewall Configuration Files ===&lt;br /&gt;
&lt;br /&gt;
 &#039;&#039;&#039;awall translate&#039;&#039;&#039; [&#039;&#039;&#039;-o&#039;&#039;&#039;|&#039;&#039;&#039;--output&#039;&#039;&#039; DIRECTORY] [&#039;&#039;&#039;-V&#039;&#039;&#039;|&#039;&#039;&#039;--verify&#039;&#039;&#039;]&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;tt&amp;gt;--verify&amp;lt;/tt&amp;gt; option makes awall verify the configuration&lt;br /&gt;
using the test mode of iptables-restore before overwriting the old&lt;br /&gt;
files.&lt;br /&gt;
&lt;br /&gt;
Specifying the output directory allows testing awall policies without&lt;br /&gt;
overwriting the current iptables and ipset configuration files. By&lt;br /&gt;
default, awall generates the configuration to &amp;lt;tt&amp;gt;/etc/iptables&amp;lt;/tt&amp;gt; &lt;br /&gt;
and &amp;lt;tt&amp;gt;/etc/ipset.d&amp;lt;/tt&amp;gt;, which are read by the init scripts.&lt;br /&gt;
&lt;br /&gt;
=== Run-Time Configuration of Firewall ===&lt;br /&gt;
&lt;br /&gt;
 &#039;&#039;&#039;awall activate&#039;&#039;&#039; [&#039;&#039;&#039;-f&#039;&#039;&#039;|&#039;&#039;&#039;--force&#039;&#039;&#039;]&lt;br /&gt;
&lt;br /&gt;
This command genereates firewall configuration from the policy files&lt;br /&gt;
and enables it. If the user confirms the new configuration by hitting&lt;br /&gt;
the Return key within 10 seconds or the &amp;lt;tt&amp;gt;--force&amp;lt;/tt&amp;gt; option is&lt;br /&gt;
used, the configuration is saved to the files. Otherwise, the old&lt;br /&gt;
configuration is restored.&lt;br /&gt;
&lt;br /&gt;
There is also a command for deleting all firewall rules:&lt;br /&gt;
&lt;br /&gt;
 &#039;&#039;&#039;awall flush&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
This command configures the firewall to drop all packets.&lt;br /&gt;
&lt;br /&gt;
=== Optional Policies ===&lt;br /&gt;
&lt;br /&gt;
Optional policies can be enabled or disabled using this command:&lt;br /&gt;
&lt;br /&gt;
 &#039;&#039;&#039;awall&#039;&#039;&#039; {&#039;&#039;&#039;enable&#039;&#039;&#039;|&#039;&#039;&#039;disable&#039;&#039;&#039;} POLICY...&lt;br /&gt;
&lt;br /&gt;
Optional policies can be listed using this command:&lt;br /&gt;
&lt;br /&gt;
 &#039;&#039;&#039;awall list&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;&#039;enabled&#039;&#039;&#039; status means that the policy has been enabled by the&lt;br /&gt;
user. The &#039;&#039;&#039;disabled&#039;&#039;&#039; status means that the policy is not in&lt;br /&gt;
use. The &#039;&#039;&#039;required&#039;&#039;&#039; status means that the policy has not been&lt;br /&gt;
enabled by the user but is in use because it is required by another&lt;br /&gt;
policy which is in use.&lt;br /&gt;
&lt;br /&gt;
=== Debugging Policies ===&lt;br /&gt;
&lt;br /&gt;
This command can be used to dump variable, zone, and other definitions&lt;br /&gt;
as well as their source policies:&lt;br /&gt;
&lt;br /&gt;
 &#039;&#039;&#039;awall dump&#039;&#039;&#039; [LEVEL]&lt;br /&gt;
&lt;br /&gt;
The level is an integer in range 0&amp;amp;ndash;5 and defaults to 0. More&lt;br /&gt;
information is displayed on higher levels.&lt;br /&gt;
&lt;br /&gt;
[[Category:Networking]]&lt;br /&gt;
[[Category:Security]]&lt;/div&gt;</summary>
		<author><name>Kunkku</name></author>
	</entry>
	<entry>
		<id>https://wiki.alpinelinux.org/w/index.php?title=Alpine_Wall_User%27s_Guide&amp;diff=8437</id>
		<title>Alpine Wall User&#039;s Guide</title>
		<link rel="alternate" type="text/html" href="https://wiki.alpinelinux.org/w/index.php?title=Alpine_Wall_User%27s_Guide&amp;diff=8437"/>
		<updated>2012-10-03T07:24:30Z</updated>

		<summary type="html">&lt;p&gt;Kunkku: /* Zones */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Configuration File Processing ==&lt;br /&gt;
&lt;br /&gt;
[[Alpine Wall]] (awall) reads its configuration from multiple&lt;br /&gt;
JSON-formatted files, called &#039;&#039;policy files&#039;&#039;. The processing starts&lt;br /&gt;
from directory &amp;lt;tt&amp;gt;/usr/share/awall/mandatory&amp;lt;/tt&amp;gt;, which contains&lt;br /&gt;
mandatory policy files shipped with APK packages. After that,&lt;br /&gt;
installation-specific policy files in &amp;lt;tt&amp;gt;/etc/awall&amp;lt;/tt&amp;gt; are&lt;br /&gt;
processed.&lt;br /&gt;
&lt;br /&gt;
The latter directory may also contain symbolic links to policy files&lt;br /&gt;
located in &amp;lt;tt&amp;gt;/usr/share/awall/optional&amp;lt;/tt&amp;gt;. These are optional&lt;br /&gt;
policies, which can be enabled on need basis. Such symbolic links are&lt;br /&gt;
easily created and destroyed using the &amp;lt;tt&amp;gt;awall enable&amp;lt;/tt&amp;gt; and &lt;br /&gt;
&amp;lt;tt&amp;gt;awall disable&amp;lt;/tt&amp;gt; commands. &amp;lt;tt&amp;gt;awall list&amp;lt;/tt&amp;gt; shows which&lt;br /&gt;
optional policies are enabled and disabled. The command also prints&lt;br /&gt;
the description of the optional policy if defined in the file using&lt;br /&gt;
a top-level attribute named &#039;&#039;&#039;description&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Sometimes a policy file depends on other policy files. In this case,&lt;br /&gt;
the policy file must have a top-level attribute &#039;&#039;&#039;import&#039;&#039;&#039;, the&lt;br /&gt;
value of which is a list of policy names, which correspond to the file&lt;br /&gt;
names without the &amp;lt;tt&amp;gt;.json&amp;lt;/tt&amp;gt; suffix. By default, the policies&lt;br /&gt;
listed there are processed before the importing policy.&lt;br /&gt;
&lt;br /&gt;
The order of the generated iptables rules generally reflects the&lt;br /&gt;
processing order of their corresponding awall policies. The processing&lt;br /&gt;
order of policies can be adjusted by defining top-level attributes&lt;br /&gt;
&#039;&#039;&#039;after&#039;&#039;&#039; and &#039;&#039;&#039;before&#039;&#039;&#039; in policy files. These attributes are&lt;br /&gt;
lists of policies, after or before which the declaring policy shall be&lt;br /&gt;
processed. Putting a policy name to either of these lists does not by&lt;br /&gt;
itself import the policy. The ordering directives are ignored with&lt;br /&gt;
respect to those policies that are not enabled by the user or imported&lt;br /&gt;
by other policies. If not defined, &#039;&#039;&#039;after&#039;&#039;&#039; is assumed to be equal&lt;br /&gt;
to the &#039;&#039;&#039;import&#039;&#039;&#039; definition of the policy.&lt;br /&gt;
&lt;br /&gt;
As the import directive does not require the path name to be&lt;br /&gt;
specified, awall expects policies to have unique names, even if&lt;br /&gt;
located in different directories. It is allowed to import optional&lt;br /&gt;
policies that are not explicitly enabled by the user. Such policies&lt;br /&gt;
show up with the &amp;lt;tt&amp;gt;required&amp;lt;/tt&amp;gt; status in the output of &amp;lt;tt&amp;gt;awall&lt;br /&gt;
list&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
== List Parameters ==&lt;br /&gt;
&lt;br /&gt;
Several awall parameters are defined as lists of values. In order to&lt;br /&gt;
facilitate manual editing of policy files, awall also accepts single&lt;br /&gt;
values in place of lists. Such values are semantically equivalent to&lt;br /&gt;
lists containing one element.&lt;br /&gt;
&lt;br /&gt;
== Variable Expansion ==&lt;br /&gt;
&lt;br /&gt;
Awall allows variable definitions in policy files. The top-level&lt;br /&gt;
attribute &#039;&#039;&#039;variable&#039;&#039;&#039; is a dictionary containing the&lt;br /&gt;
definitions. The value of a variable can be of any type (string,&lt;br /&gt;
integer, list, or dictionary).&lt;br /&gt;
&lt;br /&gt;
A variable is referenced in policy files by a string which equals the&lt;br /&gt;
variable name prepended with the &#039;&#039;&#039;$&#039;&#039;&#039; character. If the value of&lt;br /&gt;
the variable is a string, the reference can be embedded into a longer&lt;br /&gt;
string in order to substitute some part of that string (in shell&lt;br /&gt;
style). Variable references can be used when defining other variables,&lt;br /&gt;
as long as the definitions are not circular.&lt;br /&gt;
&lt;br /&gt;
Policy files can reference variables defined in other policy&lt;br /&gt;
files. Policy files can also override variables defined elsewhere by&lt;br /&gt;
redefining them. In this case, the new definition affects all policy&lt;br /&gt;
files, also those processed before the overriding policy. Awall&lt;br /&gt;
variables are in fact simple macros, since each variable remains&lt;br /&gt;
constant thoughout a single processing round. If multiple files define&lt;br /&gt;
the same variable, the definition in the file processed last takes&lt;br /&gt;
effect.&lt;br /&gt;
&lt;br /&gt;
If defined as an empty string, all non-embedded references to a&lt;br /&gt;
variable evaluate as if the attribute in question was not present in&lt;br /&gt;
the configuration. This is also the case when a string containing&lt;br /&gt;
embedded variable references finally evaluates to an empty string.&lt;br /&gt;
&lt;br /&gt;
== Configuration Objects ==&lt;br /&gt;
&lt;br /&gt;
Configuration objects can be divided into two main types.&lt;br /&gt;
&#039;&#039;Auxiliary objects&#039;&#039; model high-level concepts such as services and&lt;br /&gt;
zones. &#039;&#039;Rule objects&#039;&#039; translate into one or more iptables rules, and&lt;br /&gt;
are often defined with the help of some auxiliary objects.&lt;br /&gt;
&lt;br /&gt;
=== Services ===&lt;br /&gt;
&lt;br /&gt;
A &#039;&#039;service&#039;&#039; represents a set of network protocols. A top-level&lt;br /&gt;
attribute &#039;&#039;&#039;service&#039;&#039;&#039; is a dictionary that maps service names to&lt;br /&gt;
service definition objects, or lists thereof in more complex cases.&lt;br /&gt;
&lt;br /&gt;
A service definition object contains an attribute named &#039;&#039;&#039;proto&#039;&#039;&#039;,&lt;br /&gt;
which corresponds to the &amp;lt;tt&amp;gt;--protocol&amp;lt;/tt&amp;gt; option of iptables. The&lt;br /&gt;
protocol can be defined as a numerical value or string as defined in&lt;br /&gt;
&amp;lt;tt&amp;gt;/etc/protocols&amp;lt;/tt&amp;gt;. If the protocol is &#039;&#039;&#039;tcp&#039;&#039;&#039; or &#039;&#039;&#039;udp&#039;&#039;&#039;,&lt;br /&gt;
the scope of the service definition may be constrained by defining an&lt;br /&gt;
attribute named &#039;&#039;&#039;port&#039;&#039;&#039;, which is a list of TCP or UDP port numbers&lt;br /&gt;
or ranges thereof, separated by the &#039;&#039;&#039;-&#039;&#039;&#039; character. If the protocol&lt;br /&gt;
is &#039;&#039;&#039;icmp&#039;&#039;&#039; or &#039;&#039;&#039;icmpv6&#039;&#039;&#039;, an analogous &#039;&#039;&#039;icmp-type&#039;&#039;&#039; attribute&lt;br /&gt;
may be used. In addition, the scope of the rule is also automatically&lt;br /&gt;
limited to IPv4 or IPv6, respectively.&lt;br /&gt;
&lt;br /&gt;
=== Zones ===&lt;br /&gt;
&lt;br /&gt;
A &#039;&#039;zone&#039;&#039; represents a set of network hosts. A top-level attribute &lt;br /&gt;
&#039;&#039;&#039;zone&#039;&#039;&#039; is a dictionary that maps zone names to zone objects. A&lt;br /&gt;
zone object has an attribute named &#039;&#039;&#039;iface&#039;&#039;&#039;, &#039;&#039;&#039;addr&#039;&#039;&#039;, or&lt;br /&gt;
both. &#039;&#039;&#039;iface&#039;&#039;&#039; is a list of network interfaces and &#039;&#039;&#039;addr&#039;&#039;&#039; is a&lt;br /&gt;
list of IPv4/IPv6 host and network addresses (CIDR&lt;br /&gt;
notation). &#039;&#039;&#039;addr&#039;&#039;&#039; may also contain domain names, which are&lt;br /&gt;
expanded to IP addresses using DNS resolution. If not defined,&lt;br /&gt;
&#039;&#039;&#039;addr&#039;&#039;&#039; defaults to the entire address space and &#039;&#039;&#039;iface&#039;&#039;&#039; to all&lt;br /&gt;
interfaces. An empty zone can be defined by setting either &#039;&#039;&#039;addr&#039;&#039;&#039;&lt;br /&gt;
or &#039;&#039;&#039;iface&#039;&#039;&#039; to an empty list.&lt;br /&gt;
&lt;br /&gt;
Rule objects contain two attributes, &#039;&#039;&#039;in&#039;&#039;&#039; and &#039;&#039;&#039;out&#039;&#039;&#039;, which are&lt;br /&gt;
lists of zone names. These attributes control whether a packet matches&lt;br /&gt;
the rule or not. If a particular zone is referenced by the &#039;&#039;&#039;in&#039;&#039;&#039; &lt;br /&gt;
attribute, the rule applies to packets whose ingress interface and&lt;br /&gt;
source address are covered by the zone definition. Correspondingly, if&lt;br /&gt;
a zone is referenced by the &#039;&#039;&#039;out&#039;&#039;&#039; attribute, the rule applies to&lt;br /&gt;
packets whose egress interface and destination address are included in&lt;br /&gt;
the zone. If both &#039;&#039;&#039;in&#039;&#039;&#039; and &#039;&#039;&#039;out&#039;&#039;&#039; are defined, the packet must&lt;br /&gt;
fulfill both criteria in order to match the rule.&lt;br /&gt;
&lt;br /&gt;
The firewall host itself can be referred to using the special value&lt;br /&gt;
&#039;&#039;&#039;_fw&#039;&#039;&#039; as the zone name.&lt;br /&gt;
&lt;br /&gt;
=== Logging Classes ===&lt;br /&gt;
&lt;br /&gt;
A &#039;&#039;logging class&#039;&#039; specifies how packets matching certain rules are&lt;br /&gt;
logged. A top-level attribute &#039;&#039;&#039;log&#039;&#039;&#039; is a dictionary that maps&lt;br /&gt;
logging class names to setting objects.&lt;br /&gt;
&lt;br /&gt;
A setting object may have an attribute named &#039;&#039;&#039;mode&#039;&#039;&#039;, which&lt;br /&gt;
specifies which logging facility to use. Allowed values are &#039;&#039;&#039;log&#039;&#039;&#039;,&lt;br /&gt;
&#039;&#039;&#039;nflog&#039;&#039;&#039;, and &#039;&#039;&#039;ulog&#039;&#039;&#039;. The default is &#039;&#039;&#039;log&#039;&#039;&#039;, i.e. in-kernel&lt;br /&gt;
logging. The object may also have a &#039;&#039;&#039;limit&#039;&#039;&#039; attribute, which is an&lt;br /&gt;
integer specifying the maximum number of matching packets to be logged&lt;br /&gt;
per second per rule. Optionally, the log entries are prefixed with a&lt;br /&gt;
string configured using the &#039;&#039;&#039;prefix&#039;&#039;&#039; attribute.&lt;br /&gt;
&lt;br /&gt;
Filter and policy rules can have an attribute named &#039;&#039;&#039;log&#039;&#039;&#039;. If it&lt;br /&gt;
is a string, it is interpreted as a reference to a logging class, and&lt;br /&gt;
logging is performed according to the definitions. If the value of the&lt;br /&gt;
&#039;&#039;&#039;log&#039;&#039;&#039; attribute is &#039;&#039;&#039;true&#039;&#039;&#039; (boolean), logging is done using&lt;br /&gt;
default settings. If the value is &#039;&#039;&#039;false&#039;&#039;&#039; (boolean), logging is&lt;br /&gt;
disabled for the rule. If &#039;&#039;&#039;log&#039;&#039;&#039; is not defined, logging is done&lt;br /&gt;
using the default settings except for accept rules, for which logging&lt;br /&gt;
is omitted.&lt;br /&gt;
&lt;br /&gt;
Default logging settings can be set by defining a logging class named&lt;br /&gt;
&#039;&#039;&#039;_default&#039;&#039;&#039;. Normally, default logging uses the &#039;&#039;&#039;log&#039;&#039;&#039; mode with&lt;br /&gt;
packets limited to one per second.&lt;br /&gt;
&lt;br /&gt;
=== Rules ===&lt;br /&gt;
&lt;br /&gt;
There are six types of rule objects:&lt;br /&gt;
* Filters rules&lt;br /&gt;
* Policies rules&lt;br /&gt;
* NAT rules&lt;br /&gt;
* Packet Marking rules&lt;br /&gt;
* MSS Clamping rules&lt;br /&gt;
* Connection Tracking Bypass rules&lt;br /&gt;
&lt;br /&gt;
All rule objects can have the &#039;&#039;&#039;in&#039;&#039;&#039; and &#039;&#039;&#039;out&#039;&#039;&#039; attributes&lt;br /&gt;
referring to zones as described in the previous section. In addition,&lt;br /&gt;
the scope of the rule can be further constrained with the following&lt;br /&gt;
attributes:&lt;br /&gt;
&lt;br /&gt;
{|&lt;br /&gt;
!Attribute!!Value format!!Effect&lt;br /&gt;
|-&lt;br /&gt;
|&#039;&#039;&#039;src&#039;&#039;&#039;&lt;br /&gt;
|Similar to &#039;&#039;&#039;addr&#039;&#039;&#039; attribute of zone objects&lt;br /&gt;
|Packet&#039;s source address matches the value&lt;br /&gt;
|-&lt;br /&gt;
|&#039;&#039;&#039;dest&#039;&#039;&#039;&lt;br /&gt;
|Similar to &#039;&#039;&#039;addr&#039;&#039;&#039; attribute of zone objects&lt;br /&gt;
|Packet&#039;s destination address matches the value&lt;br /&gt;
|-&lt;br /&gt;
|&#039;&#039;&#039;ipset&#039;&#039;&#039;&lt;br /&gt;
|Object containing two attributes: &#039;&#039;&#039;name&#039;&#039;&#039; referring to an IP set and &#039;&#039;&#039;args&#039;&#039;&#039;, which is a list of strings &#039;&#039;&#039;in&#039;&#039;&#039; and &#039;&#039;&#039;out&#039;&#039;&#039;&lt;br /&gt;
|Packet matches the IP set referred here when the match arguments are taken from the source (&#039;&#039;&#039;in&#039;&#039;&#039;) and destination (&#039;&#039;&#039;out&#039;&#039;&#039;) address or port in the order specified by &#039;&#039;&#039;args&#039;&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
|&#039;&#039;&#039;ipsec&#039;&#039;&#039;&lt;br /&gt;
|&#039;&#039;&#039;in&#039;&#039;&#039; or &#039;&#039;&#039;out&#039;&#039;&#039;&lt;br /&gt;
|IPsec decapsulation perfomed on ingress (&#039;&#039;&#039;in&#039;&#039;&#039;) or encapsulation performed on egress (&#039;&#039;&#039;out&#039;&#039;&#039;)&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Rule objects are declared in type-specific top-level dictionaries in&lt;br /&gt;
awall policy files. If a packet matches multiple rules, the one&lt;br /&gt;
appearing earlier in the list takes precedence. If the matching rules&lt;br /&gt;
are defined in different policy files, the one that was processed&lt;br /&gt;
earlier takes precedence in the current implementation, but this may&lt;br /&gt;
change in future versions.&lt;br /&gt;
&lt;br /&gt;
==== Filters Rules ====&lt;br /&gt;
&lt;br /&gt;
Filter objects specify an action for packets fulfilling certain&lt;br /&gt;
criteria. The top-level attribute &#039;&#039;&#039;filter&#039;&#039;&#039; is a list of filter&lt;br /&gt;
objects. The precedence rules are similar to those of policy objects.&lt;br /&gt;
&lt;br /&gt;
In addition to the common rule attributes, filter objects can have a &lt;br /&gt;
&#039;&#039;&#039;service&#039;&#039;&#039; attribute constraining the scope to specific services&lt;br /&gt;
only. This attribute is a list of service names, referring to the&lt;br /&gt;
keys of the top-level &#039;&#039;&#039;service&#039;&#039;&#039; dictionary.&lt;br /&gt;
&lt;br /&gt;
Filter objects must have an attribute named &#039;&#039;&#039;action&#039;&#039;&#039;, the value of&lt;br /&gt;
which can be one of the following:&lt;br /&gt;
&lt;br /&gt;
{|&lt;br /&gt;
!Value!!Action&lt;br /&gt;
|-&lt;br /&gt;
|&#039;&#039;&#039;accept&#039;&#039;&#039;&lt;br /&gt;
|Accept the packet&lt;br /&gt;
|-&lt;br /&gt;
|&#039;&#039;&#039;reject&#039;&#039;&#039;&lt;br /&gt;
|Reject the packet with an ICMP error message&lt;br /&gt;
|-&lt;br /&gt;
|&#039;&#039;&#039;drop&#039;&#039;&#039;&lt;br /&gt;
|Silently drop the packet&lt;br /&gt;
|-&lt;br /&gt;
|&#039;&#039;&#039;tarpit&#039;&#039;&#039;&lt;br /&gt;
|Put incoming TCP connections into persist state and ignore attempts to close them. Silently drop non-TCP packets. (Connection tracking bypass is automatically enabled for the matching packets.)&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Filter objects, the action of which is &#039;&#039;&#039;accept&#039;&#039;&#039;, may also contain&lt;br /&gt;
limits for packet flow or new connections. These are specified with&lt;br /&gt;
the &#039;&#039;&#039;flow-limit&#039;&#039;&#039; and &#039;&#039;&#039;conn-limit&#039;&#039;&#039; attributes,&lt;br /&gt;
respectively. The values of these attributes are limit objects that&lt;br /&gt;
have two attributes: &#039;&#039;&#039;count&#039;&#039;&#039; and &#039;&#039;&#039;interval&#039;&#039;&#039;. &#039;&#039;&#039;count&#039;&#039;&#039;&lt;br /&gt;
specifies how many new connections or packets are allowed within the&lt;br /&gt;
time frame specified by &#039;&#039;&#039;interval&#039;&#039;&#039; (in seconds). The &#039;&#039;&#039;logdrop&#039;&#039;&#039;&lt;br /&gt;
action is applied to the packets exceeding the limit.&lt;br /&gt;
&lt;br /&gt;
Filter objects may have an attribute named &#039;&#039;&#039;dnat&#039;&#039;&#039;, the value of&lt;br /&gt;
which is an IPv4 address. If defined, this enables destination NAT for&lt;br /&gt;
all IPv4 packets matching the rule, such that the specified address&lt;br /&gt;
replaces the original destination address. This option has no effect&lt;br /&gt;
on IPv6 packets.&lt;br /&gt;
&lt;br /&gt;
Filter objects may have a boolean attribute named &#039;&#039;&#039;no-track&#039;&#039;&#039;. If&lt;br /&gt;
set to &#039;&#039;&#039;true&#039;&#039;&#039;, connection tracking is bypassed for the matching&lt;br /&gt;
packets. In addition, if &#039;&#039;&#039;action&#039;&#039;&#039; is set to &#039;&#039;&#039;accept&#039;&#039;&#039;, the&lt;br /&gt;
corresponding packets travelling to the reverse direction are also&lt;br /&gt;
allowed.&lt;br /&gt;
&lt;br /&gt;
==== Policies Rules ====&lt;br /&gt;
&lt;br /&gt;
Policy objects describe the default action for packets that did not&lt;br /&gt;
match any filter. The top-level attribute &#039;&#039;&#039;policy&#039;&#039;&#039; is a list of&lt;br /&gt;
policy objects.&lt;br /&gt;
&lt;br /&gt;
Policy objects must have the &#039;&#039;&#039;action&#039;&#039;&#039; attribute defined. The&lt;br /&gt;
possible values and their semantics are the same as in filter objects.&lt;br /&gt;
&lt;br /&gt;
==== NAT Rules ====&lt;br /&gt;
&lt;br /&gt;
NAT rules come in two flavors: &#039;&#039;source NAT rules&#039;&#039; and&lt;br /&gt;
&#039;&#039;destination NAT rules&#039;&#039;. These are contained in two top-level lists&lt;br /&gt;
named &#039;&#039;&#039;snat&#039;&#039;&#039; and &#039;&#039;&#039;dnat&#039;&#039;&#039;, respectively.&lt;br /&gt;
&lt;br /&gt;
Each NAT rule may have an attribute named &#039;&#039;&#039;to-addr&#039;&#039;&#039; that&lt;br /&gt;
specifies the IPv4 address range to which the original source or&lt;br /&gt;
destination address is mapped. The value can be a single IPv4 address&lt;br /&gt;
or a range specified by two addresses, separated with the &#039;&#039;&#039;-&#039;&#039;&#039;&lt;br /&gt;
character. If not defined, it defaults to the primary address of the&lt;br /&gt;
ingress interface in case of destination NAT, or that of the egress&lt;br /&gt;
interface in case of source NAT.&lt;br /&gt;
&lt;br /&gt;
Optionally, a NAT rule can specify the TCP and UDP port range to which&lt;br /&gt;
the original source or destination port is mapped. The attribute is&lt;br /&gt;
named &#039;&#039;&#039;to-port&#039;&#039;&#039;, and the value can be a single port number or a&lt;br /&gt;
range specified by two numbers, separated with the &#039;&#039;&#039;-&#039;&#039;&#039;&lt;br /&gt;
character. If &#039;&#039;&#039;to-port&#039;&#039;&#039; is not specified, the original port number&lt;br /&gt;
is kept intact.&lt;br /&gt;
&lt;br /&gt;
Like filters, NAT rules can have a &#039;&#039;&#039;service&#039;&#039;&#039; attribute&lt;br /&gt;
constraining their scope to specific services.&lt;br /&gt;
&lt;br /&gt;
NAT rules may have an &#039;&#039;&#039;action&#039;&#039;&#039; attribute set to value&lt;br /&gt;
&#039;&#039;&#039;accept&#039;&#039;&#039;. In this case, NAT is not performed on the packets&lt;br /&gt;
reaching and matching this rule.&lt;br /&gt;
&lt;br /&gt;
==== Packet Marking Rules ====&lt;br /&gt;
&lt;br /&gt;
Packet marking rules are used to mark incoming packets matching the&lt;br /&gt;
specified criteria. The mark can be used as a basis for the routing&lt;br /&gt;
decision. Each marking rule must specify the mark using the &#039;&#039;&#039;mark&#039;&#039;&#039;&lt;br /&gt;
attribute, which is a 32-bit integer.&lt;br /&gt;
&lt;br /&gt;
Normal marking rules are contained by the top-level list attribute&lt;br /&gt;
named &#039;&#039;&#039;mark&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
There is another top-level list attribute, named &#039;&#039;&#039;route-track&#039;&#039;&#039;,&lt;br /&gt;
which contains route tracking rules. These are special marking rules&lt;br /&gt;
which cause all the subsequent packets related to the same connection&lt;br /&gt;
to be marked according to the rule.&lt;br /&gt;
&lt;br /&gt;
==== MSS Clamping Rules ====&lt;br /&gt;
&lt;br /&gt;
MSS Clamping Rules are used to deal with ISPs that block ICMP&lt;br /&gt;
Fragmentation Needed or ICMPv6 Packet Too Big packets. An MSS clamping&lt;br /&gt;
rule overwrites the MSS option with a value specified with the&lt;br /&gt;
&#039;&#039;&#039;mss&#039;&#039;&#039; attribute for the matching TCP connections. If &#039;&#039;&#039;mss&#039;&#039;&#039; is&lt;br /&gt;
not specified, a suitable value is automatically determined from the&lt;br /&gt;
path MTU.&lt;br /&gt;
&lt;br /&gt;
==== Connection Tracking Bypass Rules ====&lt;br /&gt;
&lt;br /&gt;
Connection tracking bypass rules are used to disable connection&lt;br /&gt;
tracking for packets matching the specified criteria. The top-level&lt;br /&gt;
attribute &#039;&#039;&#039;no-track&#039;&#039;&#039; is a list of such rules.&lt;br /&gt;
&lt;br /&gt;
Connection tracking bypass rules may have an &#039;&#039;&#039;action&#039;&#039;&#039; attribute&lt;br /&gt;
set to value &#039;&#039;&#039;accept&#039;&#039;&#039;. The effect is similar to corresponding NAT&lt;br /&gt;
rules, i.e. connection tracking is not bypassed for the matching&lt;br /&gt;
packets.&lt;br /&gt;
&lt;br /&gt;
=== IP Sets ===&lt;br /&gt;
&lt;br /&gt;
Any IP set referenced by rule objects should be created by&lt;br /&gt;
awall. Auxiliary &#039;&#039;IP set&#039;&#039; objects are used to defined them in awall&lt;br /&gt;
policy files. The top-level attribute &#039;&#039;&#039;ipset&#039;&#039;&#039; is a dictionary, the&lt;br /&gt;
keys of which are IP set names. The values are IP set objects, which&lt;br /&gt;
have two mandatory attributes. The attribute named &#039;&#039;&#039;type&#039;&#039;&#039; &lt;br /&gt;
corresponds to the type argument of the &amp;lt;tt&amp;gt;ipset create&amp;lt;/tt&amp;gt; &lt;br /&gt;
command. &#039;&#039;&#039;family&#039;&#039;&#039; specifies whether the set is for IPv4 or IPv6&lt;br /&gt;
addresses, and the possible values are &#039;&#039;&#039;inet&#039;&#039;&#039; and &#039;&#039;&#039;inet6&#039;&#039;&#039;,&lt;br /&gt;
correspondingly.&lt;br /&gt;
&lt;br /&gt;
== Command Line Syntax ==&lt;br /&gt;
&lt;br /&gt;
=== Translating Policy Files to Firewall Configuration Files ===&lt;br /&gt;
&lt;br /&gt;
 &#039;&#039;&#039;awall translate&#039;&#039;&#039; [&#039;&#039;&#039;-o&#039;&#039;&#039;|&#039;&#039;&#039;--output&#039;&#039;&#039; DIRECTORY] [&#039;&#039;&#039;-V&#039;&#039;&#039;|&#039;&#039;&#039;--verify&#039;&#039;&#039;]&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;tt&amp;gt;--verify&amp;lt;/tt&amp;gt; option makes awall verify the configuration&lt;br /&gt;
using the test mode of iptables-restore before overwriting the old&lt;br /&gt;
files.&lt;br /&gt;
&lt;br /&gt;
Specifying the output directory allows testing awall policies without&lt;br /&gt;
overwriting the current iptables and ipset configuration files. By&lt;br /&gt;
default, awall generates the configuration to &amp;lt;tt&amp;gt;/etc/iptables&amp;lt;/tt&amp;gt; &lt;br /&gt;
and &amp;lt;tt&amp;gt;/etc/ipset.d&amp;lt;/tt&amp;gt;, which are read by the init scripts.&lt;br /&gt;
&lt;br /&gt;
=== Run-Time Configuration of Firewall ===&lt;br /&gt;
&lt;br /&gt;
 &#039;&#039;&#039;awall activate&#039;&#039;&#039; [&#039;&#039;&#039;-f&#039;&#039;&#039;|&#039;&#039;&#039;--force&#039;&#039;&#039;]&lt;br /&gt;
&lt;br /&gt;
This command genereates firewall configuration from the policy files&lt;br /&gt;
and enables it. If the user confirms the new configuration by hitting&lt;br /&gt;
the Return key within 10 seconds or the &amp;lt;tt&amp;gt;--force&amp;lt;/tt&amp;gt; option is&lt;br /&gt;
used, the configuration is saved to the files. Otherwise, the old&lt;br /&gt;
configuration is restored.&lt;br /&gt;
&lt;br /&gt;
There is also a command for deleting all firewall rules:&lt;br /&gt;
&lt;br /&gt;
 &#039;&#039;&#039;awall flush&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
This command configures the firewall to drop all packets.&lt;br /&gt;
&lt;br /&gt;
=== Optional Policies ===&lt;br /&gt;
&lt;br /&gt;
Optional policies can be enabled or disabled using this command:&lt;br /&gt;
&lt;br /&gt;
 &#039;&#039;&#039;awall&#039;&#039;&#039; {&#039;&#039;&#039;enable&#039;&#039;&#039;|&#039;&#039;&#039;disable&#039;&#039;&#039;} POLICY...&lt;br /&gt;
&lt;br /&gt;
Optional policies can be listed using this command:&lt;br /&gt;
&lt;br /&gt;
 &#039;&#039;&#039;awall list&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;&#039;enabled&#039;&#039;&#039; status means that the policy has been enabled by the&lt;br /&gt;
user. The &#039;&#039;&#039;disabled&#039;&#039;&#039; status means that the policy is not in&lt;br /&gt;
use. The &#039;&#039;&#039;required&#039;&#039;&#039; status means that the policy has not been&lt;br /&gt;
enabled by the user but is in use because it is required by another&lt;br /&gt;
policy which is in use.&lt;br /&gt;
&lt;br /&gt;
=== Debugging Policies ===&lt;br /&gt;
&lt;br /&gt;
This command can be used to dump variable, zone, and other definitions&lt;br /&gt;
as well as their source policies:&lt;br /&gt;
&lt;br /&gt;
 &#039;&#039;&#039;awall dump&#039;&#039;&#039; [LEVEL]&lt;br /&gt;
&lt;br /&gt;
The level is an integer in range 0&amp;amp;ndash;5 and defaults to 0. More&lt;br /&gt;
information is displayed on higher levels.&lt;br /&gt;
&lt;br /&gt;
[[Category:Networking]]&lt;br /&gt;
[[Category:Security]]&lt;/div&gt;</summary>
		<author><name>Kunkku</name></author>
	</entry>
	<entry>
		<id>https://wiki.alpinelinux.org/w/index.php?title=Alpine_Wall_User%27s_Guide&amp;diff=8395</id>
		<title>Alpine Wall User&#039;s Guide</title>
		<link rel="alternate" type="text/html" href="https://wiki.alpinelinux.org/w/index.php?title=Alpine_Wall_User%27s_Guide&amp;diff=8395"/>
		<updated>2012-09-13T10:12:24Z</updated>

		<summary type="html">&lt;p&gt;Kunkku: /* NAT Rules */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Configuration File Processing ==&lt;br /&gt;
&lt;br /&gt;
[[Alpine Wall]] (awall) reads its configuration from multiple&lt;br /&gt;
JSON-formatted files, called &#039;&#039;policy files&#039;&#039;. The processing starts&lt;br /&gt;
from directory &amp;lt;tt&amp;gt;/usr/share/awall/mandatory&amp;lt;/tt&amp;gt;, which contains&lt;br /&gt;
mandatory policy files shipped with APK packages. After that,&lt;br /&gt;
installation-specific policy files in &amp;lt;tt&amp;gt;/etc/awall&amp;lt;/tt&amp;gt; are&lt;br /&gt;
processed.&lt;br /&gt;
&lt;br /&gt;
The latter directory may also contain symbolic links to policy files&lt;br /&gt;
located in &amp;lt;tt&amp;gt;/usr/share/awall/optional&amp;lt;/tt&amp;gt;. These are optional&lt;br /&gt;
policies, which can be enabled on need basis. Such symbolic links are&lt;br /&gt;
easily created and destroyed using the &amp;lt;tt&amp;gt;awall enable&amp;lt;/tt&amp;gt; and &lt;br /&gt;
&amp;lt;tt&amp;gt;awall disable&amp;lt;/tt&amp;gt; commands. &amp;lt;tt&amp;gt;awall list&amp;lt;/tt&amp;gt; shows which&lt;br /&gt;
optional policies are enabled and disabled. The command also prints&lt;br /&gt;
the description of the optional policy if defined in the file using&lt;br /&gt;
a top-level attribute named &#039;&#039;&#039;description&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Sometimes a policy file depends on other policy files. In this case,&lt;br /&gt;
the policy file must have a top-level attribute &#039;&#039;&#039;import&#039;&#039;&#039;, the&lt;br /&gt;
value of which is a list of policy names, which correspond to the file&lt;br /&gt;
names without the &amp;lt;tt&amp;gt;.json&amp;lt;/tt&amp;gt; suffix. By default, the policies&lt;br /&gt;
listed there are processed before the importing policy.&lt;br /&gt;
&lt;br /&gt;
The order of the generated iptables rules generally reflects the&lt;br /&gt;
processing order of their corresponding awall policies. The processing&lt;br /&gt;
order of policies can be adjusted by defining top-level attributes&lt;br /&gt;
&#039;&#039;&#039;after&#039;&#039;&#039; and &#039;&#039;&#039;before&#039;&#039;&#039; in policy files. These attributes are&lt;br /&gt;
lists of policies, after or before which the declaring policy shall be&lt;br /&gt;
processed. Putting a policy name to either of these lists does not by&lt;br /&gt;
itself import the policy. The ordering directives are ignored with&lt;br /&gt;
respect to those policies that are not enabled by the user or imported&lt;br /&gt;
by other policies. If not defined, &#039;&#039;&#039;after&#039;&#039;&#039; is assumed to be equal&lt;br /&gt;
to the &#039;&#039;&#039;import&#039;&#039;&#039; definition of the policy.&lt;br /&gt;
&lt;br /&gt;
As the import directive does not require the path name to be&lt;br /&gt;
specified, awall expects policies to have unique names, even if&lt;br /&gt;
located in different directories. It is allowed to import optional&lt;br /&gt;
policies that are not explicitly enabled by the user. Such policies&lt;br /&gt;
show up with the &amp;lt;tt&amp;gt;required&amp;lt;/tt&amp;gt; status in the output of &amp;lt;tt&amp;gt;awall&lt;br /&gt;
list&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
== List Parameters ==&lt;br /&gt;
&lt;br /&gt;
Several awall parameters are defined as lists of values. In order to&lt;br /&gt;
facilitate manual editing of policy files, awall also accepts single&lt;br /&gt;
values in place of lists. Such values are semantically equivalent to&lt;br /&gt;
lists containing one element.&lt;br /&gt;
&lt;br /&gt;
== Variable Expansion ==&lt;br /&gt;
&lt;br /&gt;
Awall allows variable definitions in policy files. The top-level&lt;br /&gt;
attribute &#039;&#039;&#039;variable&#039;&#039;&#039; is a dictionary containing the&lt;br /&gt;
definitions. The value of a variable can be of any type (string,&lt;br /&gt;
integer, list, or dictionary).&lt;br /&gt;
&lt;br /&gt;
A variable is referenced in policy files by a string which equals the&lt;br /&gt;
variable name prepended with the &#039;&#039;&#039;$&#039;&#039;&#039; character. If the value of&lt;br /&gt;
the variable is a string, the reference can be embedded into a longer&lt;br /&gt;
string in order to substitute some part of that string (in shell&lt;br /&gt;
style). Variable references can be used when defining other variables,&lt;br /&gt;
as long as the definitions are not circular.&lt;br /&gt;
&lt;br /&gt;
Policy files can reference variables defined in other policy&lt;br /&gt;
files. Policy files can also override variables defined elsewhere by&lt;br /&gt;
redefining them. In this case, the new definition affects all policy&lt;br /&gt;
files, also those processed before the overriding policy. Awall&lt;br /&gt;
variables are in fact simple macros, since each variable remains&lt;br /&gt;
constant thoughout a single processing round. If multiple files define&lt;br /&gt;
the same variable, the definition in the file processed last takes&lt;br /&gt;
effect.&lt;br /&gt;
&lt;br /&gt;
If defined as an empty string, all non-embedded references to a&lt;br /&gt;
variable evaluate as if the attribute in question was not present in&lt;br /&gt;
the configuration. This is also the case when a string containing&lt;br /&gt;
embedded variable references finally evaluates to an empty string.&lt;br /&gt;
&lt;br /&gt;
== Configuration Objects ==&lt;br /&gt;
&lt;br /&gt;
Configuration objects can be divided into two main types.&lt;br /&gt;
&#039;&#039;Auxiliary objects&#039;&#039; model high-level concepts such as services and&lt;br /&gt;
zones. &#039;&#039;Rule objects&#039;&#039; translate into one or more iptables rules, and&lt;br /&gt;
are often defined with the help of some auxiliary objects.&lt;br /&gt;
&lt;br /&gt;
=== Services ===&lt;br /&gt;
&lt;br /&gt;
A &#039;&#039;service&#039;&#039; represents a set of network protocols. A top-level&lt;br /&gt;
attribute &#039;&#039;&#039;service&#039;&#039;&#039; is a dictionary that maps service names to&lt;br /&gt;
service definition objects, or lists thereof in more complex cases.&lt;br /&gt;
&lt;br /&gt;
A service definition object contains an attribute named &#039;&#039;&#039;proto&#039;&#039;&#039;,&lt;br /&gt;
which corresponds to the &amp;lt;tt&amp;gt;--protocol&amp;lt;/tt&amp;gt; option of iptables. The&lt;br /&gt;
protocol can be defined as a numerical value or string as defined in&lt;br /&gt;
&amp;lt;tt&amp;gt;/etc/protocols&amp;lt;/tt&amp;gt;. If the protocol is &#039;&#039;&#039;tcp&#039;&#039;&#039; or &#039;&#039;&#039;udp&#039;&#039;&#039;,&lt;br /&gt;
the scope of the service definition may be constrained by defining an&lt;br /&gt;
attribute named &#039;&#039;&#039;port&#039;&#039;&#039;, which is a list of TCP or UDP port numbers&lt;br /&gt;
or ranges thereof, separated by the &#039;&#039;&#039;-&#039;&#039;&#039; character. If the protocol&lt;br /&gt;
is &#039;&#039;&#039;icmp&#039;&#039;&#039; or &#039;&#039;&#039;icmpv6&#039;&#039;&#039;, an analogous &#039;&#039;&#039;icmp-type&#039;&#039;&#039; attribute&lt;br /&gt;
may be used. In addition, the scope of the rule is also automatically&lt;br /&gt;
limited to IPv4 or IPv6, respectively.&lt;br /&gt;
&lt;br /&gt;
=== Zones ===&lt;br /&gt;
&lt;br /&gt;
A &#039;&#039;zone&#039;&#039; represents a set of network hosts. A top-level attribute &lt;br /&gt;
&#039;&#039;&#039;zone&#039;&#039;&#039; is a dictionary that maps zone names to zone objects. A&lt;br /&gt;
zone object has an attribute named &#039;&#039;&#039;iface&#039;&#039;&#039;, &#039;&#039;&#039;addr&#039;&#039;&#039;, or&lt;br /&gt;
both. &#039;&#039;&#039;iface&#039;&#039;&#039; is a list of network interfaces and &#039;&#039;&#039;addr&#039;&#039;&#039; is a&lt;br /&gt;
list of IPv4/IPv6 host and network addresses (CIDR&lt;br /&gt;
notation). &#039;&#039;&#039;addr&#039;&#039;&#039; may also contain domain names, which are&lt;br /&gt;
expanded to IP addresses using DNS resolution. If not defined,&lt;br /&gt;
&#039;&#039;&#039;addr&#039;&#039;&#039; defaults to the entire address space and &#039;&#039;&#039;iface&#039;&#039;&#039; to all&lt;br /&gt;
interfaces. An empty zone can be defined by setting either &#039;&#039;&#039;addr&#039;&#039;&#039;&lt;br /&gt;
or &#039;&#039;&#039;iface&#039;&#039;&#039; to an empty list.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Rule objects contain two attributes, &#039;&#039;&#039;in&#039;&#039;&#039; and &#039;&#039;&#039;out&#039;&#039;&#039;, which are&lt;br /&gt;
lists of zone names. These attributes control whether a packet matches&lt;br /&gt;
the rule or not. If a particular zone is referenced by the &#039;&#039;&#039;in&#039;&#039;&#039; &lt;br /&gt;
attribute, the rule applies to packets whose ingress interface and&lt;br /&gt;
source address are covered by the zone definition. Correspondingly, if&lt;br /&gt;
a zone is referenced by the &#039;&#039;&#039;out&#039;&#039;&#039; attribute, the rule applies to&lt;br /&gt;
packets whose egress interface and destination address are included in&lt;br /&gt;
the zone. If both &#039;&#039;&#039;in&#039;&#039;&#039; and &#039;&#039;&#039;out&#039;&#039;&#039; are defined, the packet must&lt;br /&gt;
fulfill both criteria in order to match the rule.&lt;br /&gt;
&lt;br /&gt;
The firewall host itself can be referred to using the special value&lt;br /&gt;
&#039;&#039;&#039;_fw&#039;&#039;&#039; as the zone name.&lt;br /&gt;
&lt;br /&gt;
=== Logging Classes ===&lt;br /&gt;
&lt;br /&gt;
A &#039;&#039;logging class&#039;&#039; specifies how packets matching certain rules are&lt;br /&gt;
logged. A top-level attribute &#039;&#039;&#039;log&#039;&#039;&#039; is a dictionary that maps&lt;br /&gt;
logging class names to setting objects.&lt;br /&gt;
&lt;br /&gt;
A setting object may have an attribute named &#039;&#039;&#039;mode&#039;&#039;&#039;, which&lt;br /&gt;
specifies which logging facility to use. Allowed values are &#039;&#039;&#039;log&#039;&#039;&#039;,&lt;br /&gt;
&#039;&#039;&#039;nflog&#039;&#039;&#039;, and &#039;&#039;&#039;ulog&#039;&#039;&#039;. The default is &#039;&#039;&#039;log&#039;&#039;&#039;, i.e. in-kernel&lt;br /&gt;
logging. The object may also have a &#039;&#039;&#039;limit&#039;&#039;&#039; attribute, which is an&lt;br /&gt;
integer specifying the maximum number of matching packets to be logged&lt;br /&gt;
per second per rule. Optionally, the log entries are prefixed with a&lt;br /&gt;
string configured using the &#039;&#039;&#039;prefix&#039;&#039;&#039; attribute.&lt;br /&gt;
&lt;br /&gt;
Filter and policy rules can have an attribute named &#039;&#039;&#039;log&#039;&#039;&#039;. If it&lt;br /&gt;
is a string, it is interpreted as a reference to a logging class, and&lt;br /&gt;
logging is performed according to the definitions. If the value of the&lt;br /&gt;
&#039;&#039;&#039;log&#039;&#039;&#039; attribute is &#039;&#039;&#039;true&#039;&#039;&#039; (boolean), logging is done using&lt;br /&gt;
default settings. If the value is &#039;&#039;&#039;false&#039;&#039;&#039; (boolean), logging is&lt;br /&gt;
disabled for the rule. If &#039;&#039;&#039;log&#039;&#039;&#039; is not defined, logging is done&lt;br /&gt;
using the default settings except for accept rules, for which logging&lt;br /&gt;
is omitted.&lt;br /&gt;
&lt;br /&gt;
Default logging settings can be set by defining a logging class named&lt;br /&gt;
&#039;&#039;&#039;_default&#039;&#039;&#039;. Normally, default logging uses the &#039;&#039;&#039;log&#039;&#039;&#039; mode with&lt;br /&gt;
packets limited to one per second.&lt;br /&gt;
&lt;br /&gt;
=== Rules ===&lt;br /&gt;
&lt;br /&gt;
There are five types of rule objects:&lt;br /&gt;
* policies&lt;br /&gt;
* filters&lt;br /&gt;
* NAT rules&lt;br /&gt;
* packet marking rules&lt;br /&gt;
* MSS clamping rules&lt;br /&gt;
* connection tracking bypass rules&lt;br /&gt;
&lt;br /&gt;
All rule objects can have the &#039;&#039;&#039;in&#039;&#039;&#039; and &#039;&#039;&#039;out&#039;&#039;&#039; attributes&lt;br /&gt;
referring to zones as described in the previous section. In addition,&lt;br /&gt;
the scope of the rule can be further constrained with the following&lt;br /&gt;
attributes:&lt;br /&gt;
&lt;br /&gt;
{|&lt;br /&gt;
!Attribute!!Value format!!Effect&lt;br /&gt;
|-&lt;br /&gt;
|&#039;&#039;&#039;src&#039;&#039;&#039;&lt;br /&gt;
|Similar to &#039;&#039;&#039;addr&#039;&#039;&#039; attribute of zone objects&lt;br /&gt;
|Packet&#039;s source address matches the value&lt;br /&gt;
|-&lt;br /&gt;
|&#039;&#039;&#039;dest&#039;&#039;&#039;&lt;br /&gt;
|Similar to &#039;&#039;&#039;addr&#039;&#039;&#039; attribute of zone objects&lt;br /&gt;
|Packet&#039;s destination address matches the value&lt;br /&gt;
|-&lt;br /&gt;
|&#039;&#039;&#039;ipset&#039;&#039;&#039;&lt;br /&gt;
|Object containing two attributes: &#039;&#039;&#039;name&#039;&#039;&#039; referring to an IP set and &#039;&#039;&#039;args&#039;&#039;&#039;, which is a list of strings &#039;&#039;&#039;in&#039;&#039;&#039; and &#039;&#039;&#039;out&#039;&#039;&#039;&lt;br /&gt;
|Packet matches the IP set referred here when the match arguments are taken from the source (&#039;&#039;&#039;in&#039;&#039;&#039;) and destination (&#039;&#039;&#039;out&#039;&#039;&#039;) address or port in the order specified by &#039;&#039;&#039;args&#039;&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
|&#039;&#039;&#039;ipsec&#039;&#039;&#039;&lt;br /&gt;
|&#039;&#039;&#039;in&#039;&#039;&#039; or &#039;&#039;&#039;out&#039;&#039;&#039;&lt;br /&gt;
|IPsec decapsulation perfomed on ingress (&#039;&#039;&#039;in&#039;&#039;&#039;) or encapsulation performed on egress (&#039;&#039;&#039;out&#039;&#039;&#039;)&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Rule objects are declared in type-specific top-level dictionaries in&lt;br /&gt;
awall policy files. If a packet matches multiple rules, the one&lt;br /&gt;
appearing earlier in the list takes precedence. If the matching rules&lt;br /&gt;
are defined in different policy files, the one that was processed&lt;br /&gt;
earlier takes precedence in the current implementation, but this may&lt;br /&gt;
change in future versions.&lt;br /&gt;
&lt;br /&gt;
==== Filters ====&lt;br /&gt;
&lt;br /&gt;
Filter objects specify an action for packets fulfilling certain&lt;br /&gt;
criteria. The top-level attribute &#039;&#039;&#039;filter&#039;&#039;&#039; is a list of filter&lt;br /&gt;
objects. The precedence rules are similar to those of policy objects.&lt;br /&gt;
&lt;br /&gt;
In addition to the common rule attributes, filter objects can have a &lt;br /&gt;
&#039;&#039;&#039;service&#039;&#039;&#039; attribute constraining the scope to specific services&lt;br /&gt;
only. This attribute is a list of service names, referring to the&lt;br /&gt;
keys of the top-level &#039;&#039;&#039;service&#039;&#039;&#039; dictionary.&lt;br /&gt;
&lt;br /&gt;
Filter objects must have an attribute named &#039;&#039;&#039;action&#039;&#039;&#039;, the value of&lt;br /&gt;
which can be one of the following:&lt;br /&gt;
&lt;br /&gt;
{|&lt;br /&gt;
!Value!!Action&lt;br /&gt;
|-&lt;br /&gt;
|&#039;&#039;&#039;accept&#039;&#039;&#039;&lt;br /&gt;
|Accept the packet&lt;br /&gt;
|-&lt;br /&gt;
|&#039;&#039;&#039;reject&#039;&#039;&#039;&lt;br /&gt;
|Reject the packet with an ICMP error message&lt;br /&gt;
|-&lt;br /&gt;
|&#039;&#039;&#039;drop&#039;&#039;&#039;&lt;br /&gt;
|Silently drop the packet&lt;br /&gt;
|-&lt;br /&gt;
|&#039;&#039;&#039;tarpit&#039;&#039;&#039;&lt;br /&gt;
|Put incoming TCP connections into persist state and ignore attempts to close them. Silently drop non-TCP packets. (Connection tracking bypass is automatically enabled for the matching packets.)&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Filter objects, the action of which is &#039;&#039;&#039;accept&#039;&#039;&#039;, may also contain&lt;br /&gt;
limits for packet flow or new connections. These are specified with&lt;br /&gt;
the &#039;&#039;&#039;flow-limit&#039;&#039;&#039; and &#039;&#039;&#039;conn-limit&#039;&#039;&#039; attributes,&lt;br /&gt;
respectively. The values of these attributes are limit objects that&lt;br /&gt;
have two attributes: &#039;&#039;&#039;count&#039;&#039;&#039; and &#039;&#039;&#039;interval&#039;&#039;&#039;. &#039;&#039;&#039;count&#039;&#039;&#039;&lt;br /&gt;
specifies how many new connections or packets are allowed within the&lt;br /&gt;
time frame specified by &#039;&#039;&#039;interval&#039;&#039;&#039; (in seconds). The &#039;&#039;&#039;logdrop&#039;&#039;&#039;&lt;br /&gt;
action is applied to the packets exceeding the limit.&lt;br /&gt;
&lt;br /&gt;
Filter objects may have an attribute named &#039;&#039;&#039;dnat&#039;&#039;&#039;, the value of&lt;br /&gt;
which is an IPv4 address. If defined, this enables destination NAT for&lt;br /&gt;
all IPv4 packets matching the rule, such that the specified address&lt;br /&gt;
replaces the original destination address. This option has no effect&lt;br /&gt;
on IPv6 packets.&lt;br /&gt;
&lt;br /&gt;
Filter objects may have a boolean attribute named &#039;&#039;&#039;no-track&#039;&#039;&#039;. If&lt;br /&gt;
set to &#039;&#039;&#039;true&#039;&#039;&#039;, connection tracking is bypassed for the matching&lt;br /&gt;
packets. In addition, if &#039;&#039;&#039;action&#039;&#039;&#039; is set to &#039;&#039;&#039;accept&#039;&#039;&#039;, the&lt;br /&gt;
corresponding packets travelling to the reverse direction are also&lt;br /&gt;
allowed.&lt;br /&gt;
&lt;br /&gt;
==== Policies ====&lt;br /&gt;
&lt;br /&gt;
Policy objects describe the default action for packets that did not&lt;br /&gt;
match any filter. The top-level attribute &#039;&#039;&#039;policy&#039;&#039;&#039; is a list of&lt;br /&gt;
policy objects.&lt;br /&gt;
&lt;br /&gt;
Policy objects must have the &#039;&#039;&#039;action&#039;&#039;&#039; attribute defined. The&lt;br /&gt;
possible values and their semantics are the same as in filter objects.&lt;br /&gt;
&lt;br /&gt;
==== NAT Rules ====&lt;br /&gt;
&lt;br /&gt;
NAT rules come in two flavors: &#039;&#039;source NAT rules&#039;&#039; and&lt;br /&gt;
&#039;&#039;destination NAT rules&#039;&#039;. These are contained in two top-level lists&lt;br /&gt;
named &#039;&#039;&#039;snat&#039;&#039;&#039; and &#039;&#039;&#039;dnat&#039;&#039;&#039;, respectively.&lt;br /&gt;
&lt;br /&gt;
Each NAT rule may have an attribute named &#039;&#039;&#039;to-addr&#039;&#039;&#039; that&lt;br /&gt;
specifies the IPv4 address range to which the original source or&lt;br /&gt;
destination address is mapped. The value can be a single IPv4 address&lt;br /&gt;
or a range specified by two addresses, separated with the &#039;&#039;&#039;-&#039;&#039;&#039;&lt;br /&gt;
character. If not defined, it defaults to the primary address of the&lt;br /&gt;
ingress interface in case of destination NAT, or that of the egress&lt;br /&gt;
interface in case of source NAT.&lt;br /&gt;
&lt;br /&gt;
Optionally, a NAT rule can specify the TCP and UDP port range to which&lt;br /&gt;
the original source or destination port is mapped. The attribute is&lt;br /&gt;
named &#039;&#039;&#039;to-port&#039;&#039;&#039;, and the value can be a single port number or a&lt;br /&gt;
range specified by two numbers, separated with the &#039;&#039;&#039;-&#039;&#039;&#039;&lt;br /&gt;
character. If &#039;&#039;&#039;to-port&#039;&#039;&#039; is not specified, the original port number&lt;br /&gt;
is kept intact.&lt;br /&gt;
&lt;br /&gt;
Like filters, NAT rules can have a &#039;&#039;&#039;service&#039;&#039;&#039; attribute&lt;br /&gt;
constraining their scope to specific services.&lt;br /&gt;
&lt;br /&gt;
NAT rules may have an &#039;&#039;&#039;action&#039;&#039;&#039; attribute set to value&lt;br /&gt;
&#039;&#039;&#039;accept&#039;&#039;&#039;. In this case, NAT is not performed on the packets&lt;br /&gt;
reaching and matching this rule.&lt;br /&gt;
&lt;br /&gt;
==== Packet Marking Rules ====&lt;br /&gt;
&lt;br /&gt;
Packet marking rules are used to mark incoming packets matching the&lt;br /&gt;
specified criteria. The mark can be used as a basis for the routing&lt;br /&gt;
decision. Each marking rule must specify the mark using the &#039;&#039;&#039;mark&#039;&#039;&#039;&lt;br /&gt;
attribute, which is a 32-bit integer.&lt;br /&gt;
&lt;br /&gt;
Normal marking rules are contained by the top-level list attribute&lt;br /&gt;
named &#039;&#039;&#039;mark&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
There is another top-level list attribute, named &#039;&#039;&#039;route-track&#039;&#039;&#039;,&lt;br /&gt;
which contains route tracking rules. These are special marking rules&lt;br /&gt;
which cause all the subsequent packets related to the same connection&lt;br /&gt;
to be marked according to the rule.&lt;br /&gt;
&lt;br /&gt;
==== MSS Clamping Rules ====&lt;br /&gt;
&lt;br /&gt;
MSS Clamping Rules are used to deal with ISPs that block ICMP&lt;br /&gt;
Fragmentation Needed or ICMPv6 Packet Too Big packets. An MSS clamping&lt;br /&gt;
rule overwrites the MSS option with a value specified with the&lt;br /&gt;
&#039;&#039;&#039;mss&#039;&#039;&#039; attribute for the matching TCP connections. If &#039;&#039;&#039;mss&#039;&#039;&#039; is&lt;br /&gt;
not specified, a suitable value is automatically determined from the&lt;br /&gt;
path MTU.&lt;br /&gt;
&lt;br /&gt;
==== Connection Tracking Bypass Rules ====&lt;br /&gt;
&lt;br /&gt;
Connection tracking bypass rules are used to disable connection&lt;br /&gt;
tracking for packets matching the specified criteria. The top-level&lt;br /&gt;
attribute &#039;&#039;&#039;no-track&#039;&#039;&#039; is a list of such rules.&lt;br /&gt;
&lt;br /&gt;
Connection tracking bypass rules may have an &#039;&#039;&#039;action&#039;&#039;&#039; attribute&lt;br /&gt;
set to value &#039;&#039;&#039;accept&#039;&#039;&#039;. The effect is similar to corresponding NAT&lt;br /&gt;
rules, i.e. connection tracking is not bypassed for the matching&lt;br /&gt;
packets.&lt;br /&gt;
&lt;br /&gt;
=== IP Sets ===&lt;br /&gt;
&lt;br /&gt;
Any IP set referenced by rule objects should be created by&lt;br /&gt;
awall. Auxiliary &#039;&#039;IP set&#039;&#039; objects are used to defined them in awall&lt;br /&gt;
policy files. The top-level attribute &#039;&#039;&#039;ipset&#039;&#039;&#039; is a dictionary, the&lt;br /&gt;
keys of which are IP set names. The values are IP set objects, which&lt;br /&gt;
have two mandatory attributes. The attribute named &#039;&#039;&#039;type&#039;&#039;&#039; &lt;br /&gt;
corresponds to the type argument of the &amp;lt;tt&amp;gt;ipset create&amp;lt;/tt&amp;gt; &lt;br /&gt;
command. &#039;&#039;&#039;family&#039;&#039;&#039; specifies whether the set is for IPv4 or IPv6&lt;br /&gt;
addresses, and the possible values are &#039;&#039;&#039;inet&#039;&#039;&#039; and &#039;&#039;&#039;inet6&#039;&#039;&#039;,&lt;br /&gt;
correspondingly.&lt;br /&gt;
&lt;br /&gt;
== Command Line Syntax ==&lt;br /&gt;
&lt;br /&gt;
=== Translating Policy Files to Firewall Configuration Files ===&lt;br /&gt;
&lt;br /&gt;
 &#039;&#039;&#039;awall translate&#039;&#039;&#039; [&#039;&#039;&#039;-o&#039;&#039;&#039;|&#039;&#039;&#039;--output&#039;&#039;&#039; DIRECTORY] [&#039;&#039;&#039;-V&#039;&#039;&#039;|&#039;&#039;&#039;--verify&#039;&#039;&#039;]&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;tt&amp;gt;--verify&amp;lt;/tt&amp;gt; option makes awall verify the configuration&lt;br /&gt;
using the test mode of iptables-restore before overwriting the old&lt;br /&gt;
files.&lt;br /&gt;
&lt;br /&gt;
Specifying the output directory allows testing awall policies without&lt;br /&gt;
overwriting the current iptables and ipset configuration files. By&lt;br /&gt;
default, awall generates the configuration to &amp;lt;tt&amp;gt;/etc/iptables&amp;lt;/tt&amp;gt; &lt;br /&gt;
and &amp;lt;tt&amp;gt;/etc/ipset.d&amp;lt;/tt&amp;gt;, which are read by the init scripts.&lt;br /&gt;
&lt;br /&gt;
=== Run-Time Configuration of Firewall ===&lt;br /&gt;
&lt;br /&gt;
 &#039;&#039;&#039;awall activate&#039;&#039;&#039; [&#039;&#039;&#039;-f&#039;&#039;&#039;|&#039;&#039;&#039;--force&#039;&#039;&#039;]&lt;br /&gt;
&lt;br /&gt;
This command genereates firewall configuration from the policy files&lt;br /&gt;
and enables it. If the user confirms the new configuration by hitting&lt;br /&gt;
the Return key within 10 seconds or the &amp;lt;tt&amp;gt;--force&amp;lt;/tt&amp;gt; option is&lt;br /&gt;
used, the configuration is saved to the files. Otherwise, the old&lt;br /&gt;
configuration is restored.&lt;br /&gt;
&lt;br /&gt;
There is also a command for deleting all firewall rules:&lt;br /&gt;
&lt;br /&gt;
 &#039;&#039;&#039;awall flush&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
This command configures the firewall to drop all packets.&lt;br /&gt;
&lt;br /&gt;
=== Optional Policies ===&lt;br /&gt;
&lt;br /&gt;
Optional policies can be enabled or disabled using this command:&lt;br /&gt;
&lt;br /&gt;
 &#039;&#039;&#039;awall&#039;&#039;&#039; {&#039;&#039;&#039;enable&#039;&#039;&#039;|&#039;&#039;&#039;disable&#039;&#039;&#039;} POLICY...&lt;br /&gt;
&lt;br /&gt;
Optional policies can be listed using this command:&lt;br /&gt;
&lt;br /&gt;
 &#039;&#039;&#039;awall list&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;&#039;enabled&#039;&#039;&#039; status means that the policy has been enabled by the&lt;br /&gt;
user. The &#039;&#039;&#039;disabled&#039;&#039;&#039; status means that the policy is not in&lt;br /&gt;
use. The &#039;&#039;&#039;required&#039;&#039;&#039; status means that the policy has not been&lt;br /&gt;
enabled by the user but is in use because it is required by another&lt;br /&gt;
policy which is in use.&lt;br /&gt;
&lt;br /&gt;
=== Debugging Policies ===&lt;br /&gt;
&lt;br /&gt;
This command can be used to dump variable, zone, and other definitions&lt;br /&gt;
as well as their source policies:&lt;br /&gt;
&lt;br /&gt;
 &#039;&#039;&#039;awall dump&#039;&#039;&#039; [LEVEL]&lt;br /&gt;
&lt;br /&gt;
The level is an integer in range 0&amp;amp;ndash;5 and defaults to 0. More&lt;br /&gt;
information is displayed on higher levels.&lt;br /&gt;
&lt;br /&gt;
[[Category:Networking]]&lt;br /&gt;
[[Category:Security]]&lt;/div&gt;</summary>
		<author><name>Kunkku</name></author>
	</entry>
	<entry>
		<id>https://wiki.alpinelinux.org/w/index.php?title=Alpine_Wall_User%27s_Guide&amp;diff=8394</id>
		<title>Alpine Wall User&#039;s Guide</title>
		<link rel="alternate" type="text/html" href="https://wiki.alpinelinux.org/w/index.php?title=Alpine_Wall_User%27s_Guide&amp;diff=8394"/>
		<updated>2012-09-12T08:32:45Z</updated>

		<summary type="html">&lt;p&gt;Kunkku: /* Logging Classes */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Configuration File Processing ==&lt;br /&gt;
&lt;br /&gt;
[[Alpine Wall]] (awall) reads its configuration from multiple&lt;br /&gt;
JSON-formatted files, called &#039;&#039;policy files&#039;&#039;. The processing starts&lt;br /&gt;
from directory &amp;lt;tt&amp;gt;/usr/share/awall/mandatory&amp;lt;/tt&amp;gt;, which contains&lt;br /&gt;
mandatory policy files shipped with APK packages. After that,&lt;br /&gt;
installation-specific policy files in &amp;lt;tt&amp;gt;/etc/awall&amp;lt;/tt&amp;gt; are&lt;br /&gt;
processed.&lt;br /&gt;
&lt;br /&gt;
The latter directory may also contain symbolic links to policy files&lt;br /&gt;
located in &amp;lt;tt&amp;gt;/usr/share/awall/optional&amp;lt;/tt&amp;gt;. These are optional&lt;br /&gt;
policies, which can be enabled on need basis. Such symbolic links are&lt;br /&gt;
easily created and destroyed using the &amp;lt;tt&amp;gt;awall enable&amp;lt;/tt&amp;gt; and &lt;br /&gt;
&amp;lt;tt&amp;gt;awall disable&amp;lt;/tt&amp;gt; commands. &amp;lt;tt&amp;gt;awall list&amp;lt;/tt&amp;gt; shows which&lt;br /&gt;
optional policies are enabled and disabled. The command also prints&lt;br /&gt;
the description of the optional policy if defined in the file using&lt;br /&gt;
a top-level attribute named &#039;&#039;&#039;description&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Sometimes a policy file depends on other policy files. In this case,&lt;br /&gt;
the policy file must have a top-level attribute &#039;&#039;&#039;import&#039;&#039;&#039;, the&lt;br /&gt;
value of which is a list of policy names, which correspond to the file&lt;br /&gt;
names without the &amp;lt;tt&amp;gt;.json&amp;lt;/tt&amp;gt; suffix. By default, the policies&lt;br /&gt;
listed there are processed before the importing policy.&lt;br /&gt;
&lt;br /&gt;
The order of the generated iptables rules generally reflects the&lt;br /&gt;
processing order of their corresponding awall policies. The processing&lt;br /&gt;
order of policies can be adjusted by defining top-level attributes&lt;br /&gt;
&#039;&#039;&#039;after&#039;&#039;&#039; and &#039;&#039;&#039;before&#039;&#039;&#039; in policy files. These attributes are&lt;br /&gt;
lists of policies, after or before which the declaring policy shall be&lt;br /&gt;
processed. Putting a policy name to either of these lists does not by&lt;br /&gt;
itself import the policy. The ordering directives are ignored with&lt;br /&gt;
respect to those policies that are not enabled by the user or imported&lt;br /&gt;
by other policies. If not defined, &#039;&#039;&#039;after&#039;&#039;&#039; is assumed to be equal&lt;br /&gt;
to the &#039;&#039;&#039;import&#039;&#039;&#039; definition of the policy.&lt;br /&gt;
&lt;br /&gt;
As the import directive does not require the path name to be&lt;br /&gt;
specified, awall expects policies to have unique names, even if&lt;br /&gt;
located in different directories. It is allowed to import optional&lt;br /&gt;
policies that are not explicitly enabled by the user. Such policies&lt;br /&gt;
show up with the &amp;lt;tt&amp;gt;required&amp;lt;/tt&amp;gt; status in the output of &amp;lt;tt&amp;gt;awall&lt;br /&gt;
list&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
== List Parameters ==&lt;br /&gt;
&lt;br /&gt;
Several awall parameters are defined as lists of values. In order to&lt;br /&gt;
facilitate manual editing of policy files, awall also accepts single&lt;br /&gt;
values in place of lists. Such values are semantically equivalent to&lt;br /&gt;
lists containing one element.&lt;br /&gt;
&lt;br /&gt;
== Variable Expansion ==&lt;br /&gt;
&lt;br /&gt;
Awall allows variable definitions in policy files. The top-level&lt;br /&gt;
attribute &#039;&#039;&#039;variable&#039;&#039;&#039; is a dictionary containing the&lt;br /&gt;
definitions. The value of a variable can be of any type (string,&lt;br /&gt;
integer, list, or dictionary).&lt;br /&gt;
&lt;br /&gt;
A variable is referenced in policy files by a string which equals the&lt;br /&gt;
variable name prepended with the &#039;&#039;&#039;$&#039;&#039;&#039; character. If the value of&lt;br /&gt;
the variable is a string, the reference can be embedded into a longer&lt;br /&gt;
string in order to substitute some part of that string (in shell&lt;br /&gt;
style). Variable references can be used when defining other variables,&lt;br /&gt;
as long as the definitions are not circular.&lt;br /&gt;
&lt;br /&gt;
Policy files can reference variables defined in other policy&lt;br /&gt;
files. Policy files can also override variables defined elsewhere by&lt;br /&gt;
redefining them. In this case, the new definition affects all policy&lt;br /&gt;
files, also those processed before the overriding policy. Awall&lt;br /&gt;
variables are in fact simple macros, since each variable remains&lt;br /&gt;
constant thoughout a single processing round. If multiple files define&lt;br /&gt;
the same variable, the definition in the file processed last takes&lt;br /&gt;
effect.&lt;br /&gt;
&lt;br /&gt;
If defined as an empty string, all non-embedded references to a&lt;br /&gt;
variable evaluate as if the attribute in question was not present in&lt;br /&gt;
the configuration. This is also the case when a string containing&lt;br /&gt;
embedded variable references finally evaluates to an empty string.&lt;br /&gt;
&lt;br /&gt;
== Configuration Objects ==&lt;br /&gt;
&lt;br /&gt;
Configuration objects can be divided into two main types.&lt;br /&gt;
&#039;&#039;Auxiliary objects&#039;&#039; model high-level concepts such as services and&lt;br /&gt;
zones. &#039;&#039;Rule objects&#039;&#039; translate into one or more iptables rules, and&lt;br /&gt;
are often defined with the help of some auxiliary objects.&lt;br /&gt;
&lt;br /&gt;
=== Services ===&lt;br /&gt;
&lt;br /&gt;
A &#039;&#039;service&#039;&#039; represents a set of network protocols. A top-level&lt;br /&gt;
attribute &#039;&#039;&#039;service&#039;&#039;&#039; is a dictionary that maps service names to&lt;br /&gt;
service definition objects, or lists thereof in more complex cases.&lt;br /&gt;
&lt;br /&gt;
A service definition object contains an attribute named &#039;&#039;&#039;proto&#039;&#039;&#039;,&lt;br /&gt;
which corresponds to the &amp;lt;tt&amp;gt;--protocol&amp;lt;/tt&amp;gt; option of iptables. The&lt;br /&gt;
protocol can be defined as a numerical value or string as defined in&lt;br /&gt;
&amp;lt;tt&amp;gt;/etc/protocols&amp;lt;/tt&amp;gt;. If the protocol is &#039;&#039;&#039;tcp&#039;&#039;&#039; or &#039;&#039;&#039;udp&#039;&#039;&#039;,&lt;br /&gt;
the scope of the service definition may be constrained by defining an&lt;br /&gt;
attribute named &#039;&#039;&#039;port&#039;&#039;&#039;, which is a list of TCP or UDP port numbers&lt;br /&gt;
or ranges thereof, separated by the &#039;&#039;&#039;-&#039;&#039;&#039; character. If the protocol&lt;br /&gt;
is &#039;&#039;&#039;icmp&#039;&#039;&#039; or &#039;&#039;&#039;icmpv6&#039;&#039;&#039;, an analogous &#039;&#039;&#039;icmp-type&#039;&#039;&#039; attribute&lt;br /&gt;
may be used. In addition, the scope of the rule is also automatically&lt;br /&gt;
limited to IPv4 or IPv6, respectively.&lt;br /&gt;
&lt;br /&gt;
=== Zones ===&lt;br /&gt;
&lt;br /&gt;
A &#039;&#039;zone&#039;&#039; represents a set of network hosts. A top-level attribute &lt;br /&gt;
&#039;&#039;&#039;zone&#039;&#039;&#039; is a dictionary that maps zone names to zone objects. A&lt;br /&gt;
zone object has an attribute named &#039;&#039;&#039;iface&#039;&#039;&#039;, &#039;&#039;&#039;addr&#039;&#039;&#039;, or&lt;br /&gt;
both. &#039;&#039;&#039;iface&#039;&#039;&#039; is a list of network interfaces and &#039;&#039;&#039;addr&#039;&#039;&#039; is a&lt;br /&gt;
list of IPv4/IPv6 host and network addresses (CIDR&lt;br /&gt;
notation). &#039;&#039;&#039;addr&#039;&#039;&#039; may also contain domain names, which are&lt;br /&gt;
expanded to IP addresses using DNS resolution. If not defined,&lt;br /&gt;
&#039;&#039;&#039;addr&#039;&#039;&#039; defaults to the entire address space and &#039;&#039;&#039;iface&#039;&#039;&#039; to all&lt;br /&gt;
interfaces. An empty zone can be defined by setting either &#039;&#039;&#039;addr&#039;&#039;&#039;&lt;br /&gt;
or &#039;&#039;&#039;iface&#039;&#039;&#039; to an empty list.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Rule objects contain two attributes, &#039;&#039;&#039;in&#039;&#039;&#039; and &#039;&#039;&#039;out&#039;&#039;&#039;, which are&lt;br /&gt;
lists of zone names. These attributes control whether a packet matches&lt;br /&gt;
the rule or not. If a particular zone is referenced by the &#039;&#039;&#039;in&#039;&#039;&#039; &lt;br /&gt;
attribute, the rule applies to packets whose ingress interface and&lt;br /&gt;
source address are covered by the zone definition. Correspondingly, if&lt;br /&gt;
a zone is referenced by the &#039;&#039;&#039;out&#039;&#039;&#039; attribute, the rule applies to&lt;br /&gt;
packets whose egress interface and destination address are included in&lt;br /&gt;
the zone. If both &#039;&#039;&#039;in&#039;&#039;&#039; and &#039;&#039;&#039;out&#039;&#039;&#039; are defined, the packet must&lt;br /&gt;
fulfill both criteria in order to match the rule.&lt;br /&gt;
&lt;br /&gt;
The firewall host itself can be referred to using the special value&lt;br /&gt;
&#039;&#039;&#039;_fw&#039;&#039;&#039; as the zone name.&lt;br /&gt;
&lt;br /&gt;
=== Logging Classes ===&lt;br /&gt;
&lt;br /&gt;
A &#039;&#039;logging class&#039;&#039; specifies how packets matching certain rules are&lt;br /&gt;
logged. A top-level attribute &#039;&#039;&#039;log&#039;&#039;&#039; is a dictionary that maps&lt;br /&gt;
logging class names to setting objects.&lt;br /&gt;
&lt;br /&gt;
A setting object may have an attribute named &#039;&#039;&#039;mode&#039;&#039;&#039;, which&lt;br /&gt;
specifies which logging facility to use. Allowed values are &#039;&#039;&#039;log&#039;&#039;&#039;,&lt;br /&gt;
&#039;&#039;&#039;nflog&#039;&#039;&#039;, and &#039;&#039;&#039;ulog&#039;&#039;&#039;. The default is &#039;&#039;&#039;log&#039;&#039;&#039;, i.e. in-kernel&lt;br /&gt;
logging. The object may also have a &#039;&#039;&#039;limit&#039;&#039;&#039; attribute, which is an&lt;br /&gt;
integer specifying the maximum number of matching packets to be logged&lt;br /&gt;
per second per rule. Optionally, the log entries are prefixed with a&lt;br /&gt;
string configured using the &#039;&#039;&#039;prefix&#039;&#039;&#039; attribute.&lt;br /&gt;
&lt;br /&gt;
Filter and policy rules can have an attribute named &#039;&#039;&#039;log&#039;&#039;&#039;. If it&lt;br /&gt;
is a string, it is interpreted as a reference to a logging class, and&lt;br /&gt;
logging is performed according to the definitions. If the value of the&lt;br /&gt;
&#039;&#039;&#039;log&#039;&#039;&#039; attribute is &#039;&#039;&#039;true&#039;&#039;&#039; (boolean), logging is done using&lt;br /&gt;
default settings. If the value is &#039;&#039;&#039;false&#039;&#039;&#039; (boolean), logging is&lt;br /&gt;
disabled for the rule. If &#039;&#039;&#039;log&#039;&#039;&#039; is not defined, logging is done&lt;br /&gt;
using the default settings except for accept rules, for which logging&lt;br /&gt;
is omitted.&lt;br /&gt;
&lt;br /&gt;
Default logging settings can be set by defining a logging class named&lt;br /&gt;
&#039;&#039;&#039;_default&#039;&#039;&#039;. Normally, default logging uses the &#039;&#039;&#039;log&#039;&#039;&#039; mode with&lt;br /&gt;
packets limited to one per second.&lt;br /&gt;
&lt;br /&gt;
=== Rules ===&lt;br /&gt;
&lt;br /&gt;
There are five types of rule objects:&lt;br /&gt;
* policies&lt;br /&gt;
* filters&lt;br /&gt;
* NAT rules&lt;br /&gt;
* packet marking rules&lt;br /&gt;
* MSS clamping rules&lt;br /&gt;
* connection tracking bypass rules&lt;br /&gt;
&lt;br /&gt;
All rule objects can have the &#039;&#039;&#039;in&#039;&#039;&#039; and &#039;&#039;&#039;out&#039;&#039;&#039; attributes&lt;br /&gt;
referring to zones as described in the previous section. In addition,&lt;br /&gt;
the scope of the rule can be further constrained with the following&lt;br /&gt;
attributes:&lt;br /&gt;
&lt;br /&gt;
{|&lt;br /&gt;
!Attribute!!Value format!!Effect&lt;br /&gt;
|-&lt;br /&gt;
|&#039;&#039;&#039;src&#039;&#039;&#039;&lt;br /&gt;
|Similar to &#039;&#039;&#039;addr&#039;&#039;&#039; attribute of zone objects&lt;br /&gt;
|Packet&#039;s source address matches the value&lt;br /&gt;
|-&lt;br /&gt;
|&#039;&#039;&#039;dest&#039;&#039;&#039;&lt;br /&gt;
|Similar to &#039;&#039;&#039;addr&#039;&#039;&#039; attribute of zone objects&lt;br /&gt;
|Packet&#039;s destination address matches the value&lt;br /&gt;
|-&lt;br /&gt;
|&#039;&#039;&#039;ipset&#039;&#039;&#039;&lt;br /&gt;
|Object containing two attributes: &#039;&#039;&#039;name&#039;&#039;&#039; referring to an IP set and &#039;&#039;&#039;args&#039;&#039;&#039;, which is a list of strings &#039;&#039;&#039;in&#039;&#039;&#039; and &#039;&#039;&#039;out&#039;&#039;&#039;&lt;br /&gt;
|Packet matches the IP set referred here when the match arguments are taken from the source (&#039;&#039;&#039;in&#039;&#039;&#039;) and destination (&#039;&#039;&#039;out&#039;&#039;&#039;) address or port in the order specified by &#039;&#039;&#039;args&#039;&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
|&#039;&#039;&#039;ipsec&#039;&#039;&#039;&lt;br /&gt;
|&#039;&#039;&#039;in&#039;&#039;&#039; or &#039;&#039;&#039;out&#039;&#039;&#039;&lt;br /&gt;
|IPsec decapsulation perfomed on ingress (&#039;&#039;&#039;in&#039;&#039;&#039;) or encapsulation performed on egress (&#039;&#039;&#039;out&#039;&#039;&#039;)&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Rule objects are declared in type-specific top-level dictionaries in&lt;br /&gt;
awall policy files. If a packet matches multiple rules, the one&lt;br /&gt;
appearing earlier in the list takes precedence. If the matching rules&lt;br /&gt;
are defined in different policy files, the one that was processed&lt;br /&gt;
earlier takes precedence in the current implementation, but this may&lt;br /&gt;
change in future versions.&lt;br /&gt;
&lt;br /&gt;
==== Filters ====&lt;br /&gt;
&lt;br /&gt;
Filter objects specify an action for packets fulfilling certain&lt;br /&gt;
criteria. The top-level attribute &#039;&#039;&#039;filter&#039;&#039;&#039; is a list of filter&lt;br /&gt;
objects. The precedence rules are similar to those of policy objects.&lt;br /&gt;
&lt;br /&gt;
In addition to the common rule attributes, filter objects can have a &lt;br /&gt;
&#039;&#039;&#039;service&#039;&#039;&#039; attribute constraining the scope to specific services&lt;br /&gt;
only. This attribute is a list of service names, referring to the&lt;br /&gt;
keys of the top-level &#039;&#039;&#039;service&#039;&#039;&#039; dictionary.&lt;br /&gt;
&lt;br /&gt;
Filter objects must have an attribute named &#039;&#039;&#039;action&#039;&#039;&#039;, the value of&lt;br /&gt;
which can be one of the following:&lt;br /&gt;
&lt;br /&gt;
{|&lt;br /&gt;
!Value!!Action&lt;br /&gt;
|-&lt;br /&gt;
|&#039;&#039;&#039;accept&#039;&#039;&#039;&lt;br /&gt;
|Accept the packet&lt;br /&gt;
|-&lt;br /&gt;
|&#039;&#039;&#039;reject&#039;&#039;&#039;&lt;br /&gt;
|Reject the packet with an ICMP error message&lt;br /&gt;
|-&lt;br /&gt;
|&#039;&#039;&#039;drop&#039;&#039;&#039;&lt;br /&gt;
|Silently drop the packet&lt;br /&gt;
|-&lt;br /&gt;
|&#039;&#039;&#039;tarpit&#039;&#039;&#039;&lt;br /&gt;
|Put incoming TCP connections into persist state and ignore attempts to close them. Silently drop non-TCP packets. (Connection tracking bypass is automatically enabled for the matching packets.)&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Filter objects, the action of which is &#039;&#039;&#039;accept&#039;&#039;&#039;, may also contain&lt;br /&gt;
limits for packet flow or new connections. These are specified with&lt;br /&gt;
the &#039;&#039;&#039;flow-limit&#039;&#039;&#039; and &#039;&#039;&#039;conn-limit&#039;&#039;&#039; attributes,&lt;br /&gt;
respectively. The values of these attributes are limit objects that&lt;br /&gt;
have two attributes: &#039;&#039;&#039;count&#039;&#039;&#039; and &#039;&#039;&#039;interval&#039;&#039;&#039;. &#039;&#039;&#039;count&#039;&#039;&#039;&lt;br /&gt;
specifies how many new connections or packets are allowed within the&lt;br /&gt;
time frame specified by &#039;&#039;&#039;interval&#039;&#039;&#039; (in seconds). The &#039;&#039;&#039;logdrop&#039;&#039;&#039;&lt;br /&gt;
action is applied to the packets exceeding the limit.&lt;br /&gt;
&lt;br /&gt;
Filter objects may have an attribute named &#039;&#039;&#039;dnat&#039;&#039;&#039;, the value of&lt;br /&gt;
which is an IPv4 address. If defined, this enables destination NAT for&lt;br /&gt;
all IPv4 packets matching the rule, such that the specified address&lt;br /&gt;
replaces the original destination address. This option has no effect&lt;br /&gt;
on IPv6 packets.&lt;br /&gt;
&lt;br /&gt;
Filter objects may have a boolean attribute named &#039;&#039;&#039;no-track&#039;&#039;&#039;. If&lt;br /&gt;
set to &#039;&#039;&#039;true&#039;&#039;&#039;, connection tracking is bypassed for the matching&lt;br /&gt;
packets. In addition, if &#039;&#039;&#039;action&#039;&#039;&#039; is set to &#039;&#039;&#039;accept&#039;&#039;&#039;, the&lt;br /&gt;
corresponding packets travelling to the reverse direction are also&lt;br /&gt;
allowed.&lt;br /&gt;
&lt;br /&gt;
==== Policies ====&lt;br /&gt;
&lt;br /&gt;
Policy objects describe the default action for packets that did not&lt;br /&gt;
match any filter. The top-level attribute &#039;&#039;&#039;policy&#039;&#039;&#039; is a list of&lt;br /&gt;
policy objects.&lt;br /&gt;
&lt;br /&gt;
Policy objects must have the &#039;&#039;&#039;action&#039;&#039;&#039; attribute defined. The&lt;br /&gt;
possible values and their semantics are the same as in filter objects.&lt;br /&gt;
&lt;br /&gt;
==== NAT Rules ====&lt;br /&gt;
&lt;br /&gt;
NAT rules come in two flavors: &#039;&#039;source NAT rules&#039;&#039; and&lt;br /&gt;
&#039;&#039;destination NAT rules&#039;&#039;. These are contained in two top-level lists&lt;br /&gt;
named &#039;&#039;&#039;snat&#039;&#039;&#039; and &#039;&#039;&#039;dnat&#039;&#039;&#039;, respectively.&lt;br /&gt;
&lt;br /&gt;
Each NAT rule may have an attribute named &#039;&#039;&#039;ip-range&#039;&#039;&#039; that&lt;br /&gt;
specifies the IPv4 address range to which the original source or&lt;br /&gt;
destination address is mapped. The value can be a single IPv4 address&lt;br /&gt;
or a range specified by two addresses, separated with the &#039;&#039;&#039;-&#039;&#039;&#039;&lt;br /&gt;
character. If not defined, it defaults to the primary address of the&lt;br /&gt;
ingress interface in case of destination NAT, or that of the egress&lt;br /&gt;
interface in case of source NAT.&lt;br /&gt;
&lt;br /&gt;
Optionally, a NAT rule can specify the TCP and UDP port range to which&lt;br /&gt;
the original source or destination port is mapped. The attribute is&lt;br /&gt;
named &#039;&#039;&#039;port-range&#039;&#039;&#039;, and the value can be a single port number or a&lt;br /&gt;
range specified by two numbers, separated with the &#039;&#039;&#039;-&#039;&#039;&#039;&lt;br /&gt;
character. If &#039;&#039;&#039;port-range&#039;&#039;&#039; is not specified, the original port&lt;br /&gt;
number is kept intact.&lt;br /&gt;
&lt;br /&gt;
Like filters, NAT rules can have a &#039;&#039;&#039;service&#039;&#039;&#039; attribute&lt;br /&gt;
constraining their scope to specific services.&lt;br /&gt;
&lt;br /&gt;
NAT rules may have an &#039;&#039;&#039;action&#039;&#039;&#039; attribute set to value&lt;br /&gt;
&#039;&#039;&#039;accept&#039;&#039;&#039;. In this case, NAT is not performed on the packets&lt;br /&gt;
reaching and matching this rule.&lt;br /&gt;
&lt;br /&gt;
==== Packet Marking Rules ====&lt;br /&gt;
&lt;br /&gt;
Packet marking rules are used to mark incoming packets matching the&lt;br /&gt;
specified criteria. The mark can be used as a basis for the routing&lt;br /&gt;
decision. Each marking rule must specify the mark using the &#039;&#039;&#039;mark&#039;&#039;&#039;&lt;br /&gt;
attribute, which is a 32-bit integer.&lt;br /&gt;
&lt;br /&gt;
Normal marking rules are contained by the top-level list attribute&lt;br /&gt;
named &#039;&#039;&#039;mark&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
There is another top-level list attribute, named &#039;&#039;&#039;route-track&#039;&#039;&#039;,&lt;br /&gt;
which contains route tracking rules. These are special marking rules&lt;br /&gt;
which cause all the subsequent packets related to the same connection&lt;br /&gt;
to be marked according to the rule.&lt;br /&gt;
&lt;br /&gt;
==== MSS Clamping Rules ====&lt;br /&gt;
&lt;br /&gt;
MSS Clamping Rules are used to deal with ISPs that block ICMP&lt;br /&gt;
Fragmentation Needed or ICMPv6 Packet Too Big packets. An MSS clamping&lt;br /&gt;
rule overwrites the MSS option with a value specified with the&lt;br /&gt;
&#039;&#039;&#039;mss&#039;&#039;&#039; attribute for the matching TCP connections. If &#039;&#039;&#039;mss&#039;&#039;&#039; is&lt;br /&gt;
not specified, a suitable value is automatically determined from the&lt;br /&gt;
path MTU.&lt;br /&gt;
&lt;br /&gt;
==== Connection Tracking Bypass Rules ====&lt;br /&gt;
&lt;br /&gt;
Connection tracking bypass rules are used to disable connection&lt;br /&gt;
tracking for packets matching the specified criteria. The top-level&lt;br /&gt;
attribute &#039;&#039;&#039;no-track&#039;&#039;&#039; is a list of such rules.&lt;br /&gt;
&lt;br /&gt;
Connection tracking bypass rules may have an &#039;&#039;&#039;action&#039;&#039;&#039; attribute&lt;br /&gt;
set to value &#039;&#039;&#039;accept&#039;&#039;&#039;. The effect is similar to corresponding NAT&lt;br /&gt;
rules, i.e. connection tracking is not bypassed for the matching&lt;br /&gt;
packets.&lt;br /&gt;
&lt;br /&gt;
=== IP Sets ===&lt;br /&gt;
&lt;br /&gt;
Any IP set referenced by rule objects should be created by&lt;br /&gt;
awall. Auxiliary &#039;&#039;IP set&#039;&#039; objects are used to defined them in awall&lt;br /&gt;
policy files. The top-level attribute &#039;&#039;&#039;ipset&#039;&#039;&#039; is a dictionary, the&lt;br /&gt;
keys of which are IP set names. The values are IP set objects, which&lt;br /&gt;
have two mandatory attributes. The attribute named &#039;&#039;&#039;type&#039;&#039;&#039; &lt;br /&gt;
corresponds to the type argument of the &amp;lt;tt&amp;gt;ipset create&amp;lt;/tt&amp;gt; &lt;br /&gt;
command. &#039;&#039;&#039;family&#039;&#039;&#039; specifies whether the set is for IPv4 or IPv6&lt;br /&gt;
addresses, and the possible values are &#039;&#039;&#039;inet&#039;&#039;&#039; and &#039;&#039;&#039;inet6&#039;&#039;&#039;,&lt;br /&gt;
correspondingly.&lt;br /&gt;
&lt;br /&gt;
== Command Line Syntax ==&lt;br /&gt;
&lt;br /&gt;
=== Translating Policy Files to Firewall Configuration Files ===&lt;br /&gt;
&lt;br /&gt;
 &#039;&#039;&#039;awall translate&#039;&#039;&#039; [&#039;&#039;&#039;-o&#039;&#039;&#039;|&#039;&#039;&#039;--output&#039;&#039;&#039; DIRECTORY] [&#039;&#039;&#039;-V&#039;&#039;&#039;|&#039;&#039;&#039;--verify&#039;&#039;&#039;]&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;tt&amp;gt;--verify&amp;lt;/tt&amp;gt; option makes awall verify the configuration&lt;br /&gt;
using the test mode of iptables-restore before overwriting the old&lt;br /&gt;
files.&lt;br /&gt;
&lt;br /&gt;
Specifying the output directory allows testing awall policies without&lt;br /&gt;
overwriting the current iptables and ipset configuration files. By&lt;br /&gt;
default, awall generates the configuration to &amp;lt;tt&amp;gt;/etc/iptables&amp;lt;/tt&amp;gt; &lt;br /&gt;
and &amp;lt;tt&amp;gt;/etc/ipset.d&amp;lt;/tt&amp;gt;, which are read by the init scripts.&lt;br /&gt;
&lt;br /&gt;
=== Run-Time Configuration of Firewall ===&lt;br /&gt;
&lt;br /&gt;
 &#039;&#039;&#039;awall activate&#039;&#039;&#039; [&#039;&#039;&#039;-f&#039;&#039;&#039;|&#039;&#039;&#039;--force&#039;&#039;&#039;]&lt;br /&gt;
&lt;br /&gt;
This command genereates firewall configuration from the policy files&lt;br /&gt;
and enables it. If the user confirms the new configuration by hitting&lt;br /&gt;
the Return key within 10 seconds or the &amp;lt;tt&amp;gt;--force&amp;lt;/tt&amp;gt; option is&lt;br /&gt;
used, the configuration is saved to the files. Otherwise, the old&lt;br /&gt;
configuration is restored.&lt;br /&gt;
&lt;br /&gt;
There is also a command for deleting all firewall rules:&lt;br /&gt;
&lt;br /&gt;
 &#039;&#039;&#039;awall flush&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
This command configures the firewall to drop all packets.&lt;br /&gt;
&lt;br /&gt;
=== Optional Policies ===&lt;br /&gt;
&lt;br /&gt;
Optional policies can be enabled or disabled using this command:&lt;br /&gt;
&lt;br /&gt;
 &#039;&#039;&#039;awall&#039;&#039;&#039; {&#039;&#039;&#039;enable&#039;&#039;&#039;|&#039;&#039;&#039;disable&#039;&#039;&#039;} POLICY...&lt;br /&gt;
&lt;br /&gt;
Optional policies can be listed using this command:&lt;br /&gt;
&lt;br /&gt;
 &#039;&#039;&#039;awall list&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;&#039;enabled&#039;&#039;&#039; status means that the policy has been enabled by the&lt;br /&gt;
user. The &#039;&#039;&#039;disabled&#039;&#039;&#039; status means that the policy is not in&lt;br /&gt;
use. The &#039;&#039;&#039;required&#039;&#039;&#039; status means that the policy has not been&lt;br /&gt;
enabled by the user but is in use because it is required by another&lt;br /&gt;
policy which is in use.&lt;br /&gt;
&lt;br /&gt;
=== Debugging Policies ===&lt;br /&gt;
&lt;br /&gt;
This command can be used to dump variable, zone, and other definitions&lt;br /&gt;
as well as their source policies:&lt;br /&gt;
&lt;br /&gt;
 &#039;&#039;&#039;awall dump&#039;&#039;&#039; [LEVEL]&lt;br /&gt;
&lt;br /&gt;
The level is an integer in range 0&amp;amp;ndash;5 and defaults to 0. More&lt;br /&gt;
information is displayed on higher levels.&lt;br /&gt;
&lt;br /&gt;
[[Category:Networking]]&lt;br /&gt;
[[Category:Security]]&lt;/div&gt;</summary>
		<author><name>Kunkku</name></author>
	</entry>
	<entry>
		<id>https://wiki.alpinelinux.org/w/index.php?title=Alpine_Wall_User%27s_Guide&amp;diff=8387</id>
		<title>Alpine Wall User&#039;s Guide</title>
		<link rel="alternate" type="text/html" href="https://wiki.alpinelinux.org/w/index.php?title=Alpine_Wall_User%27s_Guide&amp;diff=8387"/>
		<updated>2012-09-03T11:21:51Z</updated>

		<summary type="html">&lt;p&gt;Kunkku: /* Services */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Configuration File Processing ==&lt;br /&gt;
&lt;br /&gt;
[[Alpine Wall]] (awall) reads its configuration from multiple&lt;br /&gt;
JSON-formatted files, called &#039;&#039;policy files&#039;&#039;. The processing starts&lt;br /&gt;
from directory &amp;lt;tt&amp;gt;/usr/share/awall/mandatory&amp;lt;/tt&amp;gt;, which contains&lt;br /&gt;
mandatory policy files shipped with APK packages. After that,&lt;br /&gt;
installation-specific policy files in &amp;lt;tt&amp;gt;/etc/awall&amp;lt;/tt&amp;gt; are&lt;br /&gt;
processed.&lt;br /&gt;
&lt;br /&gt;
The latter directory may also contain symbolic links to policy files&lt;br /&gt;
located in &amp;lt;tt&amp;gt;/usr/share/awall/optional&amp;lt;/tt&amp;gt;. These are optional&lt;br /&gt;
policies, which can be enabled on need basis. Such symbolic links are&lt;br /&gt;
easily created and destroyed using the &amp;lt;tt&amp;gt;awall enable&amp;lt;/tt&amp;gt; and &lt;br /&gt;
&amp;lt;tt&amp;gt;awall disable&amp;lt;/tt&amp;gt; commands. &amp;lt;tt&amp;gt;awall list&amp;lt;/tt&amp;gt; shows which&lt;br /&gt;
optional policies are enabled and disabled. The command also prints&lt;br /&gt;
the description of the optional policy if defined in the file using&lt;br /&gt;
a top-level attribute named &#039;&#039;&#039;description&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Sometimes a policy file depends on other policy files. In this case,&lt;br /&gt;
the policy file must have a top-level attribute &#039;&#039;&#039;import&#039;&#039;&#039;, the&lt;br /&gt;
value of which is a list of policy names, which correspond to the file&lt;br /&gt;
names without the &amp;lt;tt&amp;gt;.json&amp;lt;/tt&amp;gt; suffix. By default, the policies&lt;br /&gt;
listed there are processed before the importing policy.&lt;br /&gt;
&lt;br /&gt;
The order of the generated iptables rules generally reflects the&lt;br /&gt;
processing order of their corresponding awall policies. The processing&lt;br /&gt;
order of policies can be adjusted by defining top-level attributes&lt;br /&gt;
&#039;&#039;&#039;after&#039;&#039;&#039; and &#039;&#039;&#039;before&#039;&#039;&#039; in policy files. These attributes are&lt;br /&gt;
lists of policies, after or before which the declaring policy shall be&lt;br /&gt;
processed. Putting a policy name to either of these lists does not by&lt;br /&gt;
itself import the policy. The ordering directives are ignored with&lt;br /&gt;
respect to those policies that are not enabled by the user or imported&lt;br /&gt;
by other policies. If not defined, &#039;&#039;&#039;after&#039;&#039;&#039; is assumed to be equal&lt;br /&gt;
to the &#039;&#039;&#039;import&#039;&#039;&#039; definition of the policy.&lt;br /&gt;
&lt;br /&gt;
As the import directive does not require the path name to be&lt;br /&gt;
specified, awall expects policies to have unique names, even if&lt;br /&gt;
located in different directories. It is allowed to import optional&lt;br /&gt;
policies that are not explicitly enabled by the user. Such policies&lt;br /&gt;
show up with the &amp;lt;tt&amp;gt;required&amp;lt;/tt&amp;gt; status in the output of &amp;lt;tt&amp;gt;awall&lt;br /&gt;
list&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
== List Parameters ==&lt;br /&gt;
&lt;br /&gt;
Several awall parameters are defined as lists of values. In order to&lt;br /&gt;
facilitate manual editing of policy files, awall also accepts single&lt;br /&gt;
values in place of lists. Such values are semantically equivalent to&lt;br /&gt;
lists containing one element.&lt;br /&gt;
&lt;br /&gt;
== Variable Expansion ==&lt;br /&gt;
&lt;br /&gt;
Awall allows variable definitions in policy files. The top-level&lt;br /&gt;
attribute &#039;&#039;&#039;variable&#039;&#039;&#039; is a dictionary containing the&lt;br /&gt;
definitions. The value of a variable can be of any type (string,&lt;br /&gt;
integer, list, or dictionary).&lt;br /&gt;
&lt;br /&gt;
A variable is referenced in policy files by a string which equals the&lt;br /&gt;
variable name prepended with the &#039;&#039;&#039;$&#039;&#039;&#039; character. If the value of&lt;br /&gt;
the variable is a string, the reference can be embedded into a longer&lt;br /&gt;
string in order to substitute some part of that string (in shell&lt;br /&gt;
style). Variable references can be used when defining other variables,&lt;br /&gt;
as long as the definitions are not circular.&lt;br /&gt;
&lt;br /&gt;
Policy files can reference variables defined in other policy&lt;br /&gt;
files. Policy files can also override variables defined elsewhere by&lt;br /&gt;
redefining them. In this case, the new definition affects all policy&lt;br /&gt;
files, also those processed before the overriding policy. Awall&lt;br /&gt;
variables are in fact simple macros, since each variable remains&lt;br /&gt;
constant thoughout a single processing round. If multiple files define&lt;br /&gt;
the same variable, the definition in the file processed last takes&lt;br /&gt;
effect.&lt;br /&gt;
&lt;br /&gt;
If defined as an empty string, all non-embedded references to a&lt;br /&gt;
variable evaluate as if the attribute in question was not present in&lt;br /&gt;
the configuration. This is also the case when a string containing&lt;br /&gt;
embedded variable references finally evaluates to an empty string.&lt;br /&gt;
&lt;br /&gt;
== Configuration Objects ==&lt;br /&gt;
&lt;br /&gt;
Configuration objects can be divided into two main types.&lt;br /&gt;
&#039;&#039;Auxiliary objects&#039;&#039; model high-level concepts such as services and&lt;br /&gt;
zones. &#039;&#039;Rule objects&#039;&#039; translate into one or more iptables rules, and&lt;br /&gt;
are often defined with the help of some auxiliary objects.&lt;br /&gt;
&lt;br /&gt;
=== Services ===&lt;br /&gt;
&lt;br /&gt;
A &#039;&#039;service&#039;&#039; represents a set of network protocols. A top-level&lt;br /&gt;
attribute &#039;&#039;&#039;service&#039;&#039;&#039; is a dictionary that maps service names to&lt;br /&gt;
service definition objects, or lists thereof in more complex cases.&lt;br /&gt;
&lt;br /&gt;
A service definition object contains an attribute named &#039;&#039;&#039;proto&#039;&#039;&#039;,&lt;br /&gt;
which corresponds to the &amp;lt;tt&amp;gt;--protocol&amp;lt;/tt&amp;gt; option of iptables. The&lt;br /&gt;
protocol can be defined as a numerical value or string as defined in&lt;br /&gt;
&amp;lt;tt&amp;gt;/etc/protocols&amp;lt;/tt&amp;gt;. If the protocol is &#039;&#039;&#039;tcp&#039;&#039;&#039; or &#039;&#039;&#039;udp&#039;&#039;&#039;,&lt;br /&gt;
the scope of the service definition may be constrained by defining an&lt;br /&gt;
attribute named &#039;&#039;&#039;port&#039;&#039;&#039;, which is a list of TCP or UDP port numbers&lt;br /&gt;
or ranges thereof, separated by the &#039;&#039;&#039;-&#039;&#039;&#039; character. If the protocol&lt;br /&gt;
is &#039;&#039;&#039;icmp&#039;&#039;&#039; or &#039;&#039;&#039;icmpv6&#039;&#039;&#039;, an analogous &#039;&#039;&#039;icmp-type&#039;&#039;&#039; attribute&lt;br /&gt;
may be used. In addition, the scope of the rule is also automatically&lt;br /&gt;
limited to IPv4 or IPv6, respectively.&lt;br /&gt;
&lt;br /&gt;
=== Zones ===&lt;br /&gt;
&lt;br /&gt;
A &#039;&#039;zone&#039;&#039; represents a set of network hosts. A top-level attribute &lt;br /&gt;
&#039;&#039;&#039;zone&#039;&#039;&#039; is a dictionary that maps zone names to zone objects. A&lt;br /&gt;
zone object has an attribute named &#039;&#039;&#039;iface&#039;&#039;&#039;, &#039;&#039;&#039;addr&#039;&#039;&#039;, or&lt;br /&gt;
both. &#039;&#039;&#039;iface&#039;&#039;&#039; is a list of network interfaces and &#039;&#039;&#039;addr&#039;&#039;&#039; is a&lt;br /&gt;
list of IPv4/IPv6 host and network addresses (CIDR&lt;br /&gt;
notation). &#039;&#039;&#039;addr&#039;&#039;&#039; may also contain domain names, which are&lt;br /&gt;
expanded to IP addresses using DNS resolution. If not defined,&lt;br /&gt;
&#039;&#039;&#039;addr&#039;&#039;&#039; defaults to the entire address space and &#039;&#039;&#039;iface&#039;&#039;&#039; to all&lt;br /&gt;
interfaces. An empty zone can be defined by setting either &#039;&#039;&#039;addr&#039;&#039;&#039;&lt;br /&gt;
or &#039;&#039;&#039;iface&#039;&#039;&#039; to an empty list.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Rule objects contain two attributes, &#039;&#039;&#039;in&#039;&#039;&#039; and &#039;&#039;&#039;out&#039;&#039;&#039;, which are&lt;br /&gt;
lists of zone names. These attributes control whether a packet matches&lt;br /&gt;
the rule or not. If a particular zone is referenced by the &#039;&#039;&#039;in&#039;&#039;&#039; &lt;br /&gt;
attribute, the rule applies to packets whose ingress interface and&lt;br /&gt;
source address are covered by the zone definition. Correspondingly, if&lt;br /&gt;
a zone is referenced by the &#039;&#039;&#039;out&#039;&#039;&#039; attribute, the rule applies to&lt;br /&gt;
packets whose egress interface and destination address are included in&lt;br /&gt;
the zone. If both &#039;&#039;&#039;in&#039;&#039;&#039; and &#039;&#039;&#039;out&#039;&#039;&#039; are defined, the packet must&lt;br /&gt;
fulfill both criteria in order to match the rule.&lt;br /&gt;
&lt;br /&gt;
The firewall host itself can be referred to using the special value&lt;br /&gt;
&#039;&#039;&#039;_fw&#039;&#039;&#039; as the zone name.&lt;br /&gt;
&lt;br /&gt;
=== Logging Classes ===&lt;br /&gt;
&lt;br /&gt;
A &#039;&#039;logging class&#039;&#039; specifies how packets matching certain rules are&lt;br /&gt;
logged. A top-level attribute &#039;&#039;&#039;log&#039;&#039;&#039; is a dictionary that maps&lt;br /&gt;
logging class names to setting objects.&lt;br /&gt;
&lt;br /&gt;
A setting object may have an attribute named &#039;&#039;&#039;mode&#039;&#039;&#039;, which&lt;br /&gt;
specifies which logging facility to use. Allowed values are &#039;&#039;&#039;log&#039;&#039;&#039;,&lt;br /&gt;
&#039;&#039;&#039;nflog&#039;&#039;&#039;, and &#039;&#039;&#039;ulog&#039;&#039;&#039;. The default is &#039;&#039;&#039;log&#039;&#039;&#039;, i.e. in-kernel&lt;br /&gt;
logging. The object may also have a &#039;&#039;&#039;limit&#039;&#039;&#039; attribute, which is an&lt;br /&gt;
integer specifying the maximum number of matching packets to be logged&lt;br /&gt;
per second per rule.&lt;br /&gt;
&lt;br /&gt;
Filter and policy rules can have an attribute named &#039;&#039;&#039;log&#039;&#039;&#039;. If it&lt;br /&gt;
is a string, it is interpreted as a reference to a logging class, and&lt;br /&gt;
logging is performed according to the definitions. If the value of the&lt;br /&gt;
&#039;&#039;&#039;log&#039;&#039;&#039; attribute is &#039;&#039;&#039;true&#039;&#039;&#039; (boolean), logging is done using&lt;br /&gt;
default settings. If the value is &#039;&#039;&#039;false&#039;&#039;&#039; (boolean), logging is&lt;br /&gt;
disabled for the rule. If &#039;&#039;&#039;log&#039;&#039;&#039; is not defined, logging is done&lt;br /&gt;
using the default settings except for accept rules, for which logging&lt;br /&gt;
is omitted.&lt;br /&gt;
&lt;br /&gt;
Default logging settings can be set by defining a logging class named&lt;br /&gt;
&#039;&#039;&#039;_default&#039;&#039;&#039;. Normally, default logging uses the &#039;&#039;&#039;log&#039;&#039;&#039; mode with&lt;br /&gt;
packets limited to one per second.&lt;br /&gt;
&lt;br /&gt;
=== Rules ===&lt;br /&gt;
&lt;br /&gt;
There are five types of rule objects:&lt;br /&gt;
* policies&lt;br /&gt;
* filters&lt;br /&gt;
* NAT rules&lt;br /&gt;
* packet marking rules&lt;br /&gt;
* MSS clamping rules&lt;br /&gt;
* connection tracking bypass rules&lt;br /&gt;
&lt;br /&gt;
All rule objects can have the &#039;&#039;&#039;in&#039;&#039;&#039; and &#039;&#039;&#039;out&#039;&#039;&#039; attributes&lt;br /&gt;
referring to zones as described in the previous section. In addition,&lt;br /&gt;
the scope of the rule can be further constrained with the following&lt;br /&gt;
attributes:&lt;br /&gt;
&lt;br /&gt;
{|&lt;br /&gt;
!Attribute!!Value format!!Effect&lt;br /&gt;
|-&lt;br /&gt;
|&#039;&#039;&#039;src&#039;&#039;&#039;&lt;br /&gt;
|Similar to &#039;&#039;&#039;addr&#039;&#039;&#039; attribute of zone objects&lt;br /&gt;
|Packet&#039;s source address matches the value&lt;br /&gt;
|-&lt;br /&gt;
|&#039;&#039;&#039;dest&#039;&#039;&#039;&lt;br /&gt;
|Similar to &#039;&#039;&#039;addr&#039;&#039;&#039; attribute of zone objects&lt;br /&gt;
|Packet&#039;s destination address matches the value&lt;br /&gt;
|-&lt;br /&gt;
|&#039;&#039;&#039;ipset&#039;&#039;&#039;&lt;br /&gt;
|Object containing two attributes: &#039;&#039;&#039;name&#039;&#039;&#039; referring to an IP set and &#039;&#039;&#039;args&#039;&#039;&#039;, which is a list of strings &#039;&#039;&#039;in&#039;&#039;&#039; and &#039;&#039;&#039;out&#039;&#039;&#039;&lt;br /&gt;
|Packet matches the IP set referred here when the match arguments are taken from the source (&#039;&#039;&#039;in&#039;&#039;&#039;) and destination (&#039;&#039;&#039;out&#039;&#039;&#039;) address or port in the order specified by &#039;&#039;&#039;args&#039;&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
|&#039;&#039;&#039;ipsec&#039;&#039;&#039;&lt;br /&gt;
|&#039;&#039;&#039;in&#039;&#039;&#039; or &#039;&#039;&#039;out&#039;&#039;&#039;&lt;br /&gt;
|IPsec decapsulation perfomed on ingress (&#039;&#039;&#039;in&#039;&#039;&#039;) or encapsulation performed on egress (&#039;&#039;&#039;out&#039;&#039;&#039;)&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Rule objects are declared in type-specific top-level dictionaries in&lt;br /&gt;
awall policy files. If a packet matches multiple rules, the one&lt;br /&gt;
appearing earlier in the list takes precedence. If the matching rules&lt;br /&gt;
are defined in different policy files, the one that was processed&lt;br /&gt;
earlier takes precedence in the current implementation, but this may&lt;br /&gt;
change in future versions.&lt;br /&gt;
&lt;br /&gt;
==== Filters ====&lt;br /&gt;
&lt;br /&gt;
Filter objects specify an action for packets fulfilling certain&lt;br /&gt;
criteria. The top-level attribute &#039;&#039;&#039;filter&#039;&#039;&#039; is a list of filter&lt;br /&gt;
objects. The precedence rules are similar to those of policy objects.&lt;br /&gt;
&lt;br /&gt;
In addition to the common rule attributes, filter objects can have a &lt;br /&gt;
&#039;&#039;&#039;service&#039;&#039;&#039; attribute constraining the scope to specific services&lt;br /&gt;
only. This attribute is a list of service names, referring to the&lt;br /&gt;
keys of the top-level &#039;&#039;&#039;service&#039;&#039;&#039; dictionary.&lt;br /&gt;
&lt;br /&gt;
Filter objects must have an attribute named &#039;&#039;&#039;action&#039;&#039;&#039;, the value of&lt;br /&gt;
which can be one of the following:&lt;br /&gt;
&lt;br /&gt;
{|&lt;br /&gt;
!Value!!Action&lt;br /&gt;
|-&lt;br /&gt;
|&#039;&#039;&#039;accept&#039;&#039;&#039;&lt;br /&gt;
|Accept the packet&lt;br /&gt;
|-&lt;br /&gt;
|&#039;&#039;&#039;reject&#039;&#039;&#039;&lt;br /&gt;
|Reject the packet with an ICMP error message&lt;br /&gt;
|-&lt;br /&gt;
|&#039;&#039;&#039;drop&#039;&#039;&#039;&lt;br /&gt;
|Silently drop the packet&lt;br /&gt;
|-&lt;br /&gt;
|&#039;&#039;&#039;tarpit&#039;&#039;&#039;&lt;br /&gt;
|Put incoming TCP connections into persist state and ignore attempts to close them. Silently drop non-TCP packets. (Connection tracking bypass is automatically enabled for the matching packets.)&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Filter objects, the action of which is &#039;&#039;&#039;accept&#039;&#039;&#039;, may also contain&lt;br /&gt;
limits for packet flow or new connections. These are specified with&lt;br /&gt;
the &#039;&#039;&#039;flow-limit&#039;&#039;&#039; and &#039;&#039;&#039;conn-limit&#039;&#039;&#039; attributes,&lt;br /&gt;
respectively. The values of these attributes are limit objects that&lt;br /&gt;
have two attributes: &#039;&#039;&#039;count&#039;&#039;&#039; and &#039;&#039;&#039;interval&#039;&#039;&#039;. &#039;&#039;&#039;count&#039;&#039;&#039;&lt;br /&gt;
specifies how many new connections or packets are allowed within the&lt;br /&gt;
time frame specified by &#039;&#039;&#039;interval&#039;&#039;&#039; (in seconds). The &#039;&#039;&#039;logdrop&#039;&#039;&#039;&lt;br /&gt;
action is applied to the packets exceeding the limit.&lt;br /&gt;
&lt;br /&gt;
Filter objects may have an attribute named &#039;&#039;&#039;dnat&#039;&#039;&#039;, the value of&lt;br /&gt;
which is an IPv4 address. If defined, this enables destination NAT for&lt;br /&gt;
all IPv4 packets matching the rule, such that the specified address&lt;br /&gt;
replaces the original destination address. This option has no effect&lt;br /&gt;
on IPv6 packets.&lt;br /&gt;
&lt;br /&gt;
Filter objects may have a boolean attribute named &#039;&#039;&#039;no-track&#039;&#039;&#039;. If&lt;br /&gt;
set to &#039;&#039;&#039;true&#039;&#039;&#039;, connection tracking is bypassed for the matching&lt;br /&gt;
packets. In addition, if &#039;&#039;&#039;action&#039;&#039;&#039; is set to &#039;&#039;&#039;accept&#039;&#039;&#039;, the&lt;br /&gt;
corresponding packets travelling to the reverse direction are also&lt;br /&gt;
allowed.&lt;br /&gt;
&lt;br /&gt;
==== Policies ====&lt;br /&gt;
&lt;br /&gt;
Policy objects describe the default action for packets that did not&lt;br /&gt;
match any filter. The top-level attribute &#039;&#039;&#039;policy&#039;&#039;&#039; is a list of&lt;br /&gt;
policy objects.&lt;br /&gt;
&lt;br /&gt;
Policy objects must have the &#039;&#039;&#039;action&#039;&#039;&#039; attribute defined. The&lt;br /&gt;
possible values and their semantics are the same as in filter objects.&lt;br /&gt;
&lt;br /&gt;
==== NAT Rules ====&lt;br /&gt;
&lt;br /&gt;
NAT rules come in two flavors: &#039;&#039;source NAT rules&#039;&#039; and&lt;br /&gt;
&#039;&#039;destination NAT rules&#039;&#039;. These are contained in two top-level lists&lt;br /&gt;
named &#039;&#039;&#039;snat&#039;&#039;&#039; and &#039;&#039;&#039;dnat&#039;&#039;&#039;, respectively.&lt;br /&gt;
&lt;br /&gt;
Each NAT rule may have an attribute named &#039;&#039;&#039;ip-range&#039;&#039;&#039; that&lt;br /&gt;
specifies the IPv4 address range to which the original source or&lt;br /&gt;
destination address is mapped. The value can be a single IPv4 address&lt;br /&gt;
or a range specified by two addresses, separated with the &#039;&#039;&#039;-&#039;&#039;&#039;&lt;br /&gt;
character. If not defined, it defaults to the primary address of the&lt;br /&gt;
ingress interface in case of destination NAT, or that of the egress&lt;br /&gt;
interface in case of source NAT.&lt;br /&gt;
&lt;br /&gt;
Optionally, a NAT rule can specify the TCP and UDP port range to which&lt;br /&gt;
the original source or destination port is mapped. The attribute is&lt;br /&gt;
named &#039;&#039;&#039;port-range&#039;&#039;&#039;, and the value can be a single port number or a&lt;br /&gt;
range specified by two numbers, separated with the &#039;&#039;&#039;-&#039;&#039;&#039;&lt;br /&gt;
character. If &#039;&#039;&#039;port-range&#039;&#039;&#039; is not specified, the original port&lt;br /&gt;
number is kept intact.&lt;br /&gt;
&lt;br /&gt;
Like filters, NAT rules can have a &#039;&#039;&#039;service&#039;&#039;&#039; attribute&lt;br /&gt;
constraining their scope to specific services.&lt;br /&gt;
&lt;br /&gt;
NAT rules may have an &#039;&#039;&#039;action&#039;&#039;&#039; attribute set to value&lt;br /&gt;
&#039;&#039;&#039;accept&#039;&#039;&#039;. In this case, NAT is not performed on the packets&lt;br /&gt;
reaching and matching this rule.&lt;br /&gt;
&lt;br /&gt;
==== Packet Marking Rules ====&lt;br /&gt;
&lt;br /&gt;
Packet marking rules are used to mark incoming packets matching the&lt;br /&gt;
specified criteria. The mark can be used as a basis for the routing&lt;br /&gt;
decision. Each marking rule must specify the mark using the &#039;&#039;&#039;mark&#039;&#039;&#039;&lt;br /&gt;
attribute, which is a 32-bit integer.&lt;br /&gt;
&lt;br /&gt;
Normal marking rules are contained by the top-level list attribute&lt;br /&gt;
named &#039;&#039;&#039;mark&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
There is another top-level list attribute, named &#039;&#039;&#039;route-track&#039;&#039;&#039;,&lt;br /&gt;
which contains route tracking rules. These are special marking rules&lt;br /&gt;
which cause all the subsequent packets related to the same connection&lt;br /&gt;
to be marked according to the rule.&lt;br /&gt;
&lt;br /&gt;
==== MSS Clamping Rules ====&lt;br /&gt;
&lt;br /&gt;
MSS Clamping Rules are used to deal with ISPs that block ICMP&lt;br /&gt;
Fragmentation Needed or ICMPv6 Packet Too Big packets. An MSS clamping&lt;br /&gt;
rule overwrites the MSS option with a value specified with the&lt;br /&gt;
&#039;&#039;&#039;mss&#039;&#039;&#039; attribute for the matching TCP connections. If &#039;&#039;&#039;mss&#039;&#039;&#039; is&lt;br /&gt;
not specified, a suitable value is automatically determined from the&lt;br /&gt;
path MTU.&lt;br /&gt;
&lt;br /&gt;
==== Connection Tracking Bypass Rules ====&lt;br /&gt;
&lt;br /&gt;
Connection tracking bypass rules are used to disable connection&lt;br /&gt;
tracking for packets matching the specified criteria. The top-level&lt;br /&gt;
attribute &#039;&#039;&#039;no-track&#039;&#039;&#039; is a list of such rules.&lt;br /&gt;
&lt;br /&gt;
Connection tracking bypass rules may have an &#039;&#039;&#039;action&#039;&#039;&#039; attribute&lt;br /&gt;
set to value &#039;&#039;&#039;accept&#039;&#039;&#039;. The effect is similar to corresponding NAT&lt;br /&gt;
rules, i.e. connection tracking is not bypassed for the matching&lt;br /&gt;
packets.&lt;br /&gt;
&lt;br /&gt;
=== IP Sets ===&lt;br /&gt;
&lt;br /&gt;
Any IP set referenced by rule objects should be created by&lt;br /&gt;
awall. Auxiliary &#039;&#039;IP set&#039;&#039; objects are used to defined them in awall&lt;br /&gt;
policy files. The top-level attribute &#039;&#039;&#039;ipset&#039;&#039;&#039; is a dictionary, the&lt;br /&gt;
keys of which are IP set names. The values are IP set objects, which&lt;br /&gt;
have two mandatory attributes. The attribute named &#039;&#039;&#039;type&#039;&#039;&#039; &lt;br /&gt;
corresponds to the type argument of the &amp;lt;tt&amp;gt;ipset create&amp;lt;/tt&amp;gt; &lt;br /&gt;
command. &#039;&#039;&#039;family&#039;&#039;&#039; specifies whether the set is for IPv4 or IPv6&lt;br /&gt;
addresses, and the possible values are &#039;&#039;&#039;inet&#039;&#039;&#039; and &#039;&#039;&#039;inet6&#039;&#039;&#039;,&lt;br /&gt;
correspondingly.&lt;br /&gt;
&lt;br /&gt;
== Command Line Syntax ==&lt;br /&gt;
&lt;br /&gt;
=== Translating Policy Files to Firewall Configuration Files ===&lt;br /&gt;
&lt;br /&gt;
 &#039;&#039;&#039;awall translate&#039;&#039;&#039; [&#039;&#039;&#039;-o&#039;&#039;&#039;|&#039;&#039;&#039;--output&#039;&#039;&#039; DIRECTORY] [&#039;&#039;&#039;-V&#039;&#039;&#039;|&#039;&#039;&#039;--verify&#039;&#039;&#039;]&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;tt&amp;gt;--verify&amp;lt;/tt&amp;gt; option makes awall verify the configuration&lt;br /&gt;
using the test mode of iptables-restore before overwriting the old&lt;br /&gt;
files.&lt;br /&gt;
&lt;br /&gt;
Specifying the output directory allows testing awall policies without&lt;br /&gt;
overwriting the current iptables and ipset configuration files. By&lt;br /&gt;
default, awall generates the configuration to &amp;lt;tt&amp;gt;/etc/iptables&amp;lt;/tt&amp;gt; &lt;br /&gt;
and &amp;lt;tt&amp;gt;/etc/ipset.d&amp;lt;/tt&amp;gt;, which are read by the init scripts.&lt;br /&gt;
&lt;br /&gt;
=== Run-Time Configuration of Firewall ===&lt;br /&gt;
&lt;br /&gt;
 &#039;&#039;&#039;awall activate&#039;&#039;&#039; [&#039;&#039;&#039;-f&#039;&#039;&#039;|&#039;&#039;&#039;--force&#039;&#039;&#039;]&lt;br /&gt;
&lt;br /&gt;
This command genereates firewall configuration from the policy files&lt;br /&gt;
and enables it. If the user confirms the new configuration by hitting&lt;br /&gt;
the Return key within 10 seconds or the &amp;lt;tt&amp;gt;--force&amp;lt;/tt&amp;gt; option is&lt;br /&gt;
used, the configuration is saved to the files. Otherwise, the old&lt;br /&gt;
configuration is restored.&lt;br /&gt;
&lt;br /&gt;
There is also a command for deleting all firewall rules:&lt;br /&gt;
&lt;br /&gt;
 &#039;&#039;&#039;awall flush&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
This command configures the firewall to drop all packets.&lt;br /&gt;
&lt;br /&gt;
=== Optional Policies ===&lt;br /&gt;
&lt;br /&gt;
Optional policies can be enabled or disabled using this command:&lt;br /&gt;
&lt;br /&gt;
 &#039;&#039;&#039;awall&#039;&#039;&#039; {&#039;&#039;&#039;enable&#039;&#039;&#039;|&#039;&#039;&#039;disable&#039;&#039;&#039;} POLICY...&lt;br /&gt;
&lt;br /&gt;
Optional policies can be listed using this command:&lt;br /&gt;
&lt;br /&gt;
 &#039;&#039;&#039;awall list&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;&#039;enabled&#039;&#039;&#039; status means that the policy has been enabled by the&lt;br /&gt;
user. The &#039;&#039;&#039;disabled&#039;&#039;&#039; status means that the policy is not in&lt;br /&gt;
use. The &#039;&#039;&#039;required&#039;&#039;&#039; status means that the policy has not been&lt;br /&gt;
enabled by the user but is in use because it is required by another&lt;br /&gt;
policy which is in use.&lt;br /&gt;
&lt;br /&gt;
=== Debugging Policies ===&lt;br /&gt;
&lt;br /&gt;
This command can be used to dump variable, zone, and other definitions&lt;br /&gt;
as well as their source policies:&lt;br /&gt;
&lt;br /&gt;
 &#039;&#039;&#039;awall dump&#039;&#039;&#039; [LEVEL]&lt;br /&gt;
&lt;br /&gt;
The level is an integer in range 0&amp;amp;ndash;5 and defaults to 0. More&lt;br /&gt;
information is displayed on higher levels.&lt;br /&gt;
&lt;br /&gt;
[[Category:Networking]]&lt;br /&gt;
[[Category:Security]]&lt;/div&gt;</summary>
		<author><name>Kunkku</name></author>
	</entry>
	<entry>
		<id>https://wiki.alpinelinux.org/w/index.php?title=Alpine_Wall_User%27s_Guide&amp;diff=8386</id>
		<title>Alpine Wall User&#039;s Guide</title>
		<link rel="alternate" type="text/html" href="https://wiki.alpinelinux.org/w/index.php?title=Alpine_Wall_User%27s_Guide&amp;diff=8386"/>
		<updated>2012-09-03T11:19:50Z</updated>

		<summary type="html">&lt;p&gt;Kunkku: /* Filters */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Configuration File Processing ==&lt;br /&gt;
&lt;br /&gt;
[[Alpine Wall]] (awall) reads its configuration from multiple&lt;br /&gt;
JSON-formatted files, called &#039;&#039;policy files&#039;&#039;. The processing starts&lt;br /&gt;
from directory &amp;lt;tt&amp;gt;/usr/share/awall/mandatory&amp;lt;/tt&amp;gt;, which contains&lt;br /&gt;
mandatory policy files shipped with APK packages. After that,&lt;br /&gt;
installation-specific policy files in &amp;lt;tt&amp;gt;/etc/awall&amp;lt;/tt&amp;gt; are&lt;br /&gt;
processed.&lt;br /&gt;
&lt;br /&gt;
The latter directory may also contain symbolic links to policy files&lt;br /&gt;
located in &amp;lt;tt&amp;gt;/usr/share/awall/optional&amp;lt;/tt&amp;gt;. These are optional&lt;br /&gt;
policies, which can be enabled on need basis. Such symbolic links are&lt;br /&gt;
easily created and destroyed using the &amp;lt;tt&amp;gt;awall enable&amp;lt;/tt&amp;gt; and &lt;br /&gt;
&amp;lt;tt&amp;gt;awall disable&amp;lt;/tt&amp;gt; commands. &amp;lt;tt&amp;gt;awall list&amp;lt;/tt&amp;gt; shows which&lt;br /&gt;
optional policies are enabled and disabled. The command also prints&lt;br /&gt;
the description of the optional policy if defined in the file using&lt;br /&gt;
a top-level attribute named &#039;&#039;&#039;description&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Sometimes a policy file depends on other policy files. In this case,&lt;br /&gt;
the policy file must have a top-level attribute &#039;&#039;&#039;import&#039;&#039;&#039;, the&lt;br /&gt;
value of which is a list of policy names, which correspond to the file&lt;br /&gt;
names without the &amp;lt;tt&amp;gt;.json&amp;lt;/tt&amp;gt; suffix. By default, the policies&lt;br /&gt;
listed there are processed before the importing policy.&lt;br /&gt;
&lt;br /&gt;
The order of the generated iptables rules generally reflects the&lt;br /&gt;
processing order of their corresponding awall policies. The processing&lt;br /&gt;
order of policies can be adjusted by defining top-level attributes&lt;br /&gt;
&#039;&#039;&#039;after&#039;&#039;&#039; and &#039;&#039;&#039;before&#039;&#039;&#039; in policy files. These attributes are&lt;br /&gt;
lists of policies, after or before which the declaring policy shall be&lt;br /&gt;
processed. Putting a policy name to either of these lists does not by&lt;br /&gt;
itself import the policy. The ordering directives are ignored with&lt;br /&gt;
respect to those policies that are not enabled by the user or imported&lt;br /&gt;
by other policies. If not defined, &#039;&#039;&#039;after&#039;&#039;&#039; is assumed to be equal&lt;br /&gt;
to the &#039;&#039;&#039;import&#039;&#039;&#039; definition of the policy.&lt;br /&gt;
&lt;br /&gt;
As the import directive does not require the path name to be&lt;br /&gt;
specified, awall expects policies to have unique names, even if&lt;br /&gt;
located in different directories. It is allowed to import optional&lt;br /&gt;
policies that are not explicitly enabled by the user. Such policies&lt;br /&gt;
show up with the &amp;lt;tt&amp;gt;required&amp;lt;/tt&amp;gt; status in the output of &amp;lt;tt&amp;gt;awall&lt;br /&gt;
list&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
== List Parameters ==&lt;br /&gt;
&lt;br /&gt;
Several awall parameters are defined as lists of values. In order to&lt;br /&gt;
facilitate manual editing of policy files, awall also accepts single&lt;br /&gt;
values in place of lists. Such values are semantically equivalent to&lt;br /&gt;
lists containing one element.&lt;br /&gt;
&lt;br /&gt;
== Variable Expansion ==&lt;br /&gt;
&lt;br /&gt;
Awall allows variable definitions in policy files. The top-level&lt;br /&gt;
attribute &#039;&#039;&#039;variable&#039;&#039;&#039; is a dictionary containing the&lt;br /&gt;
definitions. The value of a variable can be of any type (string,&lt;br /&gt;
integer, list, or dictionary).&lt;br /&gt;
&lt;br /&gt;
A variable is referenced in policy files by a string which equals the&lt;br /&gt;
variable name prepended with the &#039;&#039;&#039;$&#039;&#039;&#039; character. If the value of&lt;br /&gt;
the variable is a string, the reference can be embedded into a longer&lt;br /&gt;
string in order to substitute some part of that string (in shell&lt;br /&gt;
style). Variable references can be used when defining other variables,&lt;br /&gt;
as long as the definitions are not circular.&lt;br /&gt;
&lt;br /&gt;
Policy files can reference variables defined in other policy&lt;br /&gt;
files. Policy files can also override variables defined elsewhere by&lt;br /&gt;
redefining them. In this case, the new definition affects all policy&lt;br /&gt;
files, also those processed before the overriding policy. Awall&lt;br /&gt;
variables are in fact simple macros, since each variable remains&lt;br /&gt;
constant thoughout a single processing round. If multiple files define&lt;br /&gt;
the same variable, the definition in the file processed last takes&lt;br /&gt;
effect.&lt;br /&gt;
&lt;br /&gt;
If defined as an empty string, all non-embedded references to a&lt;br /&gt;
variable evaluate as if the attribute in question was not present in&lt;br /&gt;
the configuration. This is also the case when a string containing&lt;br /&gt;
embedded variable references finally evaluates to an empty string.&lt;br /&gt;
&lt;br /&gt;
== Configuration Objects ==&lt;br /&gt;
&lt;br /&gt;
Configuration objects can be divided into two main types.&lt;br /&gt;
&#039;&#039;Auxiliary objects&#039;&#039; model high-level concepts such as services and&lt;br /&gt;
zones. &#039;&#039;Rule objects&#039;&#039; translate into one or more iptables rules, and&lt;br /&gt;
are often defined with the help of some auxiliary objects.&lt;br /&gt;
&lt;br /&gt;
=== Services ===&lt;br /&gt;
&lt;br /&gt;
A &#039;&#039;service&#039;&#039; represents a set of network protocols. A top-level&lt;br /&gt;
attribute &#039;&#039;&#039;service&#039;&#039;&#039; is a dictionary that maps service names to&lt;br /&gt;
service definition objects, or lists thereof in more complex cases.&lt;br /&gt;
&lt;br /&gt;
A service definition object contains an attribute named &#039;&#039;&#039;proto&#039;&#039;&#039;,&lt;br /&gt;
which corresponds to the &amp;lt;tt&amp;gt;--protocol&amp;lt;/tt&amp;gt; option of iptables. The&lt;br /&gt;
protocol can be defined as a numerical value or string as defined in&lt;br /&gt;
&amp;lt;tt&amp;gt;/etc/protocols&amp;lt;/tt&amp;gt;. If the protocol is &#039;&#039;&#039;tcp&#039;&#039;&#039; or &#039;&#039;&#039;udp&#039;&#039;&#039;,&lt;br /&gt;
the scope of the service definition may be constrained by defining an&lt;br /&gt;
attribute named &#039;&#039;&#039;port&#039;&#039;&#039;, which is a list of TCP or UDP port&lt;br /&gt;
numbers. If the protocol is &#039;&#039;&#039;icmp&#039;&#039;&#039; or &#039;&#039;&#039;icmpv6&#039;&#039;&#039;, an analogous &lt;br /&gt;
&#039;&#039;&#039;icmp-type&#039;&#039;&#039; attribute may be used. In addition, the scope of the&lt;br /&gt;
rule is also automatically limited to IPv4 or IPv6, respectively.&lt;br /&gt;
&lt;br /&gt;
=== Zones ===&lt;br /&gt;
&lt;br /&gt;
A &#039;&#039;zone&#039;&#039; represents a set of network hosts. A top-level attribute &lt;br /&gt;
&#039;&#039;&#039;zone&#039;&#039;&#039; is a dictionary that maps zone names to zone objects. A&lt;br /&gt;
zone object has an attribute named &#039;&#039;&#039;iface&#039;&#039;&#039;, &#039;&#039;&#039;addr&#039;&#039;&#039;, or&lt;br /&gt;
both. &#039;&#039;&#039;iface&#039;&#039;&#039; is a list of network interfaces and &#039;&#039;&#039;addr&#039;&#039;&#039; is a&lt;br /&gt;
list of IPv4/IPv6 host and network addresses (CIDR&lt;br /&gt;
notation). &#039;&#039;&#039;addr&#039;&#039;&#039; may also contain domain names, which are&lt;br /&gt;
expanded to IP addresses using DNS resolution. If not defined,&lt;br /&gt;
&#039;&#039;&#039;addr&#039;&#039;&#039; defaults to the entire address space and &#039;&#039;&#039;iface&#039;&#039;&#039; to all&lt;br /&gt;
interfaces. An empty zone can be defined by setting either &#039;&#039;&#039;addr&#039;&#039;&#039;&lt;br /&gt;
or &#039;&#039;&#039;iface&#039;&#039;&#039; to an empty list.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Rule objects contain two attributes, &#039;&#039;&#039;in&#039;&#039;&#039; and &#039;&#039;&#039;out&#039;&#039;&#039;, which are&lt;br /&gt;
lists of zone names. These attributes control whether a packet matches&lt;br /&gt;
the rule or not. If a particular zone is referenced by the &#039;&#039;&#039;in&#039;&#039;&#039; &lt;br /&gt;
attribute, the rule applies to packets whose ingress interface and&lt;br /&gt;
source address are covered by the zone definition. Correspondingly, if&lt;br /&gt;
a zone is referenced by the &#039;&#039;&#039;out&#039;&#039;&#039; attribute, the rule applies to&lt;br /&gt;
packets whose egress interface and destination address are included in&lt;br /&gt;
the zone. If both &#039;&#039;&#039;in&#039;&#039;&#039; and &#039;&#039;&#039;out&#039;&#039;&#039; are defined, the packet must&lt;br /&gt;
fulfill both criteria in order to match the rule.&lt;br /&gt;
&lt;br /&gt;
The firewall host itself can be referred to using the special value&lt;br /&gt;
&#039;&#039;&#039;_fw&#039;&#039;&#039; as the zone name.&lt;br /&gt;
&lt;br /&gt;
=== Logging Classes ===&lt;br /&gt;
&lt;br /&gt;
A &#039;&#039;logging class&#039;&#039; specifies how packets matching certain rules are&lt;br /&gt;
logged. A top-level attribute &#039;&#039;&#039;log&#039;&#039;&#039; is a dictionary that maps&lt;br /&gt;
logging class names to setting objects.&lt;br /&gt;
&lt;br /&gt;
A setting object may have an attribute named &#039;&#039;&#039;mode&#039;&#039;&#039;, which&lt;br /&gt;
specifies which logging facility to use. Allowed values are &#039;&#039;&#039;log&#039;&#039;&#039;,&lt;br /&gt;
&#039;&#039;&#039;nflog&#039;&#039;&#039;, and &#039;&#039;&#039;ulog&#039;&#039;&#039;. The default is &#039;&#039;&#039;log&#039;&#039;&#039;, i.e. in-kernel&lt;br /&gt;
logging. The object may also have a &#039;&#039;&#039;limit&#039;&#039;&#039; attribute, which is an&lt;br /&gt;
integer specifying the maximum number of matching packets to be logged&lt;br /&gt;
per second per rule.&lt;br /&gt;
&lt;br /&gt;
Filter and policy rules can have an attribute named &#039;&#039;&#039;log&#039;&#039;&#039;. If it&lt;br /&gt;
is a string, it is interpreted as a reference to a logging class, and&lt;br /&gt;
logging is performed according to the definitions. If the value of the&lt;br /&gt;
&#039;&#039;&#039;log&#039;&#039;&#039; attribute is &#039;&#039;&#039;true&#039;&#039;&#039; (boolean), logging is done using&lt;br /&gt;
default settings. If the value is &#039;&#039;&#039;false&#039;&#039;&#039; (boolean), logging is&lt;br /&gt;
disabled for the rule. If &#039;&#039;&#039;log&#039;&#039;&#039; is not defined, logging is done&lt;br /&gt;
using the default settings except for accept rules, for which logging&lt;br /&gt;
is omitted.&lt;br /&gt;
&lt;br /&gt;
Default logging settings can be set by defining a logging class named&lt;br /&gt;
&#039;&#039;&#039;_default&#039;&#039;&#039;. Normally, default logging uses the &#039;&#039;&#039;log&#039;&#039;&#039; mode with&lt;br /&gt;
packets limited to one per second.&lt;br /&gt;
&lt;br /&gt;
=== Rules ===&lt;br /&gt;
&lt;br /&gt;
There are five types of rule objects:&lt;br /&gt;
* policies&lt;br /&gt;
* filters&lt;br /&gt;
* NAT rules&lt;br /&gt;
* packet marking rules&lt;br /&gt;
* MSS clamping rules&lt;br /&gt;
* connection tracking bypass rules&lt;br /&gt;
&lt;br /&gt;
All rule objects can have the &#039;&#039;&#039;in&#039;&#039;&#039; and &#039;&#039;&#039;out&#039;&#039;&#039; attributes&lt;br /&gt;
referring to zones as described in the previous section. In addition,&lt;br /&gt;
the scope of the rule can be further constrained with the following&lt;br /&gt;
attributes:&lt;br /&gt;
&lt;br /&gt;
{|&lt;br /&gt;
!Attribute!!Value format!!Effect&lt;br /&gt;
|-&lt;br /&gt;
|&#039;&#039;&#039;src&#039;&#039;&#039;&lt;br /&gt;
|Similar to &#039;&#039;&#039;addr&#039;&#039;&#039; attribute of zone objects&lt;br /&gt;
|Packet&#039;s source address matches the value&lt;br /&gt;
|-&lt;br /&gt;
|&#039;&#039;&#039;dest&#039;&#039;&#039;&lt;br /&gt;
|Similar to &#039;&#039;&#039;addr&#039;&#039;&#039; attribute of zone objects&lt;br /&gt;
|Packet&#039;s destination address matches the value&lt;br /&gt;
|-&lt;br /&gt;
|&#039;&#039;&#039;ipset&#039;&#039;&#039;&lt;br /&gt;
|Object containing two attributes: &#039;&#039;&#039;name&#039;&#039;&#039; referring to an IP set and &#039;&#039;&#039;args&#039;&#039;&#039;, which is a list of strings &#039;&#039;&#039;in&#039;&#039;&#039; and &#039;&#039;&#039;out&#039;&#039;&#039;&lt;br /&gt;
|Packet matches the IP set referred here when the match arguments are taken from the source (&#039;&#039;&#039;in&#039;&#039;&#039;) and destination (&#039;&#039;&#039;out&#039;&#039;&#039;) address or port in the order specified by &#039;&#039;&#039;args&#039;&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
|&#039;&#039;&#039;ipsec&#039;&#039;&#039;&lt;br /&gt;
|&#039;&#039;&#039;in&#039;&#039;&#039; or &#039;&#039;&#039;out&#039;&#039;&#039;&lt;br /&gt;
|IPsec decapsulation perfomed on ingress (&#039;&#039;&#039;in&#039;&#039;&#039;) or encapsulation performed on egress (&#039;&#039;&#039;out&#039;&#039;&#039;)&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Rule objects are declared in type-specific top-level dictionaries in&lt;br /&gt;
awall policy files. If a packet matches multiple rules, the one&lt;br /&gt;
appearing earlier in the list takes precedence. If the matching rules&lt;br /&gt;
are defined in different policy files, the one that was processed&lt;br /&gt;
earlier takes precedence in the current implementation, but this may&lt;br /&gt;
change in future versions.&lt;br /&gt;
&lt;br /&gt;
==== Filters ====&lt;br /&gt;
&lt;br /&gt;
Filter objects specify an action for packets fulfilling certain&lt;br /&gt;
criteria. The top-level attribute &#039;&#039;&#039;filter&#039;&#039;&#039; is a list of filter&lt;br /&gt;
objects. The precedence rules are similar to those of policy objects.&lt;br /&gt;
&lt;br /&gt;
In addition to the common rule attributes, filter objects can have a &lt;br /&gt;
&#039;&#039;&#039;service&#039;&#039;&#039; attribute constraining the scope to specific services&lt;br /&gt;
only. This attribute is a list of service names, referring to the&lt;br /&gt;
keys of the top-level &#039;&#039;&#039;service&#039;&#039;&#039; dictionary.&lt;br /&gt;
&lt;br /&gt;
Filter objects must have an attribute named &#039;&#039;&#039;action&#039;&#039;&#039;, the value of&lt;br /&gt;
which can be one of the following:&lt;br /&gt;
&lt;br /&gt;
{|&lt;br /&gt;
!Value!!Action&lt;br /&gt;
|-&lt;br /&gt;
|&#039;&#039;&#039;accept&#039;&#039;&#039;&lt;br /&gt;
|Accept the packet&lt;br /&gt;
|-&lt;br /&gt;
|&#039;&#039;&#039;reject&#039;&#039;&#039;&lt;br /&gt;
|Reject the packet with an ICMP error message&lt;br /&gt;
|-&lt;br /&gt;
|&#039;&#039;&#039;drop&#039;&#039;&#039;&lt;br /&gt;
|Silently drop the packet&lt;br /&gt;
|-&lt;br /&gt;
|&#039;&#039;&#039;tarpit&#039;&#039;&#039;&lt;br /&gt;
|Put incoming TCP connections into persist state and ignore attempts to close them. Silently drop non-TCP packets. (Connection tracking bypass is automatically enabled for the matching packets.)&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Filter objects, the action of which is &#039;&#039;&#039;accept&#039;&#039;&#039;, may also contain&lt;br /&gt;
limits for packet flow or new connections. These are specified with&lt;br /&gt;
the &#039;&#039;&#039;flow-limit&#039;&#039;&#039; and &#039;&#039;&#039;conn-limit&#039;&#039;&#039; attributes,&lt;br /&gt;
respectively. The values of these attributes are limit objects that&lt;br /&gt;
have two attributes: &#039;&#039;&#039;count&#039;&#039;&#039; and &#039;&#039;&#039;interval&#039;&#039;&#039;. &#039;&#039;&#039;count&#039;&#039;&#039;&lt;br /&gt;
specifies how many new connections or packets are allowed within the&lt;br /&gt;
time frame specified by &#039;&#039;&#039;interval&#039;&#039;&#039; (in seconds). The &#039;&#039;&#039;logdrop&#039;&#039;&#039;&lt;br /&gt;
action is applied to the packets exceeding the limit.&lt;br /&gt;
&lt;br /&gt;
Filter objects may have an attribute named &#039;&#039;&#039;dnat&#039;&#039;&#039;, the value of&lt;br /&gt;
which is an IPv4 address. If defined, this enables destination NAT for&lt;br /&gt;
all IPv4 packets matching the rule, such that the specified address&lt;br /&gt;
replaces the original destination address. This option has no effect&lt;br /&gt;
on IPv6 packets.&lt;br /&gt;
&lt;br /&gt;
Filter objects may have a boolean attribute named &#039;&#039;&#039;no-track&#039;&#039;&#039;. If&lt;br /&gt;
set to &#039;&#039;&#039;true&#039;&#039;&#039;, connection tracking is bypassed for the matching&lt;br /&gt;
packets. In addition, if &#039;&#039;&#039;action&#039;&#039;&#039; is set to &#039;&#039;&#039;accept&#039;&#039;&#039;, the&lt;br /&gt;
corresponding packets travelling to the reverse direction are also&lt;br /&gt;
allowed.&lt;br /&gt;
&lt;br /&gt;
==== Policies ====&lt;br /&gt;
&lt;br /&gt;
Policy objects describe the default action for packets that did not&lt;br /&gt;
match any filter. The top-level attribute &#039;&#039;&#039;policy&#039;&#039;&#039; is a list of&lt;br /&gt;
policy objects.&lt;br /&gt;
&lt;br /&gt;
Policy objects must have the &#039;&#039;&#039;action&#039;&#039;&#039; attribute defined. The&lt;br /&gt;
possible values and their semantics are the same as in filter objects.&lt;br /&gt;
&lt;br /&gt;
==== NAT Rules ====&lt;br /&gt;
&lt;br /&gt;
NAT rules come in two flavors: &#039;&#039;source NAT rules&#039;&#039; and&lt;br /&gt;
&#039;&#039;destination NAT rules&#039;&#039;. These are contained in two top-level lists&lt;br /&gt;
named &#039;&#039;&#039;snat&#039;&#039;&#039; and &#039;&#039;&#039;dnat&#039;&#039;&#039;, respectively.&lt;br /&gt;
&lt;br /&gt;
Each NAT rule may have an attribute named &#039;&#039;&#039;ip-range&#039;&#039;&#039; that&lt;br /&gt;
specifies the IPv4 address range to which the original source or&lt;br /&gt;
destination address is mapped. The value can be a single IPv4 address&lt;br /&gt;
or a range specified by two addresses, separated with the &#039;&#039;&#039;-&#039;&#039;&#039;&lt;br /&gt;
character. If not defined, it defaults to the primary address of the&lt;br /&gt;
ingress interface in case of destination NAT, or that of the egress&lt;br /&gt;
interface in case of source NAT.&lt;br /&gt;
&lt;br /&gt;
Optionally, a NAT rule can specify the TCP and UDP port range to which&lt;br /&gt;
the original source or destination port is mapped. The attribute is&lt;br /&gt;
named &#039;&#039;&#039;port-range&#039;&#039;&#039;, and the value can be a single port number or a&lt;br /&gt;
range specified by two numbers, separated with the &#039;&#039;&#039;-&#039;&#039;&#039;&lt;br /&gt;
character. If &#039;&#039;&#039;port-range&#039;&#039;&#039; is not specified, the original port&lt;br /&gt;
number is kept intact.&lt;br /&gt;
&lt;br /&gt;
Like filters, NAT rules can have a &#039;&#039;&#039;service&#039;&#039;&#039; attribute&lt;br /&gt;
constraining their scope to specific services.&lt;br /&gt;
&lt;br /&gt;
NAT rules may have an &#039;&#039;&#039;action&#039;&#039;&#039; attribute set to value&lt;br /&gt;
&#039;&#039;&#039;accept&#039;&#039;&#039;. In this case, NAT is not performed on the packets&lt;br /&gt;
reaching and matching this rule.&lt;br /&gt;
&lt;br /&gt;
==== Packet Marking Rules ====&lt;br /&gt;
&lt;br /&gt;
Packet marking rules are used to mark incoming packets matching the&lt;br /&gt;
specified criteria. The mark can be used as a basis for the routing&lt;br /&gt;
decision. Each marking rule must specify the mark using the &#039;&#039;&#039;mark&#039;&#039;&#039;&lt;br /&gt;
attribute, which is a 32-bit integer.&lt;br /&gt;
&lt;br /&gt;
Normal marking rules are contained by the top-level list attribute&lt;br /&gt;
named &#039;&#039;&#039;mark&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
There is another top-level list attribute, named &#039;&#039;&#039;route-track&#039;&#039;&#039;,&lt;br /&gt;
which contains route tracking rules. These are special marking rules&lt;br /&gt;
which cause all the subsequent packets related to the same connection&lt;br /&gt;
to be marked according to the rule.&lt;br /&gt;
&lt;br /&gt;
==== MSS Clamping Rules ====&lt;br /&gt;
&lt;br /&gt;
MSS Clamping Rules are used to deal with ISPs that block ICMP&lt;br /&gt;
Fragmentation Needed or ICMPv6 Packet Too Big packets. An MSS clamping&lt;br /&gt;
rule overwrites the MSS option with a value specified with the&lt;br /&gt;
&#039;&#039;&#039;mss&#039;&#039;&#039; attribute for the matching TCP connections. If &#039;&#039;&#039;mss&#039;&#039;&#039; is&lt;br /&gt;
not specified, a suitable value is automatically determined from the&lt;br /&gt;
path MTU.&lt;br /&gt;
&lt;br /&gt;
==== Connection Tracking Bypass Rules ====&lt;br /&gt;
&lt;br /&gt;
Connection tracking bypass rules are used to disable connection&lt;br /&gt;
tracking for packets matching the specified criteria. The top-level&lt;br /&gt;
attribute &#039;&#039;&#039;no-track&#039;&#039;&#039; is a list of such rules.&lt;br /&gt;
&lt;br /&gt;
Connection tracking bypass rules may have an &#039;&#039;&#039;action&#039;&#039;&#039; attribute&lt;br /&gt;
set to value &#039;&#039;&#039;accept&#039;&#039;&#039;. The effect is similar to corresponding NAT&lt;br /&gt;
rules, i.e. connection tracking is not bypassed for the matching&lt;br /&gt;
packets.&lt;br /&gt;
&lt;br /&gt;
=== IP Sets ===&lt;br /&gt;
&lt;br /&gt;
Any IP set referenced by rule objects should be created by&lt;br /&gt;
awall. Auxiliary &#039;&#039;IP set&#039;&#039; objects are used to defined them in awall&lt;br /&gt;
policy files. The top-level attribute &#039;&#039;&#039;ipset&#039;&#039;&#039; is a dictionary, the&lt;br /&gt;
keys of which are IP set names. The values are IP set objects, which&lt;br /&gt;
have two mandatory attributes. The attribute named &#039;&#039;&#039;type&#039;&#039;&#039; &lt;br /&gt;
corresponds to the type argument of the &amp;lt;tt&amp;gt;ipset create&amp;lt;/tt&amp;gt; &lt;br /&gt;
command. &#039;&#039;&#039;family&#039;&#039;&#039; specifies whether the set is for IPv4 or IPv6&lt;br /&gt;
addresses, and the possible values are &#039;&#039;&#039;inet&#039;&#039;&#039; and &#039;&#039;&#039;inet6&#039;&#039;&#039;,&lt;br /&gt;
correspondingly.&lt;br /&gt;
&lt;br /&gt;
== Command Line Syntax ==&lt;br /&gt;
&lt;br /&gt;
=== Translating Policy Files to Firewall Configuration Files ===&lt;br /&gt;
&lt;br /&gt;
 &#039;&#039;&#039;awall translate&#039;&#039;&#039; [&#039;&#039;&#039;-o&#039;&#039;&#039;|&#039;&#039;&#039;--output&#039;&#039;&#039; DIRECTORY] [&#039;&#039;&#039;-V&#039;&#039;&#039;|&#039;&#039;&#039;--verify&#039;&#039;&#039;]&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;tt&amp;gt;--verify&amp;lt;/tt&amp;gt; option makes awall verify the configuration&lt;br /&gt;
using the test mode of iptables-restore before overwriting the old&lt;br /&gt;
files.&lt;br /&gt;
&lt;br /&gt;
Specifying the output directory allows testing awall policies without&lt;br /&gt;
overwriting the current iptables and ipset configuration files. By&lt;br /&gt;
default, awall generates the configuration to &amp;lt;tt&amp;gt;/etc/iptables&amp;lt;/tt&amp;gt; &lt;br /&gt;
and &amp;lt;tt&amp;gt;/etc/ipset.d&amp;lt;/tt&amp;gt;, which are read by the init scripts.&lt;br /&gt;
&lt;br /&gt;
=== Run-Time Configuration of Firewall ===&lt;br /&gt;
&lt;br /&gt;
 &#039;&#039;&#039;awall activate&#039;&#039;&#039; [&#039;&#039;&#039;-f&#039;&#039;&#039;|&#039;&#039;&#039;--force&#039;&#039;&#039;]&lt;br /&gt;
&lt;br /&gt;
This command genereates firewall configuration from the policy files&lt;br /&gt;
and enables it. If the user confirms the new configuration by hitting&lt;br /&gt;
the Return key within 10 seconds or the &amp;lt;tt&amp;gt;--force&amp;lt;/tt&amp;gt; option is&lt;br /&gt;
used, the configuration is saved to the files. Otherwise, the old&lt;br /&gt;
configuration is restored.&lt;br /&gt;
&lt;br /&gt;
There is also a command for deleting all firewall rules:&lt;br /&gt;
&lt;br /&gt;
 &#039;&#039;&#039;awall flush&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
This command configures the firewall to drop all packets.&lt;br /&gt;
&lt;br /&gt;
=== Optional Policies ===&lt;br /&gt;
&lt;br /&gt;
Optional policies can be enabled or disabled using this command:&lt;br /&gt;
&lt;br /&gt;
 &#039;&#039;&#039;awall&#039;&#039;&#039; {&#039;&#039;&#039;enable&#039;&#039;&#039;|&#039;&#039;&#039;disable&#039;&#039;&#039;} POLICY...&lt;br /&gt;
&lt;br /&gt;
Optional policies can be listed using this command:&lt;br /&gt;
&lt;br /&gt;
 &#039;&#039;&#039;awall list&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;&#039;enabled&#039;&#039;&#039; status means that the policy has been enabled by the&lt;br /&gt;
user. The &#039;&#039;&#039;disabled&#039;&#039;&#039; status means that the policy is not in&lt;br /&gt;
use. The &#039;&#039;&#039;required&#039;&#039;&#039; status means that the policy has not been&lt;br /&gt;
enabled by the user but is in use because it is required by another&lt;br /&gt;
policy which is in use.&lt;br /&gt;
&lt;br /&gt;
=== Debugging Policies ===&lt;br /&gt;
&lt;br /&gt;
This command can be used to dump variable, zone, and other definitions&lt;br /&gt;
as well as their source policies:&lt;br /&gt;
&lt;br /&gt;
 &#039;&#039;&#039;awall dump&#039;&#039;&#039; [LEVEL]&lt;br /&gt;
&lt;br /&gt;
The level is an integer in range 0&amp;amp;ndash;5 and defaults to 0. More&lt;br /&gt;
information is displayed on higher levels.&lt;br /&gt;
&lt;br /&gt;
[[Category:Networking]]&lt;br /&gt;
[[Category:Security]]&lt;/div&gt;</summary>
		<author><name>Kunkku</name></author>
	</entry>
	<entry>
		<id>https://wiki.alpinelinux.org/w/index.php?title=Alpine_Wall_User%27s_Guide&amp;diff=8385</id>
		<title>Alpine Wall User&#039;s Guide</title>
		<link rel="alternate" type="text/html" href="https://wiki.alpinelinux.org/w/index.php?title=Alpine_Wall_User%27s_Guide&amp;diff=8385"/>
		<updated>2012-08-28T10:57:07Z</updated>

		<summary type="html">&lt;p&gt;Kunkku: /* Configuration File Processing */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Configuration File Processing ==&lt;br /&gt;
&lt;br /&gt;
[[Alpine Wall]] (awall) reads its configuration from multiple&lt;br /&gt;
JSON-formatted files, called &#039;&#039;policy files&#039;&#039;. The processing starts&lt;br /&gt;
from directory &amp;lt;tt&amp;gt;/usr/share/awall/mandatory&amp;lt;/tt&amp;gt;, which contains&lt;br /&gt;
mandatory policy files shipped with APK packages. After that,&lt;br /&gt;
installation-specific policy files in &amp;lt;tt&amp;gt;/etc/awall&amp;lt;/tt&amp;gt; are&lt;br /&gt;
processed.&lt;br /&gt;
&lt;br /&gt;
The latter directory may also contain symbolic links to policy files&lt;br /&gt;
located in &amp;lt;tt&amp;gt;/usr/share/awall/optional&amp;lt;/tt&amp;gt;. These are optional&lt;br /&gt;
policies, which can be enabled on need basis. Such symbolic links are&lt;br /&gt;
easily created and destroyed using the &amp;lt;tt&amp;gt;awall enable&amp;lt;/tt&amp;gt; and &lt;br /&gt;
&amp;lt;tt&amp;gt;awall disable&amp;lt;/tt&amp;gt; commands. &amp;lt;tt&amp;gt;awall list&amp;lt;/tt&amp;gt; shows which&lt;br /&gt;
optional policies are enabled and disabled. The command also prints&lt;br /&gt;
the description of the optional policy if defined in the file using&lt;br /&gt;
a top-level attribute named &#039;&#039;&#039;description&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Sometimes a policy file depends on other policy files. In this case,&lt;br /&gt;
the policy file must have a top-level attribute &#039;&#039;&#039;import&#039;&#039;&#039;, the&lt;br /&gt;
value of which is a list of policy names, which correspond to the file&lt;br /&gt;
names without the &amp;lt;tt&amp;gt;.json&amp;lt;/tt&amp;gt; suffix. By default, the policies&lt;br /&gt;
listed there are processed before the importing policy.&lt;br /&gt;
&lt;br /&gt;
The order of the generated iptables rules generally reflects the&lt;br /&gt;
processing order of their corresponding awall policies. The processing&lt;br /&gt;
order of policies can be adjusted by defining top-level attributes&lt;br /&gt;
&#039;&#039;&#039;after&#039;&#039;&#039; and &#039;&#039;&#039;before&#039;&#039;&#039; in policy files. These attributes are&lt;br /&gt;
lists of policies, after or before which the declaring policy shall be&lt;br /&gt;
processed. Putting a policy name to either of these lists does not by&lt;br /&gt;
itself import the policy. The ordering directives are ignored with&lt;br /&gt;
respect to those policies that are not enabled by the user or imported&lt;br /&gt;
by other policies. If not defined, &#039;&#039;&#039;after&#039;&#039;&#039; is assumed to be equal&lt;br /&gt;
to the &#039;&#039;&#039;import&#039;&#039;&#039; definition of the policy.&lt;br /&gt;
&lt;br /&gt;
As the import directive does not require the path name to be&lt;br /&gt;
specified, awall expects policies to have unique names, even if&lt;br /&gt;
located in different directories. It is allowed to import optional&lt;br /&gt;
policies that are not explicitly enabled by the user. Such policies&lt;br /&gt;
show up with the &amp;lt;tt&amp;gt;required&amp;lt;/tt&amp;gt; status in the output of &amp;lt;tt&amp;gt;awall&lt;br /&gt;
list&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
== List Parameters ==&lt;br /&gt;
&lt;br /&gt;
Several awall parameters are defined as lists of values. In order to&lt;br /&gt;
facilitate manual editing of policy files, awall also accepts single&lt;br /&gt;
values in place of lists. Such values are semantically equivalent to&lt;br /&gt;
lists containing one element.&lt;br /&gt;
&lt;br /&gt;
== Variable Expansion ==&lt;br /&gt;
&lt;br /&gt;
Awall allows variable definitions in policy files. The top-level&lt;br /&gt;
attribute &#039;&#039;&#039;variable&#039;&#039;&#039; is a dictionary containing the&lt;br /&gt;
definitions. The value of a variable can be of any type (string,&lt;br /&gt;
integer, list, or dictionary).&lt;br /&gt;
&lt;br /&gt;
A variable is referenced in policy files by a string which equals the&lt;br /&gt;
variable name prepended with the &#039;&#039;&#039;$&#039;&#039;&#039; character. If the value of&lt;br /&gt;
the variable is a string, the reference can be embedded into a longer&lt;br /&gt;
string in order to substitute some part of that string (in shell&lt;br /&gt;
style). Variable references can be used when defining other variables,&lt;br /&gt;
as long as the definitions are not circular.&lt;br /&gt;
&lt;br /&gt;
Policy files can reference variables defined in other policy&lt;br /&gt;
files. Policy files can also override variables defined elsewhere by&lt;br /&gt;
redefining them. In this case, the new definition affects all policy&lt;br /&gt;
files, also those processed before the overriding policy. Awall&lt;br /&gt;
variables are in fact simple macros, since each variable remains&lt;br /&gt;
constant thoughout a single processing round. If multiple files define&lt;br /&gt;
the same variable, the definition in the file processed last takes&lt;br /&gt;
effect.&lt;br /&gt;
&lt;br /&gt;
If defined as an empty string, all non-embedded references to a&lt;br /&gt;
variable evaluate as if the attribute in question was not present in&lt;br /&gt;
the configuration. This is also the case when a string containing&lt;br /&gt;
embedded variable references finally evaluates to an empty string.&lt;br /&gt;
&lt;br /&gt;
== Configuration Objects ==&lt;br /&gt;
&lt;br /&gt;
Configuration objects can be divided into two main types.&lt;br /&gt;
&#039;&#039;Auxiliary objects&#039;&#039; model high-level concepts such as services and&lt;br /&gt;
zones. &#039;&#039;Rule objects&#039;&#039; translate into one or more iptables rules, and&lt;br /&gt;
are often defined with the help of some auxiliary objects.&lt;br /&gt;
&lt;br /&gt;
=== Services ===&lt;br /&gt;
&lt;br /&gt;
A &#039;&#039;service&#039;&#039; represents a set of network protocols. A top-level&lt;br /&gt;
attribute &#039;&#039;&#039;service&#039;&#039;&#039; is a dictionary that maps service names to&lt;br /&gt;
service definition objects, or lists thereof in more complex cases.&lt;br /&gt;
&lt;br /&gt;
A service definition object contains an attribute named &#039;&#039;&#039;proto&#039;&#039;&#039;,&lt;br /&gt;
which corresponds to the &amp;lt;tt&amp;gt;--protocol&amp;lt;/tt&amp;gt; option of iptables. The&lt;br /&gt;
protocol can be defined as a numerical value or string as defined in&lt;br /&gt;
&amp;lt;tt&amp;gt;/etc/protocols&amp;lt;/tt&amp;gt;. If the protocol is &#039;&#039;&#039;tcp&#039;&#039;&#039; or &#039;&#039;&#039;udp&#039;&#039;&#039;,&lt;br /&gt;
the scope of the service definition may be constrained by defining an&lt;br /&gt;
attribute named &#039;&#039;&#039;port&#039;&#039;&#039;, which is a list of TCP or UDP port&lt;br /&gt;
numbers. If the protocol is &#039;&#039;&#039;icmp&#039;&#039;&#039; or &#039;&#039;&#039;icmpv6&#039;&#039;&#039;, an analogous &lt;br /&gt;
&#039;&#039;&#039;icmp-type&#039;&#039;&#039; attribute may be used. In addition, the scope of the&lt;br /&gt;
rule is also automatically limited to IPv4 or IPv6, respectively.&lt;br /&gt;
&lt;br /&gt;
=== Zones ===&lt;br /&gt;
&lt;br /&gt;
A &#039;&#039;zone&#039;&#039; represents a set of network hosts. A top-level attribute &lt;br /&gt;
&#039;&#039;&#039;zone&#039;&#039;&#039; is a dictionary that maps zone names to zone objects. A&lt;br /&gt;
zone object has an attribute named &#039;&#039;&#039;iface&#039;&#039;&#039;, &#039;&#039;&#039;addr&#039;&#039;&#039;, or&lt;br /&gt;
both. &#039;&#039;&#039;iface&#039;&#039;&#039; is a list of network interfaces and &#039;&#039;&#039;addr&#039;&#039;&#039; is a&lt;br /&gt;
list of IPv4/IPv6 host and network addresses (CIDR&lt;br /&gt;
notation). &#039;&#039;&#039;addr&#039;&#039;&#039; may also contain domain names, which are&lt;br /&gt;
expanded to IP addresses using DNS resolution. If not defined,&lt;br /&gt;
&#039;&#039;&#039;addr&#039;&#039;&#039; defaults to the entire address space and &#039;&#039;&#039;iface&#039;&#039;&#039; to all&lt;br /&gt;
interfaces. An empty zone can be defined by setting either &#039;&#039;&#039;addr&#039;&#039;&#039;&lt;br /&gt;
or &#039;&#039;&#039;iface&#039;&#039;&#039; to an empty list.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Rule objects contain two attributes, &#039;&#039;&#039;in&#039;&#039;&#039; and &#039;&#039;&#039;out&#039;&#039;&#039;, which are&lt;br /&gt;
lists of zone names. These attributes control whether a packet matches&lt;br /&gt;
the rule or not. If a particular zone is referenced by the &#039;&#039;&#039;in&#039;&#039;&#039; &lt;br /&gt;
attribute, the rule applies to packets whose ingress interface and&lt;br /&gt;
source address are covered by the zone definition. Correspondingly, if&lt;br /&gt;
a zone is referenced by the &#039;&#039;&#039;out&#039;&#039;&#039; attribute, the rule applies to&lt;br /&gt;
packets whose egress interface and destination address are included in&lt;br /&gt;
the zone. If both &#039;&#039;&#039;in&#039;&#039;&#039; and &#039;&#039;&#039;out&#039;&#039;&#039; are defined, the packet must&lt;br /&gt;
fulfill both criteria in order to match the rule.&lt;br /&gt;
&lt;br /&gt;
The firewall host itself can be referred to using the special value&lt;br /&gt;
&#039;&#039;&#039;_fw&#039;&#039;&#039; as the zone name.&lt;br /&gt;
&lt;br /&gt;
=== Logging Classes ===&lt;br /&gt;
&lt;br /&gt;
A &#039;&#039;logging class&#039;&#039; specifies how packets matching certain rules are&lt;br /&gt;
logged. A top-level attribute &#039;&#039;&#039;log&#039;&#039;&#039; is a dictionary that maps&lt;br /&gt;
logging class names to setting objects.&lt;br /&gt;
&lt;br /&gt;
A setting object may have an attribute named &#039;&#039;&#039;mode&#039;&#039;&#039;, which&lt;br /&gt;
specifies which logging facility to use. Allowed values are &#039;&#039;&#039;log&#039;&#039;&#039;,&lt;br /&gt;
&#039;&#039;&#039;nflog&#039;&#039;&#039;, and &#039;&#039;&#039;ulog&#039;&#039;&#039;. The default is &#039;&#039;&#039;log&#039;&#039;&#039;, i.e. in-kernel&lt;br /&gt;
logging. The object may also have a &#039;&#039;&#039;limit&#039;&#039;&#039; attribute, which is an&lt;br /&gt;
integer specifying the maximum number of matching packets to be logged&lt;br /&gt;
per second per rule.&lt;br /&gt;
&lt;br /&gt;
Filter and policy rules can have an attribute named &#039;&#039;&#039;log&#039;&#039;&#039;. If it&lt;br /&gt;
is a string, it is interpreted as a reference to a logging class, and&lt;br /&gt;
logging is performed according to the definitions. If the value of the&lt;br /&gt;
&#039;&#039;&#039;log&#039;&#039;&#039; attribute is &#039;&#039;&#039;true&#039;&#039;&#039; (boolean), logging is done using&lt;br /&gt;
default settings. If the value is &#039;&#039;&#039;false&#039;&#039;&#039; (boolean), logging is&lt;br /&gt;
disabled for the rule. If &#039;&#039;&#039;log&#039;&#039;&#039; is not defined, logging is done&lt;br /&gt;
using the default settings except for accept rules, for which logging&lt;br /&gt;
is omitted.&lt;br /&gt;
&lt;br /&gt;
Default logging settings can be set by defining a logging class named&lt;br /&gt;
&#039;&#039;&#039;_default&#039;&#039;&#039;. Normally, default logging uses the &#039;&#039;&#039;log&#039;&#039;&#039; mode with&lt;br /&gt;
packets limited to one per second.&lt;br /&gt;
&lt;br /&gt;
=== Rules ===&lt;br /&gt;
&lt;br /&gt;
There are five types of rule objects:&lt;br /&gt;
* policies&lt;br /&gt;
* filters&lt;br /&gt;
* NAT rules&lt;br /&gt;
* packet marking rules&lt;br /&gt;
* MSS clamping rules&lt;br /&gt;
* connection tracking bypass rules&lt;br /&gt;
&lt;br /&gt;
All rule objects can have the &#039;&#039;&#039;in&#039;&#039;&#039; and &#039;&#039;&#039;out&#039;&#039;&#039; attributes&lt;br /&gt;
referring to zones as described in the previous section. In addition,&lt;br /&gt;
the scope of the rule can be further constrained with the following&lt;br /&gt;
attributes:&lt;br /&gt;
&lt;br /&gt;
{|&lt;br /&gt;
!Attribute!!Value format!!Effect&lt;br /&gt;
|-&lt;br /&gt;
|&#039;&#039;&#039;src&#039;&#039;&#039;&lt;br /&gt;
|Similar to &#039;&#039;&#039;addr&#039;&#039;&#039; attribute of zone objects&lt;br /&gt;
|Packet&#039;s source address matches the value&lt;br /&gt;
|-&lt;br /&gt;
|&#039;&#039;&#039;dest&#039;&#039;&#039;&lt;br /&gt;
|Similar to &#039;&#039;&#039;addr&#039;&#039;&#039; attribute of zone objects&lt;br /&gt;
|Packet&#039;s destination address matches the value&lt;br /&gt;
|-&lt;br /&gt;
|&#039;&#039;&#039;ipset&#039;&#039;&#039;&lt;br /&gt;
|Object containing two attributes: &#039;&#039;&#039;name&#039;&#039;&#039; referring to an IP set and &#039;&#039;&#039;args&#039;&#039;&#039;, which is a list of strings &#039;&#039;&#039;in&#039;&#039;&#039; and &#039;&#039;&#039;out&#039;&#039;&#039;&lt;br /&gt;
|Packet matches the IP set referred here when the match arguments are taken from the source (&#039;&#039;&#039;in&#039;&#039;&#039;) and destination (&#039;&#039;&#039;out&#039;&#039;&#039;) address or port in the order specified by &#039;&#039;&#039;args&#039;&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
|&#039;&#039;&#039;ipsec&#039;&#039;&#039;&lt;br /&gt;
|&#039;&#039;&#039;in&#039;&#039;&#039; or &#039;&#039;&#039;out&#039;&#039;&#039;&lt;br /&gt;
|IPsec decapsulation perfomed on ingress (&#039;&#039;&#039;in&#039;&#039;&#039;) or encapsulation performed on egress (&#039;&#039;&#039;out&#039;&#039;&#039;)&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Rule objects are declared in type-specific top-level dictionaries in&lt;br /&gt;
awall policy files. If a packet matches multiple rules, the one&lt;br /&gt;
appearing earlier in the list takes precedence. If the matching rules&lt;br /&gt;
are defined in different policy files, the one that was processed&lt;br /&gt;
earlier takes precedence in the current implementation, but this may&lt;br /&gt;
change in future versions.&lt;br /&gt;
&lt;br /&gt;
==== Filters ====&lt;br /&gt;
&lt;br /&gt;
Filter objects specify an action for packets fulfilling certain&lt;br /&gt;
criteria. The top-level attribute &#039;&#039;&#039;filter&#039;&#039;&#039; is a list of filter&lt;br /&gt;
objects. The precedence rules are similar to those of policy objects.&lt;br /&gt;
&lt;br /&gt;
In addition to the common rule attributes, filter objects can have a &lt;br /&gt;
&#039;&#039;&#039;service&#039;&#039;&#039; attribute constraining the scope to specific services&lt;br /&gt;
only. This attribute is a list of service names, referring to the&lt;br /&gt;
keys of the top-level &#039;&#039;&#039;service&#039;&#039;&#039; dictionary.&lt;br /&gt;
&lt;br /&gt;
Filter objects must have an attribute named &#039;&#039;&#039;action&#039;&#039;&#039;, the value of&lt;br /&gt;
which can be one of the following:&lt;br /&gt;
&lt;br /&gt;
{|&lt;br /&gt;
!Value!!Action&lt;br /&gt;
|-&lt;br /&gt;
|&#039;&#039;&#039;accept&#039;&#039;&#039;&lt;br /&gt;
|Accept the packet&lt;br /&gt;
|-&lt;br /&gt;
|&#039;&#039;&#039;reject&#039;&#039;&#039;&lt;br /&gt;
|Reject the packet with an ICMP error message&lt;br /&gt;
|-&lt;br /&gt;
|&#039;&#039;&#039;drop&#039;&#039;&#039;&lt;br /&gt;
|Silently drop the packet&lt;br /&gt;
|-&lt;br /&gt;
|&#039;&#039;&#039;tarpit&#039;&#039;&#039;&lt;br /&gt;
|Put incoming TCP connections into persist state and ignore attempts to close them. Silently drop non-TCP packets. (Connection tracking bypass is automatically enabled for the matching packets.)&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Filter objects, the action of which is &#039;&#039;&#039;accept&#039;&#039;&#039;, may also contain&lt;br /&gt;
limits for packet flow or new connections. These are specified with&lt;br /&gt;
the &#039;&#039;&#039;flow-limit&#039;&#039;&#039; and &#039;&#039;&#039;conn-limit&#039;&#039;&#039; attributes,&lt;br /&gt;
respectively. The values of these attributes are limit objects that&lt;br /&gt;
have two attributes: &#039;&#039;&#039;count&#039;&#039;&#039; and &#039;&#039;&#039;interval&#039;&#039;&#039;. &#039;&#039;&#039;count&#039;&#039;&#039;&lt;br /&gt;
specifies how many new connections or packets are allowed within the&lt;br /&gt;
time frame specified by &#039;&#039;&#039;interval&#039;&#039;&#039; (in seconds). The &#039;&#039;&#039;logdrop&#039;&#039;&#039;&lt;br /&gt;
action is applied to the packets exceeding the limit.&lt;br /&gt;
&lt;br /&gt;
Filter objects may have an attribute named &#039;&#039;&#039;dnat&#039;&#039;&#039;, the value of&lt;br /&gt;
which is an IPv4 address. If defined, this enables destination NAT for&lt;br /&gt;
all IPv4 packets matching the rule, such that the specified address&lt;br /&gt;
replaces the original destination address. This option has no effect&lt;br /&gt;
on IPv6 packets.&lt;br /&gt;
&lt;br /&gt;
==== Policies ====&lt;br /&gt;
&lt;br /&gt;
Policy objects describe the default action for packets that did not&lt;br /&gt;
match any filter. The top-level attribute &#039;&#039;&#039;policy&#039;&#039;&#039; is a list of&lt;br /&gt;
policy objects.&lt;br /&gt;
&lt;br /&gt;
Policy objects must have the &#039;&#039;&#039;action&#039;&#039;&#039; attribute defined. The&lt;br /&gt;
possible values and their semantics are the same as in filter objects.&lt;br /&gt;
&lt;br /&gt;
==== NAT Rules ====&lt;br /&gt;
&lt;br /&gt;
NAT rules come in two flavors: &#039;&#039;source NAT rules&#039;&#039; and&lt;br /&gt;
&#039;&#039;destination NAT rules&#039;&#039;. These are contained in two top-level lists&lt;br /&gt;
named &#039;&#039;&#039;snat&#039;&#039;&#039; and &#039;&#039;&#039;dnat&#039;&#039;&#039;, respectively.&lt;br /&gt;
&lt;br /&gt;
Each NAT rule may have an attribute named &#039;&#039;&#039;ip-range&#039;&#039;&#039; that&lt;br /&gt;
specifies the IPv4 address range to which the original source or&lt;br /&gt;
destination address is mapped. The value can be a single IPv4 address&lt;br /&gt;
or a range specified by two addresses, separated with the &#039;&#039;&#039;-&#039;&#039;&#039;&lt;br /&gt;
character. If not defined, it defaults to the primary address of the&lt;br /&gt;
ingress interface in case of destination NAT, or that of the egress&lt;br /&gt;
interface in case of source NAT.&lt;br /&gt;
&lt;br /&gt;
Optionally, a NAT rule can specify the TCP and UDP port range to which&lt;br /&gt;
the original source or destination port is mapped. The attribute is&lt;br /&gt;
named &#039;&#039;&#039;port-range&#039;&#039;&#039;, and the value can be a single port number or a&lt;br /&gt;
range specified by two numbers, separated with the &#039;&#039;&#039;-&#039;&#039;&#039;&lt;br /&gt;
character. If &#039;&#039;&#039;port-range&#039;&#039;&#039; is not specified, the original port&lt;br /&gt;
number is kept intact.&lt;br /&gt;
&lt;br /&gt;
Like filters, NAT rules can have a &#039;&#039;&#039;service&#039;&#039;&#039; attribute&lt;br /&gt;
constraining their scope to specific services.&lt;br /&gt;
&lt;br /&gt;
NAT rules may have an &#039;&#039;&#039;action&#039;&#039;&#039; attribute set to value&lt;br /&gt;
&#039;&#039;&#039;accept&#039;&#039;&#039;. In this case, NAT is not performed on the packets&lt;br /&gt;
reaching and matching this rule.&lt;br /&gt;
&lt;br /&gt;
==== Packet Marking Rules ====&lt;br /&gt;
&lt;br /&gt;
Packet marking rules are used to mark incoming packets matching the&lt;br /&gt;
specified criteria. The mark can be used as a basis for the routing&lt;br /&gt;
decision. Each marking rule must specify the mark using the &#039;&#039;&#039;mark&#039;&#039;&#039;&lt;br /&gt;
attribute, which is a 32-bit integer.&lt;br /&gt;
&lt;br /&gt;
Normal marking rules are contained by the top-level list attribute&lt;br /&gt;
named &#039;&#039;&#039;mark&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
There is another top-level list attribute, named &#039;&#039;&#039;route-track&#039;&#039;&#039;,&lt;br /&gt;
which contains route tracking rules. These are special marking rules&lt;br /&gt;
which cause all the subsequent packets related to the same connection&lt;br /&gt;
to be marked according to the rule.&lt;br /&gt;
&lt;br /&gt;
==== MSS Clamping Rules ====&lt;br /&gt;
&lt;br /&gt;
MSS Clamping Rules are used to deal with ISPs that block ICMP&lt;br /&gt;
Fragmentation Needed or ICMPv6 Packet Too Big packets. An MSS clamping&lt;br /&gt;
rule overwrites the MSS option with a value specified with the&lt;br /&gt;
&#039;&#039;&#039;mss&#039;&#039;&#039; attribute for the matching TCP connections. If &#039;&#039;&#039;mss&#039;&#039;&#039; is&lt;br /&gt;
not specified, a suitable value is automatically determined from the&lt;br /&gt;
path MTU.&lt;br /&gt;
&lt;br /&gt;
==== Connection Tracking Bypass Rules ====&lt;br /&gt;
&lt;br /&gt;
Connection tracking bypass rules are used to disable connection&lt;br /&gt;
tracking for packets matching the specified criteria. The top-level&lt;br /&gt;
attribute &#039;&#039;&#039;no-track&#039;&#039;&#039; is a list of such rules.&lt;br /&gt;
&lt;br /&gt;
Connection tracking bypass rules may have an &#039;&#039;&#039;action&#039;&#039;&#039; attribute&lt;br /&gt;
set to value &#039;&#039;&#039;accept&#039;&#039;&#039;. The effect is similar to corresponding NAT&lt;br /&gt;
rules, i.e. connection tracking is not bypassed for the matching&lt;br /&gt;
packets.&lt;br /&gt;
&lt;br /&gt;
=== IP Sets ===&lt;br /&gt;
&lt;br /&gt;
Any IP set referenced by rule objects should be created by&lt;br /&gt;
awall. Auxiliary &#039;&#039;IP set&#039;&#039; objects are used to defined them in awall&lt;br /&gt;
policy files. The top-level attribute &#039;&#039;&#039;ipset&#039;&#039;&#039; is a dictionary, the&lt;br /&gt;
keys of which are IP set names. The values are IP set objects, which&lt;br /&gt;
have two mandatory attributes. The attribute named &#039;&#039;&#039;type&#039;&#039;&#039; &lt;br /&gt;
corresponds to the type argument of the &amp;lt;tt&amp;gt;ipset create&amp;lt;/tt&amp;gt; &lt;br /&gt;
command. &#039;&#039;&#039;family&#039;&#039;&#039; specifies whether the set is for IPv4 or IPv6&lt;br /&gt;
addresses, and the possible values are &#039;&#039;&#039;inet&#039;&#039;&#039; and &#039;&#039;&#039;inet6&#039;&#039;&#039;,&lt;br /&gt;
correspondingly.&lt;br /&gt;
&lt;br /&gt;
== Command Line Syntax ==&lt;br /&gt;
&lt;br /&gt;
=== Translating Policy Files to Firewall Configuration Files ===&lt;br /&gt;
&lt;br /&gt;
 &#039;&#039;&#039;awall translate&#039;&#039;&#039; [&#039;&#039;&#039;-o&#039;&#039;&#039;|&#039;&#039;&#039;--output&#039;&#039;&#039; DIRECTORY] [&#039;&#039;&#039;-V&#039;&#039;&#039;|&#039;&#039;&#039;--verify&#039;&#039;&#039;]&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;tt&amp;gt;--verify&amp;lt;/tt&amp;gt; option makes awall verify the configuration&lt;br /&gt;
using the test mode of iptables-restore before overwriting the old&lt;br /&gt;
files.&lt;br /&gt;
&lt;br /&gt;
Specifying the output directory allows testing awall policies without&lt;br /&gt;
overwriting the current iptables and ipset configuration files. By&lt;br /&gt;
default, awall generates the configuration to &amp;lt;tt&amp;gt;/etc/iptables&amp;lt;/tt&amp;gt; &lt;br /&gt;
and &amp;lt;tt&amp;gt;/etc/ipset.d&amp;lt;/tt&amp;gt;, which are read by the init scripts.&lt;br /&gt;
&lt;br /&gt;
=== Run-Time Configuration of Firewall ===&lt;br /&gt;
&lt;br /&gt;
 &#039;&#039;&#039;awall activate&#039;&#039;&#039; [&#039;&#039;&#039;-f&#039;&#039;&#039;|&#039;&#039;&#039;--force&#039;&#039;&#039;]&lt;br /&gt;
&lt;br /&gt;
This command genereates firewall configuration from the policy files&lt;br /&gt;
and enables it. If the user confirms the new configuration by hitting&lt;br /&gt;
the Return key within 10 seconds or the &amp;lt;tt&amp;gt;--force&amp;lt;/tt&amp;gt; option is&lt;br /&gt;
used, the configuration is saved to the files. Otherwise, the old&lt;br /&gt;
configuration is restored.&lt;br /&gt;
&lt;br /&gt;
There is also a command for deleting all firewall rules:&lt;br /&gt;
&lt;br /&gt;
 &#039;&#039;&#039;awall flush&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
This command configures the firewall to drop all packets.&lt;br /&gt;
&lt;br /&gt;
=== Optional Policies ===&lt;br /&gt;
&lt;br /&gt;
Optional policies can be enabled or disabled using this command:&lt;br /&gt;
&lt;br /&gt;
 &#039;&#039;&#039;awall&#039;&#039;&#039; {&#039;&#039;&#039;enable&#039;&#039;&#039;|&#039;&#039;&#039;disable&#039;&#039;&#039;} POLICY...&lt;br /&gt;
&lt;br /&gt;
Optional policies can be listed using this command:&lt;br /&gt;
&lt;br /&gt;
 &#039;&#039;&#039;awall list&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;&#039;enabled&#039;&#039;&#039; status means that the policy has been enabled by the&lt;br /&gt;
user. The &#039;&#039;&#039;disabled&#039;&#039;&#039; status means that the policy is not in&lt;br /&gt;
use. The &#039;&#039;&#039;required&#039;&#039;&#039; status means that the policy has not been&lt;br /&gt;
enabled by the user but is in use because it is required by another&lt;br /&gt;
policy which is in use.&lt;br /&gt;
&lt;br /&gt;
=== Debugging Policies ===&lt;br /&gt;
&lt;br /&gt;
This command can be used to dump variable, zone, and other definitions&lt;br /&gt;
as well as their source policies:&lt;br /&gt;
&lt;br /&gt;
 &#039;&#039;&#039;awall dump&#039;&#039;&#039; [LEVEL]&lt;br /&gt;
&lt;br /&gt;
The level is an integer in range 0&amp;amp;ndash;5 and defaults to 0. More&lt;br /&gt;
information is displayed on higher levels.&lt;br /&gt;
&lt;br /&gt;
[[Category:Networking]]&lt;br /&gt;
[[Category:Security]]&lt;/div&gt;</summary>
		<author><name>Kunkku</name></author>
	</entry>
	<entry>
		<id>https://wiki.alpinelinux.org/w/index.php?title=Alpine_Wall_User%27s_Guide&amp;diff=8384</id>
		<title>Alpine Wall User&#039;s Guide</title>
		<link rel="alternate" type="text/html" href="https://wiki.alpinelinux.org/w/index.php?title=Alpine_Wall_User%27s_Guide&amp;diff=8384"/>
		<updated>2012-08-28T08:20:45Z</updated>

		<summary type="html">&lt;p&gt;Kunkku: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Configuration File Processing ==&lt;br /&gt;
&lt;br /&gt;
[[Alpine Wall]] (awall) reads its configuration from multiple&lt;br /&gt;
JSON-formatted files, called &#039;&#039;policy files&#039;&#039;. The processing starts&lt;br /&gt;
from directory &amp;lt;tt&amp;gt;/usr/share/awall/mandatory&amp;lt;/tt&amp;gt;, which contains&lt;br /&gt;
mandatory policy files shipped with APK packages. After that,&lt;br /&gt;
installation-specific policy files in &amp;lt;tt&amp;gt;/etc/awall&amp;lt;/tt&amp;gt; are&lt;br /&gt;
processed.&lt;br /&gt;
&lt;br /&gt;
The latter directory may also contain symbolic links to policy files&lt;br /&gt;
located in &amp;lt;tt&amp;gt;/usr/share/awall/optional&amp;lt;/tt&amp;gt;. These are optional&lt;br /&gt;
policies, which can be enabled on need basis. Such symbolic links are&lt;br /&gt;
easily created and destroyed using the &amp;lt;tt&amp;gt;awall enable&amp;lt;/tt&amp;gt; and &lt;br /&gt;
&amp;lt;tt&amp;gt;awall disable&amp;lt;/tt&amp;gt; commands. &amp;lt;tt&amp;gt;awall list&amp;lt;/tt&amp;gt; shows which&lt;br /&gt;
optional policies are enabled and disabled. The command also prints&lt;br /&gt;
the description of the optional policy if defined in the file using&lt;br /&gt;
a top-level attribute named &#039;&#039;&#039;description&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Sometimes a policy file depends on other policy files. In this case,&lt;br /&gt;
the policy file must have a top-level attribute &#039;&#039;&#039;import&#039;&#039;&#039;, the&lt;br /&gt;
value of which is a list of policy names, which correspond to the file&lt;br /&gt;
names without the &amp;lt;tt&amp;gt;.json&amp;lt;/tt&amp;gt; suffix. The policies listed there are&lt;br /&gt;
always processed before the importing policy. The order of the&lt;br /&gt;
generated iptables rules generally reflects the processing order of&lt;br /&gt;
their corresponding awall policies.&lt;br /&gt;
&lt;br /&gt;
As the import directive does not require the path name to be&lt;br /&gt;
specified, awall expects policies to have unique names, even if&lt;br /&gt;
located in different directories. It is allowed to import optional&lt;br /&gt;
policies that are not explicitly enabled by the user. Such policies&lt;br /&gt;
show up with the &amp;lt;tt&amp;gt;required&amp;lt;/tt&amp;gt; status in the output of &amp;lt;tt&amp;gt;awall&lt;br /&gt;
list&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
== List Parameters ==&lt;br /&gt;
&lt;br /&gt;
Several awall parameters are defined as lists of values. In order to&lt;br /&gt;
facilitate manual editing of policy files, awall also accepts single&lt;br /&gt;
values in place of lists. Such values are semantically equivalent to&lt;br /&gt;
lists containing one element.&lt;br /&gt;
&lt;br /&gt;
== Variable Expansion ==&lt;br /&gt;
&lt;br /&gt;
Awall allows variable definitions in policy files. The top-level&lt;br /&gt;
attribute &#039;&#039;&#039;variable&#039;&#039;&#039; is a dictionary containing the&lt;br /&gt;
definitions. The value of a variable can be of any type (string,&lt;br /&gt;
integer, list, or dictionary).&lt;br /&gt;
&lt;br /&gt;
A variable is referenced in policy files by a string which equals the&lt;br /&gt;
variable name prepended with the &#039;&#039;&#039;$&#039;&#039;&#039; character. If the value of&lt;br /&gt;
the variable is a string, the reference can be embedded into a longer&lt;br /&gt;
string in order to substitute some part of that string (in shell&lt;br /&gt;
style). Variable references can be used when defining other variables,&lt;br /&gt;
as long as the definitions are not circular.&lt;br /&gt;
&lt;br /&gt;
Policy files can reference variables defined in other policy&lt;br /&gt;
files. Policy files can also override variables defined elsewhere by&lt;br /&gt;
redefining them. In this case, the new definition affects all policy&lt;br /&gt;
files, also those processed before the overriding policy. Awall&lt;br /&gt;
variables are in fact simple macros, since each variable remains&lt;br /&gt;
constant thoughout a single processing round. If multiple files define&lt;br /&gt;
the same variable, the definition in the file processed last takes&lt;br /&gt;
effect.&lt;br /&gt;
&lt;br /&gt;
If defined as an empty string, all non-embedded references to a&lt;br /&gt;
variable evaluate as if the attribute in question was not present in&lt;br /&gt;
the configuration. This is also the case when a string containing&lt;br /&gt;
embedded variable references finally evaluates to an empty string.&lt;br /&gt;
&lt;br /&gt;
== Configuration Objects ==&lt;br /&gt;
&lt;br /&gt;
Configuration objects can be divided into two main types.&lt;br /&gt;
&#039;&#039;Auxiliary objects&#039;&#039; model high-level concepts such as services and&lt;br /&gt;
zones. &#039;&#039;Rule objects&#039;&#039; translate into one or more iptables rules, and&lt;br /&gt;
are often defined with the help of some auxiliary objects.&lt;br /&gt;
&lt;br /&gt;
=== Services ===&lt;br /&gt;
&lt;br /&gt;
A &#039;&#039;service&#039;&#039; represents a set of network protocols. A top-level&lt;br /&gt;
attribute &#039;&#039;&#039;service&#039;&#039;&#039; is a dictionary that maps service names to&lt;br /&gt;
service definition objects, or lists thereof in more complex cases.&lt;br /&gt;
&lt;br /&gt;
A service definition object contains an attribute named &#039;&#039;&#039;proto&#039;&#039;&#039;,&lt;br /&gt;
which corresponds to the &amp;lt;tt&amp;gt;--protocol&amp;lt;/tt&amp;gt; option of iptables. The&lt;br /&gt;
protocol can be defined as a numerical value or string as defined in&lt;br /&gt;
&amp;lt;tt&amp;gt;/etc/protocols&amp;lt;/tt&amp;gt;. If the protocol is &#039;&#039;&#039;tcp&#039;&#039;&#039; or &#039;&#039;&#039;udp&#039;&#039;&#039;,&lt;br /&gt;
the scope of the service definition may be constrained by defining an&lt;br /&gt;
attribute named &#039;&#039;&#039;port&#039;&#039;&#039;, which is a list of TCP or UDP port&lt;br /&gt;
numbers. If the protocol is &#039;&#039;&#039;icmp&#039;&#039;&#039; or &#039;&#039;&#039;icmpv6&#039;&#039;&#039;, an analogous &lt;br /&gt;
&#039;&#039;&#039;icmp-type&#039;&#039;&#039; attribute may be used. In addition, the scope of the&lt;br /&gt;
rule is also automatically limited to IPv4 or IPv6, respectively.&lt;br /&gt;
&lt;br /&gt;
=== Zones ===&lt;br /&gt;
&lt;br /&gt;
A &#039;&#039;zone&#039;&#039; represents a set of network hosts. A top-level attribute &lt;br /&gt;
&#039;&#039;&#039;zone&#039;&#039;&#039; is a dictionary that maps zone names to zone objects. A&lt;br /&gt;
zone object has an attribute named &#039;&#039;&#039;iface&#039;&#039;&#039;, &#039;&#039;&#039;addr&#039;&#039;&#039;, or&lt;br /&gt;
both. &#039;&#039;&#039;iface&#039;&#039;&#039; is a list of network interfaces and &#039;&#039;&#039;addr&#039;&#039;&#039; is a&lt;br /&gt;
list of IPv4/IPv6 host and network addresses (CIDR&lt;br /&gt;
notation). &#039;&#039;&#039;addr&#039;&#039;&#039; may also contain domain names, which are&lt;br /&gt;
expanded to IP addresses using DNS resolution. If not defined,&lt;br /&gt;
&#039;&#039;&#039;addr&#039;&#039;&#039; defaults to the entire address space and &#039;&#039;&#039;iface&#039;&#039;&#039; to all&lt;br /&gt;
interfaces. An empty zone can be defined by setting either &#039;&#039;&#039;addr&#039;&#039;&#039;&lt;br /&gt;
or &#039;&#039;&#039;iface&#039;&#039;&#039; to an empty list.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Rule objects contain two attributes, &#039;&#039;&#039;in&#039;&#039;&#039; and &#039;&#039;&#039;out&#039;&#039;&#039;, which are&lt;br /&gt;
lists of zone names. These attributes control whether a packet matches&lt;br /&gt;
the rule or not. If a particular zone is referenced by the &#039;&#039;&#039;in&#039;&#039;&#039; &lt;br /&gt;
attribute, the rule applies to packets whose ingress interface and&lt;br /&gt;
source address are covered by the zone definition. Correspondingly, if&lt;br /&gt;
a zone is referenced by the &#039;&#039;&#039;out&#039;&#039;&#039; attribute, the rule applies to&lt;br /&gt;
packets whose egress interface and destination address are included in&lt;br /&gt;
the zone. If both &#039;&#039;&#039;in&#039;&#039;&#039; and &#039;&#039;&#039;out&#039;&#039;&#039; are defined, the packet must&lt;br /&gt;
fulfill both criteria in order to match the rule.&lt;br /&gt;
&lt;br /&gt;
The firewall host itself can be referred to using the special value&lt;br /&gt;
&#039;&#039;&#039;_fw&#039;&#039;&#039; as the zone name.&lt;br /&gt;
&lt;br /&gt;
=== Logging Classes ===&lt;br /&gt;
&lt;br /&gt;
A &#039;&#039;logging class&#039;&#039; specifies how packets matching certain rules are&lt;br /&gt;
logged. A top-level attribute &#039;&#039;&#039;log&#039;&#039;&#039; is a dictionary that maps&lt;br /&gt;
logging class names to setting objects.&lt;br /&gt;
&lt;br /&gt;
A setting object may have an attribute named &#039;&#039;&#039;mode&#039;&#039;&#039;, which&lt;br /&gt;
specifies which logging facility to use. Allowed values are &#039;&#039;&#039;log&#039;&#039;&#039;,&lt;br /&gt;
&#039;&#039;&#039;nflog&#039;&#039;&#039;, and &#039;&#039;&#039;ulog&#039;&#039;&#039;. The default is &#039;&#039;&#039;log&#039;&#039;&#039;, i.e. in-kernel&lt;br /&gt;
logging. The object may also have a &#039;&#039;&#039;limit&#039;&#039;&#039; attribute, which is an&lt;br /&gt;
integer specifying the maximum number of matching packets to be logged&lt;br /&gt;
per second per rule.&lt;br /&gt;
&lt;br /&gt;
Filter and policy rules can have an attribute named &#039;&#039;&#039;log&#039;&#039;&#039;. If it&lt;br /&gt;
is a string, it is interpreted as a reference to a logging class, and&lt;br /&gt;
logging is performed according to the definitions. If the value of the&lt;br /&gt;
&#039;&#039;&#039;log&#039;&#039;&#039; attribute is &#039;&#039;&#039;true&#039;&#039;&#039; (boolean), logging is done using&lt;br /&gt;
default settings. If the value is &#039;&#039;&#039;false&#039;&#039;&#039; (boolean), logging is&lt;br /&gt;
disabled for the rule. If &#039;&#039;&#039;log&#039;&#039;&#039; is not defined, logging is done&lt;br /&gt;
using the default settings except for accept rules, for which logging&lt;br /&gt;
is omitted.&lt;br /&gt;
&lt;br /&gt;
Default logging settings can be set by defining a logging class named&lt;br /&gt;
&#039;&#039;&#039;_default&#039;&#039;&#039;. Normally, default logging uses the &#039;&#039;&#039;log&#039;&#039;&#039; mode with&lt;br /&gt;
packets limited to one per second.&lt;br /&gt;
&lt;br /&gt;
=== Rules ===&lt;br /&gt;
&lt;br /&gt;
There are five types of rule objects:&lt;br /&gt;
* policies&lt;br /&gt;
* filters&lt;br /&gt;
* NAT rules&lt;br /&gt;
* packet marking rules&lt;br /&gt;
* MSS clamping rules&lt;br /&gt;
* connection tracking bypass rules&lt;br /&gt;
&lt;br /&gt;
All rule objects can have the &#039;&#039;&#039;in&#039;&#039;&#039; and &#039;&#039;&#039;out&#039;&#039;&#039; attributes&lt;br /&gt;
referring to zones as described in the previous section. In addition,&lt;br /&gt;
the scope of the rule can be further constrained with the following&lt;br /&gt;
attributes:&lt;br /&gt;
&lt;br /&gt;
{|&lt;br /&gt;
!Attribute!!Value format!!Effect&lt;br /&gt;
|-&lt;br /&gt;
|&#039;&#039;&#039;src&#039;&#039;&#039;&lt;br /&gt;
|Similar to &#039;&#039;&#039;addr&#039;&#039;&#039; attribute of zone objects&lt;br /&gt;
|Packet&#039;s source address matches the value&lt;br /&gt;
|-&lt;br /&gt;
|&#039;&#039;&#039;dest&#039;&#039;&#039;&lt;br /&gt;
|Similar to &#039;&#039;&#039;addr&#039;&#039;&#039; attribute of zone objects&lt;br /&gt;
|Packet&#039;s destination address matches the value&lt;br /&gt;
|-&lt;br /&gt;
|&#039;&#039;&#039;ipset&#039;&#039;&#039;&lt;br /&gt;
|Object containing two attributes: &#039;&#039;&#039;name&#039;&#039;&#039; referring to an IP set and &#039;&#039;&#039;args&#039;&#039;&#039;, which is a list of strings &#039;&#039;&#039;in&#039;&#039;&#039; and &#039;&#039;&#039;out&#039;&#039;&#039;&lt;br /&gt;
|Packet matches the IP set referred here when the match arguments are taken from the source (&#039;&#039;&#039;in&#039;&#039;&#039;) and destination (&#039;&#039;&#039;out&#039;&#039;&#039;) address or port in the order specified by &#039;&#039;&#039;args&#039;&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
|&#039;&#039;&#039;ipsec&#039;&#039;&#039;&lt;br /&gt;
|&#039;&#039;&#039;in&#039;&#039;&#039; or &#039;&#039;&#039;out&#039;&#039;&#039;&lt;br /&gt;
|IPsec decapsulation perfomed on ingress (&#039;&#039;&#039;in&#039;&#039;&#039;) or encapsulation performed on egress (&#039;&#039;&#039;out&#039;&#039;&#039;)&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Rule objects are declared in type-specific top-level dictionaries in&lt;br /&gt;
awall policy files. If a packet matches multiple rules, the one&lt;br /&gt;
appearing earlier in the list takes precedence. If the matching rules&lt;br /&gt;
are defined in different policy files, the one that was processed&lt;br /&gt;
earlier takes precedence in the current implementation, but this may&lt;br /&gt;
change in future versions.&lt;br /&gt;
&lt;br /&gt;
==== Filters ====&lt;br /&gt;
&lt;br /&gt;
Filter objects specify an action for packets fulfilling certain&lt;br /&gt;
criteria. The top-level attribute &#039;&#039;&#039;filter&#039;&#039;&#039; is a list of filter&lt;br /&gt;
objects. The precedence rules are similar to those of policy objects.&lt;br /&gt;
&lt;br /&gt;
In addition to the common rule attributes, filter objects can have a &lt;br /&gt;
&#039;&#039;&#039;service&#039;&#039;&#039; attribute constraining the scope to specific services&lt;br /&gt;
only. This attribute is a list of service names, referring to the&lt;br /&gt;
keys of the top-level &#039;&#039;&#039;service&#039;&#039;&#039; dictionary.&lt;br /&gt;
&lt;br /&gt;
Filter objects must have an attribute named &#039;&#039;&#039;action&#039;&#039;&#039;, the value of&lt;br /&gt;
which can be one of the following:&lt;br /&gt;
&lt;br /&gt;
{|&lt;br /&gt;
!Value!!Action&lt;br /&gt;
|-&lt;br /&gt;
|&#039;&#039;&#039;accept&#039;&#039;&#039;&lt;br /&gt;
|Accept the packet&lt;br /&gt;
|-&lt;br /&gt;
|&#039;&#039;&#039;reject&#039;&#039;&#039;&lt;br /&gt;
|Reject the packet with an ICMP error message&lt;br /&gt;
|-&lt;br /&gt;
|&#039;&#039;&#039;drop&#039;&#039;&#039;&lt;br /&gt;
|Silently drop the packet&lt;br /&gt;
|-&lt;br /&gt;
|&#039;&#039;&#039;tarpit&#039;&#039;&#039;&lt;br /&gt;
|Put incoming TCP connections into persist state and ignore attempts to close them. Silently drop non-TCP packets. (Connection tracking bypass is automatically enabled for the matching packets.)&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Filter objects, the action of which is &#039;&#039;&#039;accept&#039;&#039;&#039;, may also contain&lt;br /&gt;
limits for packet flow or new connections. These are specified with&lt;br /&gt;
the &#039;&#039;&#039;flow-limit&#039;&#039;&#039; and &#039;&#039;&#039;conn-limit&#039;&#039;&#039; attributes,&lt;br /&gt;
respectively. The values of these attributes are limit objects that&lt;br /&gt;
have two attributes: &#039;&#039;&#039;count&#039;&#039;&#039; and &#039;&#039;&#039;interval&#039;&#039;&#039;. &#039;&#039;&#039;count&#039;&#039;&#039;&lt;br /&gt;
specifies how many new connections or packets are allowed within the&lt;br /&gt;
time frame specified by &#039;&#039;&#039;interval&#039;&#039;&#039; (in seconds). The &#039;&#039;&#039;logdrop&#039;&#039;&#039;&lt;br /&gt;
action is applied to the packets exceeding the limit.&lt;br /&gt;
&lt;br /&gt;
Filter objects may have an attribute named &#039;&#039;&#039;dnat&#039;&#039;&#039;, the value of&lt;br /&gt;
which is an IPv4 address. If defined, this enables destination NAT for&lt;br /&gt;
all IPv4 packets matching the rule, such that the specified address&lt;br /&gt;
replaces the original destination address. This option has no effect&lt;br /&gt;
on IPv6 packets.&lt;br /&gt;
&lt;br /&gt;
==== Policies ====&lt;br /&gt;
&lt;br /&gt;
Policy objects describe the default action for packets that did not&lt;br /&gt;
match any filter. The top-level attribute &#039;&#039;&#039;policy&#039;&#039;&#039; is a list of&lt;br /&gt;
policy objects.&lt;br /&gt;
&lt;br /&gt;
Policy objects must have the &#039;&#039;&#039;action&#039;&#039;&#039; attribute defined. The&lt;br /&gt;
possible values and their semantics are the same as in filter objects.&lt;br /&gt;
&lt;br /&gt;
==== NAT Rules ====&lt;br /&gt;
&lt;br /&gt;
NAT rules come in two flavors: &#039;&#039;source NAT rules&#039;&#039; and&lt;br /&gt;
&#039;&#039;destination NAT rules&#039;&#039;. These are contained in two top-level lists&lt;br /&gt;
named &#039;&#039;&#039;snat&#039;&#039;&#039; and &#039;&#039;&#039;dnat&#039;&#039;&#039;, respectively.&lt;br /&gt;
&lt;br /&gt;
Each NAT rule may have an attribute named &#039;&#039;&#039;ip-range&#039;&#039;&#039; that&lt;br /&gt;
specifies the IPv4 address range to which the original source or&lt;br /&gt;
destination address is mapped. The value can be a single IPv4 address&lt;br /&gt;
or a range specified by two addresses, separated with the &#039;&#039;&#039;-&#039;&#039;&#039;&lt;br /&gt;
character. If not defined, it defaults to the primary address of the&lt;br /&gt;
ingress interface in case of destination NAT, or that of the egress&lt;br /&gt;
interface in case of source NAT.&lt;br /&gt;
&lt;br /&gt;
Optionally, a NAT rule can specify the TCP and UDP port range to which&lt;br /&gt;
the original source or destination port is mapped. The attribute is&lt;br /&gt;
named &#039;&#039;&#039;port-range&#039;&#039;&#039;, and the value can be a single port number or a&lt;br /&gt;
range specified by two numbers, separated with the &#039;&#039;&#039;-&#039;&#039;&#039;&lt;br /&gt;
character. If &#039;&#039;&#039;port-range&#039;&#039;&#039; is not specified, the original port&lt;br /&gt;
number is kept intact.&lt;br /&gt;
&lt;br /&gt;
Like filters, NAT rules can have a &#039;&#039;&#039;service&#039;&#039;&#039; attribute&lt;br /&gt;
constraining their scope to specific services.&lt;br /&gt;
&lt;br /&gt;
NAT rules may have an &#039;&#039;&#039;action&#039;&#039;&#039; attribute set to value&lt;br /&gt;
&#039;&#039;&#039;accept&#039;&#039;&#039;. In this case, NAT is not performed on the packets&lt;br /&gt;
reaching and matching this rule.&lt;br /&gt;
&lt;br /&gt;
==== Packet Marking Rules ====&lt;br /&gt;
&lt;br /&gt;
Packet marking rules are used to mark incoming packets matching the&lt;br /&gt;
specified criteria. The mark can be used as a basis for the routing&lt;br /&gt;
decision. Each marking rule must specify the mark using the &#039;&#039;&#039;mark&#039;&#039;&#039;&lt;br /&gt;
attribute, which is a 32-bit integer.&lt;br /&gt;
&lt;br /&gt;
Normal marking rules are contained by the top-level list attribute&lt;br /&gt;
named &#039;&#039;&#039;mark&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
There is another top-level list attribute, named &#039;&#039;&#039;route-track&#039;&#039;&#039;,&lt;br /&gt;
which contains route tracking rules. These are special marking rules&lt;br /&gt;
which cause all the subsequent packets related to the same connection&lt;br /&gt;
to be marked according to the rule.&lt;br /&gt;
&lt;br /&gt;
==== MSS Clamping Rules ====&lt;br /&gt;
&lt;br /&gt;
MSS Clamping Rules are used to deal with ISPs that block ICMP&lt;br /&gt;
Fragmentation Needed or ICMPv6 Packet Too Big packets. An MSS clamping&lt;br /&gt;
rule overwrites the MSS option with a value specified with the&lt;br /&gt;
&#039;&#039;&#039;mss&#039;&#039;&#039; attribute for the matching TCP connections. If &#039;&#039;&#039;mss&#039;&#039;&#039; is&lt;br /&gt;
not specified, a suitable value is automatically determined from the&lt;br /&gt;
path MTU.&lt;br /&gt;
&lt;br /&gt;
==== Connection Tracking Bypass Rules ====&lt;br /&gt;
&lt;br /&gt;
Connection tracking bypass rules are used to disable connection&lt;br /&gt;
tracking for packets matching the specified criteria. The top-level&lt;br /&gt;
attribute &#039;&#039;&#039;no-track&#039;&#039;&#039; is a list of such rules.&lt;br /&gt;
&lt;br /&gt;
Connection tracking bypass rules may have an &#039;&#039;&#039;action&#039;&#039;&#039; attribute&lt;br /&gt;
set to value &#039;&#039;&#039;accept&#039;&#039;&#039;. The effect is similar to corresponding NAT&lt;br /&gt;
rules, i.e. connection tracking is not bypassed for the matching&lt;br /&gt;
packets.&lt;br /&gt;
&lt;br /&gt;
=== IP Sets ===&lt;br /&gt;
&lt;br /&gt;
Any IP set referenced by rule objects should be created by&lt;br /&gt;
awall. Auxiliary &#039;&#039;IP set&#039;&#039; objects are used to defined them in awall&lt;br /&gt;
policy files. The top-level attribute &#039;&#039;&#039;ipset&#039;&#039;&#039; is a dictionary, the&lt;br /&gt;
keys of which are IP set names. The values are IP set objects, which&lt;br /&gt;
have two mandatory attributes. The attribute named &#039;&#039;&#039;type&#039;&#039;&#039; &lt;br /&gt;
corresponds to the type argument of the &amp;lt;tt&amp;gt;ipset create&amp;lt;/tt&amp;gt; &lt;br /&gt;
command. &#039;&#039;&#039;family&#039;&#039;&#039; specifies whether the set is for IPv4 or IPv6&lt;br /&gt;
addresses, and the possible values are &#039;&#039;&#039;inet&#039;&#039;&#039; and &#039;&#039;&#039;inet6&#039;&#039;&#039;,&lt;br /&gt;
correspondingly.&lt;br /&gt;
&lt;br /&gt;
== Command Line Syntax ==&lt;br /&gt;
&lt;br /&gt;
=== Translating Policy Files to Firewall Configuration Files ===&lt;br /&gt;
&lt;br /&gt;
 &#039;&#039;&#039;awall translate&#039;&#039;&#039; [&#039;&#039;&#039;-o&#039;&#039;&#039;|&#039;&#039;&#039;--output&#039;&#039;&#039; DIRECTORY] [&#039;&#039;&#039;-V&#039;&#039;&#039;|&#039;&#039;&#039;--verify&#039;&#039;&#039;]&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;tt&amp;gt;--verify&amp;lt;/tt&amp;gt; option makes awall verify the configuration&lt;br /&gt;
using the test mode of iptables-restore before overwriting the old&lt;br /&gt;
files.&lt;br /&gt;
&lt;br /&gt;
Specifying the output directory allows testing awall policies without&lt;br /&gt;
overwriting the current iptables and ipset configuration files. By&lt;br /&gt;
default, awall generates the configuration to &amp;lt;tt&amp;gt;/etc/iptables&amp;lt;/tt&amp;gt; &lt;br /&gt;
and &amp;lt;tt&amp;gt;/etc/ipset.d&amp;lt;/tt&amp;gt;, which are read by the init scripts.&lt;br /&gt;
&lt;br /&gt;
=== Run-Time Configuration of Firewall ===&lt;br /&gt;
&lt;br /&gt;
 &#039;&#039;&#039;awall activate&#039;&#039;&#039; [&#039;&#039;&#039;-f&#039;&#039;&#039;|&#039;&#039;&#039;--force&#039;&#039;&#039;]&lt;br /&gt;
&lt;br /&gt;
This command genereates firewall configuration from the policy files&lt;br /&gt;
and enables it. If the user confirms the new configuration by hitting&lt;br /&gt;
the Return key within 10 seconds or the &amp;lt;tt&amp;gt;--force&amp;lt;/tt&amp;gt; option is&lt;br /&gt;
used, the configuration is saved to the files. Otherwise, the old&lt;br /&gt;
configuration is restored.&lt;br /&gt;
&lt;br /&gt;
There is also a command for deleting all firewall rules:&lt;br /&gt;
&lt;br /&gt;
 &#039;&#039;&#039;awall flush&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
This command configures the firewall to drop all packets.&lt;br /&gt;
&lt;br /&gt;
=== Optional Policies ===&lt;br /&gt;
&lt;br /&gt;
Optional policies can be enabled or disabled using this command:&lt;br /&gt;
&lt;br /&gt;
 &#039;&#039;&#039;awall&#039;&#039;&#039; {&#039;&#039;&#039;enable&#039;&#039;&#039;|&#039;&#039;&#039;disable&#039;&#039;&#039;} POLICY...&lt;br /&gt;
&lt;br /&gt;
Optional policies can be listed using this command:&lt;br /&gt;
&lt;br /&gt;
 &#039;&#039;&#039;awall list&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;&#039;enabled&#039;&#039;&#039; status means that the policy has been enabled by the&lt;br /&gt;
user. The &#039;&#039;&#039;disabled&#039;&#039;&#039; status means that the policy is not in&lt;br /&gt;
use. The &#039;&#039;&#039;required&#039;&#039;&#039; status means that the policy has not been&lt;br /&gt;
enabled by the user but is in use because it is required by another&lt;br /&gt;
policy which is in use.&lt;br /&gt;
&lt;br /&gt;
=== Debugging Policies ===&lt;br /&gt;
&lt;br /&gt;
This command can be used to dump variable, zone, and other definitions&lt;br /&gt;
as well as their source policies:&lt;br /&gt;
&lt;br /&gt;
 &#039;&#039;&#039;awall dump&#039;&#039;&#039; [LEVEL]&lt;br /&gt;
&lt;br /&gt;
The level is an integer in range 0&amp;amp;ndash;5 and defaults to 0. More&lt;br /&gt;
information is displayed on higher levels.&lt;br /&gt;
&lt;br /&gt;
[[Category:Networking]]&lt;br /&gt;
[[Category:Security]]&lt;/div&gt;</summary>
		<author><name>Kunkku</name></author>
	</entry>
	<entry>
		<id>https://wiki.alpinelinux.org/w/index.php?title=Alpine_Wall_User%27s_Guide&amp;diff=8351</id>
		<title>Alpine Wall User&#039;s Guide</title>
		<link rel="alternate" type="text/html" href="https://wiki.alpinelinux.org/w/index.php?title=Alpine_Wall_User%27s_Guide&amp;diff=8351"/>
		<updated>2012-07-19T05:59:37Z</updated>

		<summary type="html">&lt;p&gt;Kunkku: /* Rules */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Configuration File Processing ==&lt;br /&gt;
&lt;br /&gt;
[[Alpine Wall]] (awall) reads its configuration from multiple&lt;br /&gt;
JSON-formatted files, called &#039;&#039;policy files&#039;&#039;. The processing starts&lt;br /&gt;
from directory &amp;lt;tt&amp;gt;/usr/share/awall/mandatory&amp;lt;/tt&amp;gt;, which contains&lt;br /&gt;
mandatory policy files shipped with APK packages. After that,&lt;br /&gt;
installation-specific policy files in &amp;lt;tt&amp;gt;/etc/awall&amp;lt;/tt&amp;gt; are&lt;br /&gt;
processed.&lt;br /&gt;
&lt;br /&gt;
The latter directory may also contain symbolic links to policy files&lt;br /&gt;
located in &amp;lt;tt&amp;gt;/usr/share/awall/optional&amp;lt;/tt&amp;gt;. These are optional&lt;br /&gt;
policies, which can be enabled on need basis. Such symbolic links are&lt;br /&gt;
easily created and destroyed using the &amp;lt;tt&amp;gt;awall enable&amp;lt;/tt&amp;gt; and &lt;br /&gt;
&amp;lt;tt&amp;gt;awall disable&amp;lt;/tt&amp;gt; commands. &amp;lt;tt&amp;gt;awall list&amp;lt;/tt&amp;gt; shows which&lt;br /&gt;
optional policies are enabled and disabled. The command also prints&lt;br /&gt;
the description of the optional policy if defined in the file using&lt;br /&gt;
a top-level attribute named &#039;&#039;&#039;description&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Sometimes a policy file depends on other policy files. In this case,&lt;br /&gt;
the policy file must have a top-level attribute &#039;&#039;&#039;import&#039;&#039;&#039;, the&lt;br /&gt;
value of which is a list of policy names, which correspond to the file&lt;br /&gt;
names without the &amp;lt;tt&amp;gt;.json&amp;lt;/tt&amp;gt; suffix. The policies listed there are&lt;br /&gt;
always processed before the importing policy. The order of the&lt;br /&gt;
generated iptables rules generally reflects the processing order of&lt;br /&gt;
their corresponding awall policies.&lt;br /&gt;
&lt;br /&gt;
As the import directive does not require the path name to be&lt;br /&gt;
specified, awall expects policies to have unique names, even if&lt;br /&gt;
located in different directories. It is allowed to import optional&lt;br /&gt;
policies that are not explicitly enabled by the user. Such policies&lt;br /&gt;
show up with the &amp;lt;tt&amp;gt;required&amp;lt;/tt&amp;gt; status in the output of &amp;lt;tt&amp;gt;awall&lt;br /&gt;
list&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
== List Parameters ==&lt;br /&gt;
&lt;br /&gt;
Several awall parameters are defined as lists of values. In order to&lt;br /&gt;
facilitate manual editing of policy files, awall also accepts single&lt;br /&gt;
values in place of lists. Such values are semantically equivalent to&lt;br /&gt;
lists containing one element.&lt;br /&gt;
&lt;br /&gt;
== Variable Expansion ==&lt;br /&gt;
&lt;br /&gt;
Awall allows variable definitions in policy files. The top-level&lt;br /&gt;
attribute &#039;&#039;&#039;variable&#039;&#039;&#039; is a dictionary containing the&lt;br /&gt;
definitions. The value of a variable can be of any type (string,&lt;br /&gt;
integer, list, or dictionary).&lt;br /&gt;
&lt;br /&gt;
A variable is referenced in policy files by a string which equals the&lt;br /&gt;
variable name prepended with the &#039;&#039;&#039;$&#039;&#039;&#039; character. If the value of&lt;br /&gt;
the variable is a string, the reference can be embedded into a longer&lt;br /&gt;
string in order to substitute some part of that string (in shell&lt;br /&gt;
style). Variable references can be used when defining other variables,&lt;br /&gt;
as long as the definitions are not circular.&lt;br /&gt;
&lt;br /&gt;
Policy files can reference variables defined in other policy&lt;br /&gt;
files. Policy files can also override variables defined elsewhere by&lt;br /&gt;
redefining them. In this case, the new definition affects all policy&lt;br /&gt;
files, also those processed before the overriding policy. Awall&lt;br /&gt;
variables are in fact simple macros, since each variable remains&lt;br /&gt;
constant thoughout a single processing round. If multiple files define&lt;br /&gt;
the same variable, the definition in the file processed last takes&lt;br /&gt;
effect.&lt;br /&gt;
&lt;br /&gt;
If defined as an empty string, all non-embedded references to a&lt;br /&gt;
variable evaluate as if the attribute in question was not present in&lt;br /&gt;
the configuration. This is also the case when a string containing&lt;br /&gt;
embedded variable references finally evaluates to an empty string.&lt;br /&gt;
&lt;br /&gt;
== Configuration Objects ==&lt;br /&gt;
&lt;br /&gt;
Configuration objects can be divided into two main types.&lt;br /&gt;
&#039;&#039;Auxiliary objects&#039;&#039; model high-level concepts such as services and&lt;br /&gt;
zones. &#039;&#039;Rule objects&#039;&#039; translate into one or more iptables rules, and&lt;br /&gt;
are often defined with the help of some auxiliary objects.&lt;br /&gt;
&lt;br /&gt;
=== Services ===&lt;br /&gt;
&lt;br /&gt;
A &#039;&#039;service&#039;&#039; represents a set of network protocols. A top-level&lt;br /&gt;
attribute &#039;&#039;&#039;service&#039;&#039;&#039; is a dictionary that maps service names to&lt;br /&gt;
service definition objects, or lists thereof in more complex cases.&lt;br /&gt;
&lt;br /&gt;
A service definition object contains an attribute named &#039;&#039;&#039;proto&#039;&#039;&#039;,&lt;br /&gt;
which corresponds to the &amp;lt;tt&amp;gt;--protocol&amp;lt;/tt&amp;gt; option of iptables. The&lt;br /&gt;
protocol can be defined as a numerical value or string as defined in&lt;br /&gt;
&amp;lt;tt&amp;gt;/etc/protocols&amp;lt;/tt&amp;gt;. If the protocol is &#039;&#039;&#039;tcp&#039;&#039;&#039; or &#039;&#039;&#039;udp&#039;&#039;&#039;,&lt;br /&gt;
the scope of the service definition may be constrained by defining an&lt;br /&gt;
attribute named &#039;&#039;&#039;port&#039;&#039;&#039;, which is a list of TCP or UDP port&lt;br /&gt;
numbers. If the protocol is &#039;&#039;&#039;icmp&#039;&#039;&#039; or &#039;&#039;&#039;icmpv6&#039;&#039;&#039;, an analogous &lt;br /&gt;
&#039;&#039;&#039;icmp-type&#039;&#039;&#039; attribute may be used. In addition, the scope of the&lt;br /&gt;
rule is also automatically limited to IPv4 or IPv6, respectively.&lt;br /&gt;
&lt;br /&gt;
=== Zones ===&lt;br /&gt;
&lt;br /&gt;
A &#039;&#039;zone&#039;&#039; represents a set of network hosts. A top-level attribute &lt;br /&gt;
&#039;&#039;&#039;zone&#039;&#039;&#039; is a dictionary that maps zone names to zone objects. A&lt;br /&gt;
zone object has an attribute named &#039;&#039;&#039;iface&#039;&#039;&#039;, &#039;&#039;&#039;addr&#039;&#039;&#039;, or&lt;br /&gt;
both. &#039;&#039;&#039;iface&#039;&#039;&#039; is a list of network interfaces and &#039;&#039;&#039;addr&#039;&#039;&#039; is a&lt;br /&gt;
list of IPv4/IPv6 host and network addresses (CIDR&lt;br /&gt;
notation). &#039;&#039;&#039;addr&#039;&#039;&#039; may also contain domain names, which are&lt;br /&gt;
expanded to IP addresses using DNS resolution. If not defined,&lt;br /&gt;
&#039;&#039;&#039;addr&#039;&#039;&#039; defaults to the entire address space and &#039;&#039;&#039;iface&#039;&#039;&#039; to all&lt;br /&gt;
interfaces. An empty zone can be defined by setting either &#039;&#039;&#039;addr&#039;&#039;&#039;&lt;br /&gt;
or &#039;&#039;&#039;iface&#039;&#039;&#039; to an empty list.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Rule objects contain two attributes, &#039;&#039;&#039;in&#039;&#039;&#039; and &#039;&#039;&#039;out&#039;&#039;&#039;, which are&lt;br /&gt;
lists of zone names. These attributes control whether a packet matches&lt;br /&gt;
the rule or not. If a particular zone is referenced by the &#039;&#039;&#039;in&#039;&#039;&#039; &lt;br /&gt;
attribute, the rule applies to packets whose ingress interface and&lt;br /&gt;
source address are covered by the zone definition. Correspondingly, if&lt;br /&gt;
a zone is referenced by the &#039;&#039;&#039;out&#039;&#039;&#039; attribute, the rule applies to&lt;br /&gt;
packets whose egress interface and destination address are included in&lt;br /&gt;
the zone. If both &#039;&#039;&#039;in&#039;&#039;&#039; and &#039;&#039;&#039;out&#039;&#039;&#039; are defined, the packet must&lt;br /&gt;
fulfill both criteria in order to match the rule.&lt;br /&gt;
&lt;br /&gt;
=== Rules ===&lt;br /&gt;
&lt;br /&gt;
There are five types of rule objects:&lt;br /&gt;
* policies&lt;br /&gt;
* filters&lt;br /&gt;
* NAT rules&lt;br /&gt;
* packet marking rules&lt;br /&gt;
* MSS clamping rules&lt;br /&gt;
* connection tracking bypass rules&lt;br /&gt;
&lt;br /&gt;
All rule objects can have the &#039;&#039;&#039;in&#039;&#039;&#039; and &#039;&#039;&#039;out&#039;&#039;&#039; attributes&lt;br /&gt;
referring to zones as described in the previous section. In addition,&lt;br /&gt;
the scope of the rule can be further constrained with the following&lt;br /&gt;
attributes:&lt;br /&gt;
&lt;br /&gt;
{|&lt;br /&gt;
!Attribute!!Value format!!Effect&lt;br /&gt;
|-&lt;br /&gt;
|&#039;&#039;&#039;src&#039;&#039;&#039;&lt;br /&gt;
|Similar to &#039;&#039;&#039;addr&#039;&#039;&#039; attribute of zone objects&lt;br /&gt;
|Packet&#039;s source address matches the value&lt;br /&gt;
|-&lt;br /&gt;
|&#039;&#039;&#039;dest&#039;&#039;&#039;&lt;br /&gt;
|Similar to &#039;&#039;&#039;addr&#039;&#039;&#039; attribute of zone objects&lt;br /&gt;
|Packet&#039;s destination address matches the value&lt;br /&gt;
|-&lt;br /&gt;
|&#039;&#039;&#039;ipset&#039;&#039;&#039;&lt;br /&gt;
|Object containing two attributes: &#039;&#039;&#039;name&#039;&#039;&#039; referring to an IP set and &#039;&#039;&#039;args&#039;&#039;&#039;, which is a list of strings &#039;&#039;&#039;in&#039;&#039;&#039; and &#039;&#039;&#039;out&#039;&#039;&#039;&lt;br /&gt;
|Packet matches the IP set referred here when the match arguments are taken from the source (&#039;&#039;&#039;in&#039;&#039;&#039;) and destination (&#039;&#039;&#039;out&#039;&#039;&#039;) address or port in the order specified by &#039;&#039;&#039;args&#039;&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
|&#039;&#039;&#039;ipsec&#039;&#039;&#039;&lt;br /&gt;
|&#039;&#039;&#039;in&#039;&#039;&#039; or &#039;&#039;&#039;out&#039;&#039;&#039;&lt;br /&gt;
|IPsec decapsulation perfomed on ingress (&#039;&#039;&#039;in&#039;&#039;&#039;) or encapsulation performed on egress (&#039;&#039;&#039;out&#039;&#039;&#039;)&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Rule objects are declared in type-specific top-level dictionaries in&lt;br /&gt;
awall policy files. If a packet matches multiple rules, the one&lt;br /&gt;
appearing earlier in the list takes precedence. If the matching rules&lt;br /&gt;
are defined in different policy files, the one that was processed&lt;br /&gt;
earlier takes precedence in the current implementation, but this may&lt;br /&gt;
change in future versions.&lt;br /&gt;
&lt;br /&gt;
==== Filters ====&lt;br /&gt;
&lt;br /&gt;
Filter objects specify an action for packets fulfilling certain&lt;br /&gt;
criteria. The top-level attribute &#039;&#039;&#039;filter&#039;&#039;&#039; is a list of filter&lt;br /&gt;
objects. The precedence rules are similar to those of policy objects.&lt;br /&gt;
&lt;br /&gt;
In addition to the common rule attributes, filter objects can have a &lt;br /&gt;
&#039;&#039;&#039;service&#039;&#039;&#039; attribute constraining the scope to specific services&lt;br /&gt;
only. This attribute is a list of service names, referring to the&lt;br /&gt;
keys of the top-level &#039;&#039;&#039;service&#039;&#039;&#039; dictionary.&lt;br /&gt;
&lt;br /&gt;
Filter objects must have an attribute named &#039;&#039;&#039;action&#039;&#039;&#039;, the value of&lt;br /&gt;
which can be one of the following:&lt;br /&gt;
&lt;br /&gt;
{|&lt;br /&gt;
!Value!!Action&lt;br /&gt;
|-&lt;br /&gt;
|&#039;&#039;&#039;accept&#039;&#039;&#039;&lt;br /&gt;
|Accept the packet&lt;br /&gt;
|-&lt;br /&gt;
|&#039;&#039;&#039;reject&#039;&#039;&#039;&lt;br /&gt;
|Reject the packet with an ICMP error message&lt;br /&gt;
|-&lt;br /&gt;
|&#039;&#039;&#039;drop&#039;&#039;&#039;&lt;br /&gt;
|Silently drop the packet&lt;br /&gt;
|-&lt;br /&gt;
|&#039;&#039;&#039;logreject&#039;&#039;&#039;&lt;br /&gt;
|Similar to &#039;&#039;&#039;reject&#039;&#039;&#039; but with kernel logging&lt;br /&gt;
|-&lt;br /&gt;
|&#039;&#039;&#039;logdrop&#039;&#039;&#039;&lt;br /&gt;
|Similar to &#039;&#039;&#039;drop&#039;&#039;&#039; but with kernel logging&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Filter objects, the action of which is &#039;&#039;&#039;accept&#039;&#039;&#039;, may also contain&lt;br /&gt;
limits for packet flow or new connections. These are specified with&lt;br /&gt;
the &#039;&#039;&#039;flow-limit&#039;&#039;&#039; and &#039;&#039;&#039;conn-limit&#039;&#039;&#039; attributes,&lt;br /&gt;
respectively. The values of these attributes are limit objects that&lt;br /&gt;
have two attributes: &#039;&#039;&#039;count&#039;&#039;&#039; and &#039;&#039;&#039;interval&#039;&#039;&#039;. &#039;&#039;&#039;count&#039;&#039;&#039;&lt;br /&gt;
specifies how many new connections or packets are allowed within the&lt;br /&gt;
time frame specified by &#039;&#039;&#039;interval&#039;&#039;&#039; (in seconds). The &#039;&#039;&#039;logdrop&#039;&#039;&#039;&lt;br /&gt;
action is applied to the packets exceeding the limit.&lt;br /&gt;
&lt;br /&gt;
Filter objects may have an attribute named &#039;&#039;&#039;dnat&#039;&#039;&#039;, the value of&lt;br /&gt;
which is an IPv4 address. If defined, this enables destination NAT for&lt;br /&gt;
all IPv4 packets matching the rule, such that the specified address&lt;br /&gt;
replaces the original destination address. This option has no effect&lt;br /&gt;
on IPv6 packets.&lt;br /&gt;
&lt;br /&gt;
==== Policies ====&lt;br /&gt;
&lt;br /&gt;
Policy objects describe the default action for packets that did not&lt;br /&gt;
match any filter. The top-level attribute &#039;&#039;&#039;policy&#039;&#039;&#039; is a list of&lt;br /&gt;
policy objects.&lt;br /&gt;
&lt;br /&gt;
Policy objects must have the &#039;&#039;&#039;action&#039;&#039;&#039; attribute defined. The&lt;br /&gt;
possible values and their semantics are the same as in filter objects.&lt;br /&gt;
&lt;br /&gt;
==== NAT Rules ====&lt;br /&gt;
&lt;br /&gt;
NAT rules come in two flavors: &#039;&#039;source NAT rules&#039;&#039; and&lt;br /&gt;
&#039;&#039;destination NAT rules&#039;&#039;. These are contained in two top-level lists&lt;br /&gt;
named &#039;&#039;&#039;snat&#039;&#039;&#039; and &#039;&#039;&#039;dnat&#039;&#039;&#039;, respectively.&lt;br /&gt;
&lt;br /&gt;
Each NAT rule may have an attribute named &#039;&#039;&#039;ip-range&#039;&#039;&#039; that&lt;br /&gt;
specifies the IPv4 address range to which the original source or&lt;br /&gt;
destination address is mapped. The value can be a single IPv4 address&lt;br /&gt;
or a range specified by two addresses, separated with the &#039;&#039;&#039;-&#039;&#039;&#039;&lt;br /&gt;
character. If not defined, it defaults to the primary address of the&lt;br /&gt;
ingress interface in case of destination NAT, or that of the egress&lt;br /&gt;
interface in case of source NAT.&lt;br /&gt;
&lt;br /&gt;
Optionally, a NAT rule can specify the TCP and UDP port range to which&lt;br /&gt;
the original source or destination port is mapped. The attribute is&lt;br /&gt;
named &#039;&#039;&#039;port-range&#039;&#039;&#039;, and the value can be a single port number or a&lt;br /&gt;
range specified by two numbers, separated with the &#039;&#039;&#039;-&#039;&#039;&#039;&lt;br /&gt;
character. If &#039;&#039;&#039;port-range&#039;&#039;&#039; is not specified, the original port&lt;br /&gt;
number is kept intact.&lt;br /&gt;
&lt;br /&gt;
Like filters, NAT rules can have a &#039;&#039;&#039;service&#039;&#039;&#039; attribute&lt;br /&gt;
constraining their scope to specific services.&lt;br /&gt;
&lt;br /&gt;
NAT rules may have an &#039;&#039;&#039;action&#039;&#039;&#039; attribute set to value&lt;br /&gt;
&#039;&#039;&#039;accept&#039;&#039;&#039;. In this case, NAT is not performed on the packets&lt;br /&gt;
reaching and matching this rule.&lt;br /&gt;
&lt;br /&gt;
==== Packet Marking Rules ====&lt;br /&gt;
&lt;br /&gt;
Packet marking rules are used to mark incoming packets matching the&lt;br /&gt;
specified criteria. The mark can be used as a basis for the routing&lt;br /&gt;
decision. Each marking rule must specify the mark using the &#039;&#039;&#039;mark&#039;&#039;&#039;&lt;br /&gt;
attribute, which is a 32-bit integer.&lt;br /&gt;
&lt;br /&gt;
Normal marking rules are contained by the top-level list attribute&lt;br /&gt;
named &#039;&#039;&#039;mark&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
There is another top-level list attribute, named &#039;&#039;&#039;route-track&#039;&#039;&#039;,&lt;br /&gt;
which contains route tracking rules. These are special marking rules&lt;br /&gt;
which cause all the subsequent packets related to the same connection&lt;br /&gt;
to be marked according to the rule.&lt;br /&gt;
&lt;br /&gt;
==== MSS Clamping Rules ====&lt;br /&gt;
&lt;br /&gt;
MSS Clamping Rules are used to deal with ISPs that block ICMP&lt;br /&gt;
Fragmentation Needed or ICMPv6 Packet Too Big packets. An MSS clamping&lt;br /&gt;
rule overwrites the MSS option with a value specified with the&lt;br /&gt;
&#039;&#039;&#039;mss&#039;&#039;&#039; attribute for the matching TCP connections. If &#039;&#039;&#039;mss&#039;&#039;&#039; is&lt;br /&gt;
not specified, a suitable value is automatically determined from the&lt;br /&gt;
path MTU.&lt;br /&gt;
&lt;br /&gt;
==== Connection Tracking Bypass Rules ====&lt;br /&gt;
&lt;br /&gt;
Connection tracking bypass rules are used to disable connection&lt;br /&gt;
tracking for packets matching the specified criteria. The top-level&lt;br /&gt;
attribute &#039;&#039;&#039;no-track&#039;&#039;&#039; is a list of such rules.&lt;br /&gt;
&lt;br /&gt;
Connection tracking bypass rules may have an &#039;&#039;&#039;action&#039;&#039;&#039; attribute&lt;br /&gt;
set to value &#039;&#039;&#039;accept&#039;&#039;&#039;. The effect is similar to corresponding NAT&lt;br /&gt;
rules, i.e. connection tracking is not bypassed for the matching&lt;br /&gt;
packets.&lt;br /&gt;
&lt;br /&gt;
=== IP Sets ===&lt;br /&gt;
&lt;br /&gt;
Any IP set referenced by rule objects should be created by&lt;br /&gt;
awall. Auxiliary &#039;&#039;IP set&#039;&#039; objects are used to defined them in awall&lt;br /&gt;
policy files. The top-level attribute &#039;&#039;&#039;ipset&#039;&#039;&#039; is a dictionary, the&lt;br /&gt;
keys of which are IP set names. The values are IP set objects, which&lt;br /&gt;
have two mandatory attributes. The attribute named &#039;&#039;&#039;type&#039;&#039;&#039; &lt;br /&gt;
corresponds to the type argument of the &amp;lt;tt&amp;gt;ipset create&amp;lt;/tt&amp;gt; &lt;br /&gt;
command. &#039;&#039;&#039;family&#039;&#039;&#039; specifies whether the set is for IPv4 or IPv6&lt;br /&gt;
addresses, and the possible values are &#039;&#039;&#039;inet&#039;&#039;&#039; and &#039;&#039;&#039;inet6&#039;&#039;&#039;,&lt;br /&gt;
correspondingly.&lt;br /&gt;
&lt;br /&gt;
== Command Line Syntax ==&lt;br /&gt;
&lt;br /&gt;
=== Translating Policy Files to Firewall Configuration Files ===&lt;br /&gt;
&lt;br /&gt;
 &#039;&#039;&#039;awall translate&#039;&#039;&#039; [&#039;&#039;&#039;-o&#039;&#039;&#039;|&#039;&#039;&#039;--output&#039;&#039;&#039; DIRECTORY] [&#039;&#039;&#039;-V&#039;&#039;&#039;|&#039;&#039;&#039;--verify&#039;&#039;&#039;]&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;tt&amp;gt;--verify&amp;lt;/tt&amp;gt; option makes awall verify the configuration&lt;br /&gt;
using the test mode of iptables-restore before overwriting the old&lt;br /&gt;
files.&lt;br /&gt;
&lt;br /&gt;
Specifying the output directory allows testing awall policies without&lt;br /&gt;
overwriting the current iptables and ipset configuration files. By&lt;br /&gt;
default, awall generates the configuration to &amp;lt;tt&amp;gt;/etc/iptables&amp;lt;/tt&amp;gt; &lt;br /&gt;
and &amp;lt;tt&amp;gt;/etc/ipset.d&amp;lt;/tt&amp;gt;, which are read by the init scripts.&lt;br /&gt;
&lt;br /&gt;
=== Run-Time Configuration of Firewall ===&lt;br /&gt;
&lt;br /&gt;
 &#039;&#039;&#039;awall activate&#039;&#039;&#039; [&#039;&#039;&#039;-f&#039;&#039;&#039;|&#039;&#039;&#039;--force&#039;&#039;&#039;]&lt;br /&gt;
&lt;br /&gt;
This command genereates firewall configuration from the policy files&lt;br /&gt;
and enables it. If the user confirms the new configuration by hitting&lt;br /&gt;
the Return key within 10 seconds or the &amp;lt;tt&amp;gt;--force&amp;lt;/tt&amp;gt; option is&lt;br /&gt;
used, the configuration is saved to the files. Otherwise, the old&lt;br /&gt;
configuration is restored.&lt;br /&gt;
&lt;br /&gt;
There is also a command for deleting all firewall rules:&lt;br /&gt;
&lt;br /&gt;
 &#039;&#039;&#039;awall flush&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
This command configures the firewall to drop all packets.&lt;br /&gt;
&lt;br /&gt;
=== Optional Policies ===&lt;br /&gt;
&lt;br /&gt;
Optional policies can be enabled or disabled using this command:&lt;br /&gt;
&lt;br /&gt;
 &#039;&#039;&#039;awall&#039;&#039;&#039; {&#039;&#039;&#039;enable&#039;&#039;&#039;|&#039;&#039;&#039;disable&#039;&#039;&#039;} POLICY...&lt;br /&gt;
&lt;br /&gt;
Optional policies can be listed using this command:&lt;br /&gt;
&lt;br /&gt;
 &#039;&#039;&#039;awall list&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;&#039;enabled&#039;&#039;&#039; status means that the policy has been enabled by the&lt;br /&gt;
user. The &#039;&#039;&#039;disabled&#039;&#039;&#039; status means that the policy is not in&lt;br /&gt;
use. The &#039;&#039;&#039;required&#039;&#039;&#039; status means that the policy has not been&lt;br /&gt;
enabled by the user but is in use because it is required by another&lt;br /&gt;
policy which is in use.&lt;br /&gt;
&lt;br /&gt;
=== Debugging Policies ===&lt;br /&gt;
&lt;br /&gt;
This command can be used to dump variable, zone, and other definitions&lt;br /&gt;
as well as their source policies:&lt;br /&gt;
&lt;br /&gt;
 &#039;&#039;&#039;awall dump&#039;&#039;&#039; [LEVEL]&lt;br /&gt;
&lt;br /&gt;
The level is an integer in range 0&amp;amp;ndash;5 and defaults to 0. More&lt;br /&gt;
information is displayed on higher levels.&lt;br /&gt;
&lt;br /&gt;
[[Category:Networking]]&lt;br /&gt;
[[Category:Security]]&lt;/div&gt;</summary>
		<author><name>Kunkku</name></author>
	</entry>
	<entry>
		<id>https://wiki.alpinelinux.org/w/index.php?title=Alpine_Wall_User%27s_Guide&amp;diff=8316</id>
		<title>Alpine Wall User&#039;s Guide</title>
		<link rel="alternate" type="text/html" href="https://wiki.alpinelinux.org/w/index.php?title=Alpine_Wall_User%27s_Guide&amp;diff=8316"/>
		<updated>2012-07-13T13:22:32Z</updated>

		<summary type="html">&lt;p&gt;Kunkku: /* Debugging Policies */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Configuration File Processing ==&lt;br /&gt;
&lt;br /&gt;
[[Alpine Wall]] (awall) reads its configuration from multiple&lt;br /&gt;
JSON-formatted files, called &#039;&#039;policy files&#039;&#039;. The processing starts&lt;br /&gt;
from directory &amp;lt;tt&amp;gt;/usr/share/awall/mandatory&amp;lt;/tt&amp;gt;, which contains&lt;br /&gt;
mandatory policy files shipped with APK packages. After that,&lt;br /&gt;
installation-specific policy files in &amp;lt;tt&amp;gt;/etc/awall&amp;lt;/tt&amp;gt; are&lt;br /&gt;
processed.&lt;br /&gt;
&lt;br /&gt;
The latter directory may also contain symbolic links to policy files&lt;br /&gt;
located in &amp;lt;tt&amp;gt;/usr/share/awall/optional&amp;lt;/tt&amp;gt;. These are optional&lt;br /&gt;
policies, which can be enabled on need basis. Such symbolic links are&lt;br /&gt;
easily created and destroyed using the &amp;lt;tt&amp;gt;awall enable&amp;lt;/tt&amp;gt; and &lt;br /&gt;
&amp;lt;tt&amp;gt;awall disable&amp;lt;/tt&amp;gt; commands. &amp;lt;tt&amp;gt;awall list&amp;lt;/tt&amp;gt; shows which&lt;br /&gt;
optional policies are enabled and disabled. The command also prints&lt;br /&gt;
the description of the optional policy if defined in the file using&lt;br /&gt;
a top-level attribute named &#039;&#039;&#039;description&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Sometimes a policy file depends on other policy files. In this case,&lt;br /&gt;
the policy file must have a top-level attribute &#039;&#039;&#039;import&#039;&#039;&#039;, the&lt;br /&gt;
value of which is a list of policy names, which correspond to the file&lt;br /&gt;
names without the &amp;lt;tt&amp;gt;.json&amp;lt;/tt&amp;gt; suffix. The policies listed there are&lt;br /&gt;
always processed before the importing policy. The order of the&lt;br /&gt;
generated iptables rules generally reflects the processing order of&lt;br /&gt;
their corresponding awall policies.&lt;br /&gt;
&lt;br /&gt;
As the import directive does not require the path name to be&lt;br /&gt;
specified, awall expects policies to have unique names, even if&lt;br /&gt;
located in different directories. It is allowed to import optional&lt;br /&gt;
policies that are not explicitly enabled by the user. Such policies&lt;br /&gt;
show up with the &amp;lt;tt&amp;gt;required&amp;lt;/tt&amp;gt; status in the output of &amp;lt;tt&amp;gt;awall&lt;br /&gt;
list&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
== List Parameters ==&lt;br /&gt;
&lt;br /&gt;
Several awall parameters are defined as lists of values. In order to&lt;br /&gt;
facilitate manual editing of policy files, awall also accepts single&lt;br /&gt;
values in place of lists. Such values are semantically equivalent to&lt;br /&gt;
lists containing one element.&lt;br /&gt;
&lt;br /&gt;
== Variable Expansion ==&lt;br /&gt;
&lt;br /&gt;
Awall allows variable definitions in policy files. The top-level&lt;br /&gt;
attribute &#039;&#039;&#039;variable&#039;&#039;&#039; is a dictionary containing the&lt;br /&gt;
definitions. The value of a variable can be of any type (string,&lt;br /&gt;
integer, list, or dictionary).&lt;br /&gt;
&lt;br /&gt;
A variable is referenced in policy files by a string which equals the&lt;br /&gt;
variable name prepended with the &#039;&#039;&#039;$&#039;&#039;&#039; character. If the value of&lt;br /&gt;
the variable is a string, the reference can be embedded into a longer&lt;br /&gt;
string in order to substitute some part of that string (in shell&lt;br /&gt;
style). Variable references can be used when defining other variables,&lt;br /&gt;
as long as the definitions are not circular.&lt;br /&gt;
&lt;br /&gt;
Policy files can reference variables defined in other policy&lt;br /&gt;
files. Policy files can also override variables defined elsewhere by&lt;br /&gt;
redefining them. In this case, the new definition affects all policy&lt;br /&gt;
files, also those processed before the overriding policy. Awall&lt;br /&gt;
variables are in fact simple macros, since each variable remains&lt;br /&gt;
constant thoughout a single processing round. If multiple files define&lt;br /&gt;
the same variable, the definition in the file processed last takes&lt;br /&gt;
effect.&lt;br /&gt;
&lt;br /&gt;
If defined as an empty string, all non-embedded references to a&lt;br /&gt;
variable evaluate as if the attribute in question was not present in&lt;br /&gt;
the configuration. This is also the case when a string containing&lt;br /&gt;
embedded variable references finally evaluates to an empty string.&lt;br /&gt;
&lt;br /&gt;
== Configuration Objects ==&lt;br /&gt;
&lt;br /&gt;
Configuration objects can be divided into two main types.&lt;br /&gt;
&#039;&#039;Auxiliary objects&#039;&#039; model high-level concepts such as services and&lt;br /&gt;
zones. &#039;&#039;Rule objects&#039;&#039; translate into one or more iptables rules, and&lt;br /&gt;
are often defined with the help of some auxiliary objects.&lt;br /&gt;
&lt;br /&gt;
=== Services ===&lt;br /&gt;
&lt;br /&gt;
A &#039;&#039;service&#039;&#039; represents a set of network protocols. A top-level&lt;br /&gt;
attribute &#039;&#039;&#039;service&#039;&#039;&#039; is a dictionary that maps service names to&lt;br /&gt;
service definition objects, or lists thereof in more complex cases.&lt;br /&gt;
&lt;br /&gt;
A service definition object contains an attribute named &#039;&#039;&#039;proto&#039;&#039;&#039;,&lt;br /&gt;
which corresponds to the &amp;lt;tt&amp;gt;--protocol&amp;lt;/tt&amp;gt; option of iptables. The&lt;br /&gt;
protocol can be defined as a numerical value or string as defined in&lt;br /&gt;
&amp;lt;tt&amp;gt;/etc/protocols&amp;lt;/tt&amp;gt;. If the protocol is &#039;&#039;&#039;tcp&#039;&#039;&#039; or &#039;&#039;&#039;udp&#039;&#039;&#039;,&lt;br /&gt;
the scope of the service definition may be constrained by defining an&lt;br /&gt;
attribute named &#039;&#039;&#039;port&#039;&#039;&#039;, which is a list of TCP or UDP port&lt;br /&gt;
numbers. If the protocol is &#039;&#039;&#039;icmp&#039;&#039;&#039; or &#039;&#039;&#039;icmpv6&#039;&#039;&#039;, an analogous &lt;br /&gt;
&#039;&#039;&#039;icmp-type&#039;&#039;&#039; attribute may be used. In addition, the scope of the&lt;br /&gt;
rule is also automatically limited to IPv4 or IPv6, respectively.&lt;br /&gt;
&lt;br /&gt;
=== Zones ===&lt;br /&gt;
&lt;br /&gt;
A &#039;&#039;zone&#039;&#039; represents a set of network hosts. A top-level attribute &lt;br /&gt;
&#039;&#039;&#039;zone&#039;&#039;&#039; is a dictionary that maps zone names to zone objects. A&lt;br /&gt;
zone object has an attribute named &#039;&#039;&#039;iface&#039;&#039;&#039;, &#039;&#039;&#039;addr&#039;&#039;&#039;, or&lt;br /&gt;
both. &#039;&#039;&#039;iface&#039;&#039;&#039; is a list of network interfaces and &#039;&#039;&#039;addr&#039;&#039;&#039; is a&lt;br /&gt;
list of IPv4/IPv6 host and network addresses (CIDR&lt;br /&gt;
notation). &#039;&#039;&#039;addr&#039;&#039;&#039; may also contain domain names, which are&lt;br /&gt;
expanded to IP addresses using DNS resolution. If not defined,&lt;br /&gt;
&#039;&#039;&#039;addr&#039;&#039;&#039; defaults to the entire address space and &#039;&#039;&#039;iface&#039;&#039;&#039; to all&lt;br /&gt;
interfaces. An empty zone can be defined by setting either &#039;&#039;&#039;addr&#039;&#039;&#039;&lt;br /&gt;
or &#039;&#039;&#039;iface&#039;&#039;&#039; to an empty list.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Rule objects contain two attributes, &#039;&#039;&#039;in&#039;&#039;&#039; and &#039;&#039;&#039;out&#039;&#039;&#039;, which are&lt;br /&gt;
lists of zone names. These attributes control whether a packet matches&lt;br /&gt;
the rule or not. If a particular zone is referenced by the &#039;&#039;&#039;in&#039;&#039;&#039; &lt;br /&gt;
attribute, the rule applies to packets whose ingress interface and&lt;br /&gt;
source address are covered by the zone definition. Correspondingly, if&lt;br /&gt;
a zone is referenced by the &#039;&#039;&#039;out&#039;&#039;&#039; attribute, the rule applies to&lt;br /&gt;
packets whose egress interface and destination address are included in&lt;br /&gt;
the zone. If both &#039;&#039;&#039;in&#039;&#039;&#039; and &#039;&#039;&#039;out&#039;&#039;&#039; are defined, the packet must&lt;br /&gt;
fulfill both criteria in order to match the rule.&lt;br /&gt;
&lt;br /&gt;
=== Rules ===&lt;br /&gt;
&lt;br /&gt;
There are five types of rule objects:&lt;br /&gt;
* policies&lt;br /&gt;
* filters&lt;br /&gt;
* NAT rules&lt;br /&gt;
* packet marking rules&lt;br /&gt;
* connection tracking bypass rules&lt;br /&gt;
&lt;br /&gt;
All rule objects can have the &#039;&#039;&#039;in&#039;&#039;&#039; and &#039;&#039;&#039;out&#039;&#039;&#039; attributes&lt;br /&gt;
referring to zones as described in the previous section. In addition,&lt;br /&gt;
the scope of the rule can be further constrained with the following&lt;br /&gt;
attributes:&lt;br /&gt;
&lt;br /&gt;
{|&lt;br /&gt;
!Attribute!!Value format!!Effect&lt;br /&gt;
|-&lt;br /&gt;
|&#039;&#039;&#039;src&#039;&#039;&#039;&lt;br /&gt;
|Similar to &#039;&#039;&#039;addr&#039;&#039;&#039; attribute of zone objects&lt;br /&gt;
|Packet&#039;s source address matches the value&lt;br /&gt;
|-&lt;br /&gt;
|&#039;&#039;&#039;dest&#039;&#039;&#039;&lt;br /&gt;
|Similar to &#039;&#039;&#039;addr&#039;&#039;&#039; attribute of zone objects&lt;br /&gt;
|Packet&#039;s destination address matches the value&lt;br /&gt;
|-&lt;br /&gt;
|&#039;&#039;&#039;ipset&#039;&#039;&#039;&lt;br /&gt;
|Object containing two attributes: &#039;&#039;&#039;name&#039;&#039;&#039; referring to an IP set and &#039;&#039;&#039;args&#039;&#039;&#039;, which is a list of strings &#039;&#039;&#039;in&#039;&#039;&#039; and &#039;&#039;&#039;out&#039;&#039;&#039;&lt;br /&gt;
|Packet matches the IP set referred here when the match arguments are taken from the source (&#039;&#039;&#039;in&#039;&#039;&#039;) and destination (&#039;&#039;&#039;out&#039;&#039;&#039;) address or port in the order specified by &#039;&#039;&#039;args&#039;&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
|&#039;&#039;&#039;ipsec&#039;&#039;&#039;&lt;br /&gt;
|&#039;&#039;&#039;in&#039;&#039;&#039; or &#039;&#039;&#039;out&#039;&#039;&#039;&lt;br /&gt;
|IPsec decapsulation perfomed on ingress (&#039;&#039;&#039;in&#039;&#039;&#039;) or encapsulation performed on egress (&#039;&#039;&#039;out&#039;&#039;&#039;)&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Rule objects are declared in type-specific top-level dictionaries in&lt;br /&gt;
awall policy files. If a packet matches multiple rules, the one&lt;br /&gt;
appearing earlier in the list takes precedence. If the matching rules&lt;br /&gt;
are defined in different policy files, the one that was processed&lt;br /&gt;
earlier takes precedence in the current implementation, but this may&lt;br /&gt;
change in future versions.&lt;br /&gt;
&lt;br /&gt;
==== Filters ====&lt;br /&gt;
&lt;br /&gt;
Filter objects specify an action for packets fulfilling certain&lt;br /&gt;
criteria. The top-level attribute &#039;&#039;&#039;filter&#039;&#039;&#039; is a list of filter&lt;br /&gt;
objects. The precedence rules are similar to those of policy objects.&lt;br /&gt;
&lt;br /&gt;
In addition to the common rule attributes, filter objects can have a &lt;br /&gt;
&#039;&#039;&#039;service&#039;&#039;&#039; attribute constraining the scope to specific services&lt;br /&gt;
only. This attribute is a list of service names, referring to the&lt;br /&gt;
keys of the top-level &#039;&#039;&#039;service&#039;&#039;&#039; dictionary.&lt;br /&gt;
&lt;br /&gt;
Filter objects must have an attribute named &#039;&#039;&#039;action&#039;&#039;&#039;, the value of&lt;br /&gt;
which can be one of the following:&lt;br /&gt;
&lt;br /&gt;
{|&lt;br /&gt;
!Value!!Action&lt;br /&gt;
|-&lt;br /&gt;
|&#039;&#039;&#039;accept&#039;&#039;&#039;&lt;br /&gt;
|Accept the packet&lt;br /&gt;
|-&lt;br /&gt;
|&#039;&#039;&#039;reject&#039;&#039;&#039;&lt;br /&gt;
|Reject the packet with an ICMP error message&lt;br /&gt;
|-&lt;br /&gt;
|&#039;&#039;&#039;drop&#039;&#039;&#039;&lt;br /&gt;
|Silently drop the packet&lt;br /&gt;
|-&lt;br /&gt;
|&#039;&#039;&#039;logreject&#039;&#039;&#039;&lt;br /&gt;
|Similar to &#039;&#039;&#039;reject&#039;&#039;&#039; but with kernel logging&lt;br /&gt;
|-&lt;br /&gt;
|&#039;&#039;&#039;logdrop&#039;&#039;&#039;&lt;br /&gt;
|Similar to &#039;&#039;&#039;drop&#039;&#039;&#039; but with kernel logging&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Filter objects, the action of which is &#039;&#039;&#039;accept&#039;&#039;&#039;, may also contain&lt;br /&gt;
limits for packet flow or new connections. These are specified with&lt;br /&gt;
the &#039;&#039;&#039;flow-limit&#039;&#039;&#039; and &#039;&#039;&#039;conn-limit&#039;&#039;&#039; attributes,&lt;br /&gt;
respectively. The values of these attributes are limit objects that&lt;br /&gt;
have two attributes: &#039;&#039;&#039;count&#039;&#039;&#039; and &#039;&#039;&#039;interval&#039;&#039;&#039;. &#039;&#039;&#039;count&#039;&#039;&#039;&lt;br /&gt;
specifies how many new connections or packets are allowed within the&lt;br /&gt;
time frame specified by &#039;&#039;&#039;interval&#039;&#039;&#039; (in seconds). The &#039;&#039;&#039;logdrop&#039;&#039;&#039;&lt;br /&gt;
action is applied to the packets exceeding the limit.&lt;br /&gt;
&lt;br /&gt;
Filter objects may have an attribute named &#039;&#039;&#039;dnat&#039;&#039;&#039;, the value of&lt;br /&gt;
which is an IPv4 address. If defined, this enables destination NAT for&lt;br /&gt;
all IPv4 packets matching the rule, such that the specified address&lt;br /&gt;
replaces the original destination address. This option has no effect&lt;br /&gt;
on IPv6 packets.&lt;br /&gt;
&lt;br /&gt;
==== Policies ====&lt;br /&gt;
&lt;br /&gt;
Policy objects describe the default action for packets that did not&lt;br /&gt;
match any filter. The top-level attribute &#039;&#039;&#039;policy&#039;&#039;&#039; is a list of&lt;br /&gt;
policy objects.&lt;br /&gt;
&lt;br /&gt;
Policy objects must have the &#039;&#039;&#039;action&#039;&#039;&#039; attribute defined. The&lt;br /&gt;
possible values and their semantics are the same as in filter objects.&lt;br /&gt;
&lt;br /&gt;
==== NAT Rules ====&lt;br /&gt;
&lt;br /&gt;
NAT rules come in two flavors: &#039;&#039;source NAT rules&#039;&#039; and&lt;br /&gt;
&#039;&#039;destination NAT rules&#039;&#039;. These are contained in two top-level lists&lt;br /&gt;
named &#039;&#039;&#039;snat&#039;&#039;&#039; and &#039;&#039;&#039;dnat&#039;&#039;&#039;, respectively.&lt;br /&gt;
&lt;br /&gt;
Each NAT rule may have an attribute named &#039;&#039;&#039;ip-range&#039;&#039;&#039; that&lt;br /&gt;
specifies the IPv4 address range to which the original source or&lt;br /&gt;
destination address is mapped. The value can be a single IPv4 address&lt;br /&gt;
or a range specified by two addresses, separated with the &#039;&#039;&#039;-&#039;&#039;&#039;&lt;br /&gt;
character. If not defined, it defaults to the primary address of the&lt;br /&gt;
ingress interface in case of destination NAT, or that of the egress&lt;br /&gt;
interface in case of source NAT.&lt;br /&gt;
&lt;br /&gt;
Optionally, a NAT rule can specify the TCP and UDP port range to which&lt;br /&gt;
the original source or destination port is mapped. The attribute is&lt;br /&gt;
named &#039;&#039;&#039;port-range&#039;&#039;&#039;, and the value can be a single port number or a&lt;br /&gt;
range specified by two numbers, separated with the &#039;&#039;&#039;-&#039;&#039;&#039;&lt;br /&gt;
character. If &#039;&#039;&#039;port-range&#039;&#039;&#039; is not specified, the original port&lt;br /&gt;
number is kept intact.&lt;br /&gt;
&lt;br /&gt;
Like filters, NAT rules can have a &#039;&#039;&#039;service&#039;&#039;&#039; attribute&lt;br /&gt;
constraining their scope to specific services.&lt;br /&gt;
&lt;br /&gt;
NAT rules may have an &#039;&#039;&#039;action&#039;&#039;&#039; attribute set to value&lt;br /&gt;
&#039;&#039;&#039;accept&#039;&#039;&#039;. In this case, NAT is not performed on the packets&lt;br /&gt;
reaching and matching this rule.&lt;br /&gt;
&lt;br /&gt;
==== Packet Marking Rules ====&lt;br /&gt;
&lt;br /&gt;
Packet marking rules are used to mark incoming packets matching the&lt;br /&gt;
specified criteria. The mark can be used as a basis for the routing&lt;br /&gt;
decision. Each marking rule must specify the mark using the &#039;&#039;&#039;mark&#039;&#039;&#039;&lt;br /&gt;
attribute, which is a 32-bit integer.&lt;br /&gt;
&lt;br /&gt;
Normal marking rules are contained by the top-level list attribute&lt;br /&gt;
named &#039;&#039;&#039;mark&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
There is another top-level list attribute, named &#039;&#039;&#039;route-track&#039;&#039;&#039;,&lt;br /&gt;
which contains route tracking rules. These are special marking rules&lt;br /&gt;
which cause all the subsequent packets related to the same connection&lt;br /&gt;
to be marked according to the rule.&lt;br /&gt;
&lt;br /&gt;
==== Connection Tracking Bypass Rules ====&lt;br /&gt;
&lt;br /&gt;
Connection tracking bypass rules are used to disable connection&lt;br /&gt;
tracking for packets matching the specified criteria. The top-level&lt;br /&gt;
attribute &#039;&#039;&#039;no-track&#039;&#039;&#039; is a list of such rules.&lt;br /&gt;
&lt;br /&gt;
Connection tracking bypass rules may have an &#039;&#039;&#039;action&#039;&#039;&#039; attribute&lt;br /&gt;
set to value &#039;&#039;&#039;accept&#039;&#039;&#039;. The effect is similar to corresponding NAT&lt;br /&gt;
rules, i.e. connection tracking is not bypassed for the matching&lt;br /&gt;
packets.&lt;br /&gt;
&lt;br /&gt;
=== IP Sets ===&lt;br /&gt;
&lt;br /&gt;
Any IP set referenced by rule objects should be created by&lt;br /&gt;
awall. Auxiliary &#039;&#039;IP set&#039;&#039; objects are used to defined them in awall&lt;br /&gt;
policy files. The top-level attribute &#039;&#039;&#039;ipset&#039;&#039;&#039; is a dictionary, the&lt;br /&gt;
keys of which are IP set names. The values are IP set objects, which&lt;br /&gt;
have two mandatory attributes. The attribute named &#039;&#039;&#039;type&#039;&#039;&#039; &lt;br /&gt;
corresponds to the type argument of the &amp;lt;tt&amp;gt;ipset create&amp;lt;/tt&amp;gt; &lt;br /&gt;
command. &#039;&#039;&#039;family&#039;&#039;&#039; specifies whether the set is for IPv4 or IPv6&lt;br /&gt;
addresses, and the possible values are &#039;&#039;&#039;inet&#039;&#039;&#039; and &#039;&#039;&#039;inet6&#039;&#039;&#039;,&lt;br /&gt;
correspondingly.&lt;br /&gt;
&lt;br /&gt;
== Command Line Syntax ==&lt;br /&gt;
&lt;br /&gt;
=== Translating Policy Files to Firewall Configuration Files ===&lt;br /&gt;
&lt;br /&gt;
 &#039;&#039;&#039;awall translate&#039;&#039;&#039; [&#039;&#039;&#039;-o&#039;&#039;&#039;|&#039;&#039;&#039;--output&#039;&#039;&#039; DIRECTORY] [&#039;&#039;&#039;-V&#039;&#039;&#039;|&#039;&#039;&#039;--verify&#039;&#039;&#039;]&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;tt&amp;gt;--verify&amp;lt;/tt&amp;gt; option makes awall verify the configuration&lt;br /&gt;
using the test mode of iptables-restore before overwriting the old&lt;br /&gt;
files.&lt;br /&gt;
&lt;br /&gt;
Specifying the output directory allows testing awall policies without&lt;br /&gt;
overwriting the current iptables and ipset configuration files. By&lt;br /&gt;
default, awall generates the configuration to &amp;lt;tt&amp;gt;/etc/iptables&amp;lt;/tt&amp;gt; &lt;br /&gt;
and &amp;lt;tt&amp;gt;/etc/ipset.d&amp;lt;/tt&amp;gt;, which are read by the init scripts.&lt;br /&gt;
&lt;br /&gt;
=== Run-Time Configuration of Firewall ===&lt;br /&gt;
&lt;br /&gt;
 &#039;&#039;&#039;awall activate&#039;&#039;&#039; [&#039;&#039;&#039;-f&#039;&#039;&#039;|&#039;&#039;&#039;--force&#039;&#039;&#039;]&lt;br /&gt;
&lt;br /&gt;
This command genereates firewall configuration from the policy files&lt;br /&gt;
and enables it. If the user confirms the new configuration by hitting&lt;br /&gt;
the Return key within 10 seconds or the &amp;lt;tt&amp;gt;--force&amp;lt;/tt&amp;gt; option is&lt;br /&gt;
used, the configuration is saved to the files. Otherwise, the old&lt;br /&gt;
configuration is restored.&lt;br /&gt;
&lt;br /&gt;
There is also a command for deleting all firewall rules:&lt;br /&gt;
&lt;br /&gt;
 &#039;&#039;&#039;awall flush&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
This command configures the firewall to drop all packets.&lt;br /&gt;
&lt;br /&gt;
=== Optional Policies ===&lt;br /&gt;
&lt;br /&gt;
Optional policies can be enabled or disabled using this command:&lt;br /&gt;
&lt;br /&gt;
 &#039;&#039;&#039;awall&#039;&#039;&#039; {&#039;&#039;&#039;enable&#039;&#039;&#039;|&#039;&#039;&#039;disable&#039;&#039;&#039;} POLICY...&lt;br /&gt;
&lt;br /&gt;
Optional policies can be listed using this command:&lt;br /&gt;
&lt;br /&gt;
 &#039;&#039;&#039;awall list&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;&#039;enabled&#039;&#039;&#039; status means that the policy has been enabled by the&lt;br /&gt;
user. The &#039;&#039;&#039;disabled&#039;&#039;&#039; status means that the policy is not in&lt;br /&gt;
use. The &#039;&#039;&#039;required&#039;&#039;&#039; status means that the policy has not been&lt;br /&gt;
enabled by the user but is in use because it is required by another&lt;br /&gt;
policy which is in use.&lt;br /&gt;
&lt;br /&gt;
=== Debugging Policies ===&lt;br /&gt;
&lt;br /&gt;
This command can be used to dump variable, zone, and other definitions&lt;br /&gt;
as well as their source policies:&lt;br /&gt;
&lt;br /&gt;
 &#039;&#039;&#039;awall dump&#039;&#039;&#039; [LEVEL]&lt;br /&gt;
&lt;br /&gt;
The level is an integer in range 0&amp;amp;ndash;5 and defaults to 0. More&lt;br /&gt;
information is displayed on higher levels.&lt;br /&gt;
&lt;br /&gt;
[[Category:Networking]]&lt;br /&gt;
[[Category:Security]]&lt;/div&gt;</summary>
		<author><name>Kunkku</name></author>
	</entry>
	<entry>
		<id>https://wiki.alpinelinux.org/w/index.php?title=Alpine_Wall_User%27s_Guide&amp;diff=8315</id>
		<title>Alpine Wall User&#039;s Guide</title>
		<link rel="alternate" type="text/html" href="https://wiki.alpinelinux.org/w/index.php?title=Alpine_Wall_User%27s_Guide&amp;diff=8315"/>
		<updated>2012-07-13T11:44:50Z</updated>

		<summary type="html">&lt;p&gt;Kunkku: /* Rules */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Configuration File Processing ==&lt;br /&gt;
&lt;br /&gt;
[[Alpine Wall]] (awall) reads its configuration from multiple&lt;br /&gt;
JSON-formatted files, called &#039;&#039;policy files&#039;&#039;. The processing starts&lt;br /&gt;
from directory &amp;lt;tt&amp;gt;/usr/share/awall/mandatory&amp;lt;/tt&amp;gt;, which contains&lt;br /&gt;
mandatory policy files shipped with APK packages. After that,&lt;br /&gt;
installation-specific policy files in &amp;lt;tt&amp;gt;/etc/awall&amp;lt;/tt&amp;gt; are&lt;br /&gt;
processed.&lt;br /&gt;
&lt;br /&gt;
The latter directory may also contain symbolic links to policy files&lt;br /&gt;
located in &amp;lt;tt&amp;gt;/usr/share/awall/optional&amp;lt;/tt&amp;gt;. These are optional&lt;br /&gt;
policies, which can be enabled on need basis. Such symbolic links are&lt;br /&gt;
easily created and destroyed using the &amp;lt;tt&amp;gt;awall enable&amp;lt;/tt&amp;gt; and &lt;br /&gt;
&amp;lt;tt&amp;gt;awall disable&amp;lt;/tt&amp;gt; commands. &amp;lt;tt&amp;gt;awall list&amp;lt;/tt&amp;gt; shows which&lt;br /&gt;
optional policies are enabled and disabled. The command also prints&lt;br /&gt;
the description of the optional policy if defined in the file using&lt;br /&gt;
a top-level attribute named &#039;&#039;&#039;description&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Sometimes a policy file depends on other policy files. In this case,&lt;br /&gt;
the policy file must have a top-level attribute &#039;&#039;&#039;import&#039;&#039;&#039;, the&lt;br /&gt;
value of which is a list of policy names, which correspond to the file&lt;br /&gt;
names without the &amp;lt;tt&amp;gt;.json&amp;lt;/tt&amp;gt; suffix. The policies listed there are&lt;br /&gt;
always processed before the importing policy. The order of the&lt;br /&gt;
generated iptables rules generally reflects the processing order of&lt;br /&gt;
their corresponding awall policies.&lt;br /&gt;
&lt;br /&gt;
As the import directive does not require the path name to be&lt;br /&gt;
specified, awall expects policies to have unique names, even if&lt;br /&gt;
located in different directories. It is allowed to import optional&lt;br /&gt;
policies that are not explicitly enabled by the user. Such policies&lt;br /&gt;
show up with the &amp;lt;tt&amp;gt;required&amp;lt;/tt&amp;gt; status in the output of &amp;lt;tt&amp;gt;awall&lt;br /&gt;
list&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
== List Parameters ==&lt;br /&gt;
&lt;br /&gt;
Several awall parameters are defined as lists of values. In order to&lt;br /&gt;
facilitate manual editing of policy files, awall also accepts single&lt;br /&gt;
values in place of lists. Such values are semantically equivalent to&lt;br /&gt;
lists containing one element.&lt;br /&gt;
&lt;br /&gt;
== Variable Expansion ==&lt;br /&gt;
&lt;br /&gt;
Awall allows variable definitions in policy files. The top-level&lt;br /&gt;
attribute &#039;&#039;&#039;variable&#039;&#039;&#039; is a dictionary containing the&lt;br /&gt;
definitions. The value of a variable can be of any type (string,&lt;br /&gt;
integer, list, or dictionary).&lt;br /&gt;
&lt;br /&gt;
A variable is referenced in policy files by a string which equals the&lt;br /&gt;
variable name prepended with the &#039;&#039;&#039;$&#039;&#039;&#039; character. If the value of&lt;br /&gt;
the variable is a string, the reference can be embedded into a longer&lt;br /&gt;
string in order to substitute some part of that string (in shell&lt;br /&gt;
style). Variable references can be used when defining other variables,&lt;br /&gt;
as long as the definitions are not circular.&lt;br /&gt;
&lt;br /&gt;
Policy files can reference variables defined in other policy&lt;br /&gt;
files. Policy files can also override variables defined elsewhere by&lt;br /&gt;
redefining them. In this case, the new definition affects all policy&lt;br /&gt;
files, also those processed before the overriding policy. Awall&lt;br /&gt;
variables are in fact simple macros, since each variable remains&lt;br /&gt;
constant thoughout a single processing round. If multiple files define&lt;br /&gt;
the same variable, the definition in the file processed last takes&lt;br /&gt;
effect.&lt;br /&gt;
&lt;br /&gt;
If defined as an empty string, all non-embedded references to a&lt;br /&gt;
variable evaluate as if the attribute in question was not present in&lt;br /&gt;
the configuration. This is also the case when a string containing&lt;br /&gt;
embedded variable references finally evaluates to an empty string.&lt;br /&gt;
&lt;br /&gt;
== Configuration Objects ==&lt;br /&gt;
&lt;br /&gt;
Configuration objects can be divided into two main types.&lt;br /&gt;
&#039;&#039;Auxiliary objects&#039;&#039; model high-level concepts such as services and&lt;br /&gt;
zones. &#039;&#039;Rule objects&#039;&#039; translate into one or more iptables rules, and&lt;br /&gt;
are often defined with the help of some auxiliary objects.&lt;br /&gt;
&lt;br /&gt;
=== Services ===&lt;br /&gt;
&lt;br /&gt;
A &#039;&#039;service&#039;&#039; represents a set of network protocols. A top-level&lt;br /&gt;
attribute &#039;&#039;&#039;service&#039;&#039;&#039; is a dictionary that maps service names to&lt;br /&gt;
service definition objects, or lists thereof in more complex cases.&lt;br /&gt;
&lt;br /&gt;
A service definition object contains an attribute named &#039;&#039;&#039;proto&#039;&#039;&#039;,&lt;br /&gt;
which corresponds to the &amp;lt;tt&amp;gt;--protocol&amp;lt;/tt&amp;gt; option of iptables. The&lt;br /&gt;
protocol can be defined as a numerical value or string as defined in&lt;br /&gt;
&amp;lt;tt&amp;gt;/etc/protocols&amp;lt;/tt&amp;gt;. If the protocol is &#039;&#039;&#039;tcp&#039;&#039;&#039; or &#039;&#039;&#039;udp&#039;&#039;&#039;,&lt;br /&gt;
the scope of the service definition may be constrained by defining an&lt;br /&gt;
attribute named &#039;&#039;&#039;port&#039;&#039;&#039;, which is a list of TCP or UDP port&lt;br /&gt;
numbers. If the protocol is &#039;&#039;&#039;icmp&#039;&#039;&#039; or &#039;&#039;&#039;icmpv6&#039;&#039;&#039;, an analogous &lt;br /&gt;
&#039;&#039;&#039;icmp-type&#039;&#039;&#039; attribute may be used. In addition, the scope of the&lt;br /&gt;
rule is also automatically limited to IPv4 or IPv6, respectively.&lt;br /&gt;
&lt;br /&gt;
=== Zones ===&lt;br /&gt;
&lt;br /&gt;
A &#039;&#039;zone&#039;&#039; represents a set of network hosts. A top-level attribute &lt;br /&gt;
&#039;&#039;&#039;zone&#039;&#039;&#039; is a dictionary that maps zone names to zone objects. A&lt;br /&gt;
zone object has an attribute named &#039;&#039;&#039;iface&#039;&#039;&#039;, &#039;&#039;&#039;addr&#039;&#039;&#039;, or&lt;br /&gt;
both. &#039;&#039;&#039;iface&#039;&#039;&#039; is a list of network interfaces and &#039;&#039;&#039;addr&#039;&#039;&#039; is a&lt;br /&gt;
list of IPv4/IPv6 host and network addresses (CIDR&lt;br /&gt;
notation). &#039;&#039;&#039;addr&#039;&#039;&#039; may also contain domain names, which are&lt;br /&gt;
expanded to IP addresses using DNS resolution. If not defined,&lt;br /&gt;
&#039;&#039;&#039;addr&#039;&#039;&#039; defaults to the entire address space and &#039;&#039;&#039;iface&#039;&#039;&#039; to all&lt;br /&gt;
interfaces. An empty zone can be defined by setting either &#039;&#039;&#039;addr&#039;&#039;&#039;&lt;br /&gt;
or &#039;&#039;&#039;iface&#039;&#039;&#039; to an empty list.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Rule objects contain two attributes, &#039;&#039;&#039;in&#039;&#039;&#039; and &#039;&#039;&#039;out&#039;&#039;&#039;, which are&lt;br /&gt;
lists of zone names. These attributes control whether a packet matches&lt;br /&gt;
the rule or not. If a particular zone is referenced by the &#039;&#039;&#039;in&#039;&#039;&#039; &lt;br /&gt;
attribute, the rule applies to packets whose ingress interface and&lt;br /&gt;
source address are covered by the zone definition. Correspondingly, if&lt;br /&gt;
a zone is referenced by the &#039;&#039;&#039;out&#039;&#039;&#039; attribute, the rule applies to&lt;br /&gt;
packets whose egress interface and destination address are included in&lt;br /&gt;
the zone. If both &#039;&#039;&#039;in&#039;&#039;&#039; and &#039;&#039;&#039;out&#039;&#039;&#039; are defined, the packet must&lt;br /&gt;
fulfill both criteria in order to match the rule.&lt;br /&gt;
&lt;br /&gt;
=== Rules ===&lt;br /&gt;
&lt;br /&gt;
There are five types of rule objects:&lt;br /&gt;
* policies&lt;br /&gt;
* filters&lt;br /&gt;
* NAT rules&lt;br /&gt;
* packet marking rules&lt;br /&gt;
* connection tracking bypass rules&lt;br /&gt;
&lt;br /&gt;
All rule objects can have the &#039;&#039;&#039;in&#039;&#039;&#039; and &#039;&#039;&#039;out&#039;&#039;&#039; attributes&lt;br /&gt;
referring to zones as described in the previous section. In addition,&lt;br /&gt;
the scope of the rule can be further constrained with the following&lt;br /&gt;
attributes:&lt;br /&gt;
&lt;br /&gt;
{|&lt;br /&gt;
!Attribute!!Value format!!Effect&lt;br /&gt;
|-&lt;br /&gt;
|&#039;&#039;&#039;src&#039;&#039;&#039;&lt;br /&gt;
|Similar to &#039;&#039;&#039;addr&#039;&#039;&#039; attribute of zone objects&lt;br /&gt;
|Packet&#039;s source address matches the value&lt;br /&gt;
|-&lt;br /&gt;
|&#039;&#039;&#039;dest&#039;&#039;&#039;&lt;br /&gt;
|Similar to &#039;&#039;&#039;addr&#039;&#039;&#039; attribute of zone objects&lt;br /&gt;
|Packet&#039;s destination address matches the value&lt;br /&gt;
|-&lt;br /&gt;
|&#039;&#039;&#039;ipset&#039;&#039;&#039;&lt;br /&gt;
|Object containing two attributes: &#039;&#039;&#039;name&#039;&#039;&#039; referring to an IP set and &#039;&#039;&#039;args&#039;&#039;&#039;, which is a list of strings &#039;&#039;&#039;in&#039;&#039;&#039; and &#039;&#039;&#039;out&#039;&#039;&#039;&lt;br /&gt;
|Packet matches the IP set referred here when the match arguments are taken from the source (&#039;&#039;&#039;in&#039;&#039;&#039;) and destination (&#039;&#039;&#039;out&#039;&#039;&#039;) address or port in the order specified by &#039;&#039;&#039;args&#039;&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
|&#039;&#039;&#039;ipsec&#039;&#039;&#039;&lt;br /&gt;
|&#039;&#039;&#039;in&#039;&#039;&#039; or &#039;&#039;&#039;out&#039;&#039;&#039;&lt;br /&gt;
|IPsec decapsulation perfomed on ingress (&#039;&#039;&#039;in&#039;&#039;&#039;) or encapsulation performed on egress (&#039;&#039;&#039;out&#039;&#039;&#039;)&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Rule objects are declared in type-specific top-level dictionaries in&lt;br /&gt;
awall policy files. If a packet matches multiple rules, the one&lt;br /&gt;
appearing earlier in the list takes precedence. If the matching rules&lt;br /&gt;
are defined in different policy files, the one that was processed&lt;br /&gt;
earlier takes precedence in the current implementation, but this may&lt;br /&gt;
change in future versions.&lt;br /&gt;
&lt;br /&gt;
==== Filters ====&lt;br /&gt;
&lt;br /&gt;
Filter objects specify an action for packets fulfilling certain&lt;br /&gt;
criteria. The top-level attribute &#039;&#039;&#039;filter&#039;&#039;&#039; is a list of filter&lt;br /&gt;
objects. The precedence rules are similar to those of policy objects.&lt;br /&gt;
&lt;br /&gt;
In addition to the common rule attributes, filter objects can have a &lt;br /&gt;
&#039;&#039;&#039;service&#039;&#039;&#039; attribute constraining the scope to specific services&lt;br /&gt;
only. This attribute is a list of service names, referring to the&lt;br /&gt;
keys of the top-level &#039;&#039;&#039;service&#039;&#039;&#039; dictionary.&lt;br /&gt;
&lt;br /&gt;
Filter objects must have an attribute named &#039;&#039;&#039;action&#039;&#039;&#039;, the value of&lt;br /&gt;
which can be one of the following:&lt;br /&gt;
&lt;br /&gt;
{|&lt;br /&gt;
!Value!!Action&lt;br /&gt;
|-&lt;br /&gt;
|&#039;&#039;&#039;accept&#039;&#039;&#039;&lt;br /&gt;
|Accept the packet&lt;br /&gt;
|-&lt;br /&gt;
|&#039;&#039;&#039;reject&#039;&#039;&#039;&lt;br /&gt;
|Reject the packet with an ICMP error message&lt;br /&gt;
|-&lt;br /&gt;
|&#039;&#039;&#039;drop&#039;&#039;&#039;&lt;br /&gt;
|Silently drop the packet&lt;br /&gt;
|-&lt;br /&gt;
|&#039;&#039;&#039;logreject&#039;&#039;&#039;&lt;br /&gt;
|Similar to &#039;&#039;&#039;reject&#039;&#039;&#039; but with kernel logging&lt;br /&gt;
|-&lt;br /&gt;
|&#039;&#039;&#039;logdrop&#039;&#039;&#039;&lt;br /&gt;
|Similar to &#039;&#039;&#039;drop&#039;&#039;&#039; but with kernel logging&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Filter objects, the action of which is &#039;&#039;&#039;accept&#039;&#039;&#039;, may also contain&lt;br /&gt;
limits for packet flow or new connections. These are specified with&lt;br /&gt;
the &#039;&#039;&#039;flow-limit&#039;&#039;&#039; and &#039;&#039;&#039;conn-limit&#039;&#039;&#039; attributes,&lt;br /&gt;
respectively. The values of these attributes are limit objects that&lt;br /&gt;
have two attributes: &#039;&#039;&#039;count&#039;&#039;&#039; and &#039;&#039;&#039;interval&#039;&#039;&#039;. &#039;&#039;&#039;count&#039;&#039;&#039;&lt;br /&gt;
specifies how many new connections or packets are allowed within the&lt;br /&gt;
time frame specified by &#039;&#039;&#039;interval&#039;&#039;&#039; (in seconds). The &#039;&#039;&#039;logdrop&#039;&#039;&#039;&lt;br /&gt;
action is applied to the packets exceeding the limit.&lt;br /&gt;
&lt;br /&gt;
Filter objects may have an attribute named &#039;&#039;&#039;dnat&#039;&#039;&#039;, the value of&lt;br /&gt;
which is an IPv4 address. If defined, this enables destination NAT for&lt;br /&gt;
all IPv4 packets matching the rule, such that the specified address&lt;br /&gt;
replaces the original destination address. This option has no effect&lt;br /&gt;
on IPv6 packets.&lt;br /&gt;
&lt;br /&gt;
==== Policies ====&lt;br /&gt;
&lt;br /&gt;
Policy objects describe the default action for packets that did not&lt;br /&gt;
match any filter. The top-level attribute &#039;&#039;&#039;policy&#039;&#039;&#039; is a list of&lt;br /&gt;
policy objects.&lt;br /&gt;
&lt;br /&gt;
Policy objects must have the &#039;&#039;&#039;action&#039;&#039;&#039; attribute defined. The&lt;br /&gt;
possible values and their semantics are the same as in filter objects.&lt;br /&gt;
&lt;br /&gt;
==== NAT Rules ====&lt;br /&gt;
&lt;br /&gt;
NAT rules come in two flavors: &#039;&#039;source NAT rules&#039;&#039; and&lt;br /&gt;
&#039;&#039;destination NAT rules&#039;&#039;. These are contained in two top-level lists&lt;br /&gt;
named &#039;&#039;&#039;snat&#039;&#039;&#039; and &#039;&#039;&#039;dnat&#039;&#039;&#039;, respectively.&lt;br /&gt;
&lt;br /&gt;
Each NAT rule may have an attribute named &#039;&#039;&#039;ip-range&#039;&#039;&#039; that&lt;br /&gt;
specifies the IPv4 address range to which the original source or&lt;br /&gt;
destination address is mapped. The value can be a single IPv4 address&lt;br /&gt;
or a range specified by two addresses, separated with the &#039;&#039;&#039;-&#039;&#039;&#039;&lt;br /&gt;
character. If not defined, it defaults to the primary address of the&lt;br /&gt;
ingress interface in case of destination NAT, or that of the egress&lt;br /&gt;
interface in case of source NAT.&lt;br /&gt;
&lt;br /&gt;
Optionally, a NAT rule can specify the TCP and UDP port range to which&lt;br /&gt;
the original source or destination port is mapped. The attribute is&lt;br /&gt;
named &#039;&#039;&#039;port-range&#039;&#039;&#039;, and the value can be a single port number or a&lt;br /&gt;
range specified by two numbers, separated with the &#039;&#039;&#039;-&#039;&#039;&#039;&lt;br /&gt;
character. If &#039;&#039;&#039;port-range&#039;&#039;&#039; is not specified, the original port&lt;br /&gt;
number is kept intact.&lt;br /&gt;
&lt;br /&gt;
Like filters, NAT rules can have a &#039;&#039;&#039;service&#039;&#039;&#039; attribute&lt;br /&gt;
constraining their scope to specific services.&lt;br /&gt;
&lt;br /&gt;
NAT rules may have an &#039;&#039;&#039;action&#039;&#039;&#039; attribute set to value&lt;br /&gt;
&#039;&#039;&#039;accept&#039;&#039;&#039;. In this case, NAT is not performed on the packets&lt;br /&gt;
reaching and matching this rule.&lt;br /&gt;
&lt;br /&gt;
==== Packet Marking Rules ====&lt;br /&gt;
&lt;br /&gt;
Packet marking rules are used to mark incoming packets matching the&lt;br /&gt;
specified criteria. The mark can be used as a basis for the routing&lt;br /&gt;
decision. Each marking rule must specify the mark using the &#039;&#039;&#039;mark&#039;&#039;&#039;&lt;br /&gt;
attribute, which is a 32-bit integer.&lt;br /&gt;
&lt;br /&gt;
Normal marking rules are contained by the top-level list attribute&lt;br /&gt;
named &#039;&#039;&#039;mark&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
There is another top-level list attribute, named &#039;&#039;&#039;route-track&#039;&#039;&#039;,&lt;br /&gt;
which contains route tracking rules. These are special marking rules&lt;br /&gt;
which cause all the subsequent packets related to the same connection&lt;br /&gt;
to be marked according to the rule.&lt;br /&gt;
&lt;br /&gt;
==== Connection Tracking Bypass Rules ====&lt;br /&gt;
&lt;br /&gt;
Connection tracking bypass rules are used to disable connection&lt;br /&gt;
tracking for packets matching the specified criteria. The top-level&lt;br /&gt;
attribute &#039;&#039;&#039;no-track&#039;&#039;&#039; is a list of such rules.&lt;br /&gt;
&lt;br /&gt;
Connection tracking bypass rules may have an &#039;&#039;&#039;action&#039;&#039;&#039; attribute&lt;br /&gt;
set to value &#039;&#039;&#039;accept&#039;&#039;&#039;. The effect is similar to corresponding NAT&lt;br /&gt;
rules, i.e. connection tracking is not bypassed for the matching&lt;br /&gt;
packets.&lt;br /&gt;
&lt;br /&gt;
=== IP Sets ===&lt;br /&gt;
&lt;br /&gt;
Any IP set referenced by rule objects should be created by&lt;br /&gt;
awall. Auxiliary &#039;&#039;IP set&#039;&#039; objects are used to defined them in awall&lt;br /&gt;
policy files. The top-level attribute &#039;&#039;&#039;ipset&#039;&#039;&#039; is a dictionary, the&lt;br /&gt;
keys of which are IP set names. The values are IP set objects, which&lt;br /&gt;
have two mandatory attributes. The attribute named &#039;&#039;&#039;type&#039;&#039;&#039; &lt;br /&gt;
corresponds to the type argument of the &amp;lt;tt&amp;gt;ipset create&amp;lt;/tt&amp;gt; &lt;br /&gt;
command. &#039;&#039;&#039;family&#039;&#039;&#039; specifies whether the set is for IPv4 or IPv6&lt;br /&gt;
addresses, and the possible values are &#039;&#039;&#039;inet&#039;&#039;&#039; and &#039;&#039;&#039;inet6&#039;&#039;&#039;,&lt;br /&gt;
correspondingly.&lt;br /&gt;
&lt;br /&gt;
== Command Line Syntax ==&lt;br /&gt;
&lt;br /&gt;
=== Translating Policy Files to Firewall Configuration Files ===&lt;br /&gt;
&lt;br /&gt;
 &#039;&#039;&#039;awall translate&#039;&#039;&#039; [&#039;&#039;&#039;-o&#039;&#039;&#039;|&#039;&#039;&#039;--output&#039;&#039;&#039; DIRECTORY] [&#039;&#039;&#039;-V&#039;&#039;&#039;|&#039;&#039;&#039;--verify&#039;&#039;&#039;]&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;tt&amp;gt;--verify&amp;lt;/tt&amp;gt; option makes awall verify the configuration&lt;br /&gt;
using the test mode of iptables-restore before overwriting the old&lt;br /&gt;
files.&lt;br /&gt;
&lt;br /&gt;
Specifying the output directory allows testing awall policies without&lt;br /&gt;
overwriting the current iptables and ipset configuration files. By&lt;br /&gt;
default, awall generates the configuration to &amp;lt;tt&amp;gt;/etc/iptables&amp;lt;/tt&amp;gt; &lt;br /&gt;
and &amp;lt;tt&amp;gt;/etc/ipset.d&amp;lt;/tt&amp;gt;, which are read by the init scripts.&lt;br /&gt;
&lt;br /&gt;
=== Run-Time Configuration of Firewall ===&lt;br /&gt;
&lt;br /&gt;
 &#039;&#039;&#039;awall activate&#039;&#039;&#039; [&#039;&#039;&#039;-f&#039;&#039;&#039;|&#039;&#039;&#039;--force&#039;&#039;&#039;]&lt;br /&gt;
&lt;br /&gt;
This command genereates firewall configuration from the policy files&lt;br /&gt;
and enables it. If the user confirms the new configuration by hitting&lt;br /&gt;
the Return key within 10 seconds or the &amp;lt;tt&amp;gt;--force&amp;lt;/tt&amp;gt; option is&lt;br /&gt;
used, the configuration is saved to the files. Otherwise, the old&lt;br /&gt;
configuration is restored.&lt;br /&gt;
&lt;br /&gt;
There is also a command for deleting all firewall rules:&lt;br /&gt;
&lt;br /&gt;
 &#039;&#039;&#039;awall flush&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
This command configures the firewall to drop all packets.&lt;br /&gt;
&lt;br /&gt;
=== Optional Policies ===&lt;br /&gt;
&lt;br /&gt;
Optional policies can be enabled or disabled using this command:&lt;br /&gt;
&lt;br /&gt;
 &#039;&#039;&#039;awall&#039;&#039;&#039; {&#039;&#039;&#039;enable&#039;&#039;&#039;|&#039;&#039;&#039;disable&#039;&#039;&#039;} POLICY...&lt;br /&gt;
&lt;br /&gt;
Optional policies can be listed using this command:&lt;br /&gt;
&lt;br /&gt;
 &#039;&#039;&#039;awall list&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;&#039;enabled&#039;&#039;&#039; status means that the policy has been enabled by the&lt;br /&gt;
user. The &#039;&#039;&#039;disabled&#039;&#039;&#039; status means that the policy is not in&lt;br /&gt;
use. The &#039;&#039;&#039;required&#039;&#039;&#039; status means that the policy has not been&lt;br /&gt;
enabled by the user but is in use because it is required by another&lt;br /&gt;
policy which is in use.&lt;br /&gt;
&lt;br /&gt;
=== Debugging Policies ===&lt;br /&gt;
&lt;br /&gt;
This command can be used to dump variable, zone, and other definitions&lt;br /&gt;
as well as their source policies:&lt;br /&gt;
&lt;br /&gt;
 &#039;&#039;&#039;awall dump&#039;&#039;&#039; [LEVEL]&lt;br /&gt;
&lt;br /&gt;
The level is an integer in range 0&amp;amp;ndash;3 and defaults to 0. More&lt;br /&gt;
information is displayed on higher levels.&lt;br /&gt;
&lt;br /&gt;
[[Category:Networking]]&lt;br /&gt;
[[Category:Security]]&lt;/div&gt;</summary>
		<author><name>Kunkku</name></author>
	</entry>
	<entry>
		<id>https://wiki.alpinelinux.org/w/index.php?title=Alpine_Wall_User%27s_Guide&amp;diff=8313</id>
		<title>Alpine Wall User&#039;s Guide</title>
		<link rel="alternate" type="text/html" href="https://wiki.alpinelinux.org/w/index.php?title=Alpine_Wall_User%27s_Guide&amp;diff=8313"/>
		<updated>2012-07-12T13:00:43Z</updated>

		<summary type="html">&lt;p&gt;Kunkku: /* NAT Rules */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Configuration File Processing ==&lt;br /&gt;
&lt;br /&gt;
[[Alpine Wall]] (awall) reads its configuration from multiple&lt;br /&gt;
JSON-formatted files, called &#039;&#039;policy files&#039;&#039;. The processing starts&lt;br /&gt;
from directory &amp;lt;tt&amp;gt;/usr/share/awall/mandatory&amp;lt;/tt&amp;gt;, which contains&lt;br /&gt;
mandatory policy files shipped with APK packages. After that,&lt;br /&gt;
installation-specific policy files in &amp;lt;tt&amp;gt;/etc/awall&amp;lt;/tt&amp;gt; are&lt;br /&gt;
processed.&lt;br /&gt;
&lt;br /&gt;
The latter directory may also contain symbolic links to policy files&lt;br /&gt;
located in &amp;lt;tt&amp;gt;/usr/share/awall/optional&amp;lt;/tt&amp;gt;. These are optional&lt;br /&gt;
policies, which can be enabled on need basis. Such symbolic links are&lt;br /&gt;
easily created and destroyed using the &amp;lt;tt&amp;gt;awall enable&amp;lt;/tt&amp;gt; and &lt;br /&gt;
&amp;lt;tt&amp;gt;awall disable&amp;lt;/tt&amp;gt; commands. &amp;lt;tt&amp;gt;awall list&amp;lt;/tt&amp;gt; shows which&lt;br /&gt;
optional policies are enabled and disabled. The command also prints&lt;br /&gt;
the description of the optional policy if defined in the file using&lt;br /&gt;
a top-level attribute named &#039;&#039;&#039;description&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Sometimes a policy file depends on other policy files. In this case,&lt;br /&gt;
the policy file must have a top-level attribute &#039;&#039;&#039;import&#039;&#039;&#039;, the&lt;br /&gt;
value of which is a list of policy names, which correspond to the file&lt;br /&gt;
names without the &amp;lt;tt&amp;gt;.json&amp;lt;/tt&amp;gt; suffix. The policies listed there are&lt;br /&gt;
always processed before the importing policy. The order of the&lt;br /&gt;
generated iptables rules generally reflects the processing order of&lt;br /&gt;
their corresponding awall policies.&lt;br /&gt;
&lt;br /&gt;
As the import directive does not require the path name to be&lt;br /&gt;
specified, awall expects policies to have unique names, even if&lt;br /&gt;
located in different directories. It is allowed to import optional&lt;br /&gt;
policies that are not explicitly enabled by the user. Such policies&lt;br /&gt;
show up with the &amp;lt;tt&amp;gt;required&amp;lt;/tt&amp;gt; status in the output of &amp;lt;tt&amp;gt;awall&lt;br /&gt;
list&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
== List Parameters ==&lt;br /&gt;
&lt;br /&gt;
Several awall parameters are defined as lists of values. In order to&lt;br /&gt;
facilitate manual editing of policy files, awall also accepts single&lt;br /&gt;
values in place of lists. Such values are semantically equivalent to&lt;br /&gt;
lists containing one element.&lt;br /&gt;
&lt;br /&gt;
== Variable Expansion ==&lt;br /&gt;
&lt;br /&gt;
Awall allows variable definitions in policy files. The top-level&lt;br /&gt;
attribute &#039;&#039;&#039;variable&#039;&#039;&#039; is a dictionary containing the&lt;br /&gt;
definitions. The value of a variable can be of any type (string,&lt;br /&gt;
integer, list, or dictionary).&lt;br /&gt;
&lt;br /&gt;
A variable is referenced in policy files by a string which equals the&lt;br /&gt;
variable name prepended with the &#039;&#039;&#039;$&#039;&#039;&#039; character. If the value of&lt;br /&gt;
the variable is a string, the reference can be embedded into a longer&lt;br /&gt;
string in order to substitute some part of that string (in shell&lt;br /&gt;
style). Variable references can be used when defining other variables,&lt;br /&gt;
as long as the definitions are not circular.&lt;br /&gt;
&lt;br /&gt;
Policy files can reference variables defined in other policy&lt;br /&gt;
files. Policy files can also override variables defined elsewhere by&lt;br /&gt;
redefining them. In this case, the new definition affects all policy&lt;br /&gt;
files, also those processed before the overriding policy. Awall&lt;br /&gt;
variables are in fact simple macros, since each variable remains&lt;br /&gt;
constant thoughout a single processing round. If multiple files define&lt;br /&gt;
the same variable, the definition in the file processed last takes&lt;br /&gt;
effect.&lt;br /&gt;
&lt;br /&gt;
If defined as an empty string, all non-embedded references to a&lt;br /&gt;
variable evaluate as if the attribute in question was not present in&lt;br /&gt;
the configuration. This is also the case when a string containing&lt;br /&gt;
embedded variable references finally evaluates to an empty string.&lt;br /&gt;
&lt;br /&gt;
== Configuration Objects ==&lt;br /&gt;
&lt;br /&gt;
Configuration objects can be divided into two main types.&lt;br /&gt;
&#039;&#039;Auxiliary objects&#039;&#039; model high-level concepts such as services and&lt;br /&gt;
zones. &#039;&#039;Rule objects&#039;&#039; translate into one or more iptables rules, and&lt;br /&gt;
are often defined with the help of some auxiliary objects.&lt;br /&gt;
&lt;br /&gt;
=== Services ===&lt;br /&gt;
&lt;br /&gt;
A &#039;&#039;service&#039;&#039; represents a set of network protocols. A top-level&lt;br /&gt;
attribute &#039;&#039;&#039;service&#039;&#039;&#039; is a dictionary that maps service names to&lt;br /&gt;
service definition objects, or lists thereof in more complex cases.&lt;br /&gt;
&lt;br /&gt;
A service definition object contains an attribute named &#039;&#039;&#039;proto&#039;&#039;&#039;,&lt;br /&gt;
which corresponds to the &amp;lt;tt&amp;gt;--protocol&amp;lt;/tt&amp;gt; option of iptables. The&lt;br /&gt;
protocol can be defined as a numerical value or string as defined in&lt;br /&gt;
&amp;lt;tt&amp;gt;/etc/protocols&amp;lt;/tt&amp;gt;. If the protocol is &#039;&#039;&#039;tcp&#039;&#039;&#039; or &#039;&#039;&#039;udp&#039;&#039;&#039;,&lt;br /&gt;
the scope of the service definition may be constrained by defining an&lt;br /&gt;
attribute named &#039;&#039;&#039;port&#039;&#039;&#039;, which is a list of TCP or UDP port&lt;br /&gt;
numbers. If the protocol is &#039;&#039;&#039;icmp&#039;&#039;&#039; or &#039;&#039;&#039;icmpv6&#039;&#039;&#039;, an analogous &lt;br /&gt;
&#039;&#039;&#039;icmp-type&#039;&#039;&#039; attribute may be used. In addition, the scope of the&lt;br /&gt;
rule is also automatically limited to IPv4 or IPv6, respectively.&lt;br /&gt;
&lt;br /&gt;
=== Zones ===&lt;br /&gt;
&lt;br /&gt;
A &#039;&#039;zone&#039;&#039; represents a set of network hosts. A top-level attribute &lt;br /&gt;
&#039;&#039;&#039;zone&#039;&#039;&#039; is a dictionary that maps zone names to zone objects. A&lt;br /&gt;
zone object has an attribute named &#039;&#039;&#039;iface&#039;&#039;&#039;, &#039;&#039;&#039;addr&#039;&#039;&#039;, or&lt;br /&gt;
both. &#039;&#039;&#039;iface&#039;&#039;&#039; is a list of network interfaces and &#039;&#039;&#039;addr&#039;&#039;&#039; is a&lt;br /&gt;
list of IPv4/IPv6 host and network addresses (CIDR&lt;br /&gt;
notation). &#039;&#039;&#039;addr&#039;&#039;&#039; may also contain domain names, which are&lt;br /&gt;
expanded to IP addresses using DNS resolution. If not defined,&lt;br /&gt;
&#039;&#039;&#039;addr&#039;&#039;&#039; defaults to the entire address space and &#039;&#039;&#039;iface&#039;&#039;&#039; to all&lt;br /&gt;
interfaces. An empty zone can be defined by setting either &#039;&#039;&#039;addr&#039;&#039;&#039;&lt;br /&gt;
or &#039;&#039;&#039;iface&#039;&#039;&#039; to an empty list.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Rule objects contain two attributes, &#039;&#039;&#039;in&#039;&#039;&#039; and &#039;&#039;&#039;out&#039;&#039;&#039;, which are&lt;br /&gt;
lists of zone names. These attributes control whether a packet matches&lt;br /&gt;
the rule or not. If a particular zone is referenced by the &#039;&#039;&#039;in&#039;&#039;&#039; &lt;br /&gt;
attribute, the rule applies to packets whose ingress interface and&lt;br /&gt;
source address are covered by the zone definition. Correspondingly, if&lt;br /&gt;
a zone is referenced by the &#039;&#039;&#039;out&#039;&#039;&#039; attribute, the rule applies to&lt;br /&gt;
packets whose egress interface and destination address are included in&lt;br /&gt;
the zone. If both &#039;&#039;&#039;in&#039;&#039;&#039; and &#039;&#039;&#039;out&#039;&#039;&#039; are defined, the packet must&lt;br /&gt;
fulfill both criteria in order to match the rule.&lt;br /&gt;
&lt;br /&gt;
=== Rules ===&lt;br /&gt;
&lt;br /&gt;
There are four types of rule objects: &#039;&#039;policies&#039;&#039;, &#039;&#039;filters&#039;&#039;,&lt;br /&gt;
&#039;&#039;NAT rules&#039;&#039;, and &#039;&#039;connection tracking bypass rules&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
All rule objects can have the &#039;&#039;&#039;in&#039;&#039;&#039; and &#039;&#039;&#039;out&#039;&#039;&#039; attributes&lt;br /&gt;
referring to zones as described in the previous section. In addition,&lt;br /&gt;
the scope of the rule can be further constrained with the following&lt;br /&gt;
attributes:&lt;br /&gt;
&lt;br /&gt;
{|&lt;br /&gt;
!Attribute!!Value format!!Effect&lt;br /&gt;
|-&lt;br /&gt;
|&#039;&#039;&#039;src&#039;&#039;&#039;&lt;br /&gt;
|Similar to &#039;&#039;&#039;addr&#039;&#039;&#039; attribute of zone objects&lt;br /&gt;
|Packet&#039;s source address matches the value&lt;br /&gt;
|-&lt;br /&gt;
|&#039;&#039;&#039;dest&#039;&#039;&#039;&lt;br /&gt;
|Similar to &#039;&#039;&#039;addr&#039;&#039;&#039; attribute of zone objects&lt;br /&gt;
|Packet&#039;s destination address matches the value&lt;br /&gt;
|-&lt;br /&gt;
|&#039;&#039;&#039;ipset&#039;&#039;&#039;&lt;br /&gt;
|Object containing two attributes: &#039;&#039;&#039;name&#039;&#039;&#039; referring to an IP set and &#039;&#039;&#039;args&#039;&#039;&#039;, which is a list of strings &#039;&#039;&#039;in&#039;&#039;&#039; and &#039;&#039;&#039;out&#039;&#039;&#039;&lt;br /&gt;
|Packet matches the IP set referred here when the match arguments are taken from the source (&#039;&#039;&#039;in&#039;&#039;&#039;) and destination (&#039;&#039;&#039;out&#039;&#039;&#039;) address or port in the order specified by &#039;&#039;&#039;args&#039;&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
|&#039;&#039;&#039;ipsec&#039;&#039;&#039;&lt;br /&gt;
|&#039;&#039;&#039;in&#039;&#039;&#039; or &#039;&#039;&#039;out&#039;&#039;&#039;&lt;br /&gt;
|IPsec decapsulation perfomed on ingress (&#039;&#039;&#039;in&#039;&#039;&#039;) or encapsulation performed on egress (&#039;&#039;&#039;out&#039;&#039;&#039;)&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Rule objects are declared in type-specific top-level dictionaries in&lt;br /&gt;
awall policy files. If a packet matches multiple rules, the one&lt;br /&gt;
appearing earlier in the list takes precedence. If the matching rules&lt;br /&gt;
are defined in different policy files, the one that was processed&lt;br /&gt;
earlier takes precedence in the current implementation, but this may&lt;br /&gt;
change in future versions.&lt;br /&gt;
&lt;br /&gt;
==== Filters ====&lt;br /&gt;
&lt;br /&gt;
Filter objects specify an action for packets fulfilling certain&lt;br /&gt;
criteria. The top-level attribute &#039;&#039;&#039;filter&#039;&#039;&#039; is a list of filter&lt;br /&gt;
objects. The precedence rules are similar to those of policy objects.&lt;br /&gt;
&lt;br /&gt;
In addition to the common rule attributes, filter objects can have a &lt;br /&gt;
&#039;&#039;&#039;service&#039;&#039;&#039; attribute constraining the scope to specific services&lt;br /&gt;
only. This attribute is a list of service names, referring to the&lt;br /&gt;
keys of the top-level &#039;&#039;&#039;service&#039;&#039;&#039; dictionary.&lt;br /&gt;
&lt;br /&gt;
Filter objects must have an attribute named &#039;&#039;&#039;action&#039;&#039;&#039;, the value of&lt;br /&gt;
which can be one of the following:&lt;br /&gt;
&lt;br /&gt;
{|&lt;br /&gt;
!Value!!Action&lt;br /&gt;
|-&lt;br /&gt;
|&#039;&#039;&#039;accept&#039;&#039;&#039;&lt;br /&gt;
|Accept the packet&lt;br /&gt;
|-&lt;br /&gt;
|&#039;&#039;&#039;reject&#039;&#039;&#039;&lt;br /&gt;
|Reject the packet with an ICMP error message&lt;br /&gt;
|-&lt;br /&gt;
|&#039;&#039;&#039;drop&#039;&#039;&#039;&lt;br /&gt;
|Silently drop the packet&lt;br /&gt;
|-&lt;br /&gt;
|&#039;&#039;&#039;logreject&#039;&#039;&#039;&lt;br /&gt;
|Similar to &#039;&#039;&#039;reject&#039;&#039;&#039; but with kernel logging&lt;br /&gt;
|-&lt;br /&gt;
|&#039;&#039;&#039;logdrop&#039;&#039;&#039;&lt;br /&gt;
|Similar to &#039;&#039;&#039;drop&#039;&#039;&#039; but with kernel logging&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Filter objects, the action of which is &#039;&#039;&#039;accept&#039;&#039;&#039;, may also contain&lt;br /&gt;
limits for packet flow or new connections. These are specified with&lt;br /&gt;
the &#039;&#039;&#039;flow-limit&#039;&#039;&#039; and &#039;&#039;&#039;conn-limit&#039;&#039;&#039; attributes,&lt;br /&gt;
respectively. The values of these attributes are limit objects that&lt;br /&gt;
have two attributes: &#039;&#039;&#039;count&#039;&#039;&#039; and &#039;&#039;&#039;interval&#039;&#039;&#039;. &#039;&#039;&#039;count&#039;&#039;&#039;&lt;br /&gt;
specifies how many new connections or packets are allowed within the&lt;br /&gt;
time frame specified by &#039;&#039;&#039;interval&#039;&#039;&#039; (in seconds). The &#039;&#039;&#039;logdrop&#039;&#039;&#039;&lt;br /&gt;
action is applied to the packets exceeding the limit.&lt;br /&gt;
&lt;br /&gt;
Filter objects may have an attribute named &#039;&#039;&#039;dnat&#039;&#039;&#039;, the value of&lt;br /&gt;
which is an IPv4 address. If defined, this enables destination NAT for&lt;br /&gt;
all IPv4 packets matching the rule, such that the specified address&lt;br /&gt;
replaces the original destination address. This option has no effect&lt;br /&gt;
on IPv6 packets.&lt;br /&gt;
&lt;br /&gt;
==== Policies ====&lt;br /&gt;
&lt;br /&gt;
Policy objects describe the default action for packets that did not&lt;br /&gt;
match any filter. The top-level attribute &#039;&#039;&#039;policy&#039;&#039;&#039; is a list of&lt;br /&gt;
policy objects.&lt;br /&gt;
&lt;br /&gt;
Policy objects must have the &#039;&#039;&#039;action&#039;&#039;&#039; attribute defined. The&lt;br /&gt;
possible values and their semantics are the same as in filter objects.&lt;br /&gt;
&lt;br /&gt;
==== NAT Rules ====&lt;br /&gt;
&lt;br /&gt;
NAT rules come in two flavors: &#039;&#039;source NAT rules&#039;&#039; and&lt;br /&gt;
&#039;&#039;destination NAT rules&#039;&#039;. These are contained in two top-level lists&lt;br /&gt;
named &#039;&#039;&#039;snat&#039;&#039;&#039; and &#039;&#039;&#039;dnat&#039;&#039;&#039;, respectively.&lt;br /&gt;
&lt;br /&gt;
Each NAT rule may have an attribute named &#039;&#039;&#039;ip-range&#039;&#039;&#039; that&lt;br /&gt;
specifies the IPv4 address range to which the original source or&lt;br /&gt;
destination address is mapped. The value can be a single IPv4 address&lt;br /&gt;
or a range specified by two addresses, separated with the &#039;&#039;&#039;-&#039;&#039;&#039;&lt;br /&gt;
character. If not defined, it defaults to the primary address of the&lt;br /&gt;
ingress interface in case of destination NAT, or that of the egress&lt;br /&gt;
interface in case of source NAT.&lt;br /&gt;
&lt;br /&gt;
Optionally, a NAT rule can specify the TCP and UDP port range to which&lt;br /&gt;
the original source or destination port is mapped. The attribute is&lt;br /&gt;
named &#039;&#039;&#039;port-range&#039;&#039;&#039;, and the value can be a single port number or a&lt;br /&gt;
range specified by two numbers, separated with the &#039;&#039;&#039;-&#039;&#039;&#039;&lt;br /&gt;
character. If &#039;&#039;&#039;port-range&#039;&#039;&#039; is not specified, the original port&lt;br /&gt;
number is kept intact.&lt;br /&gt;
&lt;br /&gt;
Like filters, NAT rules can have a &#039;&#039;&#039;service&#039;&#039;&#039; attribute&lt;br /&gt;
constraining their scope to specific services.&lt;br /&gt;
&lt;br /&gt;
NAT rules may have an &#039;&#039;&#039;action&#039;&#039;&#039; attribute set to value&lt;br /&gt;
&#039;&#039;&#039;accept&#039;&#039;&#039;. In this case, NAT is not performed on the packets&lt;br /&gt;
reaching and matching this rule.&lt;br /&gt;
&lt;br /&gt;
==== Connection Tracking Bypass Rules ====&lt;br /&gt;
&lt;br /&gt;
Connection tracking bypass rules are used to disable connection&lt;br /&gt;
tracking for packets matching the specified criteria. The top-level&lt;br /&gt;
attribute &#039;&#039;&#039;no-track&#039;&#039;&#039; is a list of such rules.&lt;br /&gt;
&lt;br /&gt;
Connection tracking bypass rules may have an &#039;&#039;&#039;action&#039;&#039;&#039; attribute&lt;br /&gt;
set to value &#039;&#039;&#039;accept&#039;&#039;&#039;. The effect is similar to corresponding NAT&lt;br /&gt;
rules, i.e. connection tracking is not bypassed for the matching&lt;br /&gt;
packets.&lt;br /&gt;
&lt;br /&gt;
=== IP Sets ===&lt;br /&gt;
&lt;br /&gt;
Any IP set referenced by rule objects should be created by&lt;br /&gt;
awall. Auxiliary &#039;&#039;IP set&#039;&#039; objects are used to defined them in awall&lt;br /&gt;
policy files. The top-level attribute &#039;&#039;&#039;ipset&#039;&#039;&#039; is a dictionary, the&lt;br /&gt;
keys of which are IP set names. The values are IP set objects, which&lt;br /&gt;
have two mandatory attributes. The attribute named &#039;&#039;&#039;type&#039;&#039;&#039; &lt;br /&gt;
corresponds to the type argument of the &amp;lt;tt&amp;gt;ipset create&amp;lt;/tt&amp;gt; &lt;br /&gt;
command. &#039;&#039;&#039;family&#039;&#039;&#039; specifies whether the set is for IPv4 or IPv6&lt;br /&gt;
addresses, and the possible values are &#039;&#039;&#039;inet&#039;&#039;&#039; and &#039;&#039;&#039;inet6&#039;&#039;&#039;,&lt;br /&gt;
correspondingly.&lt;br /&gt;
&lt;br /&gt;
== Command Line Syntax ==&lt;br /&gt;
&lt;br /&gt;
=== Translating Policy Files to Firewall Configuration Files ===&lt;br /&gt;
&lt;br /&gt;
 &#039;&#039;&#039;awall translate&#039;&#039;&#039; [&#039;&#039;&#039;-o&#039;&#039;&#039;|&#039;&#039;&#039;--output&#039;&#039;&#039; DIRECTORY] [&#039;&#039;&#039;-V&#039;&#039;&#039;|&#039;&#039;&#039;--verify&#039;&#039;&#039;]&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;tt&amp;gt;--verify&amp;lt;/tt&amp;gt; option makes awall verify the configuration&lt;br /&gt;
using the test mode of iptables-restore before overwriting the old&lt;br /&gt;
files.&lt;br /&gt;
&lt;br /&gt;
Specifying the output directory allows testing awall policies without&lt;br /&gt;
overwriting the current iptables and ipset configuration files. By&lt;br /&gt;
default, awall generates the configuration to &amp;lt;tt&amp;gt;/etc/iptables&amp;lt;/tt&amp;gt; &lt;br /&gt;
and &amp;lt;tt&amp;gt;/etc/ipset.d&amp;lt;/tt&amp;gt;, which are read by the init scripts.&lt;br /&gt;
&lt;br /&gt;
=== Run-Time Configuration of Firewall ===&lt;br /&gt;
&lt;br /&gt;
 &#039;&#039;&#039;awall activate&#039;&#039;&#039; [&#039;&#039;&#039;-f&#039;&#039;&#039;|&#039;&#039;&#039;--force&#039;&#039;&#039;]&lt;br /&gt;
&lt;br /&gt;
This command genereates firewall configuration from the policy files&lt;br /&gt;
and enables it. If the user confirms the new configuration by hitting&lt;br /&gt;
the Return key within 10 seconds or the &amp;lt;tt&amp;gt;--force&amp;lt;/tt&amp;gt; option is&lt;br /&gt;
used, the configuration is saved to the files. Otherwise, the old&lt;br /&gt;
configuration is restored.&lt;br /&gt;
&lt;br /&gt;
There is also a command for deleting all firewall rules:&lt;br /&gt;
&lt;br /&gt;
 &#039;&#039;&#039;awall flush&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
This command configures the firewall to drop all packets.&lt;br /&gt;
&lt;br /&gt;
=== Optional Policies ===&lt;br /&gt;
&lt;br /&gt;
Optional policies can be enabled or disabled using this command:&lt;br /&gt;
&lt;br /&gt;
 &#039;&#039;&#039;awall&#039;&#039;&#039; {&#039;&#039;&#039;enable&#039;&#039;&#039;|&#039;&#039;&#039;disable&#039;&#039;&#039;} POLICY...&lt;br /&gt;
&lt;br /&gt;
Optional policies can be listed using this command:&lt;br /&gt;
&lt;br /&gt;
 &#039;&#039;&#039;awall list&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;&#039;enabled&#039;&#039;&#039; status means that the policy has been enabled by the&lt;br /&gt;
user. The &#039;&#039;&#039;disabled&#039;&#039;&#039; status means that the policy is not in&lt;br /&gt;
use. The &#039;&#039;&#039;required&#039;&#039;&#039; status means that the policy has not been&lt;br /&gt;
enabled by the user but is in use because it is required by another&lt;br /&gt;
policy which is in use.&lt;br /&gt;
&lt;br /&gt;
=== Debugging Policies ===&lt;br /&gt;
&lt;br /&gt;
This command can be used to dump variable, zone, and other definitions&lt;br /&gt;
as well as their source policies:&lt;br /&gt;
&lt;br /&gt;
 &#039;&#039;&#039;awall dump&#039;&#039;&#039; [LEVEL]&lt;br /&gt;
&lt;br /&gt;
The level is an integer in range 0&amp;amp;ndash;3 and defaults to 0. More&lt;br /&gt;
information is displayed on higher levels.&lt;br /&gt;
&lt;br /&gt;
[[Category:Networking]]&lt;br /&gt;
[[Category:Security]]&lt;/div&gt;</summary>
		<author><name>Kunkku</name></author>
	</entry>
	<entry>
		<id>https://wiki.alpinelinux.org/w/index.php?title=Alpine_Wall_User%27s_Guide&amp;diff=8312</id>
		<title>Alpine Wall User&#039;s Guide</title>
		<link rel="alternate" type="text/html" href="https://wiki.alpinelinux.org/w/index.php?title=Alpine_Wall_User%27s_Guide&amp;diff=8312"/>
		<updated>2012-07-12T12:20:43Z</updated>

		<summary type="html">&lt;p&gt;Kunkku: /* Connection Tracking Bypass Rules */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Configuration File Processing ==&lt;br /&gt;
&lt;br /&gt;
[[Alpine Wall]] (awall) reads its configuration from multiple&lt;br /&gt;
JSON-formatted files, called &#039;&#039;policy files&#039;&#039;. The processing starts&lt;br /&gt;
from directory &amp;lt;tt&amp;gt;/usr/share/awall/mandatory&amp;lt;/tt&amp;gt;, which contains&lt;br /&gt;
mandatory policy files shipped with APK packages. After that,&lt;br /&gt;
installation-specific policy files in &amp;lt;tt&amp;gt;/etc/awall&amp;lt;/tt&amp;gt; are&lt;br /&gt;
processed.&lt;br /&gt;
&lt;br /&gt;
The latter directory may also contain symbolic links to policy files&lt;br /&gt;
located in &amp;lt;tt&amp;gt;/usr/share/awall/optional&amp;lt;/tt&amp;gt;. These are optional&lt;br /&gt;
policies, which can be enabled on need basis. Such symbolic links are&lt;br /&gt;
easily created and destroyed using the &amp;lt;tt&amp;gt;awall enable&amp;lt;/tt&amp;gt; and &lt;br /&gt;
&amp;lt;tt&amp;gt;awall disable&amp;lt;/tt&amp;gt; commands. &amp;lt;tt&amp;gt;awall list&amp;lt;/tt&amp;gt; shows which&lt;br /&gt;
optional policies are enabled and disabled. The command also prints&lt;br /&gt;
the description of the optional policy if defined in the file using&lt;br /&gt;
a top-level attribute named &#039;&#039;&#039;description&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Sometimes a policy file depends on other policy files. In this case,&lt;br /&gt;
the policy file must have a top-level attribute &#039;&#039;&#039;import&#039;&#039;&#039;, the&lt;br /&gt;
value of which is a list of policy names, which correspond to the file&lt;br /&gt;
names without the &amp;lt;tt&amp;gt;.json&amp;lt;/tt&amp;gt; suffix. The policies listed there are&lt;br /&gt;
always processed before the importing policy. The order of the&lt;br /&gt;
generated iptables rules generally reflects the processing order of&lt;br /&gt;
their corresponding awall policies.&lt;br /&gt;
&lt;br /&gt;
As the import directive does not require the path name to be&lt;br /&gt;
specified, awall expects policies to have unique names, even if&lt;br /&gt;
located in different directories. It is allowed to import optional&lt;br /&gt;
policies that are not explicitly enabled by the user. Such policies&lt;br /&gt;
show up with the &amp;lt;tt&amp;gt;required&amp;lt;/tt&amp;gt; status in the output of &amp;lt;tt&amp;gt;awall&lt;br /&gt;
list&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
== List Parameters ==&lt;br /&gt;
&lt;br /&gt;
Several awall parameters are defined as lists of values. In order to&lt;br /&gt;
facilitate manual editing of policy files, awall also accepts single&lt;br /&gt;
values in place of lists. Such values are semantically equivalent to&lt;br /&gt;
lists containing one element.&lt;br /&gt;
&lt;br /&gt;
== Variable Expansion ==&lt;br /&gt;
&lt;br /&gt;
Awall allows variable definitions in policy files. The top-level&lt;br /&gt;
attribute &#039;&#039;&#039;variable&#039;&#039;&#039; is a dictionary containing the&lt;br /&gt;
definitions. The value of a variable can be of any type (string,&lt;br /&gt;
integer, list, or dictionary).&lt;br /&gt;
&lt;br /&gt;
A variable is referenced in policy files by a string which equals the&lt;br /&gt;
variable name prepended with the &#039;&#039;&#039;$&#039;&#039;&#039; character. If the value of&lt;br /&gt;
the variable is a string, the reference can be embedded into a longer&lt;br /&gt;
string in order to substitute some part of that string (in shell&lt;br /&gt;
style). Variable references can be used when defining other variables,&lt;br /&gt;
as long as the definitions are not circular.&lt;br /&gt;
&lt;br /&gt;
Policy files can reference variables defined in other policy&lt;br /&gt;
files. Policy files can also override variables defined elsewhere by&lt;br /&gt;
redefining them. In this case, the new definition affects all policy&lt;br /&gt;
files, also those processed before the overriding policy. Awall&lt;br /&gt;
variables are in fact simple macros, since each variable remains&lt;br /&gt;
constant thoughout a single processing round. If multiple files define&lt;br /&gt;
the same variable, the definition in the file processed last takes&lt;br /&gt;
effect.&lt;br /&gt;
&lt;br /&gt;
If defined as an empty string, all non-embedded references to a&lt;br /&gt;
variable evaluate as if the attribute in question was not present in&lt;br /&gt;
the configuration. This is also the case when a string containing&lt;br /&gt;
embedded variable references finally evaluates to an empty string.&lt;br /&gt;
&lt;br /&gt;
== Configuration Objects ==&lt;br /&gt;
&lt;br /&gt;
Configuration objects can be divided into two main types.&lt;br /&gt;
&#039;&#039;Auxiliary objects&#039;&#039; model high-level concepts such as services and&lt;br /&gt;
zones. &#039;&#039;Rule objects&#039;&#039; translate into one or more iptables rules, and&lt;br /&gt;
are often defined with the help of some auxiliary objects.&lt;br /&gt;
&lt;br /&gt;
=== Services ===&lt;br /&gt;
&lt;br /&gt;
A &#039;&#039;service&#039;&#039; represents a set of network protocols. A top-level&lt;br /&gt;
attribute &#039;&#039;&#039;service&#039;&#039;&#039; is a dictionary that maps service names to&lt;br /&gt;
service definition objects, or lists thereof in more complex cases.&lt;br /&gt;
&lt;br /&gt;
A service definition object contains an attribute named &#039;&#039;&#039;proto&#039;&#039;&#039;,&lt;br /&gt;
which corresponds to the &amp;lt;tt&amp;gt;--protocol&amp;lt;/tt&amp;gt; option of iptables. The&lt;br /&gt;
protocol can be defined as a numerical value or string as defined in&lt;br /&gt;
&amp;lt;tt&amp;gt;/etc/protocols&amp;lt;/tt&amp;gt;. If the protocol is &#039;&#039;&#039;tcp&#039;&#039;&#039; or &#039;&#039;&#039;udp&#039;&#039;&#039;,&lt;br /&gt;
the scope of the service definition may be constrained by defining an&lt;br /&gt;
attribute named &#039;&#039;&#039;port&#039;&#039;&#039;, which is a list of TCP or UDP port&lt;br /&gt;
numbers. If the protocol is &#039;&#039;&#039;icmp&#039;&#039;&#039; or &#039;&#039;&#039;icmpv6&#039;&#039;&#039;, an analogous &lt;br /&gt;
&#039;&#039;&#039;icmp-type&#039;&#039;&#039; attribute may be used. In addition, the scope of the&lt;br /&gt;
rule is also automatically limited to IPv4 or IPv6, respectively.&lt;br /&gt;
&lt;br /&gt;
=== Zones ===&lt;br /&gt;
&lt;br /&gt;
A &#039;&#039;zone&#039;&#039; represents a set of network hosts. A top-level attribute &lt;br /&gt;
&#039;&#039;&#039;zone&#039;&#039;&#039; is a dictionary that maps zone names to zone objects. A&lt;br /&gt;
zone object has an attribute named &#039;&#039;&#039;iface&#039;&#039;&#039;, &#039;&#039;&#039;addr&#039;&#039;&#039;, or&lt;br /&gt;
both. &#039;&#039;&#039;iface&#039;&#039;&#039; is a list of network interfaces and &#039;&#039;&#039;addr&#039;&#039;&#039; is a&lt;br /&gt;
list of IPv4/IPv6 host and network addresses (CIDR&lt;br /&gt;
notation). &#039;&#039;&#039;addr&#039;&#039;&#039; may also contain domain names, which are&lt;br /&gt;
expanded to IP addresses using DNS resolution. If not defined,&lt;br /&gt;
&#039;&#039;&#039;addr&#039;&#039;&#039; defaults to the entire address space and &#039;&#039;&#039;iface&#039;&#039;&#039; to all&lt;br /&gt;
interfaces. An empty zone can be defined by setting either &#039;&#039;&#039;addr&#039;&#039;&#039;&lt;br /&gt;
or &#039;&#039;&#039;iface&#039;&#039;&#039; to an empty list.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Rule objects contain two attributes, &#039;&#039;&#039;in&#039;&#039;&#039; and &#039;&#039;&#039;out&#039;&#039;&#039;, which are&lt;br /&gt;
lists of zone names. These attributes control whether a packet matches&lt;br /&gt;
the rule or not. If a particular zone is referenced by the &#039;&#039;&#039;in&#039;&#039;&#039; &lt;br /&gt;
attribute, the rule applies to packets whose ingress interface and&lt;br /&gt;
source address are covered by the zone definition. Correspondingly, if&lt;br /&gt;
a zone is referenced by the &#039;&#039;&#039;out&#039;&#039;&#039; attribute, the rule applies to&lt;br /&gt;
packets whose egress interface and destination address are included in&lt;br /&gt;
the zone. If both &#039;&#039;&#039;in&#039;&#039;&#039; and &#039;&#039;&#039;out&#039;&#039;&#039; are defined, the packet must&lt;br /&gt;
fulfill both criteria in order to match the rule.&lt;br /&gt;
&lt;br /&gt;
=== Rules ===&lt;br /&gt;
&lt;br /&gt;
There are four types of rule objects: &#039;&#039;policies&#039;&#039;, &#039;&#039;filters&#039;&#039;,&lt;br /&gt;
&#039;&#039;NAT rules&#039;&#039;, and &#039;&#039;connection tracking bypass rules&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
All rule objects can have the &#039;&#039;&#039;in&#039;&#039;&#039; and &#039;&#039;&#039;out&#039;&#039;&#039; attributes&lt;br /&gt;
referring to zones as described in the previous section. In addition,&lt;br /&gt;
the scope of the rule can be further constrained with the following&lt;br /&gt;
attributes:&lt;br /&gt;
&lt;br /&gt;
{|&lt;br /&gt;
!Attribute!!Value format!!Effect&lt;br /&gt;
|-&lt;br /&gt;
|&#039;&#039;&#039;src&#039;&#039;&#039;&lt;br /&gt;
|Similar to &#039;&#039;&#039;addr&#039;&#039;&#039; attribute of zone objects&lt;br /&gt;
|Packet&#039;s source address matches the value&lt;br /&gt;
|-&lt;br /&gt;
|&#039;&#039;&#039;dest&#039;&#039;&#039;&lt;br /&gt;
|Similar to &#039;&#039;&#039;addr&#039;&#039;&#039; attribute of zone objects&lt;br /&gt;
|Packet&#039;s destination address matches the value&lt;br /&gt;
|-&lt;br /&gt;
|&#039;&#039;&#039;ipset&#039;&#039;&#039;&lt;br /&gt;
|Object containing two attributes: &#039;&#039;&#039;name&#039;&#039;&#039; referring to an IP set and &#039;&#039;&#039;args&#039;&#039;&#039;, which is a list of strings &#039;&#039;&#039;in&#039;&#039;&#039; and &#039;&#039;&#039;out&#039;&#039;&#039;&lt;br /&gt;
|Packet matches the IP set referred here when the match arguments are taken from the source (&#039;&#039;&#039;in&#039;&#039;&#039;) and destination (&#039;&#039;&#039;out&#039;&#039;&#039;) address or port in the order specified by &#039;&#039;&#039;args&#039;&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
|&#039;&#039;&#039;ipsec&#039;&#039;&#039;&lt;br /&gt;
|&#039;&#039;&#039;in&#039;&#039;&#039; or &#039;&#039;&#039;out&#039;&#039;&#039;&lt;br /&gt;
|IPsec decapsulation perfomed on ingress (&#039;&#039;&#039;in&#039;&#039;&#039;) or encapsulation performed on egress (&#039;&#039;&#039;out&#039;&#039;&#039;)&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Rule objects are declared in type-specific top-level dictionaries in&lt;br /&gt;
awall policy files. If a packet matches multiple rules, the one&lt;br /&gt;
appearing earlier in the list takes precedence. If the matching rules&lt;br /&gt;
are defined in different policy files, the one that was processed&lt;br /&gt;
earlier takes precedence in the current implementation, but this may&lt;br /&gt;
change in future versions.&lt;br /&gt;
&lt;br /&gt;
==== Filters ====&lt;br /&gt;
&lt;br /&gt;
Filter objects specify an action for packets fulfilling certain&lt;br /&gt;
criteria. The top-level attribute &#039;&#039;&#039;filter&#039;&#039;&#039; is a list of filter&lt;br /&gt;
objects. The precedence rules are similar to those of policy objects.&lt;br /&gt;
&lt;br /&gt;
In addition to the common rule attributes, filter objects can have a &lt;br /&gt;
&#039;&#039;&#039;service&#039;&#039;&#039; attribute constraining the scope to specific services&lt;br /&gt;
only. This attribute is a list of service names, referring to the&lt;br /&gt;
keys of the top-level &#039;&#039;&#039;service&#039;&#039;&#039; dictionary.&lt;br /&gt;
&lt;br /&gt;
Filter objects must have an attribute named &#039;&#039;&#039;action&#039;&#039;&#039;, the value of&lt;br /&gt;
which can be one of the following:&lt;br /&gt;
&lt;br /&gt;
{|&lt;br /&gt;
!Value!!Action&lt;br /&gt;
|-&lt;br /&gt;
|&#039;&#039;&#039;accept&#039;&#039;&#039;&lt;br /&gt;
|Accept the packet&lt;br /&gt;
|-&lt;br /&gt;
|&#039;&#039;&#039;reject&#039;&#039;&#039;&lt;br /&gt;
|Reject the packet with an ICMP error message&lt;br /&gt;
|-&lt;br /&gt;
|&#039;&#039;&#039;drop&#039;&#039;&#039;&lt;br /&gt;
|Silently drop the packet&lt;br /&gt;
|-&lt;br /&gt;
|&#039;&#039;&#039;logreject&#039;&#039;&#039;&lt;br /&gt;
|Similar to &#039;&#039;&#039;reject&#039;&#039;&#039; but with kernel logging&lt;br /&gt;
|-&lt;br /&gt;
|&#039;&#039;&#039;logdrop&#039;&#039;&#039;&lt;br /&gt;
|Similar to &#039;&#039;&#039;drop&#039;&#039;&#039; but with kernel logging&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Filter objects, the action of which is &#039;&#039;&#039;accept&#039;&#039;&#039;, may also contain&lt;br /&gt;
limits for packet flow or new connections. These are specified with&lt;br /&gt;
the &#039;&#039;&#039;flow-limit&#039;&#039;&#039; and &#039;&#039;&#039;conn-limit&#039;&#039;&#039; attributes,&lt;br /&gt;
respectively. The values of these attributes are limit objects that&lt;br /&gt;
have two attributes: &#039;&#039;&#039;count&#039;&#039;&#039; and &#039;&#039;&#039;interval&#039;&#039;&#039;. &#039;&#039;&#039;count&#039;&#039;&#039;&lt;br /&gt;
specifies how many new connections or packets are allowed within the&lt;br /&gt;
time frame specified by &#039;&#039;&#039;interval&#039;&#039;&#039; (in seconds). The &#039;&#039;&#039;logdrop&#039;&#039;&#039;&lt;br /&gt;
action is applied to the packets exceeding the limit.&lt;br /&gt;
&lt;br /&gt;
Filter objects may have an attribute named &#039;&#039;&#039;dnat&#039;&#039;&#039;, the value of&lt;br /&gt;
which is an IPv4 address. If defined, this enables destination NAT for&lt;br /&gt;
all IPv4 packets matching the rule, such that the specified address&lt;br /&gt;
replaces the original destination address. This option has no effect&lt;br /&gt;
on IPv6 packets.&lt;br /&gt;
&lt;br /&gt;
==== Policies ====&lt;br /&gt;
&lt;br /&gt;
Policy objects describe the default action for packets that did not&lt;br /&gt;
match any filter. The top-level attribute &#039;&#039;&#039;policy&#039;&#039;&#039; is a list of&lt;br /&gt;
policy objects.&lt;br /&gt;
&lt;br /&gt;
Policy objects must have the &#039;&#039;&#039;action&#039;&#039;&#039; attribute defined. The&lt;br /&gt;
possible values and their semantics are the same as in filter objects.&lt;br /&gt;
&lt;br /&gt;
==== NAT Rules ====&lt;br /&gt;
&lt;br /&gt;
NAT rules come in two flavors: &#039;&#039;source NAT rules&#039;&#039; and&lt;br /&gt;
&#039;&#039;destination NAT rules&#039;&#039;. These are contained in two top-level lists&lt;br /&gt;
named &#039;&#039;&#039;snat&#039;&#039;&#039; and &#039;&#039;&#039;dnat&#039;&#039;&#039;, respectively.&lt;br /&gt;
&lt;br /&gt;
Each NAT rule must have an attribute named &#039;&#039;&#039;ip-range&#039;&#039;&#039; that&lt;br /&gt;
specifies the IPv4 address range to which the original source or&lt;br /&gt;
destinatinon address is mapped. The value can be a single IPv4 address&lt;br /&gt;
or a range specified by two addresses, separated with the &#039;&#039;&#039;-&#039;&#039;&#039;&lt;br /&gt;
character.&lt;br /&gt;
&lt;br /&gt;
Optionally, a NAT rule can specify the TCP and UDP port range to which&lt;br /&gt;
the original source or destination port is mapped. The attribute is&lt;br /&gt;
named &#039;&#039;&#039;port-range&#039;&#039;&#039;, and the value can be a single port number or a&lt;br /&gt;
range specified by two numbers, separated with the &#039;&#039;&#039;-&#039;&#039;&#039;&lt;br /&gt;
character. If &#039;&#039;&#039;port-range&#039;&#039;&#039; is not specified, the original port&lt;br /&gt;
number is kept intact.&lt;br /&gt;
&lt;br /&gt;
Like filters, NAT rules can have a &#039;&#039;&#039;service&#039;&#039;&#039; attribute&lt;br /&gt;
constraining their scope to specific services.&lt;br /&gt;
&lt;br /&gt;
NAT rules may have an &#039;&#039;&#039;action&#039;&#039;&#039; attribute set to value&lt;br /&gt;
&#039;&#039;&#039;accept&#039;&#039;&#039;. In this case, NAT is not performed on the packets&lt;br /&gt;
reaching and matching this rule.&lt;br /&gt;
&lt;br /&gt;
==== Connection Tracking Bypass Rules ====&lt;br /&gt;
&lt;br /&gt;
Connection tracking bypass rules are used to disable connection&lt;br /&gt;
tracking for packets matching the specified criteria. The top-level&lt;br /&gt;
attribute &#039;&#039;&#039;no-track&#039;&#039;&#039; is a list of such rules.&lt;br /&gt;
&lt;br /&gt;
Connection tracking bypass rules may have an &#039;&#039;&#039;action&#039;&#039;&#039; attribute&lt;br /&gt;
set to value &#039;&#039;&#039;accept&#039;&#039;&#039;. The effect is similar to corresponding NAT&lt;br /&gt;
rules, i.e. connection tracking is not bypassed for the matching&lt;br /&gt;
packets.&lt;br /&gt;
&lt;br /&gt;
=== IP Sets ===&lt;br /&gt;
&lt;br /&gt;
Any IP set referenced by rule objects should be created by&lt;br /&gt;
awall. Auxiliary &#039;&#039;IP set&#039;&#039; objects are used to defined them in awall&lt;br /&gt;
policy files. The top-level attribute &#039;&#039;&#039;ipset&#039;&#039;&#039; is a dictionary, the&lt;br /&gt;
keys of which are IP set names. The values are IP set objects, which&lt;br /&gt;
have two mandatory attributes. The attribute named &#039;&#039;&#039;type&#039;&#039;&#039; &lt;br /&gt;
corresponds to the type argument of the &amp;lt;tt&amp;gt;ipset create&amp;lt;/tt&amp;gt; &lt;br /&gt;
command. &#039;&#039;&#039;family&#039;&#039;&#039; specifies whether the set is for IPv4 or IPv6&lt;br /&gt;
addresses, and the possible values are &#039;&#039;&#039;inet&#039;&#039;&#039; and &#039;&#039;&#039;inet6&#039;&#039;&#039;,&lt;br /&gt;
correspondingly.&lt;br /&gt;
&lt;br /&gt;
== Command Line Syntax ==&lt;br /&gt;
&lt;br /&gt;
=== Translating Policy Files to Firewall Configuration Files ===&lt;br /&gt;
&lt;br /&gt;
 &#039;&#039;&#039;awall translate&#039;&#039;&#039; [&#039;&#039;&#039;-o&#039;&#039;&#039;|&#039;&#039;&#039;--output&#039;&#039;&#039; DIRECTORY] [&#039;&#039;&#039;-V&#039;&#039;&#039;|&#039;&#039;&#039;--verify&#039;&#039;&#039;]&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;tt&amp;gt;--verify&amp;lt;/tt&amp;gt; option makes awall verify the configuration&lt;br /&gt;
using the test mode of iptables-restore before overwriting the old&lt;br /&gt;
files.&lt;br /&gt;
&lt;br /&gt;
Specifying the output directory allows testing awall policies without&lt;br /&gt;
overwriting the current iptables and ipset configuration files. By&lt;br /&gt;
default, awall generates the configuration to &amp;lt;tt&amp;gt;/etc/iptables&amp;lt;/tt&amp;gt; &lt;br /&gt;
and &amp;lt;tt&amp;gt;/etc/ipset.d&amp;lt;/tt&amp;gt;, which are read by the init scripts.&lt;br /&gt;
&lt;br /&gt;
=== Run-Time Configuration of Firewall ===&lt;br /&gt;
&lt;br /&gt;
 &#039;&#039;&#039;awall activate&#039;&#039;&#039; [&#039;&#039;&#039;-f&#039;&#039;&#039;|&#039;&#039;&#039;--force&#039;&#039;&#039;]&lt;br /&gt;
&lt;br /&gt;
This command genereates firewall configuration from the policy files&lt;br /&gt;
and enables it. If the user confirms the new configuration by hitting&lt;br /&gt;
the Return key within 10 seconds or the &amp;lt;tt&amp;gt;--force&amp;lt;/tt&amp;gt; option is&lt;br /&gt;
used, the configuration is saved to the files. Otherwise, the old&lt;br /&gt;
configuration is restored.&lt;br /&gt;
&lt;br /&gt;
There is also a command for deleting all firewall rules:&lt;br /&gt;
&lt;br /&gt;
 &#039;&#039;&#039;awall flush&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
This command configures the firewall to drop all packets.&lt;br /&gt;
&lt;br /&gt;
=== Optional Policies ===&lt;br /&gt;
&lt;br /&gt;
Optional policies can be enabled or disabled using this command:&lt;br /&gt;
&lt;br /&gt;
 &#039;&#039;&#039;awall&#039;&#039;&#039; {&#039;&#039;&#039;enable&#039;&#039;&#039;|&#039;&#039;&#039;disable&#039;&#039;&#039;} POLICY...&lt;br /&gt;
&lt;br /&gt;
Optional policies can be listed using this command:&lt;br /&gt;
&lt;br /&gt;
 &#039;&#039;&#039;awall list&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;&#039;enabled&#039;&#039;&#039; status means that the policy has been enabled by the&lt;br /&gt;
user. The &#039;&#039;&#039;disabled&#039;&#039;&#039; status means that the policy is not in&lt;br /&gt;
use. The &#039;&#039;&#039;required&#039;&#039;&#039; status means that the policy has not been&lt;br /&gt;
enabled by the user but is in use because it is required by another&lt;br /&gt;
policy which is in use.&lt;br /&gt;
&lt;br /&gt;
=== Debugging Policies ===&lt;br /&gt;
&lt;br /&gt;
This command can be used to dump variable, zone, and other definitions&lt;br /&gt;
as well as their source policies:&lt;br /&gt;
&lt;br /&gt;
 &#039;&#039;&#039;awall dump&#039;&#039;&#039; [LEVEL]&lt;br /&gt;
&lt;br /&gt;
The level is an integer in range 0&amp;amp;ndash;3 and defaults to 0. More&lt;br /&gt;
information is displayed on higher levels.&lt;br /&gt;
&lt;br /&gt;
[[Category:Networking]]&lt;br /&gt;
[[Category:Security]]&lt;/div&gt;</summary>
		<author><name>Kunkku</name></author>
	</entry>
	<entry>
		<id>https://wiki.alpinelinux.org/w/index.php?title=Alpine_Wall_User%27s_Guide&amp;diff=8307</id>
		<title>Alpine Wall User&#039;s Guide</title>
		<link rel="alternate" type="text/html" href="https://wiki.alpinelinux.org/w/index.php?title=Alpine_Wall_User%27s_Guide&amp;diff=8307"/>
		<updated>2012-07-12T05:52:52Z</updated>

		<summary type="html">&lt;p&gt;Kunkku: /* Rules */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Configuration File Processing ==&lt;br /&gt;
&lt;br /&gt;
[[Alpine Wall]] (awall) reads its configuration from multiple&lt;br /&gt;
JSON-formatted files, called &#039;&#039;policy files&#039;&#039;. The processing starts&lt;br /&gt;
from directory &amp;lt;tt&amp;gt;/usr/share/awall/mandatory&amp;lt;/tt&amp;gt;, which contains&lt;br /&gt;
mandatory policy files shipped with APK packages. After that,&lt;br /&gt;
installation-specific policy files in &amp;lt;tt&amp;gt;/etc/awall&amp;lt;/tt&amp;gt; are&lt;br /&gt;
processed.&lt;br /&gt;
&lt;br /&gt;
The latter directory may also contain symbolic links to policy files&lt;br /&gt;
located in &amp;lt;tt&amp;gt;/usr/share/awall/optional&amp;lt;/tt&amp;gt;. These are optional&lt;br /&gt;
policies, which can be enabled on need basis. Such symbolic links are&lt;br /&gt;
easily created and destroyed using the &amp;lt;tt&amp;gt;awall enable&amp;lt;/tt&amp;gt; and &lt;br /&gt;
&amp;lt;tt&amp;gt;awall disable&amp;lt;/tt&amp;gt; commands. &amp;lt;tt&amp;gt;awall list&amp;lt;/tt&amp;gt; shows which&lt;br /&gt;
optional policies are enabled and disabled. The command also prints&lt;br /&gt;
the description of the optional policy if defined in the file using&lt;br /&gt;
a top-level attribute named &#039;&#039;&#039;description&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Sometimes a policy file depends on other policy files. In this case,&lt;br /&gt;
the policy file must have a top-level attribute &#039;&#039;&#039;import&#039;&#039;&#039;, the&lt;br /&gt;
value of which is a list of policy names, which correspond to the file&lt;br /&gt;
names without the &amp;lt;tt&amp;gt;.json&amp;lt;/tt&amp;gt; suffix. The policies listed there are&lt;br /&gt;
always processed before the importing policy. The order of the&lt;br /&gt;
generated iptables rules generally reflects the processing order of&lt;br /&gt;
their corresponding awall policies.&lt;br /&gt;
&lt;br /&gt;
As the import directive does not require the path name to be&lt;br /&gt;
specified, awall expects policies to have unique names, even if&lt;br /&gt;
located in different directories. It is allowed to import optional&lt;br /&gt;
policies that are not explicitly enabled by the user. Such policies&lt;br /&gt;
show up with the &amp;lt;tt&amp;gt;required&amp;lt;/tt&amp;gt; status in the output of &amp;lt;tt&amp;gt;awall&lt;br /&gt;
list&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
== List Parameters ==&lt;br /&gt;
&lt;br /&gt;
Several awall parameters are defined as lists of values. In order to&lt;br /&gt;
facilitate manual editing of policy files, awall also accepts single&lt;br /&gt;
values in place of lists. Such values are semantically equivalent to&lt;br /&gt;
lists containing one element.&lt;br /&gt;
&lt;br /&gt;
== Variable Expansion ==&lt;br /&gt;
&lt;br /&gt;
Awall allows variable definitions in policy files. The top-level&lt;br /&gt;
attribute &#039;&#039;&#039;variable&#039;&#039;&#039; is a dictionary containing the&lt;br /&gt;
definitions. The value of a variable can be of any type (string,&lt;br /&gt;
integer, list, or dictionary).&lt;br /&gt;
&lt;br /&gt;
A variable is referenced in policy files by a string which equals the&lt;br /&gt;
variable name prepended with the &#039;&#039;&#039;$&#039;&#039;&#039; character. If the value of&lt;br /&gt;
the variable is a string, the reference can be embedded into a longer&lt;br /&gt;
string in order to substitute some part of that string (in shell&lt;br /&gt;
style). Variable references can be used when defining other variables,&lt;br /&gt;
as long as the definitions are not circular.&lt;br /&gt;
&lt;br /&gt;
Policy files can reference variables defined in other policy&lt;br /&gt;
files. Policy files can also override variables defined elsewhere by&lt;br /&gt;
redefining them. In this case, the new definition affects all policy&lt;br /&gt;
files, also those processed before the overriding policy. Awall&lt;br /&gt;
variables are in fact simple macros, since each variable remains&lt;br /&gt;
constant thoughout a single processing round. If multiple files define&lt;br /&gt;
the same variable, the definition in the file processed last takes&lt;br /&gt;
effect.&lt;br /&gt;
&lt;br /&gt;
If defined as an empty string, all non-embedded references to a&lt;br /&gt;
variable evaluate as if the attribute in question was not present in&lt;br /&gt;
the configuration. This is also the case when a string containing&lt;br /&gt;
embedded variable references finally evaluates to an empty string.&lt;br /&gt;
&lt;br /&gt;
== Configuration Objects ==&lt;br /&gt;
&lt;br /&gt;
Configuration objects can be divided into two main types.&lt;br /&gt;
&#039;&#039;Auxiliary objects&#039;&#039; model high-level concepts such as services and&lt;br /&gt;
zones. &#039;&#039;Rule objects&#039;&#039; translate into one or more iptables rules, and&lt;br /&gt;
are often defined with the help of some auxiliary objects.&lt;br /&gt;
&lt;br /&gt;
=== Services ===&lt;br /&gt;
&lt;br /&gt;
A &#039;&#039;service&#039;&#039; represents a set of network protocols. A top-level&lt;br /&gt;
attribute &#039;&#039;&#039;service&#039;&#039;&#039; is a dictionary that maps service names to&lt;br /&gt;
service definition objects, or lists thereof in more complex cases.&lt;br /&gt;
&lt;br /&gt;
A service definition object contains an attribute named &#039;&#039;&#039;proto&#039;&#039;&#039;,&lt;br /&gt;
which corresponds to the &amp;lt;tt&amp;gt;--protocol&amp;lt;/tt&amp;gt; option of iptables. The&lt;br /&gt;
protocol can be defined as a numerical value or string as defined in&lt;br /&gt;
&amp;lt;tt&amp;gt;/etc/protocols&amp;lt;/tt&amp;gt;. If the protocol is &#039;&#039;&#039;tcp&#039;&#039;&#039; or &#039;&#039;&#039;udp&#039;&#039;&#039;,&lt;br /&gt;
the scope of the service definition may be constrained by defining an&lt;br /&gt;
attribute named &#039;&#039;&#039;port&#039;&#039;&#039;, which is a list of TCP or UDP port&lt;br /&gt;
numbers. If the protocol is &#039;&#039;&#039;icmp&#039;&#039;&#039; or &#039;&#039;&#039;icmpv6&#039;&#039;&#039;, an analogous &lt;br /&gt;
&#039;&#039;&#039;icmp-type&#039;&#039;&#039; attribute may be used. In addition, the scope of the&lt;br /&gt;
rule is also automatically limited to IPv4 or IPv6, respectively.&lt;br /&gt;
&lt;br /&gt;
=== Zones ===&lt;br /&gt;
&lt;br /&gt;
A &#039;&#039;zone&#039;&#039; represents a set of network hosts. A top-level attribute &lt;br /&gt;
&#039;&#039;&#039;zone&#039;&#039;&#039; is a dictionary that maps zone names to zone objects. A&lt;br /&gt;
zone object has an attribute named &#039;&#039;&#039;iface&#039;&#039;&#039;, &#039;&#039;&#039;addr&#039;&#039;&#039;, or&lt;br /&gt;
both. &#039;&#039;&#039;iface&#039;&#039;&#039; is a list of network interfaces and &#039;&#039;&#039;addr&#039;&#039;&#039; is a&lt;br /&gt;
list of IPv4/IPv6 host and network addresses (CIDR&lt;br /&gt;
notation). &#039;&#039;&#039;addr&#039;&#039;&#039; may also contain domain names, which are&lt;br /&gt;
expanded to IP addresses using DNS resolution. If not defined,&lt;br /&gt;
&#039;&#039;&#039;addr&#039;&#039;&#039; defaults to the entire address space and &#039;&#039;&#039;iface&#039;&#039;&#039; to all&lt;br /&gt;
interfaces. An empty zone can be defined by setting either &#039;&#039;&#039;addr&#039;&#039;&#039;&lt;br /&gt;
or &#039;&#039;&#039;iface&#039;&#039;&#039; to an empty list.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Rule objects contain two attributes, &#039;&#039;&#039;in&#039;&#039;&#039; and &#039;&#039;&#039;out&#039;&#039;&#039;, which are&lt;br /&gt;
lists of zone names. These attributes control whether a packet matches&lt;br /&gt;
the rule or not. If a particular zone is referenced by the &#039;&#039;&#039;in&#039;&#039;&#039; &lt;br /&gt;
attribute, the rule applies to packets whose ingress interface and&lt;br /&gt;
source address are covered by the zone definition. Correspondingly, if&lt;br /&gt;
a zone is referenced by the &#039;&#039;&#039;out&#039;&#039;&#039; attribute, the rule applies to&lt;br /&gt;
packets whose egress interface and destination address are included in&lt;br /&gt;
the zone. If both &#039;&#039;&#039;in&#039;&#039;&#039; and &#039;&#039;&#039;out&#039;&#039;&#039; are defined, the packet must&lt;br /&gt;
fulfill both criteria in order to match the rule.&lt;br /&gt;
&lt;br /&gt;
=== Rules ===&lt;br /&gt;
&lt;br /&gt;
There are four types of rule objects: &#039;&#039;policies&#039;&#039;, &#039;&#039;filters&#039;&#039;,&lt;br /&gt;
&#039;&#039;NAT rules&#039;&#039;, and &#039;&#039;connection tracking bypass rules&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
All rule objects can have the &#039;&#039;&#039;in&#039;&#039;&#039; and &#039;&#039;&#039;out&#039;&#039;&#039; attributes&lt;br /&gt;
referring to zones as described in the previous section. In addition,&lt;br /&gt;
the scope of the rule can be further constrained with the following&lt;br /&gt;
attributes:&lt;br /&gt;
&lt;br /&gt;
{|&lt;br /&gt;
!Attribute!!Value format!!Effect&lt;br /&gt;
|-&lt;br /&gt;
|&#039;&#039;&#039;src&#039;&#039;&#039;&lt;br /&gt;
|Similar to &#039;&#039;&#039;addr&#039;&#039;&#039; attribute of zone objects&lt;br /&gt;
|Packet&#039;s source address matches the value&lt;br /&gt;
|-&lt;br /&gt;
|&#039;&#039;&#039;dest&#039;&#039;&#039;&lt;br /&gt;
|Similar to &#039;&#039;&#039;addr&#039;&#039;&#039; attribute of zone objects&lt;br /&gt;
|Packet&#039;s destination address matches the value&lt;br /&gt;
|-&lt;br /&gt;
|&#039;&#039;&#039;ipset&#039;&#039;&#039;&lt;br /&gt;
|Object containing two attributes: &#039;&#039;&#039;name&#039;&#039;&#039; referring to an IP set and &#039;&#039;&#039;args&#039;&#039;&#039;, which is a list of strings &#039;&#039;&#039;in&#039;&#039;&#039; and &#039;&#039;&#039;out&#039;&#039;&#039;&lt;br /&gt;
|Packet matches the IP set referred here when the match arguments are taken from the source (&#039;&#039;&#039;in&#039;&#039;&#039;) and destination (&#039;&#039;&#039;out&#039;&#039;&#039;) address or port in the order specified by &#039;&#039;&#039;args&#039;&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
|&#039;&#039;&#039;ipsec&#039;&#039;&#039;&lt;br /&gt;
|&#039;&#039;&#039;in&#039;&#039;&#039; or &#039;&#039;&#039;out&#039;&#039;&#039;&lt;br /&gt;
|IPsec decapsulation perfomed on ingress (&#039;&#039;&#039;in&#039;&#039;&#039;) or encapsulation performed on egress (&#039;&#039;&#039;out&#039;&#039;&#039;)&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Rule objects are declared in type-specific top-level dictionaries in&lt;br /&gt;
awall policy files. If a packet matches multiple rules, the one&lt;br /&gt;
appearing earlier in the list takes precedence. If the matching rules&lt;br /&gt;
are defined in different policy files, the one that was processed&lt;br /&gt;
earlier takes precedence in the current implementation, but this may&lt;br /&gt;
change in future versions.&lt;br /&gt;
&lt;br /&gt;
==== Filters ====&lt;br /&gt;
&lt;br /&gt;
Filter objects specify an action for packets fulfilling certain&lt;br /&gt;
criteria. The top-level attribute &#039;&#039;&#039;filter&#039;&#039;&#039; is a list of filter&lt;br /&gt;
objects. The precedence rules are similar to those of policy objects.&lt;br /&gt;
&lt;br /&gt;
In addition to the common rule attributes, filter objects can have a &lt;br /&gt;
&#039;&#039;&#039;service&#039;&#039;&#039; attribute constraining the scope to specific services&lt;br /&gt;
only. This attribute is a list of service names, referring to the&lt;br /&gt;
keys of the top-level &#039;&#039;&#039;service&#039;&#039;&#039; dictionary.&lt;br /&gt;
&lt;br /&gt;
Filter objects must have an attribute named &#039;&#039;&#039;action&#039;&#039;&#039;, the value of&lt;br /&gt;
which can be one of the following:&lt;br /&gt;
&lt;br /&gt;
{|&lt;br /&gt;
!Value!!Action&lt;br /&gt;
|-&lt;br /&gt;
|&#039;&#039;&#039;accept&#039;&#039;&#039;&lt;br /&gt;
|Accept the packet&lt;br /&gt;
|-&lt;br /&gt;
|&#039;&#039;&#039;reject&#039;&#039;&#039;&lt;br /&gt;
|Reject the packet with an ICMP error message&lt;br /&gt;
|-&lt;br /&gt;
|&#039;&#039;&#039;drop&#039;&#039;&#039;&lt;br /&gt;
|Silently drop the packet&lt;br /&gt;
|-&lt;br /&gt;
|&#039;&#039;&#039;logreject&#039;&#039;&#039;&lt;br /&gt;
|Similar to &#039;&#039;&#039;reject&#039;&#039;&#039; but with kernel logging&lt;br /&gt;
|-&lt;br /&gt;
|&#039;&#039;&#039;logdrop&#039;&#039;&#039;&lt;br /&gt;
|Similar to &#039;&#039;&#039;drop&#039;&#039;&#039; but with kernel logging&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Filter objects, the action of which is &#039;&#039;&#039;accept&#039;&#039;&#039;, may also contain&lt;br /&gt;
limits for packet flow or new connections. These are specified with&lt;br /&gt;
the &#039;&#039;&#039;flow-limit&#039;&#039;&#039; and &#039;&#039;&#039;conn-limit&#039;&#039;&#039; attributes,&lt;br /&gt;
respectively. The values of these attributes are limit objects that&lt;br /&gt;
have two attributes: &#039;&#039;&#039;count&#039;&#039;&#039; and &#039;&#039;&#039;interval&#039;&#039;&#039;. &#039;&#039;&#039;count&#039;&#039;&#039;&lt;br /&gt;
specifies how many new connections or packets are allowed within the&lt;br /&gt;
time frame specified by &#039;&#039;&#039;interval&#039;&#039;&#039; (in seconds). The &#039;&#039;&#039;logdrop&#039;&#039;&#039;&lt;br /&gt;
action is applied to the packets exceeding the limit.&lt;br /&gt;
&lt;br /&gt;
Filter objects may have an attribute named &#039;&#039;&#039;dnat&#039;&#039;&#039;, the value of&lt;br /&gt;
which is an IPv4 address. If defined, this enables destination NAT for&lt;br /&gt;
all IPv4 packets matching the rule, such that the specified address&lt;br /&gt;
replaces the original destination address. This option has no effect&lt;br /&gt;
on IPv6 packets.&lt;br /&gt;
&lt;br /&gt;
==== Policies ====&lt;br /&gt;
&lt;br /&gt;
Policy objects describe the default action for packets that did not&lt;br /&gt;
match any filter. The top-level attribute &#039;&#039;&#039;policy&#039;&#039;&#039; is a list of&lt;br /&gt;
policy objects.&lt;br /&gt;
&lt;br /&gt;
Policy objects must have the &#039;&#039;&#039;action&#039;&#039;&#039; attribute defined. The&lt;br /&gt;
possible values and their semantics are the same as in filter objects.&lt;br /&gt;
&lt;br /&gt;
==== NAT Rules ====&lt;br /&gt;
&lt;br /&gt;
NAT rules come in two flavors: &#039;&#039;source NAT rules&#039;&#039; and&lt;br /&gt;
&#039;&#039;destination NAT rules&#039;&#039;. These are contained in two top-level lists&lt;br /&gt;
named &#039;&#039;&#039;snat&#039;&#039;&#039; and &#039;&#039;&#039;dnat&#039;&#039;&#039;, respectively.&lt;br /&gt;
&lt;br /&gt;
Each NAT rule must have an attribute named &#039;&#039;&#039;ip-range&#039;&#039;&#039; that&lt;br /&gt;
specifies the IPv4 address range to which the original source or&lt;br /&gt;
destinatinon address is mapped. The value can be a single IPv4 address&lt;br /&gt;
or a range specified by two addresses, separated with the &#039;&#039;&#039;-&#039;&#039;&#039;&lt;br /&gt;
character.&lt;br /&gt;
&lt;br /&gt;
Optionally, a NAT rule can specify the TCP and UDP port range to which&lt;br /&gt;
the original source or destination port is mapped. The attribute is&lt;br /&gt;
named &#039;&#039;&#039;port-range&#039;&#039;&#039;, and the value can be a single port number or a&lt;br /&gt;
range specified by two numbers, separated with the &#039;&#039;&#039;-&#039;&#039;&#039;&lt;br /&gt;
character. If &#039;&#039;&#039;port-range&#039;&#039;&#039; is not specified, the original port&lt;br /&gt;
number is kept intact.&lt;br /&gt;
&lt;br /&gt;
Like filters, NAT rules can have a &#039;&#039;&#039;service&#039;&#039;&#039; attribute&lt;br /&gt;
constraining their scope to specific services.&lt;br /&gt;
&lt;br /&gt;
NAT rules may have an &#039;&#039;&#039;action&#039;&#039;&#039; attribute set to value&lt;br /&gt;
&#039;&#039;&#039;accept&#039;&#039;&#039;. In this case, NAT is not performed on the packets&lt;br /&gt;
reaching and matching this rule.&lt;br /&gt;
&lt;br /&gt;
==== Connection Tracking Bypass Rules ====&lt;br /&gt;
&lt;br /&gt;
Connection tracking bypass rules are used to disable connection&lt;br /&gt;
tracking for packets matching the specified criteria. The top-level&lt;br /&gt;
attribute &#039;&#039;&#039;notrack&#039;&#039;&#039; is a list of such rules.&lt;br /&gt;
&lt;br /&gt;
Connection tracking bypass rules may have an &#039;&#039;&#039;action&#039;&#039;&#039; attribute&lt;br /&gt;
set to value &#039;&#039;&#039;accept&#039;&#039;&#039;. The effect is similar to corresponding NAT&lt;br /&gt;
rules, i.e. connection tracking is not bypassed for the matching&lt;br /&gt;
packets.&lt;br /&gt;
&lt;br /&gt;
=== IP Sets ===&lt;br /&gt;
&lt;br /&gt;
Any IP set referenced by rule objects should be created by&lt;br /&gt;
awall. Auxiliary &#039;&#039;IP set&#039;&#039; objects are used to defined them in awall&lt;br /&gt;
policy files. The top-level attribute &#039;&#039;&#039;ipset&#039;&#039;&#039; is a dictionary, the&lt;br /&gt;
keys of which are IP set names. The values are IP set objects, which&lt;br /&gt;
have two mandatory attributes. The attribute named &#039;&#039;&#039;type&#039;&#039;&#039; &lt;br /&gt;
corresponds to the type argument of the &amp;lt;tt&amp;gt;ipset create&amp;lt;/tt&amp;gt; &lt;br /&gt;
command. &#039;&#039;&#039;family&#039;&#039;&#039; specifies whether the set is for IPv4 or IPv6&lt;br /&gt;
addresses, and the possible values are &#039;&#039;&#039;inet&#039;&#039;&#039; and &#039;&#039;&#039;inet6&#039;&#039;&#039;,&lt;br /&gt;
correspondingly.&lt;br /&gt;
&lt;br /&gt;
== Command Line Syntax ==&lt;br /&gt;
&lt;br /&gt;
=== Translating Policy Files to Firewall Configuration Files ===&lt;br /&gt;
&lt;br /&gt;
 &#039;&#039;&#039;awall translate&#039;&#039;&#039; [&#039;&#039;&#039;-o&#039;&#039;&#039;|&#039;&#039;&#039;--output&#039;&#039;&#039; DIRECTORY] [&#039;&#039;&#039;-V&#039;&#039;&#039;|&#039;&#039;&#039;--verify&#039;&#039;&#039;]&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;tt&amp;gt;--verify&amp;lt;/tt&amp;gt; option makes awall verify the configuration&lt;br /&gt;
using the test mode of iptables-restore before overwriting the old&lt;br /&gt;
files.&lt;br /&gt;
&lt;br /&gt;
Specifying the output directory allows testing awall policies without&lt;br /&gt;
overwriting the current iptables and ipset configuration files. By&lt;br /&gt;
default, awall generates the configuration to &amp;lt;tt&amp;gt;/etc/iptables&amp;lt;/tt&amp;gt; &lt;br /&gt;
and &amp;lt;tt&amp;gt;/etc/ipset.d&amp;lt;/tt&amp;gt;, which are read by the init scripts.&lt;br /&gt;
&lt;br /&gt;
=== Run-Time Configuration of Firewall ===&lt;br /&gt;
&lt;br /&gt;
 &#039;&#039;&#039;awall activate&#039;&#039;&#039; [&#039;&#039;&#039;-f&#039;&#039;&#039;|&#039;&#039;&#039;--force&#039;&#039;&#039;]&lt;br /&gt;
&lt;br /&gt;
This command genereates firewall configuration from the policy files&lt;br /&gt;
and enables it. If the user confirms the new configuration by hitting&lt;br /&gt;
the Return key within 10 seconds or the &amp;lt;tt&amp;gt;--force&amp;lt;/tt&amp;gt; option is&lt;br /&gt;
used, the configuration is saved to the files. Otherwise, the old&lt;br /&gt;
configuration is restored.&lt;br /&gt;
&lt;br /&gt;
There is also a command for deleting all firewall rules:&lt;br /&gt;
&lt;br /&gt;
 &#039;&#039;&#039;awall flush&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
This command configures the firewall to drop all packets.&lt;br /&gt;
&lt;br /&gt;
=== Optional Policies ===&lt;br /&gt;
&lt;br /&gt;
Optional policies can be enabled or disabled using this command:&lt;br /&gt;
&lt;br /&gt;
 &#039;&#039;&#039;awall&#039;&#039;&#039; {&#039;&#039;&#039;enable&#039;&#039;&#039;|&#039;&#039;&#039;disable&#039;&#039;&#039;} POLICY...&lt;br /&gt;
&lt;br /&gt;
Optional policies can be listed using this command:&lt;br /&gt;
&lt;br /&gt;
 &#039;&#039;&#039;awall list&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;&#039;enabled&#039;&#039;&#039; status means that the policy has been enabled by the&lt;br /&gt;
user. The &#039;&#039;&#039;disabled&#039;&#039;&#039; status means that the policy is not in&lt;br /&gt;
use. The &#039;&#039;&#039;required&#039;&#039;&#039; status means that the policy has not been&lt;br /&gt;
enabled by the user but is in use because it is required by another&lt;br /&gt;
policy which is in use.&lt;br /&gt;
&lt;br /&gt;
=== Debugging Policies ===&lt;br /&gt;
&lt;br /&gt;
This command can be used to dump variable, zone, and other definitions&lt;br /&gt;
as well as their source policies:&lt;br /&gt;
&lt;br /&gt;
 &#039;&#039;&#039;awall dump&#039;&#039;&#039; [LEVEL]&lt;br /&gt;
&lt;br /&gt;
The level is an integer in range 0&amp;amp;ndash;3 and defaults to 0. More&lt;br /&gt;
information is displayed on higher levels.&lt;br /&gt;
&lt;br /&gt;
[[Category:Networking]]&lt;br /&gt;
[[Category:Security]]&lt;/div&gt;</summary>
		<author><name>Kunkku</name></author>
	</entry>
	<entry>
		<id>https://wiki.alpinelinux.org/w/index.php?title=Alpine_Wall_User%27s_Guide&amp;diff=8306</id>
		<title>Alpine Wall User&#039;s Guide</title>
		<link rel="alternate" type="text/html" href="https://wiki.alpinelinux.org/w/index.php?title=Alpine_Wall_User%27s_Guide&amp;diff=8306"/>
		<updated>2012-07-12T05:44:13Z</updated>

		<summary type="html">&lt;p&gt;Kunkku: /* Run-Time Configuration of Firewall */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Configuration File Processing ==&lt;br /&gt;
&lt;br /&gt;
[[Alpine Wall]] (awall) reads its configuration from multiple&lt;br /&gt;
JSON-formatted files, called &#039;&#039;policy files&#039;&#039;. The processing starts&lt;br /&gt;
from directory &amp;lt;tt&amp;gt;/usr/share/awall/mandatory&amp;lt;/tt&amp;gt;, which contains&lt;br /&gt;
mandatory policy files shipped with APK packages. After that,&lt;br /&gt;
installation-specific policy files in &amp;lt;tt&amp;gt;/etc/awall&amp;lt;/tt&amp;gt; are&lt;br /&gt;
processed.&lt;br /&gt;
&lt;br /&gt;
The latter directory may also contain symbolic links to policy files&lt;br /&gt;
located in &amp;lt;tt&amp;gt;/usr/share/awall/optional&amp;lt;/tt&amp;gt;. These are optional&lt;br /&gt;
policies, which can be enabled on need basis. Such symbolic links are&lt;br /&gt;
easily created and destroyed using the &amp;lt;tt&amp;gt;awall enable&amp;lt;/tt&amp;gt; and &lt;br /&gt;
&amp;lt;tt&amp;gt;awall disable&amp;lt;/tt&amp;gt; commands. &amp;lt;tt&amp;gt;awall list&amp;lt;/tt&amp;gt; shows which&lt;br /&gt;
optional policies are enabled and disabled. The command also prints&lt;br /&gt;
the description of the optional policy if defined in the file using&lt;br /&gt;
a top-level attribute named &#039;&#039;&#039;description&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Sometimes a policy file depends on other policy files. In this case,&lt;br /&gt;
the policy file must have a top-level attribute &#039;&#039;&#039;import&#039;&#039;&#039;, the&lt;br /&gt;
value of which is a list of policy names, which correspond to the file&lt;br /&gt;
names without the &amp;lt;tt&amp;gt;.json&amp;lt;/tt&amp;gt; suffix. The policies listed there are&lt;br /&gt;
always processed before the importing policy. The order of the&lt;br /&gt;
generated iptables rules generally reflects the processing order of&lt;br /&gt;
their corresponding awall policies.&lt;br /&gt;
&lt;br /&gt;
As the import directive does not require the path name to be&lt;br /&gt;
specified, awall expects policies to have unique names, even if&lt;br /&gt;
located in different directories. It is allowed to import optional&lt;br /&gt;
policies that are not explicitly enabled by the user. Such policies&lt;br /&gt;
show up with the &amp;lt;tt&amp;gt;required&amp;lt;/tt&amp;gt; status in the output of &amp;lt;tt&amp;gt;awall&lt;br /&gt;
list&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
== List Parameters ==&lt;br /&gt;
&lt;br /&gt;
Several awall parameters are defined as lists of values. In order to&lt;br /&gt;
facilitate manual editing of policy files, awall also accepts single&lt;br /&gt;
values in place of lists. Such values are semantically equivalent to&lt;br /&gt;
lists containing one element.&lt;br /&gt;
&lt;br /&gt;
== Variable Expansion ==&lt;br /&gt;
&lt;br /&gt;
Awall allows variable definitions in policy files. The top-level&lt;br /&gt;
attribute &#039;&#039;&#039;variable&#039;&#039;&#039; is a dictionary containing the&lt;br /&gt;
definitions. The value of a variable can be of any type (string,&lt;br /&gt;
integer, list, or dictionary).&lt;br /&gt;
&lt;br /&gt;
A variable is referenced in policy files by a string which equals the&lt;br /&gt;
variable name prepended with the &#039;&#039;&#039;$&#039;&#039;&#039; character. If the value of&lt;br /&gt;
the variable is a string, the reference can be embedded into a longer&lt;br /&gt;
string in order to substitute some part of that string (in shell&lt;br /&gt;
style). Variable references can be used when defining other variables,&lt;br /&gt;
as long as the definitions are not circular.&lt;br /&gt;
&lt;br /&gt;
Policy files can reference variables defined in other policy&lt;br /&gt;
files. Policy files can also override variables defined elsewhere by&lt;br /&gt;
redefining them. In this case, the new definition affects all policy&lt;br /&gt;
files, also those processed before the overriding policy. Awall&lt;br /&gt;
variables are in fact simple macros, since each variable remains&lt;br /&gt;
constant thoughout a single processing round. If multiple files define&lt;br /&gt;
the same variable, the definition in the file processed last takes&lt;br /&gt;
effect.&lt;br /&gt;
&lt;br /&gt;
If defined as an empty string, all non-embedded references to a&lt;br /&gt;
variable evaluate as if the attribute in question was not present in&lt;br /&gt;
the configuration. This is also the case when a string containing&lt;br /&gt;
embedded variable references finally evaluates to an empty string.&lt;br /&gt;
&lt;br /&gt;
== Configuration Objects ==&lt;br /&gt;
&lt;br /&gt;
Configuration objects can be divided into two main types.&lt;br /&gt;
&#039;&#039;Auxiliary objects&#039;&#039; model high-level concepts such as services and&lt;br /&gt;
zones. &#039;&#039;Rule objects&#039;&#039; translate into one or more iptables rules, and&lt;br /&gt;
are often defined with the help of some auxiliary objects.&lt;br /&gt;
&lt;br /&gt;
=== Services ===&lt;br /&gt;
&lt;br /&gt;
A &#039;&#039;service&#039;&#039; represents a set of network protocols. A top-level&lt;br /&gt;
attribute &#039;&#039;&#039;service&#039;&#039;&#039; is a dictionary that maps service names to&lt;br /&gt;
service definition objects, or lists thereof in more complex cases.&lt;br /&gt;
&lt;br /&gt;
A service definition object contains an attribute named &#039;&#039;&#039;proto&#039;&#039;&#039;,&lt;br /&gt;
which corresponds to the &amp;lt;tt&amp;gt;--protocol&amp;lt;/tt&amp;gt; option of iptables. The&lt;br /&gt;
protocol can be defined as a numerical value or string as defined in&lt;br /&gt;
&amp;lt;tt&amp;gt;/etc/protocols&amp;lt;/tt&amp;gt;. If the protocol is &#039;&#039;&#039;tcp&#039;&#039;&#039; or &#039;&#039;&#039;udp&#039;&#039;&#039;,&lt;br /&gt;
the scope of the service definition may be constrained by defining an&lt;br /&gt;
attribute named &#039;&#039;&#039;port&#039;&#039;&#039;, which is a list of TCP or UDP port&lt;br /&gt;
numbers. If the protocol is &#039;&#039;&#039;icmp&#039;&#039;&#039; or &#039;&#039;&#039;icmpv6&#039;&#039;&#039;, an analogous &lt;br /&gt;
&#039;&#039;&#039;icmp-type&#039;&#039;&#039; attribute may be used. In addition, the scope of the&lt;br /&gt;
rule is also automatically limited to IPv4 or IPv6, respectively.&lt;br /&gt;
&lt;br /&gt;
=== Zones ===&lt;br /&gt;
&lt;br /&gt;
A &#039;&#039;zone&#039;&#039; represents a set of network hosts. A top-level attribute &lt;br /&gt;
&#039;&#039;&#039;zone&#039;&#039;&#039; is a dictionary that maps zone names to zone objects. A&lt;br /&gt;
zone object has an attribute named &#039;&#039;&#039;iface&#039;&#039;&#039;, &#039;&#039;&#039;addr&#039;&#039;&#039;, or&lt;br /&gt;
both. &#039;&#039;&#039;iface&#039;&#039;&#039; is a list of network interfaces and &#039;&#039;&#039;addr&#039;&#039;&#039; is a&lt;br /&gt;
list of IPv4/IPv6 host and network addresses (CIDR&lt;br /&gt;
notation). &#039;&#039;&#039;addr&#039;&#039;&#039; may also contain domain names, which are&lt;br /&gt;
expanded to IP addresses using DNS resolution. If not defined,&lt;br /&gt;
&#039;&#039;&#039;addr&#039;&#039;&#039; defaults to the entire address space and &#039;&#039;&#039;iface&#039;&#039;&#039; to all&lt;br /&gt;
interfaces. An empty zone can be defined by setting either &#039;&#039;&#039;addr&#039;&#039;&#039;&lt;br /&gt;
or &#039;&#039;&#039;iface&#039;&#039;&#039; to an empty list.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Rule objects contain two attributes, &#039;&#039;&#039;in&#039;&#039;&#039; and &#039;&#039;&#039;out&#039;&#039;&#039;, which are&lt;br /&gt;
lists of zone names. These attributes control whether a packet matches&lt;br /&gt;
the rule or not. If a particular zone is referenced by the &#039;&#039;&#039;in&#039;&#039;&#039; &lt;br /&gt;
attribute, the rule applies to packets whose ingress interface and&lt;br /&gt;
source address are covered by the zone definition. Correspondingly, if&lt;br /&gt;
a zone is referenced by the &#039;&#039;&#039;out&#039;&#039;&#039; attribute, the rule applies to&lt;br /&gt;
packets whose egress interface and destination address are included in&lt;br /&gt;
the zone. If both &#039;&#039;&#039;in&#039;&#039;&#039; and &#039;&#039;&#039;out&#039;&#039;&#039; are defined, the packet must&lt;br /&gt;
fulfill both criteria in order to match the rule.&lt;br /&gt;
&lt;br /&gt;
=== Rules ===&lt;br /&gt;
&lt;br /&gt;
There are three types of rule objects: &#039;&#039;policies&#039;&#039;, &#039;&#039;filters&#039;&#039;, and &lt;br /&gt;
&#039;&#039;NAT rules&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
All rule objects can have the &#039;&#039;&#039;in&#039;&#039;&#039; and &#039;&#039;&#039;out&#039;&#039;&#039; attributes&lt;br /&gt;
referring to zones as described in the previous section. In addition,&lt;br /&gt;
the scope of the rule can be further constrained with the following&lt;br /&gt;
attributes:&lt;br /&gt;
&lt;br /&gt;
{|&lt;br /&gt;
!Attribute!!Value format!!Effect&lt;br /&gt;
|-&lt;br /&gt;
|&#039;&#039;&#039;src&#039;&#039;&#039;&lt;br /&gt;
|Similar to &#039;&#039;&#039;addr&#039;&#039;&#039; attribute of zone objects&lt;br /&gt;
|Packet&#039;s source address matches the value&lt;br /&gt;
|-&lt;br /&gt;
|&#039;&#039;&#039;dest&#039;&#039;&#039;&lt;br /&gt;
|Similar to &#039;&#039;&#039;addr&#039;&#039;&#039; attribute of zone objects&lt;br /&gt;
|Packet&#039;s destination address matches the value&lt;br /&gt;
|-&lt;br /&gt;
|&#039;&#039;&#039;ipset&#039;&#039;&#039;&lt;br /&gt;
|Object containing two attributes: &#039;&#039;&#039;name&#039;&#039;&#039; referring to an IP set and &#039;&#039;&#039;args&#039;&#039;&#039;, which is a list of strings &#039;&#039;&#039;in&#039;&#039;&#039; and &#039;&#039;&#039;out&#039;&#039;&#039;&lt;br /&gt;
|Packet matches the IP set referred here when the match arguments are taken from the source (&#039;&#039;&#039;in&#039;&#039;&#039;) and destination (&#039;&#039;&#039;out&#039;&#039;&#039;) address or port in the order specified by &#039;&#039;&#039;args&#039;&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
|&#039;&#039;&#039;ipsec&#039;&#039;&#039;&lt;br /&gt;
|&#039;&#039;&#039;in&#039;&#039;&#039; or &#039;&#039;&#039;out&#039;&#039;&#039;&lt;br /&gt;
|IPsec decapsulation perfomed on ingress (&#039;&#039;&#039;in&#039;&#039;&#039;) or encapsulation performed on egress (&#039;&#039;&#039;out&#039;&#039;&#039;)&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Rule objects are declared in type-specific top-level dictionaries in&lt;br /&gt;
awall policy files. If a packet matches multiple rules, the one&lt;br /&gt;
appearing earlier in the list takes precedence. If the matching rules&lt;br /&gt;
are defined in different policy files, the one that was processed&lt;br /&gt;
earlier takes precedence in the current implementation, but this may&lt;br /&gt;
change in future versions.&lt;br /&gt;
&lt;br /&gt;
==== Filters ====&lt;br /&gt;
&lt;br /&gt;
Filter objects specify an action for packets fulfilling certain&lt;br /&gt;
criteria. The top-level attribute &#039;&#039;&#039;filter&#039;&#039;&#039; is a list of filter&lt;br /&gt;
objects. The precedence rules are similar to those of policy objects.&lt;br /&gt;
&lt;br /&gt;
In addition to the common rule attributes, filter objects can have a &lt;br /&gt;
&#039;&#039;&#039;service&#039;&#039;&#039; attribute constraining the scope to specific services&lt;br /&gt;
only. This attribute is a list of service names, referring to the&lt;br /&gt;
keys of the top-level &#039;&#039;&#039;service&#039;&#039;&#039; dictionary.&lt;br /&gt;
&lt;br /&gt;
Filter objects must have an attribute named &#039;&#039;&#039;action&#039;&#039;&#039;, the value of&lt;br /&gt;
which can be one of the following:&lt;br /&gt;
&lt;br /&gt;
{|&lt;br /&gt;
!Value!!Action&lt;br /&gt;
|-&lt;br /&gt;
|&#039;&#039;&#039;accept&#039;&#039;&#039;&lt;br /&gt;
|Accept the packet&lt;br /&gt;
|-&lt;br /&gt;
|&#039;&#039;&#039;reject&#039;&#039;&#039;&lt;br /&gt;
|Reject the packet with an ICMP error message&lt;br /&gt;
|-&lt;br /&gt;
|&#039;&#039;&#039;drop&#039;&#039;&#039;&lt;br /&gt;
|Silently drop the packet&lt;br /&gt;
|-&lt;br /&gt;
|&#039;&#039;&#039;logreject&#039;&#039;&#039;&lt;br /&gt;
|Similar to &#039;&#039;&#039;reject&#039;&#039;&#039; but with kernel logging&lt;br /&gt;
|-&lt;br /&gt;
|&#039;&#039;&#039;logdrop&#039;&#039;&#039;&lt;br /&gt;
|Similar to &#039;&#039;&#039;drop&#039;&#039;&#039; but with kernel logging&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Filter objects, the action of which is &#039;&#039;&#039;accept&#039;&#039;&#039;, may also contain&lt;br /&gt;
limits for packet flow or new connections. These are specified with&lt;br /&gt;
the &#039;&#039;&#039;flow-limit&#039;&#039;&#039; and &#039;&#039;&#039;conn-limit&#039;&#039;&#039; attributes,&lt;br /&gt;
respectively. The values of these attributes are limit objects that&lt;br /&gt;
have two attributes: &#039;&#039;&#039;count&#039;&#039;&#039; and &#039;&#039;&#039;interval&#039;&#039;&#039;. &#039;&#039;&#039;count&#039;&#039;&#039;&lt;br /&gt;
specifies how many new connections or packets are allowed within the&lt;br /&gt;
time frame specified by &#039;&#039;&#039;interval&#039;&#039;&#039; (in seconds). The &#039;&#039;&#039;logdrop&#039;&#039;&#039;&lt;br /&gt;
action is applied to the packets exceeding the limit.&lt;br /&gt;
&lt;br /&gt;
Filter objects may have an attribute named &#039;&#039;&#039;dnat&#039;&#039;&#039;, the value of&lt;br /&gt;
which is an IPv4 address. If defined, this enables destination NAT for&lt;br /&gt;
all IPv4 packets matching the rule, such that the specified address&lt;br /&gt;
replaces the original destination address. This option has no effect&lt;br /&gt;
on IPv6 packets.&lt;br /&gt;
&lt;br /&gt;
==== Policies ====&lt;br /&gt;
&lt;br /&gt;
Policy objects describe the default action for packets that did not&lt;br /&gt;
match any filter. The top-level attribute &#039;&#039;&#039;policy&#039;&#039;&#039; is a list of&lt;br /&gt;
policy objects.&lt;br /&gt;
&lt;br /&gt;
Policy objects must have the &#039;&#039;&#039;action&#039;&#039;&#039; attribute defined. The&lt;br /&gt;
possible values and their semantics are the same as in filter objects.&lt;br /&gt;
&lt;br /&gt;
==== NAT Rules ====&lt;br /&gt;
&lt;br /&gt;
NAT rules come in two flavors: &#039;&#039;source NAT rules&#039;&#039; and&lt;br /&gt;
&#039;&#039;destination NAT rules&#039;&#039;. These are contained in two top-level lists&lt;br /&gt;
named &#039;&#039;&#039;snat&#039;&#039;&#039; and &#039;&#039;&#039;dnat&#039;&#039;&#039;, respectively.&lt;br /&gt;
&lt;br /&gt;
Each NAT rule must have an attribute named &#039;&#039;&#039;ip-range&#039;&#039;&#039; that&lt;br /&gt;
specifies the IPv4 address range to which the original source or&lt;br /&gt;
destinatinon address is mapped. The value can be a single IPv4 address&lt;br /&gt;
or a range specified by two addresses, separated with the &#039;&#039;&#039;-&#039;&#039;&#039;&lt;br /&gt;
character.&lt;br /&gt;
&lt;br /&gt;
Optionally, a NAT rule can specify the TCP and UDP port range to which&lt;br /&gt;
the original source or destination port is mapped. The attribute is&lt;br /&gt;
named &#039;&#039;&#039;port-range&#039;&#039;&#039;, and the value can be a single port number or a&lt;br /&gt;
range specified by two numbers, separated with the &#039;&#039;&#039;-&#039;&#039;&#039;&lt;br /&gt;
character. If &#039;&#039;&#039;port-range&#039;&#039;&#039; is not specified, the original port&lt;br /&gt;
number is kept intact.&lt;br /&gt;
&lt;br /&gt;
Like filters, NAT rules can have a &#039;&#039;&#039;service&#039;&#039;&#039; attribute&lt;br /&gt;
constraining their scope to specific services.&lt;br /&gt;
&lt;br /&gt;
NAT rules may have an &#039;&#039;&#039;action&#039;&#039;&#039; attribute set to value&lt;br /&gt;
&#039;&#039;&#039;accept&#039;&#039;&#039;. In this case, NAT is not performed on the packets&lt;br /&gt;
reaching and matching this rule.&lt;br /&gt;
&lt;br /&gt;
=== IP Sets ===&lt;br /&gt;
&lt;br /&gt;
Any IP set referenced by rule objects should be created by&lt;br /&gt;
awall. Auxiliary &#039;&#039;IP set&#039;&#039; objects are used to defined them in awall&lt;br /&gt;
policy files. The top-level attribute &#039;&#039;&#039;ipset&#039;&#039;&#039; is a dictionary, the&lt;br /&gt;
keys of which are IP set names. The values are IP set objects, which&lt;br /&gt;
have two mandatory attributes. The attribute named &#039;&#039;&#039;type&#039;&#039;&#039; &lt;br /&gt;
corresponds to the type argument of the &amp;lt;tt&amp;gt;ipset create&amp;lt;/tt&amp;gt; &lt;br /&gt;
command. &#039;&#039;&#039;family&#039;&#039;&#039; specifies whether the set is for IPv4 or IPv6&lt;br /&gt;
addresses, and the possible values are &#039;&#039;&#039;inet&#039;&#039;&#039; and &#039;&#039;&#039;inet6&#039;&#039;&#039;,&lt;br /&gt;
correspondingly.&lt;br /&gt;
&lt;br /&gt;
== Command Line Syntax ==&lt;br /&gt;
&lt;br /&gt;
=== Translating Policy Files to Firewall Configuration Files ===&lt;br /&gt;
&lt;br /&gt;
 &#039;&#039;&#039;awall translate&#039;&#039;&#039; [&#039;&#039;&#039;-o&#039;&#039;&#039;|&#039;&#039;&#039;--output&#039;&#039;&#039; DIRECTORY] [&#039;&#039;&#039;-V&#039;&#039;&#039;|&#039;&#039;&#039;--verify&#039;&#039;&#039;]&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;tt&amp;gt;--verify&amp;lt;/tt&amp;gt; option makes awall verify the configuration&lt;br /&gt;
using the test mode of iptables-restore before overwriting the old&lt;br /&gt;
files.&lt;br /&gt;
&lt;br /&gt;
Specifying the output directory allows testing awall policies without&lt;br /&gt;
overwriting the current iptables and ipset configuration files. By&lt;br /&gt;
default, awall generates the configuration to &amp;lt;tt&amp;gt;/etc/iptables&amp;lt;/tt&amp;gt; &lt;br /&gt;
and &amp;lt;tt&amp;gt;/etc/ipset.d&amp;lt;/tt&amp;gt;, which are read by the init scripts.&lt;br /&gt;
&lt;br /&gt;
=== Run-Time Configuration of Firewall ===&lt;br /&gt;
&lt;br /&gt;
 &#039;&#039;&#039;awall activate&#039;&#039;&#039; [&#039;&#039;&#039;-f&#039;&#039;&#039;|&#039;&#039;&#039;--force&#039;&#039;&#039;]&lt;br /&gt;
&lt;br /&gt;
This command genereates firewall configuration from the policy files&lt;br /&gt;
and enables it. If the user confirms the new configuration by hitting&lt;br /&gt;
the Return key within 10 seconds or the &amp;lt;tt&amp;gt;--force&amp;lt;/tt&amp;gt; option is&lt;br /&gt;
used, the configuration is saved to the files. Otherwise, the old&lt;br /&gt;
configuration is restored.&lt;br /&gt;
&lt;br /&gt;
There is also a command for deleting all firewall rules:&lt;br /&gt;
&lt;br /&gt;
 &#039;&#039;&#039;awall flush&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
This command configures the firewall to drop all packets.&lt;br /&gt;
&lt;br /&gt;
=== Optional Policies ===&lt;br /&gt;
&lt;br /&gt;
Optional policies can be enabled or disabled using this command:&lt;br /&gt;
&lt;br /&gt;
 &#039;&#039;&#039;awall&#039;&#039;&#039; {&#039;&#039;&#039;enable&#039;&#039;&#039;|&#039;&#039;&#039;disable&#039;&#039;&#039;} POLICY...&lt;br /&gt;
&lt;br /&gt;
Optional policies can be listed using this command:&lt;br /&gt;
&lt;br /&gt;
 &#039;&#039;&#039;awall list&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;&#039;enabled&#039;&#039;&#039; status means that the policy has been enabled by the&lt;br /&gt;
user. The &#039;&#039;&#039;disabled&#039;&#039;&#039; status means that the policy is not in&lt;br /&gt;
use. The &#039;&#039;&#039;required&#039;&#039;&#039; status means that the policy has not been&lt;br /&gt;
enabled by the user but is in use because it is required by another&lt;br /&gt;
policy which is in use.&lt;br /&gt;
&lt;br /&gt;
=== Debugging Policies ===&lt;br /&gt;
&lt;br /&gt;
This command can be used to dump variable, zone, and other definitions&lt;br /&gt;
as well as their source policies:&lt;br /&gt;
&lt;br /&gt;
 &#039;&#039;&#039;awall dump&#039;&#039;&#039; [LEVEL]&lt;br /&gt;
&lt;br /&gt;
The level is an integer in range 0&amp;amp;ndash;3 and defaults to 0. More&lt;br /&gt;
information is displayed on higher levels.&lt;br /&gt;
&lt;br /&gt;
[[Category:Networking]]&lt;br /&gt;
[[Category:Security]]&lt;/div&gt;</summary>
		<author><name>Kunkku</name></author>
	</entry>
	<entry>
		<id>https://wiki.alpinelinux.org/w/index.php?title=Alpine_Wall_User%27s_Guide&amp;diff=8305</id>
		<title>Alpine Wall User&#039;s Guide</title>
		<link rel="alternate" type="text/html" href="https://wiki.alpinelinux.org/w/index.php?title=Alpine_Wall_User%27s_Guide&amp;diff=8305"/>
		<updated>2012-07-12T05:41:55Z</updated>

		<summary type="html">&lt;p&gt;Kunkku: /* Run-Time Activation of New Firewall Configuration */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Configuration File Processing ==&lt;br /&gt;
&lt;br /&gt;
[[Alpine Wall]] (awall) reads its configuration from multiple&lt;br /&gt;
JSON-formatted files, called &#039;&#039;policy files&#039;&#039;. The processing starts&lt;br /&gt;
from directory &amp;lt;tt&amp;gt;/usr/share/awall/mandatory&amp;lt;/tt&amp;gt;, which contains&lt;br /&gt;
mandatory policy files shipped with APK packages. After that,&lt;br /&gt;
installation-specific policy files in &amp;lt;tt&amp;gt;/etc/awall&amp;lt;/tt&amp;gt; are&lt;br /&gt;
processed.&lt;br /&gt;
&lt;br /&gt;
The latter directory may also contain symbolic links to policy files&lt;br /&gt;
located in &amp;lt;tt&amp;gt;/usr/share/awall/optional&amp;lt;/tt&amp;gt;. These are optional&lt;br /&gt;
policies, which can be enabled on need basis. Such symbolic links are&lt;br /&gt;
easily created and destroyed using the &amp;lt;tt&amp;gt;awall enable&amp;lt;/tt&amp;gt; and &lt;br /&gt;
&amp;lt;tt&amp;gt;awall disable&amp;lt;/tt&amp;gt; commands. &amp;lt;tt&amp;gt;awall list&amp;lt;/tt&amp;gt; shows which&lt;br /&gt;
optional policies are enabled and disabled. The command also prints&lt;br /&gt;
the description of the optional policy if defined in the file using&lt;br /&gt;
a top-level attribute named &#039;&#039;&#039;description&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Sometimes a policy file depends on other policy files. In this case,&lt;br /&gt;
the policy file must have a top-level attribute &#039;&#039;&#039;import&#039;&#039;&#039;, the&lt;br /&gt;
value of which is a list of policy names, which correspond to the file&lt;br /&gt;
names without the &amp;lt;tt&amp;gt;.json&amp;lt;/tt&amp;gt; suffix. The policies listed there are&lt;br /&gt;
always processed before the importing policy. The order of the&lt;br /&gt;
generated iptables rules generally reflects the processing order of&lt;br /&gt;
their corresponding awall policies.&lt;br /&gt;
&lt;br /&gt;
As the import directive does not require the path name to be&lt;br /&gt;
specified, awall expects policies to have unique names, even if&lt;br /&gt;
located in different directories. It is allowed to import optional&lt;br /&gt;
policies that are not explicitly enabled by the user. Such policies&lt;br /&gt;
show up with the &amp;lt;tt&amp;gt;required&amp;lt;/tt&amp;gt; status in the output of &amp;lt;tt&amp;gt;awall&lt;br /&gt;
list&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
== List Parameters ==&lt;br /&gt;
&lt;br /&gt;
Several awall parameters are defined as lists of values. In order to&lt;br /&gt;
facilitate manual editing of policy files, awall also accepts single&lt;br /&gt;
values in place of lists. Such values are semantically equivalent to&lt;br /&gt;
lists containing one element.&lt;br /&gt;
&lt;br /&gt;
== Variable Expansion ==&lt;br /&gt;
&lt;br /&gt;
Awall allows variable definitions in policy files. The top-level&lt;br /&gt;
attribute &#039;&#039;&#039;variable&#039;&#039;&#039; is a dictionary containing the&lt;br /&gt;
definitions. The value of a variable can be of any type (string,&lt;br /&gt;
integer, list, or dictionary).&lt;br /&gt;
&lt;br /&gt;
A variable is referenced in policy files by a string which equals the&lt;br /&gt;
variable name prepended with the &#039;&#039;&#039;$&#039;&#039;&#039; character. If the value of&lt;br /&gt;
the variable is a string, the reference can be embedded into a longer&lt;br /&gt;
string in order to substitute some part of that string (in shell&lt;br /&gt;
style). Variable references can be used when defining other variables,&lt;br /&gt;
as long as the definitions are not circular.&lt;br /&gt;
&lt;br /&gt;
Policy files can reference variables defined in other policy&lt;br /&gt;
files. Policy files can also override variables defined elsewhere by&lt;br /&gt;
redefining them. In this case, the new definition affects all policy&lt;br /&gt;
files, also those processed before the overriding policy. Awall&lt;br /&gt;
variables are in fact simple macros, since each variable remains&lt;br /&gt;
constant thoughout a single processing round. If multiple files define&lt;br /&gt;
the same variable, the definition in the file processed last takes&lt;br /&gt;
effect.&lt;br /&gt;
&lt;br /&gt;
If defined as an empty string, all non-embedded references to a&lt;br /&gt;
variable evaluate as if the attribute in question was not present in&lt;br /&gt;
the configuration. This is also the case when a string containing&lt;br /&gt;
embedded variable references finally evaluates to an empty string.&lt;br /&gt;
&lt;br /&gt;
== Configuration Objects ==&lt;br /&gt;
&lt;br /&gt;
Configuration objects can be divided into two main types.&lt;br /&gt;
&#039;&#039;Auxiliary objects&#039;&#039; model high-level concepts such as services and&lt;br /&gt;
zones. &#039;&#039;Rule objects&#039;&#039; translate into one or more iptables rules, and&lt;br /&gt;
are often defined with the help of some auxiliary objects.&lt;br /&gt;
&lt;br /&gt;
=== Services ===&lt;br /&gt;
&lt;br /&gt;
A &#039;&#039;service&#039;&#039; represents a set of network protocols. A top-level&lt;br /&gt;
attribute &#039;&#039;&#039;service&#039;&#039;&#039; is a dictionary that maps service names to&lt;br /&gt;
service definition objects, or lists thereof in more complex cases.&lt;br /&gt;
&lt;br /&gt;
A service definition object contains an attribute named &#039;&#039;&#039;proto&#039;&#039;&#039;,&lt;br /&gt;
which corresponds to the &amp;lt;tt&amp;gt;--protocol&amp;lt;/tt&amp;gt; option of iptables. The&lt;br /&gt;
protocol can be defined as a numerical value or string as defined in&lt;br /&gt;
&amp;lt;tt&amp;gt;/etc/protocols&amp;lt;/tt&amp;gt;. If the protocol is &#039;&#039;&#039;tcp&#039;&#039;&#039; or &#039;&#039;&#039;udp&#039;&#039;&#039;,&lt;br /&gt;
the scope of the service definition may be constrained by defining an&lt;br /&gt;
attribute named &#039;&#039;&#039;port&#039;&#039;&#039;, which is a list of TCP or UDP port&lt;br /&gt;
numbers. If the protocol is &#039;&#039;&#039;icmp&#039;&#039;&#039; or &#039;&#039;&#039;icmpv6&#039;&#039;&#039;, an analogous &lt;br /&gt;
&#039;&#039;&#039;icmp-type&#039;&#039;&#039; attribute may be used. In addition, the scope of the&lt;br /&gt;
rule is also automatically limited to IPv4 or IPv6, respectively.&lt;br /&gt;
&lt;br /&gt;
=== Zones ===&lt;br /&gt;
&lt;br /&gt;
A &#039;&#039;zone&#039;&#039; represents a set of network hosts. A top-level attribute &lt;br /&gt;
&#039;&#039;&#039;zone&#039;&#039;&#039; is a dictionary that maps zone names to zone objects. A&lt;br /&gt;
zone object has an attribute named &#039;&#039;&#039;iface&#039;&#039;&#039;, &#039;&#039;&#039;addr&#039;&#039;&#039;, or&lt;br /&gt;
both. &#039;&#039;&#039;iface&#039;&#039;&#039; is a list of network interfaces and &#039;&#039;&#039;addr&#039;&#039;&#039; is a&lt;br /&gt;
list of IPv4/IPv6 host and network addresses (CIDR&lt;br /&gt;
notation). &#039;&#039;&#039;addr&#039;&#039;&#039; may also contain domain names, which are&lt;br /&gt;
expanded to IP addresses using DNS resolution. If not defined,&lt;br /&gt;
&#039;&#039;&#039;addr&#039;&#039;&#039; defaults to the entire address space and &#039;&#039;&#039;iface&#039;&#039;&#039; to all&lt;br /&gt;
interfaces. An empty zone can be defined by setting either &#039;&#039;&#039;addr&#039;&#039;&#039;&lt;br /&gt;
or &#039;&#039;&#039;iface&#039;&#039;&#039; to an empty list.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Rule objects contain two attributes, &#039;&#039;&#039;in&#039;&#039;&#039; and &#039;&#039;&#039;out&#039;&#039;&#039;, which are&lt;br /&gt;
lists of zone names. These attributes control whether a packet matches&lt;br /&gt;
the rule or not. If a particular zone is referenced by the &#039;&#039;&#039;in&#039;&#039;&#039; &lt;br /&gt;
attribute, the rule applies to packets whose ingress interface and&lt;br /&gt;
source address are covered by the zone definition. Correspondingly, if&lt;br /&gt;
a zone is referenced by the &#039;&#039;&#039;out&#039;&#039;&#039; attribute, the rule applies to&lt;br /&gt;
packets whose egress interface and destination address are included in&lt;br /&gt;
the zone. If both &#039;&#039;&#039;in&#039;&#039;&#039; and &#039;&#039;&#039;out&#039;&#039;&#039; are defined, the packet must&lt;br /&gt;
fulfill both criteria in order to match the rule.&lt;br /&gt;
&lt;br /&gt;
=== Rules ===&lt;br /&gt;
&lt;br /&gt;
There are three types of rule objects: &#039;&#039;policies&#039;&#039;, &#039;&#039;filters&#039;&#039;, and &lt;br /&gt;
&#039;&#039;NAT rules&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
All rule objects can have the &#039;&#039;&#039;in&#039;&#039;&#039; and &#039;&#039;&#039;out&#039;&#039;&#039; attributes&lt;br /&gt;
referring to zones as described in the previous section. In addition,&lt;br /&gt;
the scope of the rule can be further constrained with the following&lt;br /&gt;
attributes:&lt;br /&gt;
&lt;br /&gt;
{|&lt;br /&gt;
!Attribute!!Value format!!Effect&lt;br /&gt;
|-&lt;br /&gt;
|&#039;&#039;&#039;src&#039;&#039;&#039;&lt;br /&gt;
|Similar to &#039;&#039;&#039;addr&#039;&#039;&#039; attribute of zone objects&lt;br /&gt;
|Packet&#039;s source address matches the value&lt;br /&gt;
|-&lt;br /&gt;
|&#039;&#039;&#039;dest&#039;&#039;&#039;&lt;br /&gt;
|Similar to &#039;&#039;&#039;addr&#039;&#039;&#039; attribute of zone objects&lt;br /&gt;
|Packet&#039;s destination address matches the value&lt;br /&gt;
|-&lt;br /&gt;
|&#039;&#039;&#039;ipset&#039;&#039;&#039;&lt;br /&gt;
|Object containing two attributes: &#039;&#039;&#039;name&#039;&#039;&#039; referring to an IP set and &#039;&#039;&#039;args&#039;&#039;&#039;, which is a list of strings &#039;&#039;&#039;in&#039;&#039;&#039; and &#039;&#039;&#039;out&#039;&#039;&#039;&lt;br /&gt;
|Packet matches the IP set referred here when the match arguments are taken from the source (&#039;&#039;&#039;in&#039;&#039;&#039;) and destination (&#039;&#039;&#039;out&#039;&#039;&#039;) address or port in the order specified by &#039;&#039;&#039;args&#039;&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
|&#039;&#039;&#039;ipsec&#039;&#039;&#039;&lt;br /&gt;
|&#039;&#039;&#039;in&#039;&#039;&#039; or &#039;&#039;&#039;out&#039;&#039;&#039;&lt;br /&gt;
|IPsec decapsulation perfomed on ingress (&#039;&#039;&#039;in&#039;&#039;&#039;) or encapsulation performed on egress (&#039;&#039;&#039;out&#039;&#039;&#039;)&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Rule objects are declared in type-specific top-level dictionaries in&lt;br /&gt;
awall policy files. If a packet matches multiple rules, the one&lt;br /&gt;
appearing earlier in the list takes precedence. If the matching rules&lt;br /&gt;
are defined in different policy files, the one that was processed&lt;br /&gt;
earlier takes precedence in the current implementation, but this may&lt;br /&gt;
change in future versions.&lt;br /&gt;
&lt;br /&gt;
==== Filters ====&lt;br /&gt;
&lt;br /&gt;
Filter objects specify an action for packets fulfilling certain&lt;br /&gt;
criteria. The top-level attribute &#039;&#039;&#039;filter&#039;&#039;&#039; is a list of filter&lt;br /&gt;
objects. The precedence rules are similar to those of policy objects.&lt;br /&gt;
&lt;br /&gt;
In addition to the common rule attributes, filter objects can have a &lt;br /&gt;
&#039;&#039;&#039;service&#039;&#039;&#039; attribute constraining the scope to specific services&lt;br /&gt;
only. This attribute is a list of service names, referring to the&lt;br /&gt;
keys of the top-level &#039;&#039;&#039;service&#039;&#039;&#039; dictionary.&lt;br /&gt;
&lt;br /&gt;
Filter objects must have an attribute named &#039;&#039;&#039;action&#039;&#039;&#039;, the value of&lt;br /&gt;
which can be one of the following:&lt;br /&gt;
&lt;br /&gt;
{|&lt;br /&gt;
!Value!!Action&lt;br /&gt;
|-&lt;br /&gt;
|&#039;&#039;&#039;accept&#039;&#039;&#039;&lt;br /&gt;
|Accept the packet&lt;br /&gt;
|-&lt;br /&gt;
|&#039;&#039;&#039;reject&#039;&#039;&#039;&lt;br /&gt;
|Reject the packet with an ICMP error message&lt;br /&gt;
|-&lt;br /&gt;
|&#039;&#039;&#039;drop&#039;&#039;&#039;&lt;br /&gt;
|Silently drop the packet&lt;br /&gt;
|-&lt;br /&gt;
|&#039;&#039;&#039;logreject&#039;&#039;&#039;&lt;br /&gt;
|Similar to &#039;&#039;&#039;reject&#039;&#039;&#039; but with kernel logging&lt;br /&gt;
|-&lt;br /&gt;
|&#039;&#039;&#039;logdrop&#039;&#039;&#039;&lt;br /&gt;
|Similar to &#039;&#039;&#039;drop&#039;&#039;&#039; but with kernel logging&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Filter objects, the action of which is &#039;&#039;&#039;accept&#039;&#039;&#039;, may also contain&lt;br /&gt;
limits for packet flow or new connections. These are specified with&lt;br /&gt;
the &#039;&#039;&#039;flow-limit&#039;&#039;&#039; and &#039;&#039;&#039;conn-limit&#039;&#039;&#039; attributes,&lt;br /&gt;
respectively. The values of these attributes are limit objects that&lt;br /&gt;
have two attributes: &#039;&#039;&#039;count&#039;&#039;&#039; and &#039;&#039;&#039;interval&#039;&#039;&#039;. &#039;&#039;&#039;count&#039;&#039;&#039;&lt;br /&gt;
specifies how many new connections or packets are allowed within the&lt;br /&gt;
time frame specified by &#039;&#039;&#039;interval&#039;&#039;&#039; (in seconds). The &#039;&#039;&#039;logdrop&#039;&#039;&#039;&lt;br /&gt;
action is applied to the packets exceeding the limit.&lt;br /&gt;
&lt;br /&gt;
Filter objects may have an attribute named &#039;&#039;&#039;dnat&#039;&#039;&#039;, the value of&lt;br /&gt;
which is an IPv4 address. If defined, this enables destination NAT for&lt;br /&gt;
all IPv4 packets matching the rule, such that the specified address&lt;br /&gt;
replaces the original destination address. This option has no effect&lt;br /&gt;
on IPv6 packets.&lt;br /&gt;
&lt;br /&gt;
==== Policies ====&lt;br /&gt;
&lt;br /&gt;
Policy objects describe the default action for packets that did not&lt;br /&gt;
match any filter. The top-level attribute &#039;&#039;&#039;policy&#039;&#039;&#039; is a list of&lt;br /&gt;
policy objects.&lt;br /&gt;
&lt;br /&gt;
Policy objects must have the &#039;&#039;&#039;action&#039;&#039;&#039; attribute defined. The&lt;br /&gt;
possible values and their semantics are the same as in filter objects.&lt;br /&gt;
&lt;br /&gt;
==== NAT Rules ====&lt;br /&gt;
&lt;br /&gt;
NAT rules come in two flavors: &#039;&#039;source NAT rules&#039;&#039; and&lt;br /&gt;
&#039;&#039;destination NAT rules&#039;&#039;. These are contained in two top-level lists&lt;br /&gt;
named &#039;&#039;&#039;snat&#039;&#039;&#039; and &#039;&#039;&#039;dnat&#039;&#039;&#039;, respectively.&lt;br /&gt;
&lt;br /&gt;
Each NAT rule must have an attribute named &#039;&#039;&#039;ip-range&#039;&#039;&#039; that&lt;br /&gt;
specifies the IPv4 address range to which the original source or&lt;br /&gt;
destinatinon address is mapped. The value can be a single IPv4 address&lt;br /&gt;
or a range specified by two addresses, separated with the &#039;&#039;&#039;-&#039;&#039;&#039;&lt;br /&gt;
character.&lt;br /&gt;
&lt;br /&gt;
Optionally, a NAT rule can specify the TCP and UDP port range to which&lt;br /&gt;
the original source or destination port is mapped. The attribute is&lt;br /&gt;
named &#039;&#039;&#039;port-range&#039;&#039;&#039;, and the value can be a single port number or a&lt;br /&gt;
range specified by two numbers, separated with the &#039;&#039;&#039;-&#039;&#039;&#039;&lt;br /&gt;
character. If &#039;&#039;&#039;port-range&#039;&#039;&#039; is not specified, the original port&lt;br /&gt;
number is kept intact.&lt;br /&gt;
&lt;br /&gt;
Like filters, NAT rules can have a &#039;&#039;&#039;service&#039;&#039;&#039; attribute&lt;br /&gt;
constraining their scope to specific services.&lt;br /&gt;
&lt;br /&gt;
NAT rules may have an &#039;&#039;&#039;action&#039;&#039;&#039; attribute set to value&lt;br /&gt;
&#039;&#039;&#039;accept&#039;&#039;&#039;. In this case, NAT is not performed on the packets&lt;br /&gt;
reaching and matching this rule.&lt;br /&gt;
&lt;br /&gt;
=== IP Sets ===&lt;br /&gt;
&lt;br /&gt;
Any IP set referenced by rule objects should be created by&lt;br /&gt;
awall. Auxiliary &#039;&#039;IP set&#039;&#039; objects are used to defined them in awall&lt;br /&gt;
policy files. The top-level attribute &#039;&#039;&#039;ipset&#039;&#039;&#039; is a dictionary, the&lt;br /&gt;
keys of which are IP set names. The values are IP set objects, which&lt;br /&gt;
have two mandatory attributes. The attribute named &#039;&#039;&#039;type&#039;&#039;&#039; &lt;br /&gt;
corresponds to the type argument of the &amp;lt;tt&amp;gt;ipset create&amp;lt;/tt&amp;gt; &lt;br /&gt;
command. &#039;&#039;&#039;family&#039;&#039;&#039; specifies whether the set is for IPv4 or IPv6&lt;br /&gt;
addresses, and the possible values are &#039;&#039;&#039;inet&#039;&#039;&#039; and &#039;&#039;&#039;inet6&#039;&#039;&#039;,&lt;br /&gt;
correspondingly.&lt;br /&gt;
&lt;br /&gt;
== Command Line Syntax ==&lt;br /&gt;
&lt;br /&gt;
=== Translating Policy Files to Firewall Configuration Files ===&lt;br /&gt;
&lt;br /&gt;
 &#039;&#039;&#039;awall translate&#039;&#039;&#039; [&#039;&#039;&#039;-o&#039;&#039;&#039;|&#039;&#039;&#039;--output&#039;&#039;&#039; DIRECTORY] [&#039;&#039;&#039;-V&#039;&#039;&#039;|&#039;&#039;&#039;--verify&#039;&#039;&#039;]&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;tt&amp;gt;--verify&amp;lt;/tt&amp;gt; option makes awall verify the configuration&lt;br /&gt;
using the test mode of iptables-restore before overwriting the old&lt;br /&gt;
files.&lt;br /&gt;
&lt;br /&gt;
Specifying the output directory allows testing awall policies without&lt;br /&gt;
overwriting the current iptables and ipset configuration files. By&lt;br /&gt;
default, awall generates the configuration to &amp;lt;tt&amp;gt;/etc/iptables&amp;lt;/tt&amp;gt; &lt;br /&gt;
and &amp;lt;tt&amp;gt;/etc/ipset.d&amp;lt;/tt&amp;gt;, which are read by the init scripts.&lt;br /&gt;
&lt;br /&gt;
=== Run-Time Configuration of Firewall ===&lt;br /&gt;
&lt;br /&gt;
 &#039;&#039;&#039;awall activate&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
This command genereates firewall configuration from the policy files&lt;br /&gt;
and enables it. If the user confirms the new configuration by hitting&lt;br /&gt;
the Return key within 10 seconds, the configuration is saved to the&lt;br /&gt;
files. Otherwise, the old configuration is restored.&lt;br /&gt;
&lt;br /&gt;
There is also a command for deleting all firewall rules:&lt;br /&gt;
&lt;br /&gt;
 &#039;&#039;&#039;awall flush&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
This command configures the firewall to drop all packets.&lt;br /&gt;
&lt;br /&gt;
=== Optional Policies ===&lt;br /&gt;
&lt;br /&gt;
Optional policies can be enabled or disabled using this command:&lt;br /&gt;
&lt;br /&gt;
 &#039;&#039;&#039;awall&#039;&#039;&#039; {&#039;&#039;&#039;enable&#039;&#039;&#039;|&#039;&#039;&#039;disable&#039;&#039;&#039;} POLICY...&lt;br /&gt;
&lt;br /&gt;
Optional policies can be listed using this command:&lt;br /&gt;
&lt;br /&gt;
 &#039;&#039;&#039;awall list&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;&#039;enabled&#039;&#039;&#039; status means that the policy has been enabled by the&lt;br /&gt;
user. The &#039;&#039;&#039;disabled&#039;&#039;&#039; status means that the policy is not in&lt;br /&gt;
use. The &#039;&#039;&#039;required&#039;&#039;&#039; status means that the policy has not been&lt;br /&gt;
enabled by the user but is in use because it is required by another&lt;br /&gt;
policy which is in use.&lt;br /&gt;
&lt;br /&gt;
=== Debugging Policies ===&lt;br /&gt;
&lt;br /&gt;
This command can be used to dump variable, zone, and other definitions&lt;br /&gt;
as well as their source policies:&lt;br /&gt;
&lt;br /&gt;
 &#039;&#039;&#039;awall dump&#039;&#039;&#039; [LEVEL]&lt;br /&gt;
&lt;br /&gt;
The level is an integer in range 0&amp;amp;ndash;3 and defaults to 0. More&lt;br /&gt;
information is displayed on higher levels.&lt;br /&gt;
&lt;br /&gt;
[[Category:Networking]]&lt;br /&gt;
[[Category:Security]]&lt;/div&gt;</summary>
		<author><name>Kunkku</name></author>
	</entry>
	<entry>
		<id>https://wiki.alpinelinux.org/w/index.php?title=Alpine_Wall_User%27s_Guide&amp;diff=8304</id>
		<title>Alpine Wall User&#039;s Guide</title>
		<link rel="alternate" type="text/html" href="https://wiki.alpinelinux.org/w/index.php?title=Alpine_Wall_User%27s_Guide&amp;diff=8304"/>
		<updated>2012-07-12T05:38:03Z</updated>

		<summary type="html">&lt;p&gt;Kunkku: /* Rules */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Configuration File Processing ==&lt;br /&gt;
&lt;br /&gt;
[[Alpine Wall]] (awall) reads its configuration from multiple&lt;br /&gt;
JSON-formatted files, called &#039;&#039;policy files&#039;&#039;. The processing starts&lt;br /&gt;
from directory &amp;lt;tt&amp;gt;/usr/share/awall/mandatory&amp;lt;/tt&amp;gt;, which contains&lt;br /&gt;
mandatory policy files shipped with APK packages. After that,&lt;br /&gt;
installation-specific policy files in &amp;lt;tt&amp;gt;/etc/awall&amp;lt;/tt&amp;gt; are&lt;br /&gt;
processed.&lt;br /&gt;
&lt;br /&gt;
The latter directory may also contain symbolic links to policy files&lt;br /&gt;
located in &amp;lt;tt&amp;gt;/usr/share/awall/optional&amp;lt;/tt&amp;gt;. These are optional&lt;br /&gt;
policies, which can be enabled on need basis. Such symbolic links are&lt;br /&gt;
easily created and destroyed using the &amp;lt;tt&amp;gt;awall enable&amp;lt;/tt&amp;gt; and &lt;br /&gt;
&amp;lt;tt&amp;gt;awall disable&amp;lt;/tt&amp;gt; commands. &amp;lt;tt&amp;gt;awall list&amp;lt;/tt&amp;gt; shows which&lt;br /&gt;
optional policies are enabled and disabled. The command also prints&lt;br /&gt;
the description of the optional policy if defined in the file using&lt;br /&gt;
a top-level attribute named &#039;&#039;&#039;description&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Sometimes a policy file depends on other policy files. In this case,&lt;br /&gt;
the policy file must have a top-level attribute &#039;&#039;&#039;import&#039;&#039;&#039;, the&lt;br /&gt;
value of which is a list of policy names, which correspond to the file&lt;br /&gt;
names without the &amp;lt;tt&amp;gt;.json&amp;lt;/tt&amp;gt; suffix. The policies listed there are&lt;br /&gt;
always processed before the importing policy. The order of the&lt;br /&gt;
generated iptables rules generally reflects the processing order of&lt;br /&gt;
their corresponding awall policies.&lt;br /&gt;
&lt;br /&gt;
As the import directive does not require the path name to be&lt;br /&gt;
specified, awall expects policies to have unique names, even if&lt;br /&gt;
located in different directories. It is allowed to import optional&lt;br /&gt;
policies that are not explicitly enabled by the user. Such policies&lt;br /&gt;
show up with the &amp;lt;tt&amp;gt;required&amp;lt;/tt&amp;gt; status in the output of &amp;lt;tt&amp;gt;awall&lt;br /&gt;
list&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
== List Parameters ==&lt;br /&gt;
&lt;br /&gt;
Several awall parameters are defined as lists of values. In order to&lt;br /&gt;
facilitate manual editing of policy files, awall also accepts single&lt;br /&gt;
values in place of lists. Such values are semantically equivalent to&lt;br /&gt;
lists containing one element.&lt;br /&gt;
&lt;br /&gt;
== Variable Expansion ==&lt;br /&gt;
&lt;br /&gt;
Awall allows variable definitions in policy files. The top-level&lt;br /&gt;
attribute &#039;&#039;&#039;variable&#039;&#039;&#039; is a dictionary containing the&lt;br /&gt;
definitions. The value of a variable can be of any type (string,&lt;br /&gt;
integer, list, or dictionary).&lt;br /&gt;
&lt;br /&gt;
A variable is referenced in policy files by a string which equals the&lt;br /&gt;
variable name prepended with the &#039;&#039;&#039;$&#039;&#039;&#039; character. If the value of&lt;br /&gt;
the variable is a string, the reference can be embedded into a longer&lt;br /&gt;
string in order to substitute some part of that string (in shell&lt;br /&gt;
style). Variable references can be used when defining other variables,&lt;br /&gt;
as long as the definitions are not circular.&lt;br /&gt;
&lt;br /&gt;
Policy files can reference variables defined in other policy&lt;br /&gt;
files. Policy files can also override variables defined elsewhere by&lt;br /&gt;
redefining them. In this case, the new definition affects all policy&lt;br /&gt;
files, also those processed before the overriding policy. Awall&lt;br /&gt;
variables are in fact simple macros, since each variable remains&lt;br /&gt;
constant thoughout a single processing round. If multiple files define&lt;br /&gt;
the same variable, the definition in the file processed last takes&lt;br /&gt;
effect.&lt;br /&gt;
&lt;br /&gt;
If defined as an empty string, all non-embedded references to a&lt;br /&gt;
variable evaluate as if the attribute in question was not present in&lt;br /&gt;
the configuration. This is also the case when a string containing&lt;br /&gt;
embedded variable references finally evaluates to an empty string.&lt;br /&gt;
&lt;br /&gt;
== Configuration Objects ==&lt;br /&gt;
&lt;br /&gt;
Configuration objects can be divided into two main types.&lt;br /&gt;
&#039;&#039;Auxiliary objects&#039;&#039; model high-level concepts such as services and&lt;br /&gt;
zones. &#039;&#039;Rule objects&#039;&#039; translate into one or more iptables rules, and&lt;br /&gt;
are often defined with the help of some auxiliary objects.&lt;br /&gt;
&lt;br /&gt;
=== Services ===&lt;br /&gt;
&lt;br /&gt;
A &#039;&#039;service&#039;&#039; represents a set of network protocols. A top-level&lt;br /&gt;
attribute &#039;&#039;&#039;service&#039;&#039;&#039; is a dictionary that maps service names to&lt;br /&gt;
service definition objects, or lists thereof in more complex cases.&lt;br /&gt;
&lt;br /&gt;
A service definition object contains an attribute named &#039;&#039;&#039;proto&#039;&#039;&#039;,&lt;br /&gt;
which corresponds to the &amp;lt;tt&amp;gt;--protocol&amp;lt;/tt&amp;gt; option of iptables. The&lt;br /&gt;
protocol can be defined as a numerical value or string as defined in&lt;br /&gt;
&amp;lt;tt&amp;gt;/etc/protocols&amp;lt;/tt&amp;gt;. If the protocol is &#039;&#039;&#039;tcp&#039;&#039;&#039; or &#039;&#039;&#039;udp&#039;&#039;&#039;,&lt;br /&gt;
the scope of the service definition may be constrained by defining an&lt;br /&gt;
attribute named &#039;&#039;&#039;port&#039;&#039;&#039;, which is a list of TCP or UDP port&lt;br /&gt;
numbers. If the protocol is &#039;&#039;&#039;icmp&#039;&#039;&#039; or &#039;&#039;&#039;icmpv6&#039;&#039;&#039;, an analogous &lt;br /&gt;
&#039;&#039;&#039;icmp-type&#039;&#039;&#039; attribute may be used. In addition, the scope of the&lt;br /&gt;
rule is also automatically limited to IPv4 or IPv6, respectively.&lt;br /&gt;
&lt;br /&gt;
=== Zones ===&lt;br /&gt;
&lt;br /&gt;
A &#039;&#039;zone&#039;&#039; represents a set of network hosts. A top-level attribute &lt;br /&gt;
&#039;&#039;&#039;zone&#039;&#039;&#039; is a dictionary that maps zone names to zone objects. A&lt;br /&gt;
zone object has an attribute named &#039;&#039;&#039;iface&#039;&#039;&#039;, &#039;&#039;&#039;addr&#039;&#039;&#039;, or&lt;br /&gt;
both. &#039;&#039;&#039;iface&#039;&#039;&#039; is a list of network interfaces and &#039;&#039;&#039;addr&#039;&#039;&#039; is a&lt;br /&gt;
list of IPv4/IPv6 host and network addresses (CIDR&lt;br /&gt;
notation). &#039;&#039;&#039;addr&#039;&#039;&#039; may also contain domain names, which are&lt;br /&gt;
expanded to IP addresses using DNS resolution. If not defined,&lt;br /&gt;
&#039;&#039;&#039;addr&#039;&#039;&#039; defaults to the entire address space and &#039;&#039;&#039;iface&#039;&#039;&#039; to all&lt;br /&gt;
interfaces. An empty zone can be defined by setting either &#039;&#039;&#039;addr&#039;&#039;&#039;&lt;br /&gt;
or &#039;&#039;&#039;iface&#039;&#039;&#039; to an empty list.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Rule objects contain two attributes, &#039;&#039;&#039;in&#039;&#039;&#039; and &#039;&#039;&#039;out&#039;&#039;&#039;, which are&lt;br /&gt;
lists of zone names. These attributes control whether a packet matches&lt;br /&gt;
the rule or not. If a particular zone is referenced by the &#039;&#039;&#039;in&#039;&#039;&#039; &lt;br /&gt;
attribute, the rule applies to packets whose ingress interface and&lt;br /&gt;
source address are covered by the zone definition. Correspondingly, if&lt;br /&gt;
a zone is referenced by the &#039;&#039;&#039;out&#039;&#039;&#039; attribute, the rule applies to&lt;br /&gt;
packets whose egress interface and destination address are included in&lt;br /&gt;
the zone. If both &#039;&#039;&#039;in&#039;&#039;&#039; and &#039;&#039;&#039;out&#039;&#039;&#039; are defined, the packet must&lt;br /&gt;
fulfill both criteria in order to match the rule.&lt;br /&gt;
&lt;br /&gt;
=== Rules ===&lt;br /&gt;
&lt;br /&gt;
There are three types of rule objects: &#039;&#039;policies&#039;&#039;, &#039;&#039;filters&#039;&#039;, and &lt;br /&gt;
&#039;&#039;NAT rules&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
All rule objects can have the &#039;&#039;&#039;in&#039;&#039;&#039; and &#039;&#039;&#039;out&#039;&#039;&#039; attributes&lt;br /&gt;
referring to zones as described in the previous section. In addition,&lt;br /&gt;
the scope of the rule can be further constrained with the following&lt;br /&gt;
attributes:&lt;br /&gt;
&lt;br /&gt;
{|&lt;br /&gt;
!Attribute!!Value format!!Effect&lt;br /&gt;
|-&lt;br /&gt;
|&#039;&#039;&#039;src&#039;&#039;&#039;&lt;br /&gt;
|Similar to &#039;&#039;&#039;addr&#039;&#039;&#039; attribute of zone objects&lt;br /&gt;
|Packet&#039;s source address matches the value&lt;br /&gt;
|-&lt;br /&gt;
|&#039;&#039;&#039;dest&#039;&#039;&#039;&lt;br /&gt;
|Similar to &#039;&#039;&#039;addr&#039;&#039;&#039; attribute of zone objects&lt;br /&gt;
|Packet&#039;s destination address matches the value&lt;br /&gt;
|-&lt;br /&gt;
|&#039;&#039;&#039;ipset&#039;&#039;&#039;&lt;br /&gt;
|Object containing two attributes: &#039;&#039;&#039;name&#039;&#039;&#039; referring to an IP set and &#039;&#039;&#039;args&#039;&#039;&#039;, which is a list of strings &#039;&#039;&#039;in&#039;&#039;&#039; and &#039;&#039;&#039;out&#039;&#039;&#039;&lt;br /&gt;
|Packet matches the IP set referred here when the match arguments are taken from the source (&#039;&#039;&#039;in&#039;&#039;&#039;) and destination (&#039;&#039;&#039;out&#039;&#039;&#039;) address or port in the order specified by &#039;&#039;&#039;args&#039;&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
|&#039;&#039;&#039;ipsec&#039;&#039;&#039;&lt;br /&gt;
|&#039;&#039;&#039;in&#039;&#039;&#039; or &#039;&#039;&#039;out&#039;&#039;&#039;&lt;br /&gt;
|IPsec decapsulation perfomed on ingress (&#039;&#039;&#039;in&#039;&#039;&#039;) or encapsulation performed on egress (&#039;&#039;&#039;out&#039;&#039;&#039;)&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Rule objects are declared in type-specific top-level dictionaries in&lt;br /&gt;
awall policy files. If a packet matches multiple rules, the one&lt;br /&gt;
appearing earlier in the list takes precedence. If the matching rules&lt;br /&gt;
are defined in different policy files, the one that was processed&lt;br /&gt;
earlier takes precedence in the current implementation, but this may&lt;br /&gt;
change in future versions.&lt;br /&gt;
&lt;br /&gt;
==== Filters ====&lt;br /&gt;
&lt;br /&gt;
Filter objects specify an action for packets fulfilling certain&lt;br /&gt;
criteria. The top-level attribute &#039;&#039;&#039;filter&#039;&#039;&#039; is a list of filter&lt;br /&gt;
objects. The precedence rules are similar to those of policy objects.&lt;br /&gt;
&lt;br /&gt;
In addition to the common rule attributes, filter objects can have a &lt;br /&gt;
&#039;&#039;&#039;service&#039;&#039;&#039; attribute constraining the scope to specific services&lt;br /&gt;
only. This attribute is a list of service names, referring to the&lt;br /&gt;
keys of the top-level &#039;&#039;&#039;service&#039;&#039;&#039; dictionary.&lt;br /&gt;
&lt;br /&gt;
Filter objects must have an attribute named &#039;&#039;&#039;action&#039;&#039;&#039;, the value of&lt;br /&gt;
which can be one of the following:&lt;br /&gt;
&lt;br /&gt;
{|&lt;br /&gt;
!Value!!Action&lt;br /&gt;
|-&lt;br /&gt;
|&#039;&#039;&#039;accept&#039;&#039;&#039;&lt;br /&gt;
|Accept the packet&lt;br /&gt;
|-&lt;br /&gt;
|&#039;&#039;&#039;reject&#039;&#039;&#039;&lt;br /&gt;
|Reject the packet with an ICMP error message&lt;br /&gt;
|-&lt;br /&gt;
|&#039;&#039;&#039;drop&#039;&#039;&#039;&lt;br /&gt;
|Silently drop the packet&lt;br /&gt;
|-&lt;br /&gt;
|&#039;&#039;&#039;logreject&#039;&#039;&#039;&lt;br /&gt;
|Similar to &#039;&#039;&#039;reject&#039;&#039;&#039; but with kernel logging&lt;br /&gt;
|-&lt;br /&gt;
|&#039;&#039;&#039;logdrop&#039;&#039;&#039;&lt;br /&gt;
|Similar to &#039;&#039;&#039;drop&#039;&#039;&#039; but with kernel logging&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Filter objects, the action of which is &#039;&#039;&#039;accept&#039;&#039;&#039;, may also contain&lt;br /&gt;
limits for packet flow or new connections. These are specified with&lt;br /&gt;
the &#039;&#039;&#039;flow-limit&#039;&#039;&#039; and &#039;&#039;&#039;conn-limit&#039;&#039;&#039; attributes,&lt;br /&gt;
respectively. The values of these attributes are limit objects that&lt;br /&gt;
have two attributes: &#039;&#039;&#039;count&#039;&#039;&#039; and &#039;&#039;&#039;interval&#039;&#039;&#039;. &#039;&#039;&#039;count&#039;&#039;&#039;&lt;br /&gt;
specifies how many new connections or packets are allowed within the&lt;br /&gt;
time frame specified by &#039;&#039;&#039;interval&#039;&#039;&#039; (in seconds). The &#039;&#039;&#039;logdrop&#039;&#039;&#039;&lt;br /&gt;
action is applied to the packets exceeding the limit.&lt;br /&gt;
&lt;br /&gt;
Filter objects may have an attribute named &#039;&#039;&#039;dnat&#039;&#039;&#039;, the value of&lt;br /&gt;
which is an IPv4 address. If defined, this enables destination NAT for&lt;br /&gt;
all IPv4 packets matching the rule, such that the specified address&lt;br /&gt;
replaces the original destination address. This option has no effect&lt;br /&gt;
on IPv6 packets.&lt;br /&gt;
&lt;br /&gt;
==== Policies ====&lt;br /&gt;
&lt;br /&gt;
Policy objects describe the default action for packets that did not&lt;br /&gt;
match any filter. The top-level attribute &#039;&#039;&#039;policy&#039;&#039;&#039; is a list of&lt;br /&gt;
policy objects.&lt;br /&gt;
&lt;br /&gt;
Policy objects must have the &#039;&#039;&#039;action&#039;&#039;&#039; attribute defined. The&lt;br /&gt;
possible values and their semantics are the same as in filter objects.&lt;br /&gt;
&lt;br /&gt;
==== NAT Rules ====&lt;br /&gt;
&lt;br /&gt;
NAT rules come in two flavors: &#039;&#039;source NAT rules&#039;&#039; and&lt;br /&gt;
&#039;&#039;destination NAT rules&#039;&#039;. These are contained in two top-level lists&lt;br /&gt;
named &#039;&#039;&#039;snat&#039;&#039;&#039; and &#039;&#039;&#039;dnat&#039;&#039;&#039;, respectively.&lt;br /&gt;
&lt;br /&gt;
Each NAT rule must have an attribute named &#039;&#039;&#039;ip-range&#039;&#039;&#039; that&lt;br /&gt;
specifies the IPv4 address range to which the original source or&lt;br /&gt;
destinatinon address is mapped. The value can be a single IPv4 address&lt;br /&gt;
or a range specified by two addresses, separated with the &#039;&#039;&#039;-&#039;&#039;&#039;&lt;br /&gt;
character.&lt;br /&gt;
&lt;br /&gt;
Optionally, a NAT rule can specify the TCP and UDP port range to which&lt;br /&gt;
the original source or destination port is mapped. The attribute is&lt;br /&gt;
named &#039;&#039;&#039;port-range&#039;&#039;&#039;, and the value can be a single port number or a&lt;br /&gt;
range specified by two numbers, separated with the &#039;&#039;&#039;-&#039;&#039;&#039;&lt;br /&gt;
character. If &#039;&#039;&#039;port-range&#039;&#039;&#039; is not specified, the original port&lt;br /&gt;
number is kept intact.&lt;br /&gt;
&lt;br /&gt;
Like filters, NAT rules can have a &#039;&#039;&#039;service&#039;&#039;&#039; attribute&lt;br /&gt;
constraining their scope to specific services.&lt;br /&gt;
&lt;br /&gt;
NAT rules may have an &#039;&#039;&#039;action&#039;&#039;&#039; attribute set to value&lt;br /&gt;
&#039;&#039;&#039;accept&#039;&#039;&#039;. In this case, NAT is not performed on the packets&lt;br /&gt;
reaching and matching this rule.&lt;br /&gt;
&lt;br /&gt;
=== IP Sets ===&lt;br /&gt;
&lt;br /&gt;
Any IP set referenced by rule objects should be created by&lt;br /&gt;
awall. Auxiliary &#039;&#039;IP set&#039;&#039; objects are used to defined them in awall&lt;br /&gt;
policy files. The top-level attribute &#039;&#039;&#039;ipset&#039;&#039;&#039; is a dictionary, the&lt;br /&gt;
keys of which are IP set names. The values are IP set objects, which&lt;br /&gt;
have two mandatory attributes. The attribute named &#039;&#039;&#039;type&#039;&#039;&#039; &lt;br /&gt;
corresponds to the type argument of the &amp;lt;tt&amp;gt;ipset create&amp;lt;/tt&amp;gt; &lt;br /&gt;
command. &#039;&#039;&#039;family&#039;&#039;&#039; specifies whether the set is for IPv4 or IPv6&lt;br /&gt;
addresses, and the possible values are &#039;&#039;&#039;inet&#039;&#039;&#039; and &#039;&#039;&#039;inet6&#039;&#039;&#039;,&lt;br /&gt;
correspondingly.&lt;br /&gt;
&lt;br /&gt;
== Command Line Syntax ==&lt;br /&gt;
&lt;br /&gt;
=== Translating Policy Files to Firewall Configuration Files ===&lt;br /&gt;
&lt;br /&gt;
 &#039;&#039;&#039;awall translate&#039;&#039;&#039; [&#039;&#039;&#039;-o&#039;&#039;&#039;|&#039;&#039;&#039;--output&#039;&#039;&#039; DIRECTORY] [&#039;&#039;&#039;-V&#039;&#039;&#039;|&#039;&#039;&#039;--verify&#039;&#039;&#039;]&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;tt&amp;gt;--verify&amp;lt;/tt&amp;gt; option makes awall verify the configuration&lt;br /&gt;
using the test mode of iptables-restore before overwriting the old&lt;br /&gt;
files.&lt;br /&gt;
&lt;br /&gt;
Specifying the output directory allows testing awall policies without&lt;br /&gt;
overwriting the current iptables and ipset configuration files. By&lt;br /&gt;
default, awall generates the configuration to &amp;lt;tt&amp;gt;/etc/iptables&amp;lt;/tt&amp;gt; &lt;br /&gt;
and &amp;lt;tt&amp;gt;/etc/ipset.d&amp;lt;/tt&amp;gt;, which are read by the init scripts.&lt;br /&gt;
&lt;br /&gt;
=== Run-Time Activation of New Firewall Configuration ===&lt;br /&gt;
&lt;br /&gt;
 &#039;&#039;&#039;awall activate&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
This command genereates firewall configuration from the policy files&lt;br /&gt;
and enables it. If the user confirms the new configuration by hitting&lt;br /&gt;
the Return key within 10 seconds, the configuration is saved to the&lt;br /&gt;
files. Otherwise, the old configuration is restored.&lt;br /&gt;
&lt;br /&gt;
=== Optional Policies ===&lt;br /&gt;
&lt;br /&gt;
Optional policies can be enabled or disabled using this command:&lt;br /&gt;
&lt;br /&gt;
 &#039;&#039;&#039;awall&#039;&#039;&#039; {&#039;&#039;&#039;enable&#039;&#039;&#039;|&#039;&#039;&#039;disable&#039;&#039;&#039;} POLICY...&lt;br /&gt;
&lt;br /&gt;
Optional policies can be listed using this command:&lt;br /&gt;
&lt;br /&gt;
 &#039;&#039;&#039;awall list&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;&#039;enabled&#039;&#039;&#039; status means that the policy has been enabled by the&lt;br /&gt;
user. The &#039;&#039;&#039;disabled&#039;&#039;&#039; status means that the policy is not in&lt;br /&gt;
use. The &#039;&#039;&#039;required&#039;&#039;&#039; status means that the policy has not been&lt;br /&gt;
enabled by the user but is in use because it is required by another&lt;br /&gt;
policy which is in use.&lt;br /&gt;
&lt;br /&gt;
=== Debugging Policies ===&lt;br /&gt;
&lt;br /&gt;
This command can be used to dump variable, zone, and other definitions&lt;br /&gt;
as well as their source policies:&lt;br /&gt;
&lt;br /&gt;
 &#039;&#039;&#039;awall dump&#039;&#039;&#039; [LEVEL]&lt;br /&gt;
&lt;br /&gt;
The level is an integer in range 0&amp;amp;ndash;3 and defaults to 0. More&lt;br /&gt;
information is displayed on higher levels.&lt;br /&gt;
&lt;br /&gt;
[[Category:Networking]]&lt;br /&gt;
[[Category:Security]]&lt;/div&gt;</summary>
		<author><name>Kunkku</name></author>
	</entry>
	<entry>
		<id>https://wiki.alpinelinux.org/w/index.php?title=Alpine_Wall_User%27s_Guide&amp;diff=8303</id>
		<title>Alpine Wall User&#039;s Guide</title>
		<link rel="alternate" type="text/html" href="https://wiki.alpinelinux.org/w/index.php?title=Alpine_Wall_User%27s_Guide&amp;diff=8303"/>
		<updated>2012-07-12T05:20:00Z</updated>

		<summary type="html">&lt;p&gt;Kunkku: /* Zones */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Configuration File Processing ==&lt;br /&gt;
&lt;br /&gt;
[[Alpine Wall]] (awall) reads its configuration from multiple&lt;br /&gt;
JSON-formatted files, called &#039;&#039;policy files&#039;&#039;. The processing starts&lt;br /&gt;
from directory &amp;lt;tt&amp;gt;/usr/share/awall/mandatory&amp;lt;/tt&amp;gt;, which contains&lt;br /&gt;
mandatory policy files shipped with APK packages. After that,&lt;br /&gt;
installation-specific policy files in &amp;lt;tt&amp;gt;/etc/awall&amp;lt;/tt&amp;gt; are&lt;br /&gt;
processed.&lt;br /&gt;
&lt;br /&gt;
The latter directory may also contain symbolic links to policy files&lt;br /&gt;
located in &amp;lt;tt&amp;gt;/usr/share/awall/optional&amp;lt;/tt&amp;gt;. These are optional&lt;br /&gt;
policies, which can be enabled on need basis. Such symbolic links are&lt;br /&gt;
easily created and destroyed using the &amp;lt;tt&amp;gt;awall enable&amp;lt;/tt&amp;gt; and &lt;br /&gt;
&amp;lt;tt&amp;gt;awall disable&amp;lt;/tt&amp;gt; commands. &amp;lt;tt&amp;gt;awall list&amp;lt;/tt&amp;gt; shows which&lt;br /&gt;
optional policies are enabled and disabled. The command also prints&lt;br /&gt;
the description of the optional policy if defined in the file using&lt;br /&gt;
a top-level attribute named &#039;&#039;&#039;description&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Sometimes a policy file depends on other policy files. In this case,&lt;br /&gt;
the policy file must have a top-level attribute &#039;&#039;&#039;import&#039;&#039;&#039;, the&lt;br /&gt;
value of which is a list of policy names, which correspond to the file&lt;br /&gt;
names without the &amp;lt;tt&amp;gt;.json&amp;lt;/tt&amp;gt; suffix. The policies listed there are&lt;br /&gt;
always processed before the importing policy. The order of the&lt;br /&gt;
generated iptables rules generally reflects the processing order of&lt;br /&gt;
their corresponding awall policies.&lt;br /&gt;
&lt;br /&gt;
As the import directive does not require the path name to be&lt;br /&gt;
specified, awall expects policies to have unique names, even if&lt;br /&gt;
located in different directories. It is allowed to import optional&lt;br /&gt;
policies that are not explicitly enabled by the user. Such policies&lt;br /&gt;
show up with the &amp;lt;tt&amp;gt;required&amp;lt;/tt&amp;gt; status in the output of &amp;lt;tt&amp;gt;awall&lt;br /&gt;
list&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
== List Parameters ==&lt;br /&gt;
&lt;br /&gt;
Several awall parameters are defined as lists of values. In order to&lt;br /&gt;
facilitate manual editing of policy files, awall also accepts single&lt;br /&gt;
values in place of lists. Such values are semantically equivalent to&lt;br /&gt;
lists containing one element.&lt;br /&gt;
&lt;br /&gt;
== Variable Expansion ==&lt;br /&gt;
&lt;br /&gt;
Awall allows variable definitions in policy files. The top-level&lt;br /&gt;
attribute &#039;&#039;&#039;variable&#039;&#039;&#039; is a dictionary containing the&lt;br /&gt;
definitions. The value of a variable can be of any type (string,&lt;br /&gt;
integer, list, or dictionary).&lt;br /&gt;
&lt;br /&gt;
A variable is referenced in policy files by a string which equals the&lt;br /&gt;
variable name prepended with the &#039;&#039;&#039;$&#039;&#039;&#039; character. If the value of&lt;br /&gt;
the variable is a string, the reference can be embedded into a longer&lt;br /&gt;
string in order to substitute some part of that string (in shell&lt;br /&gt;
style). Variable references can be used when defining other variables,&lt;br /&gt;
as long as the definitions are not circular.&lt;br /&gt;
&lt;br /&gt;
Policy files can reference variables defined in other policy&lt;br /&gt;
files. Policy files can also override variables defined elsewhere by&lt;br /&gt;
redefining them. In this case, the new definition affects all policy&lt;br /&gt;
files, also those processed before the overriding policy. Awall&lt;br /&gt;
variables are in fact simple macros, since each variable remains&lt;br /&gt;
constant thoughout a single processing round. If multiple files define&lt;br /&gt;
the same variable, the definition in the file processed last takes&lt;br /&gt;
effect.&lt;br /&gt;
&lt;br /&gt;
If defined as an empty string, all non-embedded references to a&lt;br /&gt;
variable evaluate as if the attribute in question was not present in&lt;br /&gt;
the configuration. This is also the case when a string containing&lt;br /&gt;
embedded variable references finally evaluates to an empty string.&lt;br /&gt;
&lt;br /&gt;
== Configuration Objects ==&lt;br /&gt;
&lt;br /&gt;
Configuration objects can be divided into two main types.&lt;br /&gt;
&#039;&#039;Auxiliary objects&#039;&#039; model high-level concepts such as services and&lt;br /&gt;
zones. &#039;&#039;Rule objects&#039;&#039; translate into one or more iptables rules, and&lt;br /&gt;
are often defined with the help of some auxiliary objects.&lt;br /&gt;
&lt;br /&gt;
=== Services ===&lt;br /&gt;
&lt;br /&gt;
A &#039;&#039;service&#039;&#039; represents a set of network protocols. A top-level&lt;br /&gt;
attribute &#039;&#039;&#039;service&#039;&#039;&#039; is a dictionary that maps service names to&lt;br /&gt;
service definition objects, or lists thereof in more complex cases.&lt;br /&gt;
&lt;br /&gt;
A service definition object contains an attribute named &#039;&#039;&#039;proto&#039;&#039;&#039;,&lt;br /&gt;
which corresponds to the &amp;lt;tt&amp;gt;--protocol&amp;lt;/tt&amp;gt; option of iptables. The&lt;br /&gt;
protocol can be defined as a numerical value or string as defined in&lt;br /&gt;
&amp;lt;tt&amp;gt;/etc/protocols&amp;lt;/tt&amp;gt;. If the protocol is &#039;&#039;&#039;tcp&#039;&#039;&#039; or &#039;&#039;&#039;udp&#039;&#039;&#039;,&lt;br /&gt;
the scope of the service definition may be constrained by defining an&lt;br /&gt;
attribute named &#039;&#039;&#039;port&#039;&#039;&#039;, which is a list of TCP or UDP port&lt;br /&gt;
numbers. If the protocol is &#039;&#039;&#039;icmp&#039;&#039;&#039; or &#039;&#039;&#039;icmpv6&#039;&#039;&#039;, an analogous &lt;br /&gt;
&#039;&#039;&#039;icmp-type&#039;&#039;&#039; attribute may be used. In addition, the scope of the&lt;br /&gt;
rule is also automatically limited to IPv4 or IPv6, respectively.&lt;br /&gt;
&lt;br /&gt;
=== Zones ===&lt;br /&gt;
&lt;br /&gt;
A &#039;&#039;zone&#039;&#039; represents a set of network hosts. A top-level attribute &lt;br /&gt;
&#039;&#039;&#039;zone&#039;&#039;&#039; is a dictionary that maps zone names to zone objects. A&lt;br /&gt;
zone object has an attribute named &#039;&#039;&#039;iface&#039;&#039;&#039;, &#039;&#039;&#039;addr&#039;&#039;&#039;, or&lt;br /&gt;
both. &#039;&#039;&#039;iface&#039;&#039;&#039; is a list of network interfaces and &#039;&#039;&#039;addr&#039;&#039;&#039; is a&lt;br /&gt;
list of IPv4/IPv6 host and network addresses (CIDR&lt;br /&gt;
notation). &#039;&#039;&#039;addr&#039;&#039;&#039; may also contain domain names, which are&lt;br /&gt;
expanded to IP addresses using DNS resolution. If not defined,&lt;br /&gt;
&#039;&#039;&#039;addr&#039;&#039;&#039; defaults to the entire address space and &#039;&#039;&#039;iface&#039;&#039;&#039; to all&lt;br /&gt;
interfaces. An empty zone can be defined by setting either &#039;&#039;&#039;addr&#039;&#039;&#039;&lt;br /&gt;
or &#039;&#039;&#039;iface&#039;&#039;&#039; to an empty list.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Rule objects contain two attributes, &#039;&#039;&#039;in&#039;&#039;&#039; and &#039;&#039;&#039;out&#039;&#039;&#039;, which are&lt;br /&gt;
lists of zone names. These attributes control whether a packet matches&lt;br /&gt;
the rule or not. If a particular zone is referenced by the &#039;&#039;&#039;in&#039;&#039;&#039; &lt;br /&gt;
attribute, the rule applies to packets whose ingress interface and&lt;br /&gt;
source address are covered by the zone definition. Correspondingly, if&lt;br /&gt;
a zone is referenced by the &#039;&#039;&#039;out&#039;&#039;&#039; attribute, the rule applies to&lt;br /&gt;
packets whose egress interface and destination address are included in&lt;br /&gt;
the zone. If both &#039;&#039;&#039;in&#039;&#039;&#039; and &#039;&#039;&#039;out&#039;&#039;&#039; are defined, the packet must&lt;br /&gt;
fulfill both criteria in order to match the rule.&lt;br /&gt;
&lt;br /&gt;
=== Rules ===&lt;br /&gt;
&lt;br /&gt;
There are three types of rule objects: &#039;&#039;policies&#039;&#039;, &#039;&#039;filters&#039;&#039;, and &lt;br /&gt;
&#039;&#039;NAT rules&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
All rule objects can have the &#039;&#039;&#039;in&#039;&#039;&#039; and &#039;&#039;&#039;out&#039;&#039;&#039; attributes&lt;br /&gt;
referring to zones as described in the previous section. In addition,&lt;br /&gt;
the scope of the rule can be further constrained with the following&lt;br /&gt;
attributes:&lt;br /&gt;
&lt;br /&gt;
{|&lt;br /&gt;
!Attribute!!Value format!!Effect&lt;br /&gt;
|-&lt;br /&gt;
|&#039;&#039;&#039;src&#039;&#039;&#039;&lt;br /&gt;
|Similar to &#039;&#039;&#039;addr&#039;&#039;&#039; attribute of zone objects&lt;br /&gt;
|Packet&#039;s source address matches the value&lt;br /&gt;
|-&lt;br /&gt;
|&#039;&#039;&#039;dest&#039;&#039;&#039;&lt;br /&gt;
|Similar to &#039;&#039;&#039;addr&#039;&#039;&#039; attribute of zone objects&lt;br /&gt;
|Packet&#039;s destination address matches the value&lt;br /&gt;
|-&lt;br /&gt;
|&#039;&#039;&#039;ipset&#039;&#039;&#039;&lt;br /&gt;
|Object containing two attributes: &#039;&#039;&#039;name&#039;&#039;&#039; referring to an IP set and &#039;&#039;&#039;args&#039;&#039;&#039;, which is a list of strings &#039;&#039;&#039;in&#039;&#039;&#039; and &#039;&#039;&#039;out&#039;&#039;&#039;&lt;br /&gt;
|Packet matches the IP set referred here when the match arguments are taken from the source (&#039;&#039;&#039;in&#039;&#039;&#039;) and destination (&#039;&#039;&#039;out&#039;&#039;&#039;) address or port in the order specified by &#039;&#039;&#039;args&#039;&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
|&#039;&#039;&#039;ipsec&#039;&#039;&#039;&lt;br /&gt;
|&#039;&#039;&#039;in&#039;&#039;&#039; or &#039;&#039;&#039;out&#039;&#039;&#039;&lt;br /&gt;
|IPsec decapsulation perfomed on ingress (&#039;&#039;&#039;in&#039;&#039;&#039;) or encapsulation performed on egress (&#039;&#039;&#039;out&#039;&#039;&#039;)&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Rule objects must have an attribute named &#039;&#039;&#039;action&#039;&#039;&#039;, the value of&lt;br /&gt;
which can be one of the following:&lt;br /&gt;
&lt;br /&gt;
{|&lt;br /&gt;
!Value!!Action&lt;br /&gt;
|-&lt;br /&gt;
|&#039;&#039;&#039;accept&#039;&#039;&#039;&lt;br /&gt;
|Accept the packet&lt;br /&gt;
|-&lt;br /&gt;
|&#039;&#039;&#039;reject&#039;&#039;&#039;&lt;br /&gt;
|Reject the packet with an ICMP error message&lt;br /&gt;
|-&lt;br /&gt;
|&#039;&#039;&#039;drop&#039;&#039;&#039;&lt;br /&gt;
|Silently drop the packet&lt;br /&gt;
|-&lt;br /&gt;
|&#039;&#039;&#039;logreject&#039;&#039;&#039;&lt;br /&gt;
|Similar to &#039;&#039;&#039;reject&#039;&#039;&#039; but with kernel logging&lt;br /&gt;
|-&lt;br /&gt;
|&#039;&#039;&#039;logdrop&#039;&#039;&#039;&lt;br /&gt;
|Similar to &#039;&#039;&#039;drop&#039;&#039;&#039; but with kernel logging&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Rule objects are declared in type-specific top-level dictionaries in&lt;br /&gt;
awall policy files. If a packet matches multiple rules, the one&lt;br /&gt;
appearing earlier in the list takes precedence. If the matching rules&lt;br /&gt;
are defined in different policy files, the one that was processed&lt;br /&gt;
earlier takes precedence in the current implementation, but this may&lt;br /&gt;
change in future versions.&lt;br /&gt;
&lt;br /&gt;
==== Filters ====&lt;br /&gt;
&lt;br /&gt;
Filter objects specify an action for packets fulfilling certain&lt;br /&gt;
criteria. The top-level attribute &#039;&#039;&#039;filter&#039;&#039;&#039; is a list of filter&lt;br /&gt;
objects. The precedence rules are similar to those of policy objects.&lt;br /&gt;
&lt;br /&gt;
In addition to the common rule attributes, filter objects can have a &lt;br /&gt;
&#039;&#039;&#039;service&#039;&#039;&#039; attribute constraining the scope to specific services&lt;br /&gt;
only. This attribute is a list of service names, referring to the&lt;br /&gt;
keys of the top-level &#039;&#039;&#039;service&#039;&#039;&#039; dictionary.&lt;br /&gt;
&lt;br /&gt;
Filter objects may also contain limits for packet flow or new&lt;br /&gt;
connections. These are specified with the &#039;&#039;&#039;flow-limit&#039;&#039;&#039; and&lt;br /&gt;
&#039;&#039;&#039;conn-limit&#039;&#039;&#039; attributes, respectively. The values of these&lt;br /&gt;
attributes are limit objects that have two attributes: &#039;&#039;&#039;count&#039;&#039;&#039; and&lt;br /&gt;
&#039;&#039;&#039;interval&#039;&#039;&#039;. &#039;&#039;&#039;count&#039;&#039;&#039; specifies how many new connections or&lt;br /&gt;
packets are allowed within the time frame specified by &#039;&#039;&#039;interval&#039;&#039;&#039; &lt;br /&gt;
(in seconds). The &#039;&#039;&#039;logdrop&#039;&#039;&#039; action is applied to the packets&lt;br /&gt;
exceeding the limit.&lt;br /&gt;
&lt;br /&gt;
Filter objects may have an attribute named &#039;&#039;&#039;dnat&#039;&#039;&#039;, the value of&lt;br /&gt;
which is an IPv4 address. If defined, this enables destination NAT for&lt;br /&gt;
all IPv4 packets matching the rule, such that the specified address&lt;br /&gt;
replaces the original destination address. This option has no effect&lt;br /&gt;
on IPv6 packets.&lt;br /&gt;
&lt;br /&gt;
==== Policies ====&lt;br /&gt;
&lt;br /&gt;
Policy objects describe the default action for packets that did not&lt;br /&gt;
match any filter. The top-level attribute &#039;&#039;&#039;policy&#039;&#039;&#039; is a list of&lt;br /&gt;
policy objects. Policy objects do not have other attributes than those&lt;br /&gt;
common to all rule objects.&lt;br /&gt;
&lt;br /&gt;
==== NAT Rules ====&lt;br /&gt;
&lt;br /&gt;
NAT rules come in two flavors: &#039;&#039;source NAT rules&#039;&#039; and&lt;br /&gt;
&#039;&#039;destination NAT rules&#039;&#039;. These are contained in two top-level lists&lt;br /&gt;
named &#039;&#039;&#039;snat&#039;&#039;&#039; and &#039;&#039;&#039;dnat&#039;&#039;&#039;, respectively.&lt;br /&gt;
&lt;br /&gt;
Each NAT rule must have an attribute named &#039;&#039;&#039;ip-range&#039;&#039;&#039; that&lt;br /&gt;
specifies the IPv4 address range to which the original source or&lt;br /&gt;
destinatinon address is mapped. The value can be a single IPv4 address&lt;br /&gt;
or a range specified by two addresses, separated with the &#039;&#039;&#039;-&#039;&#039;&#039;&lt;br /&gt;
character.&lt;br /&gt;
&lt;br /&gt;
Optionally, a NAT rule can specify the TCP and UDP port range to which&lt;br /&gt;
the original source or destination port is mapped. The attribute is&lt;br /&gt;
named &#039;&#039;&#039;port-range&#039;&#039;&#039;, and the value can be a single port number or a&lt;br /&gt;
range specified by two numbers, separated with the &#039;&#039;&#039;-&#039;&#039;&#039;&lt;br /&gt;
character. If &#039;&#039;&#039;port-range&#039;&#039;&#039; is not specified, the original port&lt;br /&gt;
number is kept intact.&lt;br /&gt;
&lt;br /&gt;
Like filters, NAT rules can have a &#039;&#039;&#039;service&#039;&#039;&#039; attribute&lt;br /&gt;
constraining their scope to specific services.&lt;br /&gt;
&lt;br /&gt;
=== IP Sets ===&lt;br /&gt;
&lt;br /&gt;
Any IP set referenced by rule objects should be created by&lt;br /&gt;
awall. Auxiliary &#039;&#039;IP set&#039;&#039; objects are used to defined them in awall&lt;br /&gt;
policy files. The top-level attribute &#039;&#039;&#039;ipset&#039;&#039;&#039; is a dictionary, the&lt;br /&gt;
keys of which are IP set names. The values are IP set objects, which&lt;br /&gt;
have two mandatory attributes. The attribute named &#039;&#039;&#039;type&#039;&#039;&#039; &lt;br /&gt;
corresponds to the type argument of the &amp;lt;tt&amp;gt;ipset create&amp;lt;/tt&amp;gt; &lt;br /&gt;
command. &#039;&#039;&#039;family&#039;&#039;&#039; specifies whether the set is for IPv4 or IPv6&lt;br /&gt;
addresses, and the possible values are &#039;&#039;&#039;inet&#039;&#039;&#039; and &#039;&#039;&#039;inet6&#039;&#039;&#039;,&lt;br /&gt;
correspondingly.&lt;br /&gt;
&lt;br /&gt;
== Command Line Syntax ==&lt;br /&gt;
&lt;br /&gt;
=== Translating Policy Files to Firewall Configuration Files ===&lt;br /&gt;
&lt;br /&gt;
 &#039;&#039;&#039;awall translate&#039;&#039;&#039; [&#039;&#039;&#039;-o&#039;&#039;&#039;|&#039;&#039;&#039;--output&#039;&#039;&#039; DIRECTORY] [&#039;&#039;&#039;-V&#039;&#039;&#039;|&#039;&#039;&#039;--verify&#039;&#039;&#039;]&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;tt&amp;gt;--verify&amp;lt;/tt&amp;gt; option makes awall verify the configuration&lt;br /&gt;
using the test mode of iptables-restore before overwriting the old&lt;br /&gt;
files.&lt;br /&gt;
&lt;br /&gt;
Specifying the output directory allows testing awall policies without&lt;br /&gt;
overwriting the current iptables and ipset configuration files. By&lt;br /&gt;
default, awall generates the configuration to &amp;lt;tt&amp;gt;/etc/iptables&amp;lt;/tt&amp;gt; &lt;br /&gt;
and &amp;lt;tt&amp;gt;/etc/ipset.d&amp;lt;/tt&amp;gt;, which are read by the init scripts.&lt;br /&gt;
&lt;br /&gt;
=== Run-Time Activation of New Firewall Configuration ===&lt;br /&gt;
&lt;br /&gt;
 &#039;&#039;&#039;awall activate&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
This command genereates firewall configuration from the policy files&lt;br /&gt;
and enables it. If the user confirms the new configuration by hitting&lt;br /&gt;
the Return key within 10 seconds, the configuration is saved to the&lt;br /&gt;
files. Otherwise, the old configuration is restored.&lt;br /&gt;
&lt;br /&gt;
=== Optional Policies ===&lt;br /&gt;
&lt;br /&gt;
Optional policies can be enabled or disabled using this command:&lt;br /&gt;
&lt;br /&gt;
 &#039;&#039;&#039;awall&#039;&#039;&#039; {&#039;&#039;&#039;enable&#039;&#039;&#039;|&#039;&#039;&#039;disable&#039;&#039;&#039;} POLICY...&lt;br /&gt;
&lt;br /&gt;
Optional policies can be listed using this command:&lt;br /&gt;
&lt;br /&gt;
 &#039;&#039;&#039;awall list&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;&#039;enabled&#039;&#039;&#039; status means that the policy has been enabled by the&lt;br /&gt;
user. The &#039;&#039;&#039;disabled&#039;&#039;&#039; status means that the policy is not in&lt;br /&gt;
use. The &#039;&#039;&#039;required&#039;&#039;&#039; status means that the policy has not been&lt;br /&gt;
enabled by the user but is in use because it is required by another&lt;br /&gt;
policy which is in use.&lt;br /&gt;
&lt;br /&gt;
=== Debugging Policies ===&lt;br /&gt;
&lt;br /&gt;
This command can be used to dump variable, zone, and other definitions&lt;br /&gt;
as well as their source policies:&lt;br /&gt;
&lt;br /&gt;
 &#039;&#039;&#039;awall dump&#039;&#039;&#039; [LEVEL]&lt;br /&gt;
&lt;br /&gt;
The level is an integer in range 0&amp;amp;ndash;3 and defaults to 0. More&lt;br /&gt;
information is displayed on higher levels.&lt;br /&gt;
&lt;br /&gt;
[[Category:Networking]]&lt;br /&gt;
[[Category:Security]]&lt;/div&gt;</summary>
		<author><name>Kunkku</name></author>
	</entry>
	<entry>
		<id>https://wiki.alpinelinux.org/w/index.php?title=Alpine_Wall_User%27s_Guide&amp;diff=8302</id>
		<title>Alpine Wall User&#039;s Guide</title>
		<link rel="alternate" type="text/html" href="https://wiki.alpinelinux.org/w/index.php?title=Alpine_Wall_User%27s_Guide&amp;diff=8302"/>
		<updated>2012-07-12T05:16:53Z</updated>

		<summary type="html">&lt;p&gt;Kunkku: /* Command Line Syntax */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Configuration File Processing ==&lt;br /&gt;
&lt;br /&gt;
[[Alpine Wall]] (awall) reads its configuration from multiple&lt;br /&gt;
JSON-formatted files, called &#039;&#039;policy files&#039;&#039;. The processing starts&lt;br /&gt;
from directory &amp;lt;tt&amp;gt;/usr/share/awall/mandatory&amp;lt;/tt&amp;gt;, which contains&lt;br /&gt;
mandatory policy files shipped with APK packages. After that,&lt;br /&gt;
installation-specific policy files in &amp;lt;tt&amp;gt;/etc/awall&amp;lt;/tt&amp;gt; are&lt;br /&gt;
processed.&lt;br /&gt;
&lt;br /&gt;
The latter directory may also contain symbolic links to policy files&lt;br /&gt;
located in &amp;lt;tt&amp;gt;/usr/share/awall/optional&amp;lt;/tt&amp;gt;. These are optional&lt;br /&gt;
policies, which can be enabled on need basis. Such symbolic links are&lt;br /&gt;
easily created and destroyed using the &amp;lt;tt&amp;gt;awall enable&amp;lt;/tt&amp;gt; and &lt;br /&gt;
&amp;lt;tt&amp;gt;awall disable&amp;lt;/tt&amp;gt; commands. &amp;lt;tt&amp;gt;awall list&amp;lt;/tt&amp;gt; shows which&lt;br /&gt;
optional policies are enabled and disabled. The command also prints&lt;br /&gt;
the description of the optional policy if defined in the file using&lt;br /&gt;
a top-level attribute named &#039;&#039;&#039;description&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Sometimes a policy file depends on other policy files. In this case,&lt;br /&gt;
the policy file must have a top-level attribute &#039;&#039;&#039;import&#039;&#039;&#039;, the&lt;br /&gt;
value of which is a list of policy names, which correspond to the file&lt;br /&gt;
names without the &amp;lt;tt&amp;gt;.json&amp;lt;/tt&amp;gt; suffix. The policies listed there are&lt;br /&gt;
always processed before the importing policy. The order of the&lt;br /&gt;
generated iptables rules generally reflects the processing order of&lt;br /&gt;
their corresponding awall policies.&lt;br /&gt;
&lt;br /&gt;
As the import directive does not require the path name to be&lt;br /&gt;
specified, awall expects policies to have unique names, even if&lt;br /&gt;
located in different directories. It is allowed to import optional&lt;br /&gt;
policies that are not explicitly enabled by the user. Such policies&lt;br /&gt;
show up with the &amp;lt;tt&amp;gt;required&amp;lt;/tt&amp;gt; status in the output of &amp;lt;tt&amp;gt;awall&lt;br /&gt;
list&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
== List Parameters ==&lt;br /&gt;
&lt;br /&gt;
Several awall parameters are defined as lists of values. In order to&lt;br /&gt;
facilitate manual editing of policy files, awall also accepts single&lt;br /&gt;
values in place of lists. Such values are semantically equivalent to&lt;br /&gt;
lists containing one element.&lt;br /&gt;
&lt;br /&gt;
== Variable Expansion ==&lt;br /&gt;
&lt;br /&gt;
Awall allows variable definitions in policy files. The top-level&lt;br /&gt;
attribute &#039;&#039;&#039;variable&#039;&#039;&#039; is a dictionary containing the&lt;br /&gt;
definitions. The value of a variable can be of any type (string,&lt;br /&gt;
integer, list, or dictionary).&lt;br /&gt;
&lt;br /&gt;
A variable is referenced in policy files by a string which equals the&lt;br /&gt;
variable name prepended with the &#039;&#039;&#039;$&#039;&#039;&#039; character. If the value of&lt;br /&gt;
the variable is a string, the reference can be embedded into a longer&lt;br /&gt;
string in order to substitute some part of that string (in shell&lt;br /&gt;
style). Variable references can be used when defining other variables,&lt;br /&gt;
as long as the definitions are not circular.&lt;br /&gt;
&lt;br /&gt;
Policy files can reference variables defined in other policy&lt;br /&gt;
files. Policy files can also override variables defined elsewhere by&lt;br /&gt;
redefining them. In this case, the new definition affects all policy&lt;br /&gt;
files, also those processed before the overriding policy. Awall&lt;br /&gt;
variables are in fact simple macros, since each variable remains&lt;br /&gt;
constant thoughout a single processing round. If multiple files define&lt;br /&gt;
the same variable, the definition in the file processed last takes&lt;br /&gt;
effect.&lt;br /&gt;
&lt;br /&gt;
If defined as an empty string, all non-embedded references to a&lt;br /&gt;
variable evaluate as if the attribute in question was not present in&lt;br /&gt;
the configuration. This is also the case when a string containing&lt;br /&gt;
embedded variable references finally evaluates to an empty string.&lt;br /&gt;
&lt;br /&gt;
== Configuration Objects ==&lt;br /&gt;
&lt;br /&gt;
Configuration objects can be divided into two main types.&lt;br /&gt;
&#039;&#039;Auxiliary objects&#039;&#039; model high-level concepts such as services and&lt;br /&gt;
zones. &#039;&#039;Rule objects&#039;&#039; translate into one or more iptables rules, and&lt;br /&gt;
are often defined with the help of some auxiliary objects.&lt;br /&gt;
&lt;br /&gt;
=== Services ===&lt;br /&gt;
&lt;br /&gt;
A &#039;&#039;service&#039;&#039; represents a set of network protocols. A top-level&lt;br /&gt;
attribute &#039;&#039;&#039;service&#039;&#039;&#039; is a dictionary that maps service names to&lt;br /&gt;
service definition objects, or lists thereof in more complex cases.&lt;br /&gt;
&lt;br /&gt;
A service definition object contains an attribute named &#039;&#039;&#039;proto&#039;&#039;&#039;,&lt;br /&gt;
which corresponds to the &amp;lt;tt&amp;gt;--protocol&amp;lt;/tt&amp;gt; option of iptables. The&lt;br /&gt;
protocol can be defined as a numerical value or string as defined in&lt;br /&gt;
&amp;lt;tt&amp;gt;/etc/protocols&amp;lt;/tt&amp;gt;. If the protocol is &#039;&#039;&#039;tcp&#039;&#039;&#039; or &#039;&#039;&#039;udp&#039;&#039;&#039;,&lt;br /&gt;
the scope of the service definition may be constrained by defining an&lt;br /&gt;
attribute named &#039;&#039;&#039;port&#039;&#039;&#039;, which is a list of TCP or UDP port&lt;br /&gt;
numbers. If the protocol is &#039;&#039;&#039;icmp&#039;&#039;&#039; or &#039;&#039;&#039;icmpv6&#039;&#039;&#039;, an analogous &lt;br /&gt;
&#039;&#039;&#039;icmp-type&#039;&#039;&#039; attribute may be used. In addition, the scope of the&lt;br /&gt;
rule is also automatically limited to IPv4 or IPv6, respectively.&lt;br /&gt;
&lt;br /&gt;
=== Zones ===&lt;br /&gt;
&lt;br /&gt;
A &#039;&#039;zone&#039;&#039; represents a set of network hosts. A top-level attribute &lt;br /&gt;
&#039;&#039;&#039;zone&#039;&#039;&#039; is a dictionary that maps zone names to zone objects. A&lt;br /&gt;
zone object has an attribute named &#039;&#039;&#039;iface&#039;&#039;&#039;, &#039;&#039;&#039;addr&#039;&#039;&#039;, or&lt;br /&gt;
both. &#039;&#039;&#039;iface&#039;&#039;&#039; is a list of network interfaces and &#039;&#039;&#039;addr&#039;&#039;&#039; is a&lt;br /&gt;
list of IPv4/IPv6 host and network addresses (CIDR&lt;br /&gt;
notation). &#039;&#039;&#039;addr&#039;&#039;&#039; may also contain domain names, which are&lt;br /&gt;
expanded to IP addresses using DNS resolution. If not defined,&lt;br /&gt;
&#039;&#039;&#039;addr&#039;&#039;&#039; defaults to the entire address space and &#039;&#039;&#039;iface&#039;&#039;&#039; to all&lt;br /&gt;
interfaces.&lt;br /&gt;
&lt;br /&gt;
Rule objects contain two attributes, &#039;&#039;&#039;in&#039;&#039;&#039; and &#039;&#039;&#039;out&#039;&#039;&#039;, which are&lt;br /&gt;
lists of zone names. These attributes control whether a packet matches&lt;br /&gt;
the rule or not. If a particular zone is referenced by the &#039;&#039;&#039;in&#039;&#039;&#039; &lt;br /&gt;
attribute, the rule applies to packets whose ingress interface and&lt;br /&gt;
source address are covered by the zone definition. Correspondingly, if&lt;br /&gt;
a zone is referenced by the &#039;&#039;&#039;out&#039;&#039;&#039; attribute, the rule applies to&lt;br /&gt;
packets whose egress interface and destination address are included in&lt;br /&gt;
the zone. If both &#039;&#039;&#039;in&#039;&#039;&#039; and &#039;&#039;&#039;out&#039;&#039;&#039; are defined, the packet must&lt;br /&gt;
fulfill both criteria in order to match the rule.&lt;br /&gt;
&lt;br /&gt;
=== Rules ===&lt;br /&gt;
&lt;br /&gt;
There are three types of rule objects: &#039;&#039;policies&#039;&#039;, &#039;&#039;filters&#039;&#039;, and &lt;br /&gt;
&#039;&#039;NAT rules&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
All rule objects can have the &#039;&#039;&#039;in&#039;&#039;&#039; and &#039;&#039;&#039;out&#039;&#039;&#039; attributes&lt;br /&gt;
referring to zones as described in the previous section. In addition,&lt;br /&gt;
the scope of the rule can be further constrained with the following&lt;br /&gt;
attributes:&lt;br /&gt;
&lt;br /&gt;
{|&lt;br /&gt;
!Attribute!!Value format!!Effect&lt;br /&gt;
|-&lt;br /&gt;
|&#039;&#039;&#039;src&#039;&#039;&#039;&lt;br /&gt;
|Similar to &#039;&#039;&#039;addr&#039;&#039;&#039; attribute of zone objects&lt;br /&gt;
|Packet&#039;s source address matches the value&lt;br /&gt;
|-&lt;br /&gt;
|&#039;&#039;&#039;dest&#039;&#039;&#039;&lt;br /&gt;
|Similar to &#039;&#039;&#039;addr&#039;&#039;&#039; attribute of zone objects&lt;br /&gt;
|Packet&#039;s destination address matches the value&lt;br /&gt;
|-&lt;br /&gt;
|&#039;&#039;&#039;ipset&#039;&#039;&#039;&lt;br /&gt;
|Object containing two attributes: &#039;&#039;&#039;name&#039;&#039;&#039; referring to an IP set and &#039;&#039;&#039;args&#039;&#039;&#039;, which is a list of strings &#039;&#039;&#039;in&#039;&#039;&#039; and &#039;&#039;&#039;out&#039;&#039;&#039;&lt;br /&gt;
|Packet matches the IP set referred here when the match arguments are taken from the source (&#039;&#039;&#039;in&#039;&#039;&#039;) and destination (&#039;&#039;&#039;out&#039;&#039;&#039;) address or port in the order specified by &#039;&#039;&#039;args&#039;&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
|&#039;&#039;&#039;ipsec&#039;&#039;&#039;&lt;br /&gt;
|&#039;&#039;&#039;in&#039;&#039;&#039; or &#039;&#039;&#039;out&#039;&#039;&#039;&lt;br /&gt;
|IPsec decapsulation perfomed on ingress (&#039;&#039;&#039;in&#039;&#039;&#039;) or encapsulation performed on egress (&#039;&#039;&#039;out&#039;&#039;&#039;)&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Rule objects must have an attribute named &#039;&#039;&#039;action&#039;&#039;&#039;, the value of&lt;br /&gt;
which can be one of the following:&lt;br /&gt;
&lt;br /&gt;
{|&lt;br /&gt;
!Value!!Action&lt;br /&gt;
|-&lt;br /&gt;
|&#039;&#039;&#039;accept&#039;&#039;&#039;&lt;br /&gt;
|Accept the packet&lt;br /&gt;
|-&lt;br /&gt;
|&#039;&#039;&#039;reject&#039;&#039;&#039;&lt;br /&gt;
|Reject the packet with an ICMP error message&lt;br /&gt;
|-&lt;br /&gt;
|&#039;&#039;&#039;drop&#039;&#039;&#039;&lt;br /&gt;
|Silently drop the packet&lt;br /&gt;
|-&lt;br /&gt;
|&#039;&#039;&#039;logreject&#039;&#039;&#039;&lt;br /&gt;
|Similar to &#039;&#039;&#039;reject&#039;&#039;&#039; but with kernel logging&lt;br /&gt;
|-&lt;br /&gt;
|&#039;&#039;&#039;logdrop&#039;&#039;&#039;&lt;br /&gt;
|Similar to &#039;&#039;&#039;drop&#039;&#039;&#039; but with kernel logging&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Rule objects are declared in type-specific top-level dictionaries in&lt;br /&gt;
awall policy files. If a packet matches multiple rules, the one&lt;br /&gt;
appearing earlier in the list takes precedence. If the matching rules&lt;br /&gt;
are defined in different policy files, the one that was processed&lt;br /&gt;
earlier takes precedence in the current implementation, but this may&lt;br /&gt;
change in future versions.&lt;br /&gt;
&lt;br /&gt;
==== Filters ====&lt;br /&gt;
&lt;br /&gt;
Filter objects specify an action for packets fulfilling certain&lt;br /&gt;
criteria. The top-level attribute &#039;&#039;&#039;filter&#039;&#039;&#039; is a list of filter&lt;br /&gt;
objects. The precedence rules are similar to those of policy objects.&lt;br /&gt;
&lt;br /&gt;
In addition to the common rule attributes, filter objects can have a &lt;br /&gt;
&#039;&#039;&#039;service&#039;&#039;&#039; attribute constraining the scope to specific services&lt;br /&gt;
only. This attribute is a list of service names, referring to the&lt;br /&gt;
keys of the top-level &#039;&#039;&#039;service&#039;&#039;&#039; dictionary.&lt;br /&gt;
&lt;br /&gt;
Filter objects may also contain limits for packet flow or new&lt;br /&gt;
connections. These are specified with the &#039;&#039;&#039;flow-limit&#039;&#039;&#039; and&lt;br /&gt;
&#039;&#039;&#039;conn-limit&#039;&#039;&#039; attributes, respectively. The values of these&lt;br /&gt;
attributes are limit objects that have two attributes: &#039;&#039;&#039;count&#039;&#039;&#039; and&lt;br /&gt;
&#039;&#039;&#039;interval&#039;&#039;&#039;. &#039;&#039;&#039;count&#039;&#039;&#039; specifies how many new connections or&lt;br /&gt;
packets are allowed within the time frame specified by &#039;&#039;&#039;interval&#039;&#039;&#039; &lt;br /&gt;
(in seconds). The &#039;&#039;&#039;logdrop&#039;&#039;&#039; action is applied to the packets&lt;br /&gt;
exceeding the limit.&lt;br /&gt;
&lt;br /&gt;
Filter objects may have an attribute named &#039;&#039;&#039;dnat&#039;&#039;&#039;, the value of&lt;br /&gt;
which is an IPv4 address. If defined, this enables destination NAT for&lt;br /&gt;
all IPv4 packets matching the rule, such that the specified address&lt;br /&gt;
replaces the original destination address. This option has no effect&lt;br /&gt;
on IPv6 packets.&lt;br /&gt;
&lt;br /&gt;
==== Policies ====&lt;br /&gt;
&lt;br /&gt;
Policy objects describe the default action for packets that did not&lt;br /&gt;
match any filter. The top-level attribute &#039;&#039;&#039;policy&#039;&#039;&#039; is a list of&lt;br /&gt;
policy objects. Policy objects do not have other attributes than those&lt;br /&gt;
common to all rule objects.&lt;br /&gt;
&lt;br /&gt;
==== NAT Rules ====&lt;br /&gt;
&lt;br /&gt;
NAT rules come in two flavors: &#039;&#039;source NAT rules&#039;&#039; and&lt;br /&gt;
&#039;&#039;destination NAT rules&#039;&#039;. These are contained in two top-level lists&lt;br /&gt;
named &#039;&#039;&#039;snat&#039;&#039;&#039; and &#039;&#039;&#039;dnat&#039;&#039;&#039;, respectively.&lt;br /&gt;
&lt;br /&gt;
Each NAT rule must have an attribute named &#039;&#039;&#039;ip-range&#039;&#039;&#039; that&lt;br /&gt;
specifies the IPv4 address range to which the original source or&lt;br /&gt;
destinatinon address is mapped. The value can be a single IPv4 address&lt;br /&gt;
or a range specified by two addresses, separated with the &#039;&#039;&#039;-&#039;&#039;&#039;&lt;br /&gt;
character.&lt;br /&gt;
&lt;br /&gt;
Optionally, a NAT rule can specify the TCP and UDP port range to which&lt;br /&gt;
the original source or destination port is mapped. The attribute is&lt;br /&gt;
named &#039;&#039;&#039;port-range&#039;&#039;&#039;, and the value can be a single port number or a&lt;br /&gt;
range specified by two numbers, separated with the &#039;&#039;&#039;-&#039;&#039;&#039;&lt;br /&gt;
character. If &#039;&#039;&#039;port-range&#039;&#039;&#039; is not specified, the original port&lt;br /&gt;
number is kept intact.&lt;br /&gt;
&lt;br /&gt;
Like filters, NAT rules can have a &#039;&#039;&#039;service&#039;&#039;&#039; attribute&lt;br /&gt;
constraining their scope to specific services.&lt;br /&gt;
&lt;br /&gt;
=== IP Sets ===&lt;br /&gt;
&lt;br /&gt;
Any IP set referenced by rule objects should be created by&lt;br /&gt;
awall. Auxiliary &#039;&#039;IP set&#039;&#039; objects are used to defined them in awall&lt;br /&gt;
policy files. The top-level attribute &#039;&#039;&#039;ipset&#039;&#039;&#039; is a dictionary, the&lt;br /&gt;
keys of which are IP set names. The values are IP set objects, which&lt;br /&gt;
have two mandatory attributes. The attribute named &#039;&#039;&#039;type&#039;&#039;&#039; &lt;br /&gt;
corresponds to the type argument of the &amp;lt;tt&amp;gt;ipset create&amp;lt;/tt&amp;gt; &lt;br /&gt;
command. &#039;&#039;&#039;family&#039;&#039;&#039; specifies whether the set is for IPv4 or IPv6&lt;br /&gt;
addresses, and the possible values are &#039;&#039;&#039;inet&#039;&#039;&#039; and &#039;&#039;&#039;inet6&#039;&#039;&#039;,&lt;br /&gt;
correspondingly.&lt;br /&gt;
&lt;br /&gt;
== Command Line Syntax ==&lt;br /&gt;
&lt;br /&gt;
=== Translating Policy Files to Firewall Configuration Files ===&lt;br /&gt;
&lt;br /&gt;
 &#039;&#039;&#039;awall translate&#039;&#039;&#039; [&#039;&#039;&#039;-o&#039;&#039;&#039;|&#039;&#039;&#039;--output&#039;&#039;&#039; DIRECTORY] [&#039;&#039;&#039;-V&#039;&#039;&#039;|&#039;&#039;&#039;--verify&#039;&#039;&#039;]&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;tt&amp;gt;--verify&amp;lt;/tt&amp;gt; option makes awall verify the configuration&lt;br /&gt;
using the test mode of iptables-restore before overwriting the old&lt;br /&gt;
files.&lt;br /&gt;
&lt;br /&gt;
Specifying the output directory allows testing awall policies without&lt;br /&gt;
overwriting the current iptables and ipset configuration files. By&lt;br /&gt;
default, awall generates the configuration to &amp;lt;tt&amp;gt;/etc/iptables&amp;lt;/tt&amp;gt; &lt;br /&gt;
and &amp;lt;tt&amp;gt;/etc/ipset.d&amp;lt;/tt&amp;gt;, which are read by the init scripts.&lt;br /&gt;
&lt;br /&gt;
=== Run-Time Activation of New Firewall Configuration ===&lt;br /&gt;
&lt;br /&gt;
 &#039;&#039;&#039;awall activate&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
This command genereates firewall configuration from the policy files&lt;br /&gt;
and enables it. If the user confirms the new configuration by hitting&lt;br /&gt;
the Return key within 10 seconds, the configuration is saved to the&lt;br /&gt;
files. Otherwise, the old configuration is restored.&lt;br /&gt;
&lt;br /&gt;
=== Optional Policies ===&lt;br /&gt;
&lt;br /&gt;
Optional policies can be enabled or disabled using this command:&lt;br /&gt;
&lt;br /&gt;
 &#039;&#039;&#039;awall&#039;&#039;&#039; {&#039;&#039;&#039;enable&#039;&#039;&#039;|&#039;&#039;&#039;disable&#039;&#039;&#039;} POLICY...&lt;br /&gt;
&lt;br /&gt;
Optional policies can be listed using this command:&lt;br /&gt;
&lt;br /&gt;
 &#039;&#039;&#039;awall list&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;&#039;enabled&#039;&#039;&#039; status means that the policy has been enabled by the&lt;br /&gt;
user. The &#039;&#039;&#039;disabled&#039;&#039;&#039; status means that the policy is not in&lt;br /&gt;
use. The &#039;&#039;&#039;required&#039;&#039;&#039; status means that the policy has not been&lt;br /&gt;
enabled by the user but is in use because it is required by another&lt;br /&gt;
policy which is in use.&lt;br /&gt;
&lt;br /&gt;
=== Debugging Policies ===&lt;br /&gt;
&lt;br /&gt;
This command can be used to dump variable, zone, and other definitions&lt;br /&gt;
as well as their source policies:&lt;br /&gt;
&lt;br /&gt;
 &#039;&#039;&#039;awall dump&#039;&#039;&#039; [LEVEL]&lt;br /&gt;
&lt;br /&gt;
The level is an integer in range 0&amp;amp;ndash;3 and defaults to 0. More&lt;br /&gt;
information is displayed on higher levels.&lt;br /&gt;
&lt;br /&gt;
[[Category:Networking]]&lt;br /&gt;
[[Category:Security]]&lt;/div&gt;</summary>
		<author><name>Kunkku</name></author>
	</entry>
	<entry>
		<id>https://wiki.alpinelinux.org/w/index.php?title=Alpine_Wall_User%27s_Guide&amp;diff=7937</id>
		<title>Alpine Wall User&#039;s Guide</title>
		<link rel="alternate" type="text/html" href="https://wiki.alpinelinux.org/w/index.php?title=Alpine_Wall_User%27s_Guide&amp;diff=7937"/>
		<updated>2012-05-03T06:19:07Z</updated>

		<summary type="html">&lt;p&gt;Kunkku: /* Rules */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Configuration File Processing ==&lt;br /&gt;
&lt;br /&gt;
[[Alpine Wall]] (awall) reads its configuration from multiple&lt;br /&gt;
JSON-formatted files, called &#039;&#039;policy files&#039;&#039;. The processing starts&lt;br /&gt;
from directory &amp;lt;tt&amp;gt;/usr/share/awall/mandatory&amp;lt;/tt&amp;gt;, which contains&lt;br /&gt;
mandatory policy files shipped with APK packages. After that,&lt;br /&gt;
installation-specific policy files in &amp;lt;tt&amp;gt;/etc/awall&amp;lt;/tt&amp;gt; are&lt;br /&gt;
processed.&lt;br /&gt;
&lt;br /&gt;
The latter directory may also contain symbolic links to policy files&lt;br /&gt;
located in &amp;lt;tt&amp;gt;/usr/share/awall/optional&amp;lt;/tt&amp;gt;. These are optional&lt;br /&gt;
policies, which can be enabled on need basis. Such symbolic links are&lt;br /&gt;
easily created and destroyed using the &amp;lt;tt&amp;gt;awall enable&amp;lt;/tt&amp;gt; and&lt;br /&gt;
&amp;lt;tt&amp;gt;awall disable&amp;lt;/tt&amp;gt; commands. &amp;lt;tt&amp;gt;awall list&amp;lt;/tt&amp;gt; shows which&lt;br /&gt;
optional policies are enabled and disabled. The command also prints&lt;br /&gt;
the description of the optional policy if defined in the file using&lt;br /&gt;
a top-level attribute named &#039;&#039;&#039;description&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Sometimes a policy file depends on other policy files. In this case,&lt;br /&gt;
the policy file must have a top-level attribute &#039;&#039;&#039;import&#039;&#039;&#039;, the&lt;br /&gt;
value of which is a list of policy names, which correspond to the file&lt;br /&gt;
names without the &amp;lt;tt&amp;gt;.json&amp;lt;/tt&amp;gt; suffix. The policies listed there are&lt;br /&gt;
always processed before the importing policy. The order of the&lt;br /&gt;
generated iptables rules generally reflects the processing order of&lt;br /&gt;
their corresponding awall policies.&lt;br /&gt;
&lt;br /&gt;
As the import directive does not require the path name to be&lt;br /&gt;
specified, awall expects policies to have unique names, even if&lt;br /&gt;
located in different directories. It is allowed to import optional&lt;br /&gt;
policies that are not explicitly enabled by the user. Such policies&lt;br /&gt;
show up with the &amp;lt;tt&amp;gt;required&amp;lt;/tt&amp;gt; status in the output of &amp;lt;tt&amp;gt;awall&lt;br /&gt;
list&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
== List Parameters ==&lt;br /&gt;
&lt;br /&gt;
Several awall parameters are defined as lists of values. In order to&lt;br /&gt;
facilitate manual editing of policy files, awall also accepts single&lt;br /&gt;
values in place of lists. Such values are semantically equivalent to&lt;br /&gt;
lists containing one element.&lt;br /&gt;
&lt;br /&gt;
== Variable Expansion ==&lt;br /&gt;
&lt;br /&gt;
Awall allows variable definitions in policy files. The top-level&lt;br /&gt;
attribute &#039;&#039;&#039;variable&#039;&#039;&#039; is a dictionary containing the&lt;br /&gt;
definitions. The value of a variable can be of any type (string,&lt;br /&gt;
integer, list, or dictionary).&lt;br /&gt;
&lt;br /&gt;
A variable is referenced in policy files by a string which equals the&lt;br /&gt;
variable name prepended with the &#039;&#039;&#039;$&#039;&#039;&#039; character. If the value of&lt;br /&gt;
the variable is a string, the reference can be embedded into a longer&lt;br /&gt;
string in order to substitute some part of that string (in shell&lt;br /&gt;
style). Variable references can be used when defining other variables,&lt;br /&gt;
as long as the definitions are not circular.&lt;br /&gt;
&lt;br /&gt;
Policy files can reference variables defined in other policy&lt;br /&gt;
files. Policy files can also override variables defined elsewhere by&lt;br /&gt;
redefining them. In this case, the new definition affects all policy&lt;br /&gt;
files, also those processed before the overriding policy. Awall&lt;br /&gt;
variables are in fact simple macros, since each variable remains&lt;br /&gt;
constant thoughout a single processing round. If multiple files define&lt;br /&gt;
the same variable, the definition in the file processed last takes&lt;br /&gt;
effect.&lt;br /&gt;
&lt;br /&gt;
If defined as an empty string, all non-embedded references to a&lt;br /&gt;
variable evaluate as if the attribute in question was not present in&lt;br /&gt;
the configuration. This is also the case when a string containing&lt;br /&gt;
embedded variable references finally evaluates to an empty string.&lt;br /&gt;
&lt;br /&gt;
== Configuration Objects ==&lt;br /&gt;
&lt;br /&gt;
Configuration objects can be divided into two main types.&lt;br /&gt;
&#039;&#039;Auxiliary objects&#039;&#039; model high-level concepts such as services and&lt;br /&gt;
zones. &#039;&#039;Rule objects&#039;&#039; translate into one or more iptables rules, and&lt;br /&gt;
are often defined with the help of some auxiliary objects.&lt;br /&gt;
&lt;br /&gt;
=== Services ===&lt;br /&gt;
&lt;br /&gt;
A &#039;&#039;service&#039;&#039; represents a set of network protocols. A top-level&lt;br /&gt;
attribute &#039;&#039;&#039;service&#039;&#039;&#039; is a dictionary that maps service names to&lt;br /&gt;
service definition objects, or lists thereof in more complex cases.&lt;br /&gt;
&lt;br /&gt;
A service definition object contains an attribute named &#039;&#039;&#039;proto&#039;&#039;&#039;,&lt;br /&gt;
which corresponds to the &amp;lt;tt&amp;gt;--protocol&amp;lt;/tt&amp;gt; option of iptables. The&lt;br /&gt;
protocol can be defined as a numerical value or string as defined in&lt;br /&gt;
&amp;lt;tt&amp;gt;/etc/protocols&amp;lt;/tt&amp;gt;. If the protocol is &#039;&#039;&#039;tcp&#039;&#039;&#039; or &#039;&#039;&#039;udp&#039;&#039;&#039;,&lt;br /&gt;
the scope of the service definition may be constrained by defining an&lt;br /&gt;
attribute named &#039;&#039;&#039;port&#039;&#039;&#039;, which is a list of TCP or UDP port&lt;br /&gt;
numbers. If the protocol is &#039;&#039;&#039;icmp&#039;&#039;&#039; or &#039;&#039;&#039;icmpv6&#039;&#039;&#039;, an analogous&lt;br /&gt;
&#039;&#039;&#039;icmp-type&#039;&#039;&#039; attribute may be used. In addition, the scope of the&lt;br /&gt;
rule is also automatically limited to IPv4 or IPv6, respectively.&lt;br /&gt;
&lt;br /&gt;
=== Zones ===&lt;br /&gt;
&lt;br /&gt;
A &#039;&#039;zone&#039;&#039; represents a set of network hosts. A top-level attribute&lt;br /&gt;
&#039;&#039;&#039;zone&#039;&#039;&#039; is a dictionary that maps zone names to zone objects. A&lt;br /&gt;
zone object has an attribute named &#039;&#039;&#039;iface&#039;&#039;&#039;, &#039;&#039;&#039;addr&#039;&#039;&#039;, or&lt;br /&gt;
both. &#039;&#039;&#039;iface&#039;&#039;&#039; is a list of network interfaces and &#039;&#039;&#039;addr&#039;&#039;&#039; is a&lt;br /&gt;
list of IPv4/IPv6 host and network addresses (CIDR&lt;br /&gt;
notation). &#039;&#039;&#039;addr&#039;&#039;&#039; may also contain domain names, which are&lt;br /&gt;
expanded to IP addresses using DNS resolution. If not defined,&lt;br /&gt;
&#039;&#039;&#039;addr&#039;&#039;&#039; defaults to the entire address space and &#039;&#039;&#039;iface&#039;&#039;&#039; to all&lt;br /&gt;
interfaces.&lt;br /&gt;
&lt;br /&gt;
Rule objects contain two attributes, &#039;&#039;&#039;in&#039;&#039;&#039; and &#039;&#039;&#039;out&#039;&#039;&#039;, which are&lt;br /&gt;
lists of zone names. These attributes control whether a packet matches&lt;br /&gt;
the rule or not. If a particular zone is referenced by the &#039;&#039;&#039;in&#039;&#039;&#039;&lt;br /&gt;
attribute, the rule applies to packets whose ingress interface and&lt;br /&gt;
source address are covered by the zone definition. Correspondingly, if&lt;br /&gt;
a zone is referenced by the &#039;&#039;&#039;out&#039;&#039;&#039; attribute, the rule applies to&lt;br /&gt;
packets whose egress interface and destination address are included in&lt;br /&gt;
the zone. If both &#039;&#039;&#039;in&#039;&#039;&#039; and &#039;&#039;&#039;out&#039;&#039;&#039; are defined, the packet must&lt;br /&gt;
fulfill both criteria in order to match the rule.&lt;br /&gt;
&lt;br /&gt;
=== Rules ===&lt;br /&gt;
&lt;br /&gt;
There are three types of rule objects: &#039;&#039;policies&#039;&#039;, &#039;&#039;filters&#039;&#039;, and&lt;br /&gt;
&#039;&#039;NAT rules&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
All rule objects can have the &#039;&#039;&#039;in&#039;&#039;&#039; and &#039;&#039;&#039;out&#039;&#039;&#039; attributes&lt;br /&gt;
referring to zones as described in the previous section. In addition,&lt;br /&gt;
the scope of the rule can be further constrained with the following&lt;br /&gt;
attributes:&lt;br /&gt;
&lt;br /&gt;
{|&lt;br /&gt;
!Attribute!!Value format!!Effect&lt;br /&gt;
|-&lt;br /&gt;
|&#039;&#039;&#039;src&#039;&#039;&#039;&lt;br /&gt;
|Similar to &#039;&#039;&#039;addr&#039;&#039;&#039; attribute of zone objects&lt;br /&gt;
|Packet&#039;s source address matches the value&lt;br /&gt;
|-&lt;br /&gt;
|&#039;&#039;&#039;dest&#039;&#039;&#039;&lt;br /&gt;
|Similar to &#039;&#039;&#039;addr&#039;&#039;&#039; attribute of zone objects&lt;br /&gt;
|Packet&#039;s destination address matches the value&lt;br /&gt;
|-&lt;br /&gt;
|&#039;&#039;&#039;ipset&#039;&#039;&#039;&lt;br /&gt;
|Object containing two attributes: &#039;&#039;&#039;name&#039;&#039;&#039; referring to an IP set and &#039;&#039;&#039;args&#039;&#039;&#039;, which is a list of strings &#039;&#039;&#039;in&#039;&#039;&#039; and &#039;&#039;&#039;out&#039;&#039;&#039;&lt;br /&gt;
|Packet matches the IP set referred here when the match arguments are taken from the source (&#039;&#039;&#039;in&#039;&#039;&#039;) and destination (&#039;&#039;&#039;out&#039;&#039;&#039;) address or port in the order specified by &#039;&#039;&#039;args&#039;&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
|&#039;&#039;&#039;ipsec&#039;&#039;&#039;&lt;br /&gt;
|&#039;&#039;&#039;in&#039;&#039;&#039; or &#039;&#039;&#039;out&#039;&#039;&#039;&lt;br /&gt;
|IPsec decapsulation perfomed on ingress (&#039;&#039;&#039;in&#039;&#039;&#039;) or encapsulation performed on egress (&#039;&#039;&#039;out&#039;&#039;&#039;)&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Rule objects must have an attribute named &#039;&#039;&#039;action&#039;&#039;&#039;, the value of&lt;br /&gt;
which can be one of the following:&lt;br /&gt;
&lt;br /&gt;
{|&lt;br /&gt;
!Value!!Action&lt;br /&gt;
|-&lt;br /&gt;
|&#039;&#039;&#039;accept&#039;&#039;&#039;&lt;br /&gt;
|Accept the packet&lt;br /&gt;
|-&lt;br /&gt;
|&#039;&#039;&#039;reject&#039;&#039;&#039;&lt;br /&gt;
|Reject the packet with an ICMP error message&lt;br /&gt;
|-&lt;br /&gt;
|&#039;&#039;&#039;drop&#039;&#039;&#039;&lt;br /&gt;
|Silently drop the packet&lt;br /&gt;
|-&lt;br /&gt;
|&#039;&#039;&#039;logreject&#039;&#039;&#039;&lt;br /&gt;
|Similar to &#039;&#039;&#039;reject&#039;&#039;&#039; but with kernel logging&lt;br /&gt;
|-&lt;br /&gt;
|&#039;&#039;&#039;logdrop&#039;&#039;&#039;&lt;br /&gt;
|Similar to &#039;&#039;&#039;drop&#039;&#039;&#039; but with kernel logging&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Rule objects are declared in type-specific top-level dictionaries in&lt;br /&gt;
awall policy files. If a packet matches multiple rules, the one&lt;br /&gt;
appearing earlier in the list takes precedence. If the matching rules&lt;br /&gt;
are defined in different policy files, the one that was processed&lt;br /&gt;
earlier takes precedence in the current implementation, but this may&lt;br /&gt;
change in future versions.&lt;br /&gt;
&lt;br /&gt;
==== Filters ====&lt;br /&gt;
&lt;br /&gt;
Filter objects specify an action for packets fulfilling certain&lt;br /&gt;
criteria. The top-level attribute &#039;&#039;&#039;filter&#039;&#039;&#039; is a list of filter&lt;br /&gt;
objects. The precedence rules are similar to those of policy objects.&lt;br /&gt;
&lt;br /&gt;
In addition to the common rule attributes, filter objects can have a&lt;br /&gt;
&#039;&#039;&#039;service&#039;&#039;&#039; attribute constraining the scope to specific services&lt;br /&gt;
only. This attribute is a list of service names, referring to the&lt;br /&gt;
keys of the top-level &#039;&#039;&#039;service&#039;&#039;&#039; dictionary.&lt;br /&gt;
&lt;br /&gt;
Filter objects may also contain limits for packet flow or new&lt;br /&gt;
connections. These are specified with the &#039;&#039;&#039;flow-limit&#039;&#039;&#039; and&lt;br /&gt;
&#039;&#039;&#039;conn-limit&#039;&#039;&#039; attributes, respectively. The values of these&lt;br /&gt;
attributes are limit objects that have two attributes: &#039;&#039;&#039;count&#039;&#039;&#039; and&lt;br /&gt;
&#039;&#039;&#039;interval&#039;&#039;&#039;. &#039;&#039;&#039;count&#039;&#039;&#039; specifies how many new connections or&lt;br /&gt;
packets are allowed within the time frame specified by &#039;&#039;&#039;interval&#039;&#039;&#039;&lt;br /&gt;
(in seconds). The &#039;&#039;&#039;logdrop&#039;&#039;&#039; action is applied to the packets&lt;br /&gt;
exceeding the limit.&lt;br /&gt;
&lt;br /&gt;
Filter objects may have an attribute named &#039;&#039;&#039;dnat&#039;&#039;&#039;, the value of&lt;br /&gt;
which is an IPv4 address. If defined, this enables destination NAT for&lt;br /&gt;
all IPv4 packets matching the rule, such that the specified address&lt;br /&gt;
replaces the original destination address. This option has no effect&lt;br /&gt;
on IPv6 packets.&lt;br /&gt;
&lt;br /&gt;
==== Policies ====&lt;br /&gt;
&lt;br /&gt;
Policy objects describe the default action for packets that did not&lt;br /&gt;
match any filter. The top-level attribute &#039;&#039;&#039;policy&#039;&#039;&#039; is a list of&lt;br /&gt;
policy objects. Policy objects do not have other attributes than those&lt;br /&gt;
common to all rule objects.&lt;br /&gt;
&lt;br /&gt;
==== NAT Rules ====&lt;br /&gt;
&lt;br /&gt;
NAT rules come in two flavors: &#039;&#039;source NAT rules&#039;&#039; and&lt;br /&gt;
&#039;&#039;destination NAT rules&#039;&#039;. These are contained in two top-level lists&lt;br /&gt;
named &#039;&#039;&#039;snat&#039;&#039;&#039; and &#039;&#039;&#039;dnat&#039;&#039;&#039;, respectively.&lt;br /&gt;
&lt;br /&gt;
Each NAT rule must have an attribute named &#039;&#039;&#039;ip-range&#039;&#039;&#039; that&lt;br /&gt;
specifies the IPv4 address range to which the original source or&lt;br /&gt;
destinatinon address is mapped. The value can be a single IPv4 address&lt;br /&gt;
or a range specified by two addresses, separated with the &#039;&#039;&#039;-&#039;&#039;&#039;&lt;br /&gt;
character.&lt;br /&gt;
&lt;br /&gt;
Optionally, a NAT rule can specify the TCP and UDP port range to which&lt;br /&gt;
the original source or destination port is mapped. The attribute is&lt;br /&gt;
named &#039;&#039;&#039;port-range&#039;&#039;&#039;, and the value can be a single port number or a&lt;br /&gt;
range specified by two numbers, separated with the &#039;&#039;&#039;-&#039;&#039;&#039;&lt;br /&gt;
character. If &#039;&#039;&#039;port-range&#039;&#039;&#039; is not specified, the original port&lt;br /&gt;
number is kept intact.&lt;br /&gt;
&lt;br /&gt;
Like filters, NAT rules can have a &#039;&#039;&#039;service&#039;&#039;&#039; attribute&lt;br /&gt;
constraining their scope to specific services.&lt;br /&gt;
&lt;br /&gt;
=== IP Sets ===&lt;br /&gt;
&lt;br /&gt;
Any IP set referenced by rule objects should be created by&lt;br /&gt;
awall. Auxiliary &#039;&#039;IP set&#039;&#039; objects are used to defined them in awall&lt;br /&gt;
policy files. The top-level attribute &#039;&#039;&#039;ipset&#039;&#039;&#039; is a dictionary, the&lt;br /&gt;
keys of which are IP set names. The values are IP set objects, which&lt;br /&gt;
have two mandatory attributes. The attribute named &#039;&#039;&#039;type&#039;&#039;&#039;&lt;br /&gt;
corresponds to the type argument of the &amp;lt;tt&amp;gt;ipset create&amp;lt;/tt&amp;gt;&lt;br /&gt;
command. &#039;&#039;&#039;family&#039;&#039;&#039; specifies whether the set is for IPv4 or IPv6&lt;br /&gt;
addresses, and the possible values are &#039;&#039;&#039;inet&#039;&#039;&#039; and &#039;&#039;&#039;inet6&#039;&#039;&#039;,&lt;br /&gt;
correspondingly.&lt;br /&gt;
&lt;br /&gt;
== Command Line Syntax ==&lt;br /&gt;
&lt;br /&gt;
=== Translating Policy Files to Firewall Configuration Files ===&lt;br /&gt;
&lt;br /&gt;
 &#039;&#039;&#039;awall translate&#039;&#039;&#039; [&#039;&#039;&#039;-o&#039;&#039;&#039;|&#039;&#039;&#039;--output&#039;&#039;&#039; DIRECTORY] [&#039;&#039;&#039;-V&#039;&#039;&#039;|&#039;&#039;&#039;--verify&#039;&#039;&#039;]&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;tt&amp;gt;--verify&amp;lt;/tt&amp;gt; option makes awall verify the configuration&lt;br /&gt;
using the test mode of iptables-restore before overwriting the old&lt;br /&gt;
files.&lt;br /&gt;
&lt;br /&gt;
Specifying the output directory allows testing awall policies without&lt;br /&gt;
overwriting the current iptables and ipset configuration files. By&lt;br /&gt;
default, awall generates the configuration to &amp;lt;tt&amp;gt;/etc/iptables&amp;lt;/tt&amp;gt;&lt;br /&gt;
and &amp;lt;tt&amp;gt;/etc/ipset.d&amp;lt;/tt&amp;gt;, which are read by the init scripts.&lt;br /&gt;
&lt;br /&gt;
=== Run-Time Activation of New Firewall Configuration ===&lt;br /&gt;
&lt;br /&gt;
 &#039;&#039;&#039;awall activate&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
This command genereates firewall configuration from the policy files&lt;br /&gt;
and enables it. If the user confirms the new configuration by hitting&lt;br /&gt;
the Return key within 10 seconds, the configuration is saved to the&lt;br /&gt;
files. Otherwise, the old configuration is restored.&lt;br /&gt;
&lt;br /&gt;
=== Optional Policies ===&lt;br /&gt;
&lt;br /&gt;
Optional policies can be enabled or disabled using this command:&lt;br /&gt;
&lt;br /&gt;
 &#039;&#039;&#039;awall&#039;&#039;&#039; {&#039;&#039;&#039;enable&#039;&#039;&#039;|&#039;&#039;&#039;disable&#039;&#039;&#039;} POLICY...&lt;br /&gt;
&lt;br /&gt;
Optional policies can be listed using this command:&lt;br /&gt;
&lt;br /&gt;
 &#039;&#039;&#039;awall list&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;&#039;enabled&#039;&#039;&#039; status means that the policy has been enabled by the&lt;br /&gt;
user. The &#039;&#039;&#039;disabled&#039;&#039;&#039; status means that the policy is not in&lt;br /&gt;
use. The &#039;&#039;&#039;required&#039;&#039;&#039; status means that the policy has not been&lt;br /&gt;
enabled by the user but is in use because it is required by another&lt;br /&gt;
policy which is in use.&lt;/div&gt;</summary>
		<author><name>Kunkku</name></author>
	</entry>
	<entry>
		<id>https://wiki.alpinelinux.org/w/index.php?title=Alpine_Wall_User%27s_Guide&amp;diff=7936</id>
		<title>Alpine Wall User&#039;s Guide</title>
		<link rel="alternate" type="text/html" href="https://wiki.alpinelinux.org/w/index.php?title=Alpine_Wall_User%27s_Guide&amp;diff=7936"/>
		<updated>2012-05-03T05:59:42Z</updated>

		<summary type="html">&lt;p&gt;Kunkku: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Configuration File Processing ==&lt;br /&gt;
&lt;br /&gt;
[[Alpine Wall]] (awall) reads its configuration from multiple&lt;br /&gt;
JSON-formatted files, called &#039;&#039;policy files&#039;&#039;. The processing starts&lt;br /&gt;
from directory &amp;lt;tt&amp;gt;/usr/share/awall/mandatory&amp;lt;/tt&amp;gt;, which contains&lt;br /&gt;
mandatory policy files shipped with APK packages. After that,&lt;br /&gt;
installation-specific policy files in &amp;lt;tt&amp;gt;/etc/awall&amp;lt;/tt&amp;gt; are&lt;br /&gt;
processed.&lt;br /&gt;
&lt;br /&gt;
The latter directory may also contain symbolic links to policy files&lt;br /&gt;
located in &amp;lt;tt&amp;gt;/usr/share/awall/optional&amp;lt;/tt&amp;gt;. These are optional&lt;br /&gt;
policies, which can be enabled on need basis. Such symbolic links are&lt;br /&gt;
easily created and destroyed using the &amp;lt;tt&amp;gt;awall enable&amp;lt;/tt&amp;gt; and&lt;br /&gt;
&amp;lt;tt&amp;gt;awall disable&amp;lt;/tt&amp;gt; commands. &amp;lt;tt&amp;gt;awall list&amp;lt;/tt&amp;gt; shows which&lt;br /&gt;
optional policies are enabled and disabled. The command also prints&lt;br /&gt;
the description of the optional policy if defined in the file using&lt;br /&gt;
a top-level attribute named &#039;&#039;&#039;description&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Sometimes a policy file depends on other policy files. In this case,&lt;br /&gt;
the policy file must have a top-level attribute &#039;&#039;&#039;import&#039;&#039;&#039;, the&lt;br /&gt;
value of which is a list of policy names, which correspond to the file&lt;br /&gt;
names without the &amp;lt;tt&amp;gt;.json&amp;lt;/tt&amp;gt; suffix. The policies listed there are&lt;br /&gt;
always processed before the importing policy. The order of the&lt;br /&gt;
generated iptables rules generally reflects the processing order of&lt;br /&gt;
their corresponding awall policies.&lt;br /&gt;
&lt;br /&gt;
As the import directive does not require the path name to be&lt;br /&gt;
specified, awall expects policies to have unique names, even if&lt;br /&gt;
located in different directories. It is allowed to import optional&lt;br /&gt;
policies that are not explicitly enabled by the user. Such policies&lt;br /&gt;
show up with the &amp;lt;tt&amp;gt;required&amp;lt;/tt&amp;gt; status in the output of &amp;lt;tt&amp;gt;awall&lt;br /&gt;
list&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
== List Parameters ==&lt;br /&gt;
&lt;br /&gt;
Several awall parameters are defined as lists of values. In order to&lt;br /&gt;
facilitate manual editing of policy files, awall also accepts single&lt;br /&gt;
values in place of lists. Such values are semantically equivalent to&lt;br /&gt;
lists containing one element.&lt;br /&gt;
&lt;br /&gt;
== Variable Expansion ==&lt;br /&gt;
&lt;br /&gt;
Awall allows variable definitions in policy files. The top-level&lt;br /&gt;
attribute &#039;&#039;&#039;variable&#039;&#039;&#039; is a dictionary containing the&lt;br /&gt;
definitions. The value of a variable can be of any type (string,&lt;br /&gt;
integer, list, or dictionary).&lt;br /&gt;
&lt;br /&gt;
A variable is referenced in policy files by a string which equals the&lt;br /&gt;
variable name prepended with the &#039;&#039;&#039;$&#039;&#039;&#039; character. If the value of&lt;br /&gt;
the variable is a string, the reference can be embedded into a longer&lt;br /&gt;
string in order to substitute some part of that string (in shell&lt;br /&gt;
style). Variable references can be used when defining other variables,&lt;br /&gt;
as long as the definitions are not circular.&lt;br /&gt;
&lt;br /&gt;
Policy files can reference variables defined in other policy&lt;br /&gt;
files. Policy files can also override variables defined elsewhere by&lt;br /&gt;
redefining them. In this case, the new definition affects all policy&lt;br /&gt;
files, also those processed before the overriding policy. Awall&lt;br /&gt;
variables are in fact simple macros, since each variable remains&lt;br /&gt;
constant thoughout a single processing round. If multiple files define&lt;br /&gt;
the same variable, the definition in the file processed last takes&lt;br /&gt;
effect.&lt;br /&gt;
&lt;br /&gt;
If defined as an empty string, all non-embedded references to a&lt;br /&gt;
variable evaluate as if the attribute in question was not present in&lt;br /&gt;
the configuration. This is also the case when a string containing&lt;br /&gt;
embedded variable references finally evaluates to an empty string.&lt;br /&gt;
&lt;br /&gt;
== Configuration Objects ==&lt;br /&gt;
&lt;br /&gt;
Configuration objects can be divided into two main types.&lt;br /&gt;
&#039;&#039;Auxiliary objects&#039;&#039; model high-level concepts such as services and&lt;br /&gt;
zones. &#039;&#039;Rule objects&#039;&#039; translate into one or more iptables rules, and&lt;br /&gt;
are often defined with the help of some auxiliary objects.&lt;br /&gt;
&lt;br /&gt;
=== Services ===&lt;br /&gt;
&lt;br /&gt;
A &#039;&#039;service&#039;&#039; represents a set of network protocols. A top-level&lt;br /&gt;
attribute &#039;&#039;&#039;service&#039;&#039;&#039; is a dictionary that maps service names to&lt;br /&gt;
service definition objects, or lists thereof in more complex cases.&lt;br /&gt;
&lt;br /&gt;
A service definition object contains an attribute named &#039;&#039;&#039;proto&#039;&#039;&#039;,&lt;br /&gt;
which corresponds to the &amp;lt;tt&amp;gt;--protocol&amp;lt;/tt&amp;gt; option of iptables. The&lt;br /&gt;
protocol can be defined as a numerical value or string as defined in&lt;br /&gt;
&amp;lt;tt&amp;gt;/etc/protocols&amp;lt;/tt&amp;gt;. If the protocol is &#039;&#039;&#039;tcp&#039;&#039;&#039; or &#039;&#039;&#039;udp&#039;&#039;&#039;,&lt;br /&gt;
the scope of the service definition may be constrained by defining an&lt;br /&gt;
attribute named &#039;&#039;&#039;port&#039;&#039;&#039;, which is a list of TCP or UDP port&lt;br /&gt;
numbers. If the protocol is &#039;&#039;&#039;icmp&#039;&#039;&#039; or &#039;&#039;&#039;icmpv6&#039;&#039;&#039;, an analogous&lt;br /&gt;
&#039;&#039;&#039;icmp-type&#039;&#039;&#039; attribute may be used. In addition, the scope of the&lt;br /&gt;
rule is also automatically limited to IPv4 or IPv6, respectively.&lt;br /&gt;
&lt;br /&gt;
=== Zones ===&lt;br /&gt;
&lt;br /&gt;
A &#039;&#039;zone&#039;&#039; represents a set of network hosts. A top-level attribute&lt;br /&gt;
&#039;&#039;&#039;zone&#039;&#039;&#039; is a dictionary that maps zone names to zone objects. A&lt;br /&gt;
zone object has an attribute named &#039;&#039;&#039;iface&#039;&#039;&#039;, &#039;&#039;&#039;addr&#039;&#039;&#039;, or&lt;br /&gt;
both. &#039;&#039;&#039;iface&#039;&#039;&#039; is a list of network interfaces and &#039;&#039;&#039;addr&#039;&#039;&#039; is a&lt;br /&gt;
list of IPv4/IPv6 host and network addresses (CIDR&lt;br /&gt;
notation). &#039;&#039;&#039;addr&#039;&#039;&#039; may also contain domain names, which are&lt;br /&gt;
expanded to IP addresses using DNS resolution. If not defined,&lt;br /&gt;
&#039;&#039;&#039;addr&#039;&#039;&#039; defaults to the entire address space and &#039;&#039;&#039;iface&#039;&#039;&#039; to all&lt;br /&gt;
interfaces.&lt;br /&gt;
&lt;br /&gt;
Rule objects contain two attributes, &#039;&#039;&#039;in&#039;&#039;&#039; and &#039;&#039;&#039;out&#039;&#039;&#039;, which are&lt;br /&gt;
lists of zone names. These attributes control whether a packet matches&lt;br /&gt;
the rule or not. If a particular zone is referenced by the &#039;&#039;&#039;in&#039;&#039;&#039;&lt;br /&gt;
attribute, the rule applies to packets whose ingress interface and&lt;br /&gt;
source address are covered by the zone definition. Correspondingly, if&lt;br /&gt;
a zone is referenced by the &#039;&#039;&#039;out&#039;&#039;&#039; attribute, the rule applies to&lt;br /&gt;
packets whose egress interface and destination address are included in&lt;br /&gt;
the zone. If both &#039;&#039;&#039;in&#039;&#039;&#039; and &#039;&#039;&#039;out&#039;&#039;&#039; are defined, the packet must&lt;br /&gt;
fulfill both criteria in order to match the rule.&lt;br /&gt;
&lt;br /&gt;
=== Rules ===&lt;br /&gt;
&lt;br /&gt;
There are three types of rule objects: &#039;&#039;policies&#039;&#039;, &#039;&#039;filters&#039;&#039;, and&lt;br /&gt;
&#039;&#039;NAT rules&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
All rule objects can have the &#039;&#039;&#039;in&#039;&#039;&#039; and &#039;&#039;&#039;out&#039;&#039;&#039; attributes&lt;br /&gt;
referring to zones as described in the previous section. In addition,&lt;br /&gt;
the scope of the rule can be further constrained with the following&lt;br /&gt;
attributes:&lt;br /&gt;
&lt;br /&gt;
{|&lt;br /&gt;
!Attribute!!Value format!!Effect&lt;br /&gt;
|-&lt;br /&gt;
|&#039;&#039;&#039;src&#039;&#039;&#039;&lt;br /&gt;
|Similar to &#039;&#039;&#039;addr&#039;&#039;&#039; attribute of zone objects&lt;br /&gt;
|Packet&#039;s source address matches the value&lt;br /&gt;
|-&lt;br /&gt;
|&#039;&#039;&#039;dest&#039;&#039;&#039;&lt;br /&gt;
|Similar to &#039;&#039;&#039;addr&#039;&#039;&#039; attribute of zone objects&lt;br /&gt;
|Packet&#039;s destination address matches the value&lt;br /&gt;
|-&lt;br /&gt;
|&#039;&#039;&#039;ipset&#039;&#039;&#039;&lt;br /&gt;
|Object containing two attributes: &#039;&#039;&#039;name&#039;&#039;&#039; referring to an IP set and &#039;&#039;&#039;args&#039;&#039;&#039;, which is a list of strings &#039;&#039;&#039;in&#039;&#039;&#039; and &#039;&#039;&#039;out&#039;&#039;&#039;&lt;br /&gt;
|Packet matches the IP set referred here when the match arguments are taken from the source (&#039;&#039;&#039;in&#039;&#039;&#039;) and destination (&#039;&#039;&#039;out&#039;&#039;&#039;) address or port in the order specified by &#039;&#039;&#039;args&#039;&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
|&#039;&#039;&#039;ipsec&#039;&#039;&#039;&lt;br /&gt;
|&#039;&#039;&#039;in&#039;&#039;&#039; or &#039;&#039;&#039;out&#039;&#039;&#039;&lt;br /&gt;
|IPsec decapsulation perfomed on ingress (&#039;&#039;&#039;in&#039;&#039;&#039;) or encapsulation performed on egress (&#039;&#039;&#039;out&#039;&#039;&#039;)&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Rule objects must have an attribute named &#039;&#039;&#039;action&#039;&#039;&#039;, the value of&lt;br /&gt;
which can be one of the following:&lt;br /&gt;
&lt;br /&gt;
{|&lt;br /&gt;
!Value!!Action&lt;br /&gt;
|-&lt;br /&gt;
|&#039;&#039;&#039;accept&#039;&#039;&#039;&lt;br /&gt;
|Accept the packet&lt;br /&gt;
|-&lt;br /&gt;
|&#039;&#039;&#039;reject&#039;&#039;&#039;&lt;br /&gt;
|Reject the packet with an ICMP error message&lt;br /&gt;
|-&lt;br /&gt;
|&#039;&#039;&#039;drop&#039;&#039;&#039;&lt;br /&gt;
|Silently drop the packet&lt;br /&gt;
|-&lt;br /&gt;
|&#039;&#039;&#039;logreject&#039;&#039;&#039;&lt;br /&gt;
|Similar to &#039;&#039;&#039;reject&#039;&#039;&#039; but with kernel logging&lt;br /&gt;
|-&lt;br /&gt;
|&#039;&#039;&#039;logdrop&#039;&#039;&#039;&lt;br /&gt;
|Similar to &#039;&#039;&#039;drop&#039;&#039;&#039; but with kernel logging&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Rule objects are declared in type-specific top-level dictionaries in&lt;br /&gt;
awall policy files. If a packet matches multiple rules, the one&lt;br /&gt;
appearing earlier in the list takes precedence. If the matching rules&lt;br /&gt;
are in defined by different policy files, the one that was processed&lt;br /&gt;
earlier takes precedence.&lt;br /&gt;
&lt;br /&gt;
==== Filters ====&lt;br /&gt;
&lt;br /&gt;
Filter objects specify an action for packets fulfilling certain&lt;br /&gt;
criteria. The top-level attribute &#039;&#039;&#039;filter&#039;&#039;&#039; is a list of filter&lt;br /&gt;
objects. The precedence rules are similar to those of policy objects.&lt;br /&gt;
&lt;br /&gt;
In addition to the common rule attributes, filter objects can have a&lt;br /&gt;
&#039;&#039;&#039;service&#039;&#039;&#039; attribute constraining the scope to specific services&lt;br /&gt;
only. This attribute is a list of service names, referring to the&lt;br /&gt;
keys of the top-level &#039;&#039;&#039;service&#039;&#039;&#039; dictionary.&lt;br /&gt;
&lt;br /&gt;
Filter objects may also contain limits for packet flow or new&lt;br /&gt;
connections. These are specified with the &#039;&#039;&#039;flow-limit&#039;&#039;&#039; and&lt;br /&gt;
&#039;&#039;&#039;conn-limit&#039;&#039;&#039; attributes, respectively. The values of these&lt;br /&gt;
attributes are limit objects that have two attributes: &#039;&#039;&#039;count&#039;&#039;&#039; and&lt;br /&gt;
&#039;&#039;&#039;interval&#039;&#039;&#039;. &#039;&#039;&#039;count&#039;&#039;&#039; specifies how many new connections or&lt;br /&gt;
packets are allowed within the time frame specified by &#039;&#039;&#039;interval&#039;&#039;&#039;&lt;br /&gt;
(in seconds). The &#039;&#039;&#039;logdrop&#039;&#039;&#039; action is applied to the packets&lt;br /&gt;
exceeding the limit.&lt;br /&gt;
&lt;br /&gt;
Filter objects may have an attribute named &#039;&#039;&#039;dnat&#039;&#039;&#039;, the value of&lt;br /&gt;
which is an IPv4 address. If defined, this enables destination NAT for&lt;br /&gt;
all IPv4 packets matching the rule, such that the specified address&lt;br /&gt;
replaces the original destination address. This option has no effect&lt;br /&gt;
on IPv6 packets.&lt;br /&gt;
&lt;br /&gt;
==== Policies ====&lt;br /&gt;
&lt;br /&gt;
Policy objects describe the default action for packets that did not&lt;br /&gt;
match any filter. The top-level attribute &#039;&#039;&#039;policy&#039;&#039;&#039; is a list of&lt;br /&gt;
policy objects. Policy objects do not have other attributes than those&lt;br /&gt;
common to all rule objects.&lt;br /&gt;
&lt;br /&gt;
==== NAT Rules ====&lt;br /&gt;
&lt;br /&gt;
NAT rules come in two flavors: &#039;&#039;source NAT rules&#039;&#039; and&lt;br /&gt;
&#039;&#039;destination NAT rules&#039;&#039;. These are contained in two top-level lists&lt;br /&gt;
named &#039;&#039;&#039;snat&#039;&#039;&#039; and &#039;&#039;&#039;dnat&#039;&#039;&#039;, respectively.&lt;br /&gt;
&lt;br /&gt;
Each NAT rule must have an attribute named &#039;&#039;&#039;ip-range&#039;&#039;&#039; that&lt;br /&gt;
specifies the IPv4 address range to which the original source or&lt;br /&gt;
destinatinon address is mapped. The value can be a single IPv4 address&lt;br /&gt;
or a range specified by two addresses, separated with the &#039;&#039;&#039;-&#039;&#039;&#039;&lt;br /&gt;
character.&lt;br /&gt;
&lt;br /&gt;
Optionally, a NAT rule can specify the TCP and UDP port range to which&lt;br /&gt;
the original source or destination port is mapped. The attribute is&lt;br /&gt;
named &#039;&#039;&#039;port-range&#039;&#039;&#039;, and the value can be a single port number or a&lt;br /&gt;
range specified by two numbers, separated with the &#039;&#039;&#039;-&#039;&#039;&#039;&lt;br /&gt;
character. If &#039;&#039;&#039;port-range&#039;&#039;&#039; is not specified, the original port&lt;br /&gt;
number is kept intact.&lt;br /&gt;
&lt;br /&gt;
Like filters, NAT rules can have a &#039;&#039;&#039;service&#039;&#039;&#039; attribute&lt;br /&gt;
constraining their scope to specific services.&lt;br /&gt;
&lt;br /&gt;
=== IP Sets ===&lt;br /&gt;
&lt;br /&gt;
Any IP set referenced by rule objects should be created by&lt;br /&gt;
awall. Auxiliary &#039;&#039;IP set&#039;&#039; objects are used to defined them in awall&lt;br /&gt;
policy files. The top-level attribute &#039;&#039;&#039;ipset&#039;&#039;&#039; is a dictionary, the&lt;br /&gt;
keys of which are IP set names. The values are IP set objects, which&lt;br /&gt;
have two mandatory attributes. The attribute named &#039;&#039;&#039;type&#039;&#039;&#039;&lt;br /&gt;
corresponds to the type argument of the &amp;lt;tt&amp;gt;ipset create&amp;lt;/tt&amp;gt;&lt;br /&gt;
command. &#039;&#039;&#039;family&#039;&#039;&#039; specifies whether the set is for IPv4 or IPv6&lt;br /&gt;
addresses, and the possible values are &#039;&#039;&#039;inet&#039;&#039;&#039; and &#039;&#039;&#039;inet6&#039;&#039;&#039;,&lt;br /&gt;
correspondingly.&lt;br /&gt;
&lt;br /&gt;
== Command Line Syntax ==&lt;br /&gt;
&lt;br /&gt;
=== Translating Policy Files to Firewall Configuration Files ===&lt;br /&gt;
&lt;br /&gt;
 &#039;&#039;&#039;awall translate&#039;&#039;&#039; [&#039;&#039;&#039;-o&#039;&#039;&#039;|&#039;&#039;&#039;--output&#039;&#039;&#039; DIRECTORY] [&#039;&#039;&#039;-V&#039;&#039;&#039;|&#039;&#039;&#039;--verify&#039;&#039;&#039;]&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;tt&amp;gt;--verify&amp;lt;/tt&amp;gt; option makes awall verify the configuration&lt;br /&gt;
using the test mode of iptables-restore before overwriting the old&lt;br /&gt;
files.&lt;br /&gt;
&lt;br /&gt;
Specifying the output directory allows testing awall policies without&lt;br /&gt;
overwriting the current iptables and ipset configuration files. By&lt;br /&gt;
default, awall generates the configuration to &amp;lt;tt&amp;gt;/etc/iptables&amp;lt;/tt&amp;gt;&lt;br /&gt;
and &amp;lt;tt&amp;gt;/etc/ipset.d&amp;lt;/tt&amp;gt;, which are read by the init scripts.&lt;br /&gt;
&lt;br /&gt;
=== Run-Time Activation of New Firewall Configuration ===&lt;br /&gt;
&lt;br /&gt;
 &#039;&#039;&#039;awall activate&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
This command genereates firewall configuration from the policy files&lt;br /&gt;
and enables it. If the user confirms the new configuration by hitting&lt;br /&gt;
the Return key within 10 seconds, the configuration is saved to the&lt;br /&gt;
files. Otherwise, the old configuration is restored.&lt;br /&gt;
&lt;br /&gt;
=== Optional Policies ===&lt;br /&gt;
&lt;br /&gt;
Optional policies can be enabled or disabled using this command:&lt;br /&gt;
&lt;br /&gt;
 &#039;&#039;&#039;awall&#039;&#039;&#039; {&#039;&#039;&#039;enable&#039;&#039;&#039;|&#039;&#039;&#039;disable&#039;&#039;&#039;} POLICY...&lt;br /&gt;
&lt;br /&gt;
Optional policies can be listed using this command:&lt;br /&gt;
&lt;br /&gt;
 &#039;&#039;&#039;awall list&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;&#039;enabled&#039;&#039;&#039; status means that the policy has been enabled by the&lt;br /&gt;
user. The &#039;&#039;&#039;disabled&#039;&#039;&#039; status means that the policy is not in&lt;br /&gt;
use. The &#039;&#039;&#039;required&#039;&#039;&#039; status means that the policy has not been&lt;br /&gt;
enabled by the user but is in use because it is required by another&lt;br /&gt;
policy which is in use.&lt;/div&gt;</summary>
		<author><name>Kunkku</name></author>
	</entry>
</feed>