How to Install APF Firewall

NOOT: Versie nummers kunnen afwijken van de vermelde versienummers op deze pagina!


Download APF:

mkdir /root/downloads
cd /root/downloads
wget http://www.rfxnetworks.com/downloads/apf-current.tar.gz



Pak de bestanden uit:
tar -xvzf apf-current.tar.gz
rm -f apf-current.tar.gz



Installeer APF:
# cd apf-0.9.7-1
# sh ./install.sh

Configuratie bestand aanpassen:
# cd /etc/apf
# nano -w conf.apf

Scroll naar beneden en vindt: (met de toetsencombinatie ctrl + w kan je ook zoeken)

USE_DS="0"
Verander dit naar:
USE_DS="1"

Nu moeten we de poorten in dit configuratie bestand gaan wijzigen.

Hieronder staan de poorten die ingevuld moeten zijn.

Common ingress (inbound) TCP ports
IG_TCP_CPORTS="21,22,25,53,80,443,587,110,143,995,2222,2525,7000,9667,6000_7000"
Noot: als SSH gebruik maakt van een andere poort als 22 dan moet je deze hier ook veranderen!

Code:
Common ingress (inbound) UDP ports
IG_UDP_CPORTS="53,6277"

Code:
Common ICMP (inbound) types
IG_ICMP_TYPES="3,5,11,0,30,8"

Code:
Common egress (outbound) TCP ports
EG_TCP_CPORTS="21,25,37,53,80,110,113,#123,443,587,43,873,953,2703,3306"

Code:
Common egress (outbound) UDP ports
EG_UDP_CPORTS="20,21,53,873,953,6277"

Code:
Common ICMP (outbound) types
EG_ICMP_TYPES="all"

Sla het bestand op:

(ctrl + x)

Start APF:


#  /usr/local/sbin/apf -s
Overige commando zijn:
-s start
-r herstart
-f flush - stop
-l list
-st status
-a HOST allow HOST
-d HOST deny HOST

Laat je ssh verbinding open staan en open een nieuwe ssh connectie naar je server.

(dit i.v.m controle of je jezelf niet heb uitgesloten van je server!)

Als alles nog bereikbaar is moeten we nog 1 ding doen:


# cd /etc/apf
# nano -w conf.apf

Scroll naar beneden en vindt: (met de toetsencombinatie ctrl + w kan je ook zoeken)
DEVEL_MODE="1"
change it to
DEVEL_MODE="0"

Sla het bestand weer op:

(ctrl + x)



Herstart APF:
# /usr/local/sbin/apf -r



-- Verwijder IP uit de block lijst --
Om een IP adres weer toegang te geven tot de server dien je het IP adres uit de deny list te verwijderen.

# nano /etc/apf/deny_hosts.rules

Verwijder het IP adres en sla het bestand weer op:
ctrl+x en kies voor "yes" [enter]
Herstart APF:
/usr/local/sbin/apf -r



Meer informatie: http://www.rfxnetworks.com/apf.php


Was this article helpful?

mood_bad Dislike 0
mood Like 3
visibility Views: 14332