Advanced Policy Firewall (APF) is an iptables(netfilter) based firewall system designed around the essential needs of todays Internet deployed servers and the unique needs of custom deployed Linux installations.
Make sure iptables is installed:
yum install iptables*
Download, unpack, and install APF from source:
cd /usr/local/src
wget http://www.rfxn.com/downloads/apf-current.tar.gz
tar -zxf apf-current.tar.gz
cd apf-9*
./install.sh
Backup the original APF config file:
cp /etc/apf/conf.apf /etc/apf/conf.apf.bak
Now edit the current APF config file:
nano -w /etc/apf/conf.apf
Change the following values:
* RAB="0" to RAB="1"
* RAB_PSCAN_LEVEL="2" to RAB_PSCAN_LEVEL="3"
* TCR_PASS="1" to TCR_PASS="0"
* DLIST_PHP="0" to DLIST_PHP="1"
* DLIST_SPAMHAUS="0" to DLIST_SPAMHAUS="1"
* DLIST_DSHIELD="0" to DLIST_DSHIELD="1"
* DLIST_RESERVED="0" to DLIST_RESERVED="1"
Find IFACE_IN= and IFACE_OUT= in /etc/apf/conf.apf and verify that they match your network interface.
Locate HELPER_SSH_PORT=”22″ and change it to your SSH port IF you changed it in your sshd_config.
Locate IG_TCP_CPORTS=”22″ and change it to your SSH port IF you changed it in your sshd_config.
Now restart the APF:
/usr/local/sbin/apf -r
Now relogin though ssh again, to verify that you still can login into your server.
When your happy with your firewall and everything works fine, Edit /apf.conf find DEVEL_MODE=”1″ and change it to DEVEL_MODE=”0″.
Restart the APF again:
/usr/local/sbin/apf -r
Make sure APF starts automatic after restart:
chkconfig --add apf
chkconfig --level 345 apf on
The firewall should now be active!
Here are some common ports used by cpanel:
Cpanel:
IG_TCP_CPORTS=”20,21,22,25,26,53,80,110,143,443,465,993,995,2082,2083,2086,2087,2095,2096″
IG_UDP_CPORTS=”21,53,873″
EGF=”1″
EG_TCP_CPORTS=”21,22,25,26,27,37,43,53,80,110,113,443,465,873,2089″
EG_UDP_CPORTS=”20,21,37,53,873″