How to install APF Firewall and DDoS Deflate protection

→ Are you a new visitor? Please visit the page guidance for new visitors ←

About APF firewall

APF Firewall stands for Advance Policy Firewall, exactly as it name, it is script that contains a certain set of firewall rules. These rules are all being saved inside the folder /etc/apf/ directory and can be changed using any editor.

This script is one of the best firewall scripts that I’ve used so far for my personal websites. One other that could be compared to is CSF (Config Server Firewall), but this, while it is really good, but I found it really confusing on some parts, although I do use it on some shared hosting server.

Well without delaying anymore then this, lets get started and install our little script.

Once we are in the install folder (in my case this is apf-9.7.2) we can start the installation.

The result wold be something similar to the output bellow:

Now we need to configure our little firewall rules so that we won’t be blocked, in case you connect remotely to you server via SSH, do not forget to open you SSH port.

The configuration file is located at:

There would be a default configuration already set, you will need to go over it at least once and carefully open the ports that you need your server to have.

Restart APF to test the configuration:

If everything is alright, open the configuration file once more and change the bellow setting


And run the restart command once again.

Useful commands



(D)DoS Deflate is another shell script that is being used by hosting providers or individuals that manage their own server. This script however is being used together with APF Firewall and is running on a cronjob to make sure visits are being checked. While the option is ok, I believe LFD from CSF package I mentioned earlier has better advantage over this. But nevertheless this script does it job that was made for.

To install DDoS Deflate, we follow the bellow commands:

A few settings need to be set before we start using it, open the bellow file and then follow the comments inside the file:

Each of the options are explain there, you just need to be sure you’re reading them and have a bit of patience.

That’s it for now, do not forget to share it if you like it.

Request an article ←