Skip to main content
APF Firewall

APF firewall instalation and configuration

Configuring iptables rules can be complex so APF firewall greatly simplifies working with it.

This tutorial explains how you can install and configure APF on CentOS 5.11 and CentOS 6.7, 32 and 64 Bit OS versions which lets you easily configure iptables to secure server.

First of all we will update server software:

Now we will download, extract and install APF:

APF configuration files are located in the /etc/apf/ folder on your server:

  • conf.apf – file contains firewall configuration
  • allow_hosts.rules – file contains whitelisted IP addresses
  • deny_hosts.rules – file contains IPs that are being blocked

We will edit configuration file /etc/apf/conf.apf:

  • IFACE_IN – Depending on your setup but is usually “venet0” or “eth0” interface (run ifconfig when not sure)
  • IFACE_OUT – Same as IFACE_IN
  • SET_MONOKERN – On OpenVZ and Virtuozzo VPS servers set this to “1” otherwise leave it to “0”
  • IG_TCP_CPORTS – These are the INBOUND TCP ports you want to open. Open “22,80” 22 for SSH and 80 for HTTP
  • IG_UDP_CPORTS – Open inbound UDP ports. Open “53” if you run a DNS server

Save file and restart APF:

If you are SURE that you have a working configuration open again configuration file /etc/apf/conf.apf and edit:

  • DEVEL_MODE – Set this to “0”

Save file and restart APF:

We can use the following commands with APF:

  • apf -s # start firewall
  • apf -r # restart firewall
  • apf -f # stop firewall
  • apf -l # list statistics
  • apf -st # status of firewall
  • apf -a host # allow connections from “host”
  • apf -d host # block connections from “host”

SkyHosting

Best Hosting Services: .rs domain registration, Web Hosting, VPS Servers, SSL Certificates. Visit us SkyHosting.

Leave a Reply

Your email address will not be published. Required fields are marked *