<?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=Tsarna</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=Tsarna"/>
	<link rel="alternate" type="text/html" href="https://wiki.alpinelinux.org/wiki/Special:Contributions/Tsarna"/>
	<updated>2026-05-06T10:51:10Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.40.0</generator>
	<entry>
		<id>https://wiki.alpinelinux.org/w/index.php?title=Zero-To-Awall&amp;diff=17760</id>
		<title>Zero-To-Awall</title>
		<link rel="alternate" type="text/html" href="https://wiki.alpinelinux.org/w/index.php?title=Zero-To-Awall&amp;diff=17760"/>
		<updated>2020-06-28T16:12:28Z</updated>

		<summary type="html">&lt;p&gt;Tsarna: /* Activating firewall rules at boot */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Awall for dummies =&lt;br /&gt;
&lt;br /&gt;
This howto is aimed at users with no (or little) experience with iptables and other firewall frameworks (like Shorewall).&lt;br /&gt;
&lt;br /&gt;
This howto is going to be split into 5 parts.&lt;br /&gt;
&lt;br /&gt;
# Defining our base json file which holds our zones and base policies.&lt;br /&gt;
# Creating service policies.&lt;br /&gt;
# Using aliases and custom services.&lt;br /&gt;
# Enabling and testing policies.&lt;br /&gt;
# Finishing up and making it start (at boot)&lt;br /&gt;
&lt;br /&gt;
NOTE: please be aware that all configuration files are stored as JSON files. JSON is not a human friendly standard, &lt;br /&gt;
for instance it does not support comments so you will have to move them outside of the json structure.&lt;br /&gt;
Beginners should use a decent text editor with JSON highlight support which will make your life easier.&lt;br /&gt;
Since recent versions of [[Alpine Wall|awall]] it is also possible to use yaml instead of json but this is out of the scope of this howto.&lt;br /&gt;
&lt;br /&gt;
== Base policies ==&lt;br /&gt;
&lt;br /&gt;
Creating zones depends on the function of your firewall. Is it installed on a endpoint (server) or will it act as a router and filter/forward.&lt;br /&gt;
For this howto we assume you are going to setup a router and use NAT to forward services (ports) to different hosts on your network.&lt;br /&gt;
&lt;br /&gt;
For each interface on router we will setup a zone and assign it a zone name. We do this by creating the following file: /etc/awall/private/base.json&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
  &amp;quot;description&amp;quot;: &amp;quot;Base zones and policies&amp;quot;,&lt;br /&gt;
&lt;br /&gt;
  &amp;quot;zone&amp;quot;: {&lt;br /&gt;
    &amp;quot;WAN&amp;quot;: { &amp;quot;iface&amp;quot;: &amp;quot;eth0&amp;quot; },&lt;br /&gt;
    &amp;quot;LAN&amp;quot;: { &amp;quot;iface&amp;quot;: &amp;quot;eth1&amp;quot; },&lt;br /&gt;
    &amp;quot;VPN&amp;quot;: { &amp;quot;iface&amp;quot;: &amp;quot;tun+&amp;quot; }&lt;br /&gt;
  },&lt;br /&gt;
&lt;br /&gt;
  &amp;quot;policy&amp;quot;: [&lt;br /&gt;
     { &amp;quot;in&amp;quot;: &amp;quot;VPN&amp;quot;, &amp;quot;action&amp;quot;: &amp;quot;accept&amp;quot; },&lt;br /&gt;
     { &amp;quot;out&amp;quot;: &amp;quot;VPN&amp;quot;, &amp;quot;action&amp;quot;: &amp;quot;accept&amp;quot; },&lt;br /&gt;
     { &amp;quot;in&amp;quot;: &amp;quot;LAN&amp;quot;, &amp;quot;action&amp;quot;: &amp;quot;accept&amp;quot; },&lt;br /&gt;
     { &amp;quot;out&amp;quot;: &amp;quot;LAN&amp;quot;, &amp;quot;action&amp;quot;: &amp;quot;accept&amp;quot; },&lt;br /&gt;
     { &amp;quot;in&amp;quot;: &amp;quot;_fw&amp;quot;, &amp;quot;action&amp;quot;: &amp;quot;accept&amp;quot; },&lt;br /&gt;
     { &amp;quot;in&amp;quot;: &amp;quot;_fw&amp;quot;, &amp;quot;out&amp;quot;:  &amp;quot;WAN&amp;quot; , &amp;quot;action&amp;quot;: &amp;quot;accept&amp;quot; },&lt;br /&gt;
     { &amp;quot;in&amp;quot;: &amp;quot;WAN&amp;quot;, &amp;quot;action&amp;quot;: &amp;quot;drop&amp;quot; }&lt;br /&gt;
  ],&lt;br /&gt;
&lt;br /&gt;
  &amp;quot;snat&amp;quot;: [ { &amp;quot;out&amp;quot;: &amp;quot;WAN&amp;quot; } ],&lt;br /&gt;
&lt;br /&gt;
  &amp;quot;clamp-mss&amp;quot;: [ { &amp;quot;out&amp;quot;: &amp;quot;WAN&amp;quot; } ]&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Lets break this down into sections&lt;br /&gt;
&lt;br /&gt;
=== description ===&lt;br /&gt;
&lt;br /&gt;
The description is here just for reference and will be used by &amp;lt;code&amp;gt;awall list&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
=== zone ===&lt;br /&gt;
&lt;br /&gt;
This is where our zones are defined. Zones are defined based on a interface and assigned a name to be used in your policies.&lt;br /&gt;
In our example you can see that we have two real interfaces eth0 and eth1 and one or more virtual interfaces tun+ (the plus sign stands for any digit like tun0 tun1 and so on). In case you are installing awall on an endpoint (a server) then you will most probably not have the eth1 interfaces and can leave it out. In our example the tun+ interface is added as it is very commonly used like when using openvpn.&lt;br /&gt;
&lt;br /&gt;
=== policy ===&lt;br /&gt;
&lt;br /&gt;
These are our main policies. It will tell our firewall what to do with when a packet enters or leaves from one of the zones (interfaces).&lt;br /&gt;
You will notice a special &amp;lt;code&amp;gt;_fw&amp;lt;/code&amp;gt; name which means the internal firewall (the local machine) which means the packet does not leave the firewall via another interface but should be send to one of the local services.&lt;br /&gt;
You can see that we by default do not filter any package coming from or going to our VPN zone/interface. You could instead change the default action to drop all packets and create separate policies to allow specific traffic but this is out of the scope of this howto.&lt;br /&gt;
&lt;br /&gt;
=== snat ===&lt;br /&gt;
&lt;br /&gt;
Apply source nat for outgoing packets. This is only needed if your firewall acts as a router and traffic behind the router needs a modified source address (translate from local ip to public ip).&lt;br /&gt;
&lt;br /&gt;
=== clamp-mss ===&lt;br /&gt;
&lt;br /&gt;
https://github.com/alpinelinux/awall#mss-clamping-rules&lt;br /&gt;
&lt;br /&gt;
== Service policies ==&lt;br /&gt;
&lt;br /&gt;
Now that we have the base firewall in place we can start to define specific policies so our services will be reachable from the outside world.\&lt;br /&gt;
By default we are blocking all traffic coming in on our WAN interface (action=drop). The first thing we want to open is our SSH port/service. To do this we need to create a new policy inside the &amp;quot;optional&amp;quot; directory.&lt;br /&gt;
You could be wondering why the optional name, thats is because mandatory policies are stored in &amp;lt;code&amp;gt;/usr/share/awall/mandatory&amp;lt;/code&amp;gt; and not to be touched and our optional policies can be enabled/disabled on the run.&lt;br /&gt;
&lt;br /&gt;
=== SSH service ===&lt;br /&gt;
&lt;br /&gt;
To add our SSH policies we create a new file: /etc/awall/optional/ssh.json&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
  &amp;quot;description&amp;quot;: &amp;quot;Allow rate-limited SSH on WAN&amp;quot;,&lt;br /&gt;
&lt;br /&gt;
  &amp;quot;filter&amp;quot;: [&lt;br /&gt;
    {&lt;br /&gt;
      &amp;quot;in&amp;quot;: &amp;quot;WAN&amp;quot;,&lt;br /&gt;
      &amp;quot;out&amp;quot;: &amp;quot;_fw&amp;quot;,&lt;br /&gt;
      &amp;quot;service&amp;quot;: &amp;quot;ssh&amp;quot;,&lt;br /&gt;
      &amp;quot;action&amp;quot;: &amp;quot;accept&amp;quot;,&lt;br /&gt;
      &amp;quot;conn-limit&amp;quot;: { &amp;quot;count&amp;quot;: 3, &amp;quot;interval&amp;quot;: 20 }&lt;br /&gt;
    }&lt;br /&gt;
  ]&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== description ====&lt;br /&gt;
&lt;br /&gt;
This is similar for any policy&lt;br /&gt;
&lt;br /&gt;
==== Filter ====&lt;br /&gt;
&lt;br /&gt;
This is the actual filter that is currently set to drop the packets arriving or leaving the interface.&lt;br /&gt;
&lt;br /&gt;
===== in =====&lt;br /&gt;
&lt;br /&gt;
The interface the packets arrive on, in this case its the WAN interface.&lt;br /&gt;
&lt;br /&gt;
===== out =====&lt;br /&gt;
&lt;br /&gt;
The interface the packets leave on, in this case its _fw which means it does not leave our firewall/device and is targeted at our local SSH service.&lt;br /&gt;
&lt;br /&gt;
===== service =====&lt;br /&gt;
&lt;br /&gt;
This is the service definition provided by awall or a custom service which we will discuss later on.&lt;br /&gt;
&lt;br /&gt;
===== action =====&lt;br /&gt;
&lt;br /&gt;
The action on the packet, this inverts the default action of drop and accepts the packets.&lt;br /&gt;
&lt;br /&gt;
===== conn-limit =====&lt;br /&gt;
&lt;br /&gt;
This is a special feature of our firewall/iptables to allow only a certain amount of packets in a certain amount of time. For more information please check our awall manual.&lt;br /&gt;
&lt;br /&gt;
=== SSH to another Host ===&lt;br /&gt;
&lt;br /&gt;
edit the following file: /etc/awall/optional/ssh-to-hostname.json&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
&lt;br /&gt;
  &amp;quot;description&amp;quot;: &amp;quot;Forward SSH to hostname&amp;quot;,&lt;br /&gt;
&lt;br /&gt;
  &amp;quot;filter&amp;quot;: [&lt;br /&gt;
    {&lt;br /&gt;
      &amp;quot;in&amp;quot;: &amp;quot;WAN&amp;quot;,&lt;br /&gt;
      &amp;quot;service&amp;quot;: { &amp;quot;proto&amp;quot;: &amp;quot;tcp&amp;quot;, &amp;quot;port&amp;quot;: 22001 },&lt;br /&gt;
      &amp;quot;action&amp;quot;: &amp;quot;accept&amp;quot;,&lt;br /&gt;
      &amp;quot;conn-limit&amp;quot;: { &amp;quot;count&amp;quot;: 3, &amp;quot;interval&amp;quot;: 20 }&lt;br /&gt;
    }&lt;br /&gt;
  ],&lt;br /&gt;
&lt;br /&gt;
  &amp;quot;dnat&amp;quot;: [&lt;br /&gt;
    {&lt;br /&gt;
      &amp;quot;in&amp;quot;: &amp;quot;WAN&amp;quot;,&lt;br /&gt;
      &amp;quot;dest&amp;quot;: &amp;quot;$SERVER&amp;quot;,&lt;br /&gt;
      &amp;quot;service&amp;quot;: { &amp;quot;proto&amp;quot;: &amp;quot;tcp&amp;quot;, &amp;quot;port&amp;quot;: 22001 },&lt;br /&gt;
      &amp;quot;to-port&amp;quot;: &amp;quot;22&amp;quot;&lt;br /&gt;
    }&lt;br /&gt;
  ]&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Lets discuss the differences between this policy and the previous SSH policy.&lt;br /&gt;
&lt;br /&gt;
==== Filter ====&lt;br /&gt;
&lt;br /&gt;
===== service =====&lt;br /&gt;
&lt;br /&gt;
Because port 22 is already in use by our own firewall, we need to listen on a different port. In this example we listen on port 22001.&lt;br /&gt;
And because we are not using the default port 22 we need to define our own service specification.&lt;br /&gt;
&lt;br /&gt;
==== dnat ====&lt;br /&gt;
&lt;br /&gt;
Also known as destination NAT.&lt;br /&gt;
&lt;br /&gt;
===== dest =====&lt;br /&gt;
&lt;br /&gt;
The destination the packet will be forwarded to. In this case we are using a variable named $HOSTNAME. Anywhere in your policies you can define your own variables and use them.&lt;br /&gt;
In our case we have used a file in /etc/awall/private/aliases.json more on this topic later on.&lt;br /&gt;
&lt;br /&gt;
===== to-port =====&lt;br /&gt;
&lt;br /&gt;
This is the destination target port number. The packet will be forwarded from 22001 to 22 on the $hostname&lt;br /&gt;
&lt;br /&gt;
=== OpenVPN Service ===&lt;br /&gt;
&lt;br /&gt;
This is the most generic config available. It does nothing more then opening port(s) defined for our openvpn service in &amp;lt;code&amp;gt;/etc/awall/private/custom-services.json&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
&lt;br /&gt;
    &amp;quot;description&amp;quot;: &amp;quot;Allow local OpenVPN&amp;quot;,&lt;br /&gt;
&lt;br /&gt;
    &amp;quot;filter&amp;quot;: [&lt;br /&gt;
        {&lt;br /&gt;
            &amp;quot;in&amp;quot;: &amp;quot;WAN&amp;quot;,&lt;br /&gt;
            &amp;quot;out&amp;quot;: &amp;quot;_fw&amp;quot;,&lt;br /&gt;
            &amp;quot;service&amp;quot;: &amp;quot;openvpn&amp;quot;,&lt;br /&gt;
            &amp;quot;action&amp;quot;: &amp;quot;accept&amp;quot;&lt;br /&gt;
        }&lt;br /&gt;
    ]&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Allow ping on WAN ===&lt;br /&gt;
&lt;br /&gt;
Allow rate-limited ping on WAN. Which has the same kind of flow limit as our previous SSH policy.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
&lt;br /&gt;
  &amp;quot;description&amp;quot;: &amp;quot;Allow rate-limited ping on WAN&amp;quot;,&lt;br /&gt;
&lt;br /&gt;
  &amp;quot;filter&amp;quot;: [&lt;br /&gt;
    {&lt;br /&gt;
      &amp;quot;in&amp;quot;: &amp;quot;WAN&amp;quot;,&lt;br /&gt;
      &amp;quot;out&amp;quot;: &amp;quot;_fw&amp;quot;,&lt;br /&gt;
      &amp;quot;service&amp;quot;: &amp;quot;ping&amp;quot;,&lt;br /&gt;
      &amp;quot;action&amp;quot;: &amp;quot;accept&amp;quot;,&lt;br /&gt;
      &amp;quot;flow-limit&amp;quot;: { &amp;quot;count&amp;quot;: 10, &amp;quot;interval&amp;quot;: 6 }&lt;br /&gt;
    }&lt;br /&gt;
  ]&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Using aliases and custom services ==&lt;br /&gt;
&lt;br /&gt;
=== Aliases ===&lt;br /&gt;
&lt;br /&gt;
To make life easier when your firewall rules increase, it can be nice to map specific hosts to names.&lt;br /&gt;
Awall supports something called [https://github.com/alpinelinux/awall#variable-expansion variable expansion] which is a mapping between a value and a variable.&lt;br /&gt;
When you have many devices behind your firewall/router, your policies can be harder to read. Also when one of your devices IP address change you will have to update all of your policies.&lt;br /&gt;
With awalls variables you can assign the ip address of a device to a variable name. Edit the following file: &amp;lt;code&amp;gt;/etc/awall/private/aliases.json&amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
  &amp;quot;description&amp;quot;: &amp;quot;Hostname aliases&amp;quot;,&lt;br /&gt;
&lt;br /&gt;
  &amp;quot;variable&amp;quot;: {&lt;br /&gt;
    &amp;quot;PRINTER&amp;quot;: &amp;quot;192.168.1.1&amp;quot;,&lt;br /&gt;
    &amp;quot;SERVER&amp;quot;: &amp;quot;192.168.1.2&amp;quot;&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Look in the example above where $SERVER is used to forward port 22001 to port 22.&lt;br /&gt;
&lt;br /&gt;
NOTE: You are not limited to assigning only IP addresses to variables. You can use it however you like. More information can be found in the awall manual.&lt;br /&gt;
&lt;br /&gt;
=== Custom services ===&lt;br /&gt;
&lt;br /&gt;
Awall includes a predefined list of [https://github.com/alpinelinux/awall/blob/master/json/services.json services]. If the service you try to define in your policy does not exist in awalls services list you can define services yourself.&lt;br /&gt;
&lt;br /&gt;
Create the file: &amp;lt;code&amp;gt;/etc/awall/private/custom-services.json&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;service&amp;quot;: {&lt;br /&gt;
&lt;br /&gt;
        &amp;quot;mqtt&amp;quot;: [&lt;br /&gt;
            { &amp;quot;proto&amp;quot;: &amp;quot;udp&amp;quot;, &amp;quot;port&amp;quot;: 1883 },&lt;br /&gt;
            { &amp;quot;proto&amp;quot;: &amp;quot;tcp&amp;quot;, &amp;quot;port&amp;quot;: 1883 }&lt;br /&gt;
        ],&lt;br /&gt;
&lt;br /&gt;
        &amp;quot;openvpn&amp;quot;: [&lt;br /&gt;
            { &amp;quot;proto&amp;quot;: &amp;quot;udp&amp;quot;, &amp;quot;port&amp;quot;: 1194 },&lt;br /&gt;
            { &amp;quot;proto&amp;quot;: &amp;quot;tcp&amp;quot;, &amp;quot;port&amp;quot;: 1194 }&lt;br /&gt;
        ]&lt;br /&gt;
&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
NOTE: although you are free to name your policy files however you want, you cannot name this file &amp;lt;code&amp;gt;services.json&amp;lt;/code&amp;gt; because this policy name is already in use by the included services.json of awall.&lt;br /&gt;
&lt;br /&gt;
== Using our policies ==&lt;br /&gt;
&lt;br /&gt;
You should now have two directories in your awall config directory named optional and private with multiple json files. The biggest difference between these two directories is the ability to enable and disable policies located in the optional directory. When you enable a policy by using &amp;lt;code&amp;gt;awall enable policy-name&amp;lt;/code&amp;gt; awall will generate a symlink in your awall config directory and will automatically load them when you activate the firewall. To be able to also use the files in the private directory we will need to include them in one of our optional policies. You can name the file however you like as long it doesn&#039;t conflict with existing policies names (including the ones in private directory and awall&#039;s system policies). Example names would be hostname.json main.json firewall.json. For this example we will use main.json.&lt;br /&gt;
&lt;br /&gt;
Create the file: &amp;lt;code&amp;gt;/etc/awall/optional/main.json&amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
  &amp;quot;description&amp;quot;: &amp;quot;Main firewall&amp;quot;,&lt;br /&gt;
&lt;br /&gt;
  &amp;quot;import&amp;quot;: [ &amp;quot;base&amp;quot;, &amp;quot;aliases&amp;quot;, &amp;quot;custom-services&amp;quot; ]&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Contents of your awall directory:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
awall&lt;br /&gt;
│&lt;br /&gt;
├── optional&lt;br /&gt;
│   ├── main.json&lt;br /&gt;
│   ├── openvpn.json&lt;br /&gt;
│   ├── ssh-to-hostname.json&lt;br /&gt;
│   └── ssh.json&lt;br /&gt;
└── private&lt;br /&gt;
    ├── aliases.json&lt;br /&gt;
    ├── base.json&lt;br /&gt;
    └── custom-services.json&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Enabling optional policies ===&lt;br /&gt;
&lt;br /&gt;
Lets enable our created policies. First we list them by running &amp;lt;code&amp;gt;awall list&amp;lt;/code&amp;gt; which would show something like:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
openvpn         disabled  Allow local OpenVPN&lt;br /&gt;
main            disabled  Main firewall&lt;br /&gt;
ping            disabled  Allow rate-limited ping on WAN&lt;br /&gt;
ssh             disabled  Allow rate-limited SSH on WAN&lt;br /&gt;
ssh-to-hostname disabled  Forward SSH to hostname&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Each of these needs to be enabled:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
awall enable openvpn&lt;br /&gt;
awall enable main&lt;br /&gt;
awall enable ping&lt;br /&gt;
awall enable ssh&lt;br /&gt;
awall enable ssh-to-hostname&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The contents of your awall directory should now look like:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
awall/&lt;br /&gt;
├── main.json -&amp;gt; ./optional/main.json&lt;br /&gt;
├── openvpn.json -&amp;gt; ./optional/openvpn.json&lt;br /&gt;
├── optional&lt;br /&gt;
│   ├── main.json&lt;br /&gt;
│   ├── openvpn.json&lt;br /&gt;
│   ├── ping.json&lt;br /&gt;
│   ├── ssh-to-hostname.json&lt;br /&gt;
│   └── ssh.json&lt;br /&gt;
├── ping.json -&amp;gt; ./optional/ping.json&lt;br /&gt;
├── private&lt;br /&gt;
│   ├── aliases.json&lt;br /&gt;
│   ├── base.json&lt;br /&gt;
│   └── custom-services.json&lt;br /&gt;
├── ssh-to-hostname.json -&amp;gt; ./optional/ssh-to-hostname.json&lt;br /&gt;
└── ssh.json -&amp;gt; ./optional/ssh.json&lt;br /&gt;
&lt;br /&gt;
2 directories, 13 files&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Testing policies ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;awall translate --verify&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
if everything goes well the output should be null.&lt;br /&gt;
&lt;br /&gt;
=== Activating the firewall ===&lt;br /&gt;
&lt;br /&gt;
Now that all our policies are verified for proper json we can activate it.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;awall activate&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This will load the firewall rules and show you a message to confirm. If by accident you made a mistake and lock yourself out you just have to wait for awall to disable itself again.&lt;br /&gt;
&lt;br /&gt;
== Finishing up ==&lt;br /&gt;
&lt;br /&gt;
=== Activating firewall rules at boot ===&lt;br /&gt;
&lt;br /&gt;
When awall has been properly activated it will generate a file with all iptables rules which iptables will read when its is started via openrc.&lt;br /&gt;
Make sure you have added iptables to an openrc runlevel. If using snat, also enable ipset for the masquerade set.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;rc-update add iptables&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;rc-update add ipset&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Allow IPv4 forwarding ===&lt;br /&gt;
&lt;br /&gt;
To allow iptables to forward packets from one zone to the other we need to enable this at the iptables level.&lt;br /&gt;
&lt;br /&gt;
==== On the fly ====&lt;br /&gt;
&lt;br /&gt;
To enable it on the fly:&lt;br /&gt;
&amp;lt;code&amp;gt;sysctl -w net.ipv4.ip_forward=1&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Enable within iptables tools (at boot) ====&lt;br /&gt;
&lt;br /&gt;
Add the following to:&lt;br /&gt;
&amp;lt;code&amp;gt;/etc/conf.d/iptables&amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Enable/disable IPv4 forwarding with the rules&lt;br /&gt;
IPFORWARD=&amp;quot;yes&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= See also =&lt;br /&gt;
* [[How-To Alpine Wall]]&lt;br /&gt;
&lt;br /&gt;
[[Category:Security]]&lt;/div&gt;</summary>
		<author><name>Tsarna</name></author>
	</entry>
	<entry>
		<id>https://wiki.alpinelinux.org/w/index.php?title=Zero-To-Awall&amp;diff=17759</id>
		<title>Zero-To-Awall</title>
		<link rel="alternate" type="text/html" href="https://wiki.alpinelinux.org/w/index.php?title=Zero-To-Awall&amp;diff=17759"/>
		<updated>2020-06-28T16:11:49Z</updated>

		<summary type="html">&lt;p&gt;Tsarna: /* Activating firewall rules at boot */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Awall for dummies =&lt;br /&gt;
&lt;br /&gt;
This howto is aimed at users with no (or little) experience with iptables and other firewall frameworks (like Shorewall).&lt;br /&gt;
&lt;br /&gt;
This howto is going to be split into 5 parts.&lt;br /&gt;
&lt;br /&gt;
# Defining our base json file which holds our zones and base policies.&lt;br /&gt;
# Creating service policies.&lt;br /&gt;
# Using aliases and custom services.&lt;br /&gt;
# Enabling and testing policies.&lt;br /&gt;
# Finishing up and making it start (at boot)&lt;br /&gt;
&lt;br /&gt;
NOTE: please be aware that all configuration files are stored as JSON files. JSON is not a human friendly standard, &lt;br /&gt;
for instance it does not support comments so you will have to move them outside of the json structure.&lt;br /&gt;
Beginners should use a decent text editor with JSON highlight support which will make your life easier.&lt;br /&gt;
Since recent versions of [[Alpine Wall|awall]] it is also possible to use yaml instead of json but this is out of the scope of this howto.&lt;br /&gt;
&lt;br /&gt;
== Base policies ==&lt;br /&gt;
&lt;br /&gt;
Creating zones depends on the function of your firewall. Is it installed on a endpoint (server) or will it act as a router and filter/forward.&lt;br /&gt;
For this howto we assume you are going to setup a router and use NAT to forward services (ports) to different hosts on your network.&lt;br /&gt;
&lt;br /&gt;
For each interface on router we will setup a zone and assign it a zone name. We do this by creating the following file: /etc/awall/private/base.json&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
  &amp;quot;description&amp;quot;: &amp;quot;Base zones and policies&amp;quot;,&lt;br /&gt;
&lt;br /&gt;
  &amp;quot;zone&amp;quot;: {&lt;br /&gt;
    &amp;quot;WAN&amp;quot;: { &amp;quot;iface&amp;quot;: &amp;quot;eth0&amp;quot; },&lt;br /&gt;
    &amp;quot;LAN&amp;quot;: { &amp;quot;iface&amp;quot;: &amp;quot;eth1&amp;quot; },&lt;br /&gt;
    &amp;quot;VPN&amp;quot;: { &amp;quot;iface&amp;quot;: &amp;quot;tun+&amp;quot; }&lt;br /&gt;
  },&lt;br /&gt;
&lt;br /&gt;
  &amp;quot;policy&amp;quot;: [&lt;br /&gt;
     { &amp;quot;in&amp;quot;: &amp;quot;VPN&amp;quot;, &amp;quot;action&amp;quot;: &amp;quot;accept&amp;quot; },&lt;br /&gt;
     { &amp;quot;out&amp;quot;: &amp;quot;VPN&amp;quot;, &amp;quot;action&amp;quot;: &amp;quot;accept&amp;quot; },&lt;br /&gt;
     { &amp;quot;in&amp;quot;: &amp;quot;LAN&amp;quot;, &amp;quot;action&amp;quot;: &amp;quot;accept&amp;quot; },&lt;br /&gt;
     { &amp;quot;out&amp;quot;: &amp;quot;LAN&amp;quot;, &amp;quot;action&amp;quot;: &amp;quot;accept&amp;quot; },&lt;br /&gt;
     { &amp;quot;in&amp;quot;: &amp;quot;_fw&amp;quot;, &amp;quot;action&amp;quot;: &amp;quot;accept&amp;quot; },&lt;br /&gt;
     { &amp;quot;in&amp;quot;: &amp;quot;_fw&amp;quot;, &amp;quot;out&amp;quot;:  &amp;quot;WAN&amp;quot; , &amp;quot;action&amp;quot;: &amp;quot;accept&amp;quot; },&lt;br /&gt;
     { &amp;quot;in&amp;quot;: &amp;quot;WAN&amp;quot;, &amp;quot;action&amp;quot;: &amp;quot;drop&amp;quot; }&lt;br /&gt;
  ],&lt;br /&gt;
&lt;br /&gt;
  &amp;quot;snat&amp;quot;: [ { &amp;quot;out&amp;quot;: &amp;quot;WAN&amp;quot; } ],&lt;br /&gt;
&lt;br /&gt;
  &amp;quot;clamp-mss&amp;quot;: [ { &amp;quot;out&amp;quot;: &amp;quot;WAN&amp;quot; } ]&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Lets break this down into sections&lt;br /&gt;
&lt;br /&gt;
=== description ===&lt;br /&gt;
&lt;br /&gt;
The description is here just for reference and will be used by &amp;lt;code&amp;gt;awall list&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
=== zone ===&lt;br /&gt;
&lt;br /&gt;
This is where our zones are defined. Zones are defined based on a interface and assigned a name to be used in your policies.&lt;br /&gt;
In our example you can see that we have two real interfaces eth0 and eth1 and one or more virtual interfaces tun+ (the plus sign stands for any digit like tun0 tun1 and so on). In case you are installing awall on an endpoint (a server) then you will most probably not have the eth1 interfaces and can leave it out. In our example the tun+ interface is added as it is very commonly used like when using openvpn.&lt;br /&gt;
&lt;br /&gt;
=== policy ===&lt;br /&gt;
&lt;br /&gt;
These are our main policies. It will tell our firewall what to do with when a packet enters or leaves from one of the zones (interfaces).&lt;br /&gt;
You will notice a special &amp;lt;code&amp;gt;_fw&amp;lt;/code&amp;gt; name which means the internal firewall (the local machine) which means the packet does not leave the firewall via another interface but should be send to one of the local services.&lt;br /&gt;
You can see that we by default do not filter any package coming from or going to our VPN zone/interface. You could instead change the default action to drop all packets and create separate policies to allow specific traffic but this is out of the scope of this howto.&lt;br /&gt;
&lt;br /&gt;
=== snat ===&lt;br /&gt;
&lt;br /&gt;
Apply source nat for outgoing packets. This is only needed if your firewall acts as a router and traffic behind the router needs a modified source address (translate from local ip to public ip).&lt;br /&gt;
&lt;br /&gt;
=== clamp-mss ===&lt;br /&gt;
&lt;br /&gt;
https://github.com/alpinelinux/awall#mss-clamping-rules&lt;br /&gt;
&lt;br /&gt;
== Service policies ==&lt;br /&gt;
&lt;br /&gt;
Now that we have the base firewall in place we can start to define specific policies so our services will be reachable from the outside world.\&lt;br /&gt;
By default we are blocking all traffic coming in on our WAN interface (action=drop). The first thing we want to open is our SSH port/service. To do this we need to create a new policy inside the &amp;quot;optional&amp;quot; directory.&lt;br /&gt;
You could be wondering why the optional name, thats is because mandatory policies are stored in &amp;lt;code&amp;gt;/usr/share/awall/mandatory&amp;lt;/code&amp;gt; and not to be touched and our optional policies can be enabled/disabled on the run.&lt;br /&gt;
&lt;br /&gt;
=== SSH service ===&lt;br /&gt;
&lt;br /&gt;
To add our SSH policies we create a new file: /etc/awall/optional/ssh.json&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
  &amp;quot;description&amp;quot;: &amp;quot;Allow rate-limited SSH on WAN&amp;quot;,&lt;br /&gt;
&lt;br /&gt;
  &amp;quot;filter&amp;quot;: [&lt;br /&gt;
    {&lt;br /&gt;
      &amp;quot;in&amp;quot;: &amp;quot;WAN&amp;quot;,&lt;br /&gt;
      &amp;quot;out&amp;quot;: &amp;quot;_fw&amp;quot;,&lt;br /&gt;
      &amp;quot;service&amp;quot;: &amp;quot;ssh&amp;quot;,&lt;br /&gt;
      &amp;quot;action&amp;quot;: &amp;quot;accept&amp;quot;,&lt;br /&gt;
      &amp;quot;conn-limit&amp;quot;: { &amp;quot;count&amp;quot;: 3, &amp;quot;interval&amp;quot;: 20 }&lt;br /&gt;
    }&lt;br /&gt;
  ]&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== description ====&lt;br /&gt;
&lt;br /&gt;
This is similar for any policy&lt;br /&gt;
&lt;br /&gt;
==== Filter ====&lt;br /&gt;
&lt;br /&gt;
This is the actual filter that is currently set to drop the packets arriving or leaving the interface.&lt;br /&gt;
&lt;br /&gt;
===== in =====&lt;br /&gt;
&lt;br /&gt;
The interface the packets arrive on, in this case its the WAN interface.&lt;br /&gt;
&lt;br /&gt;
===== out =====&lt;br /&gt;
&lt;br /&gt;
The interface the packets leave on, in this case its _fw which means it does not leave our firewall/device and is targeted at our local SSH service.&lt;br /&gt;
&lt;br /&gt;
===== service =====&lt;br /&gt;
&lt;br /&gt;
This is the service definition provided by awall or a custom service which we will discuss later on.&lt;br /&gt;
&lt;br /&gt;
===== action =====&lt;br /&gt;
&lt;br /&gt;
The action on the packet, this inverts the default action of drop and accepts the packets.&lt;br /&gt;
&lt;br /&gt;
===== conn-limit =====&lt;br /&gt;
&lt;br /&gt;
This is a special feature of our firewall/iptables to allow only a certain amount of packets in a certain amount of time. For more information please check our awall manual.&lt;br /&gt;
&lt;br /&gt;
=== SSH to another Host ===&lt;br /&gt;
&lt;br /&gt;
edit the following file: /etc/awall/optional/ssh-to-hostname.json&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
&lt;br /&gt;
  &amp;quot;description&amp;quot;: &amp;quot;Forward SSH to hostname&amp;quot;,&lt;br /&gt;
&lt;br /&gt;
  &amp;quot;filter&amp;quot;: [&lt;br /&gt;
    {&lt;br /&gt;
      &amp;quot;in&amp;quot;: &amp;quot;WAN&amp;quot;,&lt;br /&gt;
      &amp;quot;service&amp;quot;: { &amp;quot;proto&amp;quot;: &amp;quot;tcp&amp;quot;, &amp;quot;port&amp;quot;: 22001 },&lt;br /&gt;
      &amp;quot;action&amp;quot;: &amp;quot;accept&amp;quot;,&lt;br /&gt;
      &amp;quot;conn-limit&amp;quot;: { &amp;quot;count&amp;quot;: 3, &amp;quot;interval&amp;quot;: 20 }&lt;br /&gt;
    }&lt;br /&gt;
  ],&lt;br /&gt;
&lt;br /&gt;
  &amp;quot;dnat&amp;quot;: [&lt;br /&gt;
    {&lt;br /&gt;
      &amp;quot;in&amp;quot;: &amp;quot;WAN&amp;quot;,&lt;br /&gt;
      &amp;quot;dest&amp;quot;: &amp;quot;$SERVER&amp;quot;,&lt;br /&gt;
      &amp;quot;service&amp;quot;: { &amp;quot;proto&amp;quot;: &amp;quot;tcp&amp;quot;, &amp;quot;port&amp;quot;: 22001 },&lt;br /&gt;
      &amp;quot;to-port&amp;quot;: &amp;quot;22&amp;quot;&lt;br /&gt;
    }&lt;br /&gt;
  ]&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Lets discuss the differences between this policy and the previous SSH policy.&lt;br /&gt;
&lt;br /&gt;
==== Filter ====&lt;br /&gt;
&lt;br /&gt;
===== service =====&lt;br /&gt;
&lt;br /&gt;
Because port 22 is already in use by our own firewall, we need to listen on a different port. In this example we listen on port 22001.&lt;br /&gt;
And because we are not using the default port 22 we need to define our own service specification.&lt;br /&gt;
&lt;br /&gt;
==== dnat ====&lt;br /&gt;
&lt;br /&gt;
Also known as destination NAT.&lt;br /&gt;
&lt;br /&gt;
===== dest =====&lt;br /&gt;
&lt;br /&gt;
The destination the packet will be forwarded to. In this case we are using a variable named $HOSTNAME. Anywhere in your policies you can define your own variables and use them.&lt;br /&gt;
In our case we have used a file in /etc/awall/private/aliases.json more on this topic later on.&lt;br /&gt;
&lt;br /&gt;
===== to-port =====&lt;br /&gt;
&lt;br /&gt;
This is the destination target port number. The packet will be forwarded from 22001 to 22 on the $hostname&lt;br /&gt;
&lt;br /&gt;
=== OpenVPN Service ===&lt;br /&gt;
&lt;br /&gt;
This is the most generic config available. It does nothing more then opening port(s) defined for our openvpn service in &amp;lt;code&amp;gt;/etc/awall/private/custom-services.json&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
&lt;br /&gt;
    &amp;quot;description&amp;quot;: &amp;quot;Allow local OpenVPN&amp;quot;,&lt;br /&gt;
&lt;br /&gt;
    &amp;quot;filter&amp;quot;: [&lt;br /&gt;
        {&lt;br /&gt;
            &amp;quot;in&amp;quot;: &amp;quot;WAN&amp;quot;,&lt;br /&gt;
            &amp;quot;out&amp;quot;: &amp;quot;_fw&amp;quot;,&lt;br /&gt;
            &amp;quot;service&amp;quot;: &amp;quot;openvpn&amp;quot;,&lt;br /&gt;
            &amp;quot;action&amp;quot;: &amp;quot;accept&amp;quot;&lt;br /&gt;
        }&lt;br /&gt;
    ]&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Allow ping on WAN ===&lt;br /&gt;
&lt;br /&gt;
Allow rate-limited ping on WAN. Which has the same kind of flow limit as our previous SSH policy.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
&lt;br /&gt;
  &amp;quot;description&amp;quot;: &amp;quot;Allow rate-limited ping on WAN&amp;quot;,&lt;br /&gt;
&lt;br /&gt;
  &amp;quot;filter&amp;quot;: [&lt;br /&gt;
    {&lt;br /&gt;
      &amp;quot;in&amp;quot;: &amp;quot;WAN&amp;quot;,&lt;br /&gt;
      &amp;quot;out&amp;quot;: &amp;quot;_fw&amp;quot;,&lt;br /&gt;
      &amp;quot;service&amp;quot;: &amp;quot;ping&amp;quot;,&lt;br /&gt;
      &amp;quot;action&amp;quot;: &amp;quot;accept&amp;quot;,&lt;br /&gt;
      &amp;quot;flow-limit&amp;quot;: { &amp;quot;count&amp;quot;: 10, &amp;quot;interval&amp;quot;: 6 }&lt;br /&gt;
    }&lt;br /&gt;
  ]&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Using aliases and custom services ==&lt;br /&gt;
&lt;br /&gt;
=== Aliases ===&lt;br /&gt;
&lt;br /&gt;
To make life easier when your firewall rules increase, it can be nice to map specific hosts to names.&lt;br /&gt;
Awall supports something called [https://github.com/alpinelinux/awall#variable-expansion variable expansion] which is a mapping between a value and a variable.&lt;br /&gt;
When you have many devices behind your firewall/router, your policies can be harder to read. Also when one of your devices IP address change you will have to update all of your policies.&lt;br /&gt;
With awalls variables you can assign the ip address of a device to a variable name. Edit the following file: &amp;lt;code&amp;gt;/etc/awall/private/aliases.json&amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
  &amp;quot;description&amp;quot;: &amp;quot;Hostname aliases&amp;quot;,&lt;br /&gt;
&lt;br /&gt;
  &amp;quot;variable&amp;quot;: {&lt;br /&gt;
    &amp;quot;PRINTER&amp;quot;: &amp;quot;192.168.1.1&amp;quot;,&lt;br /&gt;
    &amp;quot;SERVER&amp;quot;: &amp;quot;192.168.1.2&amp;quot;&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Look in the example above where $SERVER is used to forward port 22001 to port 22.&lt;br /&gt;
&lt;br /&gt;
NOTE: You are not limited to assigning only IP addresses to variables. You can use it however you like. More information can be found in the awall manual.&lt;br /&gt;
&lt;br /&gt;
=== Custom services ===&lt;br /&gt;
&lt;br /&gt;
Awall includes a predefined list of [https://github.com/alpinelinux/awall/blob/master/json/services.json services]. If the service you try to define in your policy does not exist in awalls services list you can define services yourself.&lt;br /&gt;
&lt;br /&gt;
Create the file: &amp;lt;code&amp;gt;/etc/awall/private/custom-services.json&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;service&amp;quot;: {&lt;br /&gt;
&lt;br /&gt;
        &amp;quot;mqtt&amp;quot;: [&lt;br /&gt;
            { &amp;quot;proto&amp;quot;: &amp;quot;udp&amp;quot;, &amp;quot;port&amp;quot;: 1883 },&lt;br /&gt;
            { &amp;quot;proto&amp;quot;: &amp;quot;tcp&amp;quot;, &amp;quot;port&amp;quot;: 1883 }&lt;br /&gt;
        ],&lt;br /&gt;
&lt;br /&gt;
        &amp;quot;openvpn&amp;quot;: [&lt;br /&gt;
            { &amp;quot;proto&amp;quot;: &amp;quot;udp&amp;quot;, &amp;quot;port&amp;quot;: 1194 },&lt;br /&gt;
            { &amp;quot;proto&amp;quot;: &amp;quot;tcp&amp;quot;, &amp;quot;port&amp;quot;: 1194 }&lt;br /&gt;
        ]&lt;br /&gt;
&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
NOTE: although you are free to name your policy files however you want, you cannot name this file &amp;lt;code&amp;gt;services.json&amp;lt;/code&amp;gt; because this policy name is already in use by the included services.json of awall.&lt;br /&gt;
&lt;br /&gt;
== Using our policies ==&lt;br /&gt;
&lt;br /&gt;
You should now have two directories in your awall config directory named optional and private with multiple json files. The biggest difference between these two directories is the ability to enable and disable policies located in the optional directory. When you enable a policy by using &amp;lt;code&amp;gt;awall enable policy-name&amp;lt;/code&amp;gt; awall will generate a symlink in your awall config directory and will automatically load them when you activate the firewall. To be able to also use the files in the private directory we will need to include them in one of our optional policies. You can name the file however you like as long it doesn&#039;t conflict with existing policies names (including the ones in private directory and awall&#039;s system policies). Example names would be hostname.json main.json firewall.json. For this example we will use main.json.&lt;br /&gt;
&lt;br /&gt;
Create the file: &amp;lt;code&amp;gt;/etc/awall/optional/main.json&amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
  &amp;quot;description&amp;quot;: &amp;quot;Main firewall&amp;quot;,&lt;br /&gt;
&lt;br /&gt;
  &amp;quot;import&amp;quot;: [ &amp;quot;base&amp;quot;, &amp;quot;aliases&amp;quot;, &amp;quot;custom-services&amp;quot; ]&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Contents of your awall directory:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
awall&lt;br /&gt;
│&lt;br /&gt;
├── optional&lt;br /&gt;
│   ├── main.json&lt;br /&gt;
│   ├── openvpn.json&lt;br /&gt;
│   ├── ssh-to-hostname.json&lt;br /&gt;
│   └── ssh.json&lt;br /&gt;
└── private&lt;br /&gt;
    ├── aliases.json&lt;br /&gt;
    ├── base.json&lt;br /&gt;
    └── custom-services.json&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Enabling optional policies ===&lt;br /&gt;
&lt;br /&gt;
Lets enable our created policies. First we list them by running &amp;lt;code&amp;gt;awall list&amp;lt;/code&amp;gt; which would show something like:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
openvpn         disabled  Allow local OpenVPN&lt;br /&gt;
main            disabled  Main firewall&lt;br /&gt;
ping            disabled  Allow rate-limited ping on WAN&lt;br /&gt;
ssh             disabled  Allow rate-limited SSH on WAN&lt;br /&gt;
ssh-to-hostname disabled  Forward SSH to hostname&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Each of these needs to be enabled:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
awall enable openvpn&lt;br /&gt;
awall enable main&lt;br /&gt;
awall enable ping&lt;br /&gt;
awall enable ssh&lt;br /&gt;
awall enable ssh-to-hostname&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The contents of your awall directory should now look like:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
awall/&lt;br /&gt;
├── main.json -&amp;gt; ./optional/main.json&lt;br /&gt;
├── openvpn.json -&amp;gt; ./optional/openvpn.json&lt;br /&gt;
├── optional&lt;br /&gt;
│   ├── main.json&lt;br /&gt;
│   ├── openvpn.json&lt;br /&gt;
│   ├── ping.json&lt;br /&gt;
│   ├── ssh-to-hostname.json&lt;br /&gt;
│   └── ssh.json&lt;br /&gt;
├── ping.json -&amp;gt; ./optional/ping.json&lt;br /&gt;
├── private&lt;br /&gt;
│   ├── aliases.json&lt;br /&gt;
│   ├── base.json&lt;br /&gt;
│   └── custom-services.json&lt;br /&gt;
├── ssh-to-hostname.json -&amp;gt; ./optional/ssh-to-hostname.json&lt;br /&gt;
└── ssh.json -&amp;gt; ./optional/ssh.json&lt;br /&gt;
&lt;br /&gt;
2 directories, 13 files&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Testing policies ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;awall translate --verify&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
if everything goes well the output should be null.&lt;br /&gt;
&lt;br /&gt;
=== Activating the firewall ===&lt;br /&gt;
&lt;br /&gt;
Now that all our policies are verified for proper json we can activate it.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;awall activate&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This will load the firewall rules and show you a message to confirm. If by accident you made a mistake and lock yourself out you just have to wait for awall to disable itself again.&lt;br /&gt;
&lt;br /&gt;
== Finishing up ==&lt;br /&gt;
&lt;br /&gt;
=== Activating firewall rules at boot ===&lt;br /&gt;
&lt;br /&gt;
When awall has been properly activated it will generate a file with all iptables rules which iptables will read when its is started via openrc.&lt;br /&gt;
Make sure you have added iptables to an openrc runlevel. If using snat, also enable ipset for the masquerade set.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;rc-update add iptables&lt;br /&gt;
rc-update add ipset&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Allow IPv4 forwarding ===&lt;br /&gt;
&lt;br /&gt;
To allow iptables to forward packets from one zone to the other we need to enable this at the iptables level.&lt;br /&gt;
&lt;br /&gt;
==== On the fly ====&lt;br /&gt;
&lt;br /&gt;
To enable it on the fly:&lt;br /&gt;
&amp;lt;code&amp;gt;sysctl -w net.ipv4.ip_forward=1&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Enable within iptables tools (at boot) ====&lt;br /&gt;
&lt;br /&gt;
Add the following to:&lt;br /&gt;
&amp;lt;code&amp;gt;/etc/conf.d/iptables&amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Enable/disable IPv4 forwarding with the rules&lt;br /&gt;
IPFORWARD=&amp;quot;yes&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= See also =&lt;br /&gt;
* [[How-To Alpine Wall]]&lt;br /&gt;
&lt;br /&gt;
[[Category:Security]]&lt;/div&gt;</summary>
		<author><name>Tsarna</name></author>
	</entry>
	<entry>
		<id>https://wiki.alpinelinux.org/w/index.php?title=Zero-To-Awall&amp;diff=17758</id>
		<title>Zero-To-Awall</title>
		<link rel="alternate" type="text/html" href="https://wiki.alpinelinux.org/w/index.php?title=Zero-To-Awall&amp;diff=17758"/>
		<updated>2020-06-28T16:11:29Z</updated>

		<summary type="html">&lt;p&gt;Tsarna: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Awall for dummies =&lt;br /&gt;
&lt;br /&gt;
This howto is aimed at users with no (or little) experience with iptables and other firewall frameworks (like Shorewall).&lt;br /&gt;
&lt;br /&gt;
This howto is going to be split into 5 parts.&lt;br /&gt;
&lt;br /&gt;
# Defining our base json file which holds our zones and base policies.&lt;br /&gt;
# Creating service policies.&lt;br /&gt;
# Using aliases and custom services.&lt;br /&gt;
# Enabling and testing policies.&lt;br /&gt;
# Finishing up and making it start (at boot)&lt;br /&gt;
&lt;br /&gt;
NOTE: please be aware that all configuration files are stored as JSON files. JSON is not a human friendly standard, &lt;br /&gt;
for instance it does not support comments so you will have to move them outside of the json structure.&lt;br /&gt;
Beginners should use a decent text editor with JSON highlight support which will make your life easier.&lt;br /&gt;
Since recent versions of [[Alpine Wall|awall]] it is also possible to use yaml instead of json but this is out of the scope of this howto.&lt;br /&gt;
&lt;br /&gt;
== Base policies ==&lt;br /&gt;
&lt;br /&gt;
Creating zones depends on the function of your firewall. Is it installed on a endpoint (server) or will it act as a router and filter/forward.&lt;br /&gt;
For this howto we assume you are going to setup a router and use NAT to forward services (ports) to different hosts on your network.&lt;br /&gt;
&lt;br /&gt;
For each interface on router we will setup a zone and assign it a zone name. We do this by creating the following file: /etc/awall/private/base.json&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
  &amp;quot;description&amp;quot;: &amp;quot;Base zones and policies&amp;quot;,&lt;br /&gt;
&lt;br /&gt;
  &amp;quot;zone&amp;quot;: {&lt;br /&gt;
    &amp;quot;WAN&amp;quot;: { &amp;quot;iface&amp;quot;: &amp;quot;eth0&amp;quot; },&lt;br /&gt;
    &amp;quot;LAN&amp;quot;: { &amp;quot;iface&amp;quot;: &amp;quot;eth1&amp;quot; },&lt;br /&gt;
    &amp;quot;VPN&amp;quot;: { &amp;quot;iface&amp;quot;: &amp;quot;tun+&amp;quot; }&lt;br /&gt;
  },&lt;br /&gt;
&lt;br /&gt;
  &amp;quot;policy&amp;quot;: [&lt;br /&gt;
     { &amp;quot;in&amp;quot;: &amp;quot;VPN&amp;quot;, &amp;quot;action&amp;quot;: &amp;quot;accept&amp;quot; },&lt;br /&gt;
     { &amp;quot;out&amp;quot;: &amp;quot;VPN&amp;quot;, &amp;quot;action&amp;quot;: &amp;quot;accept&amp;quot; },&lt;br /&gt;
     { &amp;quot;in&amp;quot;: &amp;quot;LAN&amp;quot;, &amp;quot;action&amp;quot;: &amp;quot;accept&amp;quot; },&lt;br /&gt;
     { &amp;quot;out&amp;quot;: &amp;quot;LAN&amp;quot;, &amp;quot;action&amp;quot;: &amp;quot;accept&amp;quot; },&lt;br /&gt;
     { &amp;quot;in&amp;quot;: &amp;quot;_fw&amp;quot;, &amp;quot;action&amp;quot;: &amp;quot;accept&amp;quot; },&lt;br /&gt;
     { &amp;quot;in&amp;quot;: &amp;quot;_fw&amp;quot;, &amp;quot;out&amp;quot;:  &amp;quot;WAN&amp;quot; , &amp;quot;action&amp;quot;: &amp;quot;accept&amp;quot; },&lt;br /&gt;
     { &amp;quot;in&amp;quot;: &amp;quot;WAN&amp;quot;, &amp;quot;action&amp;quot;: &amp;quot;drop&amp;quot; }&lt;br /&gt;
  ],&lt;br /&gt;
&lt;br /&gt;
  &amp;quot;snat&amp;quot;: [ { &amp;quot;out&amp;quot;: &amp;quot;WAN&amp;quot; } ],&lt;br /&gt;
&lt;br /&gt;
  &amp;quot;clamp-mss&amp;quot;: [ { &amp;quot;out&amp;quot;: &amp;quot;WAN&amp;quot; } ]&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Lets break this down into sections&lt;br /&gt;
&lt;br /&gt;
=== description ===&lt;br /&gt;
&lt;br /&gt;
The description is here just for reference and will be used by &amp;lt;code&amp;gt;awall list&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
=== zone ===&lt;br /&gt;
&lt;br /&gt;
This is where our zones are defined. Zones are defined based on a interface and assigned a name to be used in your policies.&lt;br /&gt;
In our example you can see that we have two real interfaces eth0 and eth1 and one or more virtual interfaces tun+ (the plus sign stands for any digit like tun0 tun1 and so on). In case you are installing awall on an endpoint (a server) then you will most probably not have the eth1 interfaces and can leave it out. In our example the tun+ interface is added as it is very commonly used like when using openvpn.&lt;br /&gt;
&lt;br /&gt;
=== policy ===&lt;br /&gt;
&lt;br /&gt;
These are our main policies. It will tell our firewall what to do with when a packet enters or leaves from one of the zones (interfaces).&lt;br /&gt;
You will notice a special &amp;lt;code&amp;gt;_fw&amp;lt;/code&amp;gt; name which means the internal firewall (the local machine) which means the packet does not leave the firewall via another interface but should be send to one of the local services.&lt;br /&gt;
You can see that we by default do not filter any package coming from or going to our VPN zone/interface. You could instead change the default action to drop all packets and create separate policies to allow specific traffic but this is out of the scope of this howto.&lt;br /&gt;
&lt;br /&gt;
=== snat ===&lt;br /&gt;
&lt;br /&gt;
Apply source nat for outgoing packets. This is only needed if your firewall acts as a router and traffic behind the router needs a modified source address (translate from local ip to public ip).&lt;br /&gt;
&lt;br /&gt;
=== clamp-mss ===&lt;br /&gt;
&lt;br /&gt;
https://github.com/alpinelinux/awall#mss-clamping-rules&lt;br /&gt;
&lt;br /&gt;
== Service policies ==&lt;br /&gt;
&lt;br /&gt;
Now that we have the base firewall in place we can start to define specific policies so our services will be reachable from the outside world.\&lt;br /&gt;
By default we are blocking all traffic coming in on our WAN interface (action=drop). The first thing we want to open is our SSH port/service. To do this we need to create a new policy inside the &amp;quot;optional&amp;quot; directory.&lt;br /&gt;
You could be wondering why the optional name, thats is because mandatory policies are stored in &amp;lt;code&amp;gt;/usr/share/awall/mandatory&amp;lt;/code&amp;gt; and not to be touched and our optional policies can be enabled/disabled on the run.&lt;br /&gt;
&lt;br /&gt;
=== SSH service ===&lt;br /&gt;
&lt;br /&gt;
To add our SSH policies we create a new file: /etc/awall/optional/ssh.json&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
  &amp;quot;description&amp;quot;: &amp;quot;Allow rate-limited SSH on WAN&amp;quot;,&lt;br /&gt;
&lt;br /&gt;
  &amp;quot;filter&amp;quot;: [&lt;br /&gt;
    {&lt;br /&gt;
      &amp;quot;in&amp;quot;: &amp;quot;WAN&amp;quot;,&lt;br /&gt;
      &amp;quot;out&amp;quot;: &amp;quot;_fw&amp;quot;,&lt;br /&gt;
      &amp;quot;service&amp;quot;: &amp;quot;ssh&amp;quot;,&lt;br /&gt;
      &amp;quot;action&amp;quot;: &amp;quot;accept&amp;quot;,&lt;br /&gt;
      &amp;quot;conn-limit&amp;quot;: { &amp;quot;count&amp;quot;: 3, &amp;quot;interval&amp;quot;: 20 }&lt;br /&gt;
    }&lt;br /&gt;
  ]&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== description ====&lt;br /&gt;
&lt;br /&gt;
This is similar for any policy&lt;br /&gt;
&lt;br /&gt;
==== Filter ====&lt;br /&gt;
&lt;br /&gt;
This is the actual filter that is currently set to drop the packets arriving or leaving the interface.&lt;br /&gt;
&lt;br /&gt;
===== in =====&lt;br /&gt;
&lt;br /&gt;
The interface the packets arrive on, in this case its the WAN interface.&lt;br /&gt;
&lt;br /&gt;
===== out =====&lt;br /&gt;
&lt;br /&gt;
The interface the packets leave on, in this case its _fw which means it does not leave our firewall/device and is targeted at our local SSH service.&lt;br /&gt;
&lt;br /&gt;
===== service =====&lt;br /&gt;
&lt;br /&gt;
This is the service definition provided by awall or a custom service which we will discuss later on.&lt;br /&gt;
&lt;br /&gt;
===== action =====&lt;br /&gt;
&lt;br /&gt;
The action on the packet, this inverts the default action of drop and accepts the packets.&lt;br /&gt;
&lt;br /&gt;
===== conn-limit =====&lt;br /&gt;
&lt;br /&gt;
This is a special feature of our firewall/iptables to allow only a certain amount of packets in a certain amount of time. For more information please check our awall manual.&lt;br /&gt;
&lt;br /&gt;
=== SSH to another Host ===&lt;br /&gt;
&lt;br /&gt;
edit the following file: /etc/awall/optional/ssh-to-hostname.json&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
&lt;br /&gt;
  &amp;quot;description&amp;quot;: &amp;quot;Forward SSH to hostname&amp;quot;,&lt;br /&gt;
&lt;br /&gt;
  &amp;quot;filter&amp;quot;: [&lt;br /&gt;
    {&lt;br /&gt;
      &amp;quot;in&amp;quot;: &amp;quot;WAN&amp;quot;,&lt;br /&gt;
      &amp;quot;service&amp;quot;: { &amp;quot;proto&amp;quot;: &amp;quot;tcp&amp;quot;, &amp;quot;port&amp;quot;: 22001 },&lt;br /&gt;
      &amp;quot;action&amp;quot;: &amp;quot;accept&amp;quot;,&lt;br /&gt;
      &amp;quot;conn-limit&amp;quot;: { &amp;quot;count&amp;quot;: 3, &amp;quot;interval&amp;quot;: 20 }&lt;br /&gt;
    }&lt;br /&gt;
  ],&lt;br /&gt;
&lt;br /&gt;
  &amp;quot;dnat&amp;quot;: [&lt;br /&gt;
    {&lt;br /&gt;
      &amp;quot;in&amp;quot;: &amp;quot;WAN&amp;quot;,&lt;br /&gt;
      &amp;quot;dest&amp;quot;: &amp;quot;$SERVER&amp;quot;,&lt;br /&gt;
      &amp;quot;service&amp;quot;: { &amp;quot;proto&amp;quot;: &amp;quot;tcp&amp;quot;, &amp;quot;port&amp;quot;: 22001 },&lt;br /&gt;
      &amp;quot;to-port&amp;quot;: &amp;quot;22&amp;quot;&lt;br /&gt;
    }&lt;br /&gt;
  ]&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Lets discuss the differences between this policy and the previous SSH policy.&lt;br /&gt;
&lt;br /&gt;
==== Filter ====&lt;br /&gt;
&lt;br /&gt;
===== service =====&lt;br /&gt;
&lt;br /&gt;
Because port 22 is already in use by our own firewall, we need to listen on a different port. In this example we listen on port 22001.&lt;br /&gt;
And because we are not using the default port 22 we need to define our own service specification.&lt;br /&gt;
&lt;br /&gt;
==== dnat ====&lt;br /&gt;
&lt;br /&gt;
Also known as destination NAT.&lt;br /&gt;
&lt;br /&gt;
===== dest =====&lt;br /&gt;
&lt;br /&gt;
The destination the packet will be forwarded to. In this case we are using a variable named $HOSTNAME. Anywhere in your policies you can define your own variables and use them.&lt;br /&gt;
In our case we have used a file in /etc/awall/private/aliases.json more on this topic later on.&lt;br /&gt;
&lt;br /&gt;
===== to-port =====&lt;br /&gt;
&lt;br /&gt;
This is the destination target port number. The packet will be forwarded from 22001 to 22 on the $hostname&lt;br /&gt;
&lt;br /&gt;
=== OpenVPN Service ===&lt;br /&gt;
&lt;br /&gt;
This is the most generic config available. It does nothing more then opening port(s) defined for our openvpn service in &amp;lt;code&amp;gt;/etc/awall/private/custom-services.json&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
&lt;br /&gt;
    &amp;quot;description&amp;quot;: &amp;quot;Allow local OpenVPN&amp;quot;,&lt;br /&gt;
&lt;br /&gt;
    &amp;quot;filter&amp;quot;: [&lt;br /&gt;
        {&lt;br /&gt;
            &amp;quot;in&amp;quot;: &amp;quot;WAN&amp;quot;,&lt;br /&gt;
            &amp;quot;out&amp;quot;: &amp;quot;_fw&amp;quot;,&lt;br /&gt;
            &amp;quot;service&amp;quot;: &amp;quot;openvpn&amp;quot;,&lt;br /&gt;
            &amp;quot;action&amp;quot;: &amp;quot;accept&amp;quot;&lt;br /&gt;
        }&lt;br /&gt;
    ]&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Allow ping on WAN ===&lt;br /&gt;
&lt;br /&gt;
Allow rate-limited ping on WAN. Which has the same kind of flow limit as our previous SSH policy.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
&lt;br /&gt;
  &amp;quot;description&amp;quot;: &amp;quot;Allow rate-limited ping on WAN&amp;quot;,&lt;br /&gt;
&lt;br /&gt;
  &amp;quot;filter&amp;quot;: [&lt;br /&gt;
    {&lt;br /&gt;
      &amp;quot;in&amp;quot;: &amp;quot;WAN&amp;quot;,&lt;br /&gt;
      &amp;quot;out&amp;quot;: &amp;quot;_fw&amp;quot;,&lt;br /&gt;
      &amp;quot;service&amp;quot;: &amp;quot;ping&amp;quot;,&lt;br /&gt;
      &amp;quot;action&amp;quot;: &amp;quot;accept&amp;quot;,&lt;br /&gt;
      &amp;quot;flow-limit&amp;quot;: { &amp;quot;count&amp;quot;: 10, &amp;quot;interval&amp;quot;: 6 }&lt;br /&gt;
    }&lt;br /&gt;
  ]&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Using aliases and custom services ==&lt;br /&gt;
&lt;br /&gt;
=== Aliases ===&lt;br /&gt;
&lt;br /&gt;
To make life easier when your firewall rules increase, it can be nice to map specific hosts to names.&lt;br /&gt;
Awall supports something called [https://github.com/alpinelinux/awall#variable-expansion variable expansion] which is a mapping between a value and a variable.&lt;br /&gt;
When you have many devices behind your firewall/router, your policies can be harder to read. Also when one of your devices IP address change you will have to update all of your policies.&lt;br /&gt;
With awalls variables you can assign the ip address of a device to a variable name. Edit the following file: &amp;lt;code&amp;gt;/etc/awall/private/aliases.json&amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
  &amp;quot;description&amp;quot;: &amp;quot;Hostname aliases&amp;quot;,&lt;br /&gt;
&lt;br /&gt;
  &amp;quot;variable&amp;quot;: {&lt;br /&gt;
    &amp;quot;PRINTER&amp;quot;: &amp;quot;192.168.1.1&amp;quot;,&lt;br /&gt;
    &amp;quot;SERVER&amp;quot;: &amp;quot;192.168.1.2&amp;quot;&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Look in the example above where $SERVER is used to forward port 22001 to port 22.&lt;br /&gt;
&lt;br /&gt;
NOTE: You are not limited to assigning only IP addresses to variables. You can use it however you like. More information can be found in the awall manual.&lt;br /&gt;
&lt;br /&gt;
=== Custom services ===&lt;br /&gt;
&lt;br /&gt;
Awall includes a predefined list of [https://github.com/alpinelinux/awall/blob/master/json/services.json services]. If the service you try to define in your policy does not exist in awalls services list you can define services yourself.&lt;br /&gt;
&lt;br /&gt;
Create the file: &amp;lt;code&amp;gt;/etc/awall/private/custom-services.json&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;service&amp;quot;: {&lt;br /&gt;
&lt;br /&gt;
        &amp;quot;mqtt&amp;quot;: [&lt;br /&gt;
            { &amp;quot;proto&amp;quot;: &amp;quot;udp&amp;quot;, &amp;quot;port&amp;quot;: 1883 },&lt;br /&gt;
            { &amp;quot;proto&amp;quot;: &amp;quot;tcp&amp;quot;, &amp;quot;port&amp;quot;: 1883 }&lt;br /&gt;
        ],&lt;br /&gt;
&lt;br /&gt;
        &amp;quot;openvpn&amp;quot;: [&lt;br /&gt;
            { &amp;quot;proto&amp;quot;: &amp;quot;udp&amp;quot;, &amp;quot;port&amp;quot;: 1194 },&lt;br /&gt;
            { &amp;quot;proto&amp;quot;: &amp;quot;tcp&amp;quot;, &amp;quot;port&amp;quot;: 1194 }&lt;br /&gt;
        ]&lt;br /&gt;
&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
NOTE: although you are free to name your policy files however you want, you cannot name this file &amp;lt;code&amp;gt;services.json&amp;lt;/code&amp;gt; because this policy name is already in use by the included services.json of awall.&lt;br /&gt;
&lt;br /&gt;
== Using our policies ==&lt;br /&gt;
&lt;br /&gt;
You should now have two directories in your awall config directory named optional and private with multiple json files. The biggest difference between these two directories is the ability to enable and disable policies located in the optional directory. When you enable a policy by using &amp;lt;code&amp;gt;awall enable policy-name&amp;lt;/code&amp;gt; awall will generate a symlink in your awall config directory and will automatically load them when you activate the firewall. To be able to also use the files in the private directory we will need to include them in one of our optional policies. You can name the file however you like as long it doesn&#039;t conflict with existing policies names (including the ones in private directory and awall&#039;s system policies). Example names would be hostname.json main.json firewall.json. For this example we will use main.json.&lt;br /&gt;
&lt;br /&gt;
Create the file: &amp;lt;code&amp;gt;/etc/awall/optional/main.json&amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
  &amp;quot;description&amp;quot;: &amp;quot;Main firewall&amp;quot;,&lt;br /&gt;
&lt;br /&gt;
  &amp;quot;import&amp;quot;: [ &amp;quot;base&amp;quot;, &amp;quot;aliases&amp;quot;, &amp;quot;custom-services&amp;quot; ]&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Contents of your awall directory:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
awall&lt;br /&gt;
│&lt;br /&gt;
├── optional&lt;br /&gt;
│   ├── main.json&lt;br /&gt;
│   ├── openvpn.json&lt;br /&gt;
│   ├── ssh-to-hostname.json&lt;br /&gt;
│   └── ssh.json&lt;br /&gt;
└── private&lt;br /&gt;
    ├── aliases.json&lt;br /&gt;
    ├── base.json&lt;br /&gt;
    └── custom-services.json&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Enabling optional policies ===&lt;br /&gt;
&lt;br /&gt;
Lets enable our created policies. First we list them by running &amp;lt;code&amp;gt;awall list&amp;lt;/code&amp;gt; which would show something like:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
openvpn         disabled  Allow local OpenVPN&lt;br /&gt;
main            disabled  Main firewall&lt;br /&gt;
ping            disabled  Allow rate-limited ping on WAN&lt;br /&gt;
ssh             disabled  Allow rate-limited SSH on WAN&lt;br /&gt;
ssh-to-hostname disabled  Forward SSH to hostname&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Each of these needs to be enabled:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
awall enable openvpn&lt;br /&gt;
awall enable main&lt;br /&gt;
awall enable ping&lt;br /&gt;
awall enable ssh&lt;br /&gt;
awall enable ssh-to-hostname&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The contents of your awall directory should now look like:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
awall/&lt;br /&gt;
├── main.json -&amp;gt; ./optional/main.json&lt;br /&gt;
├── openvpn.json -&amp;gt; ./optional/openvpn.json&lt;br /&gt;
├── optional&lt;br /&gt;
│   ├── main.json&lt;br /&gt;
│   ├── openvpn.json&lt;br /&gt;
│   ├── ping.json&lt;br /&gt;
│   ├── ssh-to-hostname.json&lt;br /&gt;
│   └── ssh.json&lt;br /&gt;
├── ping.json -&amp;gt; ./optional/ping.json&lt;br /&gt;
├── private&lt;br /&gt;
│   ├── aliases.json&lt;br /&gt;
│   ├── base.json&lt;br /&gt;
│   └── custom-services.json&lt;br /&gt;
├── ssh-to-hostname.json -&amp;gt; ./optional/ssh-to-hostname.json&lt;br /&gt;
└── ssh.json -&amp;gt; ./optional/ssh.json&lt;br /&gt;
&lt;br /&gt;
2 directories, 13 files&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Testing policies ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;awall translate --verify&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
if everything goes well the output should be null.&lt;br /&gt;
&lt;br /&gt;
=== Activating the firewall ===&lt;br /&gt;
&lt;br /&gt;
Now that all our policies are verified for proper json we can activate it.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;awall activate&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This will load the firewall rules and show you a message to confirm. If by accident you made a mistake and lock yourself out you just have to wait for awall to disable itself again.&lt;br /&gt;
&lt;br /&gt;
== Finishing up ==&lt;br /&gt;
&lt;br /&gt;
=== Activating firewall rules at boot ===&lt;br /&gt;
&lt;br /&gt;
When awall has been properly activated it will generate a file with all iptables rules which iptables will read when its is started via openrc.&lt;br /&gt;
Make sure you have added iptables to an openrc runlevel. If using snat, also enable ipset for the masquerade set.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;rc-update add iptables&amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;rc-update add ipset&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Allow IPv4 forwarding ===&lt;br /&gt;
&lt;br /&gt;
To allow iptables to forward packets from one zone to the other we need to enable this at the iptables level.&lt;br /&gt;
&lt;br /&gt;
==== On the fly ====&lt;br /&gt;
&lt;br /&gt;
To enable it on the fly:&lt;br /&gt;
&amp;lt;code&amp;gt;sysctl -w net.ipv4.ip_forward=1&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Enable within iptables tools (at boot) ====&lt;br /&gt;
&lt;br /&gt;
Add the following to:&lt;br /&gt;
&amp;lt;code&amp;gt;/etc/conf.d/iptables&amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Enable/disable IPv4 forwarding with the rules&lt;br /&gt;
IPFORWARD=&amp;quot;yes&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= See also =&lt;br /&gt;
* [[How-To Alpine Wall]]&lt;br /&gt;
&lt;br /&gt;
[[Category:Security]]&lt;/div&gt;</summary>
		<author><name>Tsarna</name></author>
	</entry>
	<entry>
		<id>https://wiki.alpinelinux.org/w/index.php?title=Alpine_Install:_from_a_disc_to_PC_Engines_APU&amp;diff=17317</id>
		<title>Alpine Install: from a disc to PC Engines APU</title>
		<link rel="alternate" type="text/html" href="https://wiki.alpinelinux.org/w/index.php?title=Alpine_Install:_from_a_disc_to_PC_Engines_APU&amp;diff=17317"/>
		<updated>2020-05-04T05:21:28Z</updated>

		<summary type="html">&lt;p&gt;Tsarna: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Category:Installation]]&lt;br /&gt;
&lt;br /&gt;
The following instructions were tested with an apu2d4 and Alpine 3.11.6.&lt;br /&gt;
&lt;br /&gt;
== Installing on second generation PC Engines APU systems (apu2, apu3, apu4) ==&lt;br /&gt;
&lt;br /&gt;
# It&#039;s probably a good idea to ensure that the BIOS / Firmware is up to date.&lt;br /&gt;
# [[Create_a_Bootable_USB]] thumb drive with the current standard x86_64 image from the downloads page.&lt;br /&gt;
# Attach to the serial console. Configure your terminal emulator for 115200 8n1.&lt;br /&gt;
# Power on the APU.&lt;br /&gt;
# When prompted, hit F10 and select to boot from USB.&lt;br /&gt;
# At the boot prompt, &#039;&#039;&#039;quickly&#039;&#039;&#039; type a slash to interrupt the default boot, which has a short timeout.&lt;br /&gt;
# Continue entering the remainder of this command at your leisure. It should have only one slash at the start, to be clear:  &amp;lt;code&amp;gt;/boot/vmlinuz-lts modules=loop,squashfs,sd-mod,usb-storage nomodeset console=ttyS0,115200 initrd=/boot/initramfs-lts&amp;lt;/code&amp;gt;&lt;br /&gt;
# Alpine should come up as normal.&lt;br /&gt;
# [[Alpine_newbie_install_manual#Ways_to_install_Alpine_into_machines_or_virtuals|Proceed with installation as normal.]]&lt;br /&gt;
# &#039;&#039;&#039;Before&#039;&#039;&#039; rebooting, edit /boot/extlinux.conf.&lt;br /&gt;
## Add &amp;lt;code&amp;gt;SERIAL 0 115200&amp;lt;/code&amp;gt; as the first line in the file.&lt;br /&gt;
## In the &amp;lt;code&amp;gt;APPEND&amp;lt;/code&amp;gt; line, replace &amp;lt;code&amp;gt;quiet&amp;lt;/code&amp;gt; with &amp;lt;code&amp;gt;console=ttyS0,115200&amp;lt;/code&amp;gt;&lt;br /&gt;
# Remove the thumb drive.&lt;br /&gt;
# Cross your fingers and reboot. The system should boot properly with console on serial.&lt;br /&gt;
# Edit &amp;lt;code&amp;gt;/etc/update-extlinux.conf&amp;lt;/code&amp;gt; so that if extlinux.conf is regenerated it will retain these settings:&lt;br /&gt;
## Update the line with &amp;lt;code&amp;gt;serial_port&amp;lt;/code&amp;gt; to read &amp;lt;code&amp;gt;serial_port=0&amp;lt;/code&amp;gt;&lt;br /&gt;
## Update the &amp;lt;code&amp;gt;serial_baud&amp;lt;/code&amp;gt; line to read &amp;lt;code&amp;gt;serial_baud=115200&amp;lt;/code&amp;gt;&lt;br /&gt;
## Update the &amp;lt;code&amp;gt;default_kernel_opts&amp;lt;/code&amp;gt; line to replace &amp;lt;code&amp;gt;quiet&amp;lt;/code&amp;gt; with &amp;lt;code&amp;gt;console=ttyS0,115200&amp;lt;/code&amp;gt;&lt;br /&gt;
# Run &amp;lt;code&amp;gt;update-extlinux&amp;lt;/code&amp;gt;&lt;br /&gt;
# Examine &amp;lt;code&amp;gt;/boot/extlinux.conf&amp;lt;/code&amp;gt;.&lt;br /&gt;
## Make sure it looks OK. Compare with /boot/extlinux.conf-old.&lt;br /&gt;
## If something looks wrong, &amp;lt;code&amp;gt;mv /boot/extlinux.conf-old /boot/extlinux.conf&amp;lt;/code&amp;gt; to roll back the changes and try to figure out what went wrong&lt;br /&gt;
# Cross your fingers and reboot. The system should boot properly with console on serial.&lt;/div&gt;</summary>
		<author><name>Tsarna</name></author>
	</entry>
	<entry>
		<id>https://wiki.alpinelinux.org/w/index.php?title=Alpine_Install:_from_a_disc_to_PC_Engines_APU&amp;diff=17313</id>
		<title>Alpine Install: from a disc to PC Engines APU</title>
		<link rel="alternate" type="text/html" href="https://wiki.alpinelinux.org/w/index.php?title=Alpine_Install:_from_a_disc_to_PC_Engines_APU&amp;diff=17313"/>
		<updated>2020-05-02T20:41:00Z</updated>

		<summary type="html">&lt;p&gt;Tsarna: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Category:Installation]]&lt;br /&gt;
&lt;br /&gt;
The following instructions were tested with an apu2d4 and Alpine 3.11.6.&lt;br /&gt;
&lt;br /&gt;
== Installing on second generation PC Engines APU systems (apu2, apu3, apu4) ==&lt;br /&gt;
&lt;br /&gt;
# It&#039;s probably a good idea to ensure that the BIOS / Firmware is up to date.&lt;br /&gt;
# [[Create_a_Bootable_USB]] thumb drive with the current standard x86_64 image from the downloads page.&lt;br /&gt;
# Attach to the serial console. Configure your terminal emulator for 115200 8n1.&lt;br /&gt;
# Power on the APU.&lt;br /&gt;
# When prompted, hit F10 and select to boot from USB.&lt;br /&gt;
# At the boot prompt, &#039;&#039;&#039;quickly&#039;&#039;&#039; type a slash to interrupt the default boot, which has a short timeout.&lt;br /&gt;
# Continue entering the remainder of this command at your leisure. It should have only one slash at the start, to be clear:  &amp;lt;code&amp;gt;/boot/vmlinuz-lts modules=loop,squashfs,sd-mod,usb-storage nomodeset console=ttyS0,115200 initrd=/boot/initramfs-lts&amp;lt;/code&amp;gt;&lt;br /&gt;
# Alpine should come up as normal.&lt;br /&gt;
# [[Alpine_newbie_install_manual#Ways_to_install_Alpine_into_machines_or_virtuals|Proceed with installation as normal.]]&lt;br /&gt;
# &#039;&#039;&#039;Before&#039;&#039;&#039; rebooting, edit /boot/extlinux.conf.&lt;br /&gt;
## Add &amp;lt;code&amp;gt;SERIAL 0 115200&amp;lt;/code&amp;gt; as the first line in the file.&lt;br /&gt;
## In the &amp;lt;code&amp;gt;APPEND&amp;lt;/code&amp;gt; line, replace &amp;lt;code&amp;gt;quiet&amp;lt;/code&amp;gt; with &amp;lt;code&amp;gt;console=ttyS0,115200&amp;lt;/code&amp;gt;&lt;br /&gt;
# Remove the thumb drive.&lt;br /&gt;
# Cross your fingers and reboot. The system should boot properly with console on serial.&lt;br /&gt;
# Edit &amp;lt;code&amp;gt;/etc/update-extlinux.conf&amp;lt;/code&amp;gt; so that if extlinux.conf is regenerated it will retain these settings:&lt;br /&gt;
## Update the line with &amp;lt;code&amp;gt;serial_port&amp;lt;/code&amp;gt; to read &amp;lt;code&amp;gt;serial_port=0&amp;lt;/code&amp;gt;&lt;br /&gt;
## Update the &amp;lt;code&amp;gt;serial_baud&amp;lt;/code&amp;gt; line to read &amp;lt;code&amp;gt;serial_baud=115200&amp;lt;/code&amp;gt;&lt;br /&gt;
## Update the &amp;lt;code&amp;gt;default_kernel_opts&amp;lt;/code&amp;gt; line to &amp;lt;code&amp;gt;quiet&amp;lt;/code&amp;gt; with &amp;lt;code&amp;gt;console=ttyS0,115200&amp;lt;/code&amp;gt;&lt;br /&gt;
# Run &amp;lt;code&amp;gt;update-extlinux&amp;lt;/code&amp;gt;&lt;br /&gt;
# Examine &amp;lt;code&amp;gt;/boot/extlinux.conf&amp;lt;/code&amp;gt;.&lt;br /&gt;
## Make sure it looks OK. Compare with /boot/extlinux.conf-old.&lt;br /&gt;
## If something looks wrong, &amp;lt;code&amp;gt;mv /boot/extlinux.conf-old /boot/extlinux.conf&amp;lt;/code&amp;gt; to roll back the changes and try to figure out what went wrong&lt;br /&gt;
# Cross your fingers and reboot. The system should boot properly with console on serial.&lt;/div&gt;</summary>
		<author><name>Tsarna</name></author>
	</entry>
	<entry>
		<id>https://wiki.alpinelinux.org/w/index.php?title=Alpine_Install:_from_a_disc_to_PC_Engines_APU&amp;diff=17312</id>
		<title>Alpine Install: from a disc to PC Engines APU</title>
		<link rel="alternate" type="text/html" href="https://wiki.alpinelinux.org/w/index.php?title=Alpine_Install:_from_a_disc_to_PC_Engines_APU&amp;diff=17312"/>
		<updated>2020-05-02T20:33:25Z</updated>

		<summary type="html">&lt;p&gt;Tsarna: FIx formatting, not specific versions tested&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Category:Installation]]&lt;br /&gt;
&lt;br /&gt;
== Installing on second generation PC Engines APU systems (apu2, apu3, apu4) ==&lt;br /&gt;
&lt;br /&gt;
The following instructions were tested with an apu2e4 and Alpine 3.11.6.&lt;br /&gt;
&lt;br /&gt;
# It&#039;s probably a good idea to ensure that the BIOS / Firmware is up to date.&lt;br /&gt;
# [[Create_a_Bootable_USB]] thumb drive with the current standard x86_64 image from the downloads page.&lt;br /&gt;
# Attach to the serial console. Configure your terminal emulator for 115200 8n1.&lt;br /&gt;
# Power on the APU.&lt;br /&gt;
# When prompted, hit F10 and select to boot from USB.&lt;br /&gt;
# At the boot prompt, &#039;&#039;&#039;quickly&#039;&#039;&#039; type a slash to interrupt the default boot, which has a short timeout.&lt;br /&gt;
# Continue entering the remainder of this command at your leisure. It should have only one slash at the start, to be clear:  &amp;lt;code&amp;gt;/boot/vmlinuz-lts modules=loop,squashfs,sd-mod,usb-storage nomodeset console=ttyS0,115200 initrd=/boot/initramfs-lts&amp;lt;/code&amp;gt;&lt;br /&gt;
# Alpine should come up as normal.&lt;br /&gt;
# [[Alpine_newbie_install_manual#Ways_to_install_Alpine_into_machines_or_virtuals|Proceed with installation as normal.]]&lt;br /&gt;
# &#039;&#039;&#039;Before&#039;&#039;&#039; rebooting, edit /boot/extlinux.conf.&lt;br /&gt;
## Add &amp;lt;code&amp;gt;SERIAL 0 115200&amp;lt;/code&amp;gt; as the first line in the file.&lt;br /&gt;
## In the &amp;lt;code&amp;gt;APPEND&amp;lt;/code&amp;gt; line, replace &amp;lt;code&amp;gt;quiet&amp;lt;/code&amp;gt; with &amp;lt;code&amp;gt;console=ttyS0,115200&amp;lt;/code&amp;gt;&lt;br /&gt;
# Remove the thumb drive.&lt;br /&gt;
# Cross your fingers and reboot. The system should boot properly with console on serial.&lt;br /&gt;
# Edit &amp;lt;code&amp;gt;/etc/update-extlinux.conf&amp;lt;/code&amp;gt; so that if extlinux.conf is regenerated it will retain these settings:&lt;br /&gt;
## Update the line with &amp;lt;code&amp;gt;serial_port&amp;lt;/code&amp;gt; to read &amp;lt;code&amp;gt;serial_port=0&amp;lt;/code&amp;gt;&lt;br /&gt;
## Update the &amp;lt;code&amp;gt;serial_baud&amp;lt;/code&amp;gt; line to read &amp;lt;code&amp;gt;serial_baud=115200&amp;lt;/code&amp;gt;&lt;br /&gt;
## Update the &amp;lt;code&amp;gt;default_kernel_opts&amp;lt;/code&amp;gt; line to &amp;lt;code&amp;gt;quiet&amp;lt;/code&amp;gt; with &amp;lt;code&amp;gt;console=ttyS0,115200&amp;lt;/code&amp;gt;&lt;br /&gt;
# Run &amp;lt;code&amp;gt;update-extlinux&amp;lt;/code&amp;gt;&lt;br /&gt;
# Examine &amp;lt;code&amp;gt;/boot/extlinux.conf&amp;lt;/code&amp;gt;.&lt;br /&gt;
## Make sure it looks OK. Compare with /boot/extlinux.conf-old.&lt;br /&gt;
## If something looks wrong, &amp;lt;code&amp;gt;mv /boot/extlinux.conf-old /boot/extlinux.conf&amp;lt;/code&amp;gt; to roll back the changes and try to figure out what went wrong&lt;br /&gt;
# Cross your fingers and reboot. The system should boot properly with console on serial.&lt;/div&gt;</summary>
		<author><name>Tsarna</name></author>
	</entry>
	<entry>
		<id>https://wiki.alpinelinux.org/w/index.php?title=Alpine_Install:_from_a_disc_to_PC_Engines_APU&amp;diff=17311</id>
		<title>Alpine Install: from a disc to PC Engines APU</title>
		<link rel="alternate" type="text/html" href="https://wiki.alpinelinux.org/w/index.php?title=Alpine_Install:_from_a_disc_to_PC_Engines_APU&amp;diff=17311"/>
		<updated>2020-05-02T20:31:16Z</updated>

		<summary type="html">&lt;p&gt;Tsarna: Fix formatting&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Category:Installation]]&lt;br /&gt;
&lt;br /&gt;
== Installing on second generation PC Engines APU systems (apu2, apu3, apu4) ==&lt;br /&gt;
&lt;br /&gt;
# It&#039;s probably a good idea to ensure that the BIOS / Firmware is up to date.&lt;br /&gt;
# [[Create_a_Bootable_USB]] thumb drive with the current standard x86_64 image from the downloads page.&lt;br /&gt;
# Attach to the serial console. Configure your terminal emulator for 115200 8n1.&lt;br /&gt;
# Power on the APU.&lt;br /&gt;
# When prompted, hit F10 and select to boot from USB.&lt;br /&gt;
# At the boot prompt, &#039;&#039;&#039;quickly&#039;&#039;&#039; type a slash to interrupt the default boot, which has a short timeout.&lt;br /&gt;
# Continue entering the remainder of this command at your leisure. It should have only one slash at the start, to be clear:  &amp;lt;code&amp;gt;/boot/vmlinuz-lts modules=loop,squashfs,sd-mod,usb-storage nomodeset console=ttyS0,115200 initrd=/boot/initramfs-lts&amp;lt;/code&amp;gt;&lt;br /&gt;
# Alpine should come up as normal.&lt;br /&gt;
# [[Alpine_newbie_install_manual#Ways_to_install_Alpine_into_machines_or_virtuals|Proceed with installation as normal.]]&lt;br /&gt;
# &#039;&#039;&#039;Before&#039;&#039;&#039; rebooting, edit /boot/extlinux.conf.&lt;br /&gt;
## Add &amp;lt;code&amp;gt;SERIAL 0 115200&amp;lt;/code&amp;gt; as the first line in the file.&lt;br /&gt;
## In the &amp;lt;code&amp;gt;APPEND&amp;lt;/code&amp;gt; line, replace &amp;lt;code&amp;gt;quiet&amp;lt;/code&amp;gt; with &amp;lt;code&amp;gt;console=ttyS0,115200&amp;lt;/code&amp;gt;&lt;br /&gt;
# Remove the thumb drive.&lt;br /&gt;
# Cross your fingers and reboot. The system should boot properly with console on serial.&lt;br /&gt;
# Edit &amp;lt;code&amp;gt;/etc/update-extlinux.conf&amp;lt;code&amp;gt; so that if extlinux.conf is regenerated it will retain these settings:&lt;br /&gt;
## Update the line with &amp;lt;code&amp;gt;serial_port&amp;lt;/code&amp;gt; to read &amp;lt;code&amp;gt;serial_port=0&amp;lt;/code&amp;gt;&lt;br /&gt;
## Update the &amp;lt;code&amp;gt;serial_baud&amp;lt;/code&amp;gt; line to read &amp;lt;code&amp;gt;serial_baud=115200&amp;lt;/code&amp;gt;&lt;br /&gt;
## Update the &amp;lt;code&amp;gt;default_kernel_opts&amp;lt;/code&amp;gt; line to &amp;lt;code&amp;gt;quiet&amp;lt;/code&amp;gt; with &amp;lt;code&amp;gt;console=ttyS0,115200&amp;lt;/code&amp;gt;&lt;br /&gt;
# Run &amp;lt;code&amp;gt;update-extlinux&amp;lt;/code&amp;gt;&lt;br /&gt;
# Examine &amp;lt;code&amp;gt;/boot/extlinux.conf&amp;lt;/code&amp;gt;.&lt;br /&gt;
## Make sure it looks OK. Compare with /boot/extlinux.conf-old.&lt;br /&gt;
## If something looks wrong, &amp;lt;code&amp;gt;mv /boot/extlinux.conf-old /boot/extlinux.conf&amp;lt;/code&amp;gt; to roll back the changes and try to figure out what went wrong&lt;br /&gt;
# Cross your fingers and reboot. The system should boot properly with console on serial.&lt;/div&gt;</summary>
		<author><name>Tsarna</name></author>
	</entry>
	<entry>
		<id>https://wiki.alpinelinux.org/w/index.php?title=Alpine_Install:_from_a_disc_to_PC_Engines_APU&amp;diff=17310</id>
		<title>Alpine Install: from a disc to PC Engines APU</title>
		<link rel="alternate" type="text/html" href="https://wiki.alpinelinux.org/w/index.php?title=Alpine_Install:_from_a_disc_to_PC_Engines_APU&amp;diff=17310"/>
		<updated>2020-05-02T20:29:36Z</updated>

		<summary type="html">&lt;p&gt;Tsarna: How to install on APU2-series systems from PC Engines&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Category:Installation]]&lt;br /&gt;
&lt;br /&gt;
== Installing on second generation PC Engines APU systems (apu2, apu3, apu4) ==&lt;br /&gt;
&lt;br /&gt;
# It&#039;s probably a good idea to ensure that the BIOS / Firmware is up to date.&lt;br /&gt;
# [[Create_a_Bootable_USB]] thumb drive with the current standard x86_64 image from the downloads page.&lt;br /&gt;
# Attach to the serial console. Configure your terminal emulator for 115200 8n1.&lt;br /&gt;
# Power on the APU.&lt;br /&gt;
# When prompted, hit F10 and select to boot from USB.&lt;br /&gt;
# At the boot prompt, &#039;&#039;&#039;quickly&#039;&#039;&#039; type a slash to interrupt the default boot, which has a short timeout.&lt;br /&gt;
# Continue entering the remainder of this command at your leisure. It should have only one slash at the start, to be clear:  &amp;lt;code&amp;gt;/boot/vmlinuz-lts modules=loop,squashfs,sd-mod,usb-storage nomodeset console=ttyS0,115200 initrd=/boot/initramfs-lts&amp;lt;/code&amp;gt;&lt;br /&gt;
# Alpine should come up as normal.&lt;br /&gt;
# [[Alpine_newbie_install_manual#Ways_to_install_Alpine_into_machines_or_virtuals|Proceed with installation as normal.]]&lt;br /&gt;
# &#039;&#039;&#039;Before&#039;&#039;&#039; rebooting, edit /boot/extlinux.conf.&lt;br /&gt;
  # Add &amp;lt;code&amp;gt;SERIAL 0 115200&amp;lt;/code&amp;gt; as the first line in the file.&lt;br /&gt;
  # In the &amp;lt;code&amp;gt;APPEND&amp;lt;/code&amp;gt; line, replace &amp;lt;code&amp;gt;quiet&amp;lt;/code&amp;gt; with &amp;lt;code&amp;gt;console=ttyS0,115200&amp;lt;/code&amp;gt;&lt;br /&gt;
# Remove the thumb drive.&lt;br /&gt;
# Cross your fingers and reboot. The system should boot properly with console on serial.&lt;br /&gt;
# Edit &amp;lt;code&amp;gt;/etc/update-extlinux.conf&amp;lt;code&amp;gt; so that if extlinux.conf is regenerated it will retain these settings:&lt;br /&gt;
  # Update the line with &amp;lt;code&amp;gt;serial_port&amp;lt;/code&amp;gt; to read &amp;lt;code&amp;gt;serial_port=0&amp;lt;/code&amp;gt;&lt;br /&gt;
  # Update the &amp;lt;code&amp;gt;serial_baud&amp;lt;/code&amp;gt; line to read &amp;lt;code&amp;gt;serial_baud=115200&amp;lt;/code&amp;gt;&lt;br /&gt;
  # Update the &amp;lt;code&amp;gt;default_kernel_opts&amp;lt;/code&amp;gt; line to &amp;lt;code&amp;gt;quiet&amp;lt;/code&amp;gt; with &amp;lt;code&amp;gt;console=ttyS0,115200&amp;lt;/code&amp;gt;&lt;br /&gt;
# Run &amp;lt;code&amp;gt;update-extlinux&amp;lt;/code&amp;gt;&lt;br /&gt;
# Examine &amp;lt;code&amp;gt;/boot/extlinux.conf&amp;lt;/code&amp;gt;.&lt;br /&gt;
  # Make sure it looks OK. Compare with /boot/extlinux.conf-old.&lt;br /&gt;
  # If something looks wrong, &amp;lt;code&amp;gt;mv /boot/extlinux.conf-old /boot/extlinux.conf&amp;lt;/code&amp;gt; to roll back the changes and try to figure out what went wrong&lt;br /&gt;
# Cross your fingers and reboot. The system should boot properly with console on serial.&lt;/div&gt;</summary>
		<author><name>Tsarna</name></author>
	</entry>
</feed>