Instalando o APF
Acesse o SSH:
cd /usr/local/src/
wget http://www.rfxnetworks.com/downloads/apf-current.tar.gz
tar -zxvf apf-current.tar.gz; cd apf-*
sh ./install.sh
Para configurar o APF, abra no seu editor favorito:
cd /etc/apf
vi conf.apf
No início das configurações verifique a variável DEVEL_MODE:
DEVEL_MODE=”1″
Sempre que editar as regras do APF é interessante mante-la com valor 1, pois se algum problema ocorrer ela voltará ao arquivo original após 5 minutos.
Localize as variáveis que definem a INTERFACE DE ENTRADA E SAIDA:
IFACE_IN=”eth0″
IFACE_OUT=”eth0″
Se você estiver utiliando a SOFTLAYER altere para eth1:
IFACE_IN=”eth1″
IFACE_OUT=”eth1″
Localize também:
IFACE_TRUSTED=”"
E altere para:
IFACE_TRUSTED=”eth0″
Agora deveremos configurar as variaveis responsáveis por permitir o acesso TCP, UDP e ICMP. A configuração abaixo é indicada em caso de CPANEL, lembrando também que se você alterou a porta do SSH (22), deverá alterar na linha abaixo:
# Common ingress (inbound) TCP ports
IG_TCP_CPORTS=”20,21,22,25,26,53,80,110,143,161,443,465,623,993,995,2082,2083,2086,2087,2095,2096,3306,3389,6666″
# Common ingress (inbound) UDP ports
IG_UDP_CPORTS=”21,53,161,465,623,873″
# Common ICMP (inbound) types
# ‘internals/icmp.types’ for type definition; ‘all’ is wildcard for any
IG_ICMP_TYPES=”3,5,11,0,30,8″
Substitua também os valores das variáveis conforme abaixo:
# Egress filtering [0 = Disabled / 1 = Enabled]
EGF=”1″
# Common egress (outbound) TCP ports
EG_TCP_CPORTS=”21,22,25,26,27,37,43,53,80,110,113,161,443,465,623,873,2089,3389″
# Common egress (outbound) UDP ports
EG_UDP_CPORTS=”20,21,53,161,465,623,873″
# Common ICMP egress (outbound) types
# ‘internals/icmp.types’ for type definition; ‘all’ is wildcard for any
EG_ICMP_TYPES=”all”
A opção abaixo habilita a proteçao para redes suspeitas (uma espécie de blacklist):
USE_DS=”1″
Salve as alterações no arquivo de configuração e reinicie:
apf -r
Development mode enabled!; firewall will flush every 5 minutes.
Lembre-se, que o arquivo será restaurado em 5 minutos, por isso é importante que se tudo estiver ok você retire o modo “Development”.
Abra e edite a arquivo de configuração:
DEVEL_MODE=”0″
Reinicie o APF:
apf -r
Adicione para iniciar automaticamente:
chkconfig –level 2345 apf on
Fonte: http://curso.brlogic.com/blog/
