Layer 7 + Slackware Linux 12 + Kernel 2.6.25 + IPTables 1.4 (passo a passo)
Dica publicada em Linux / Segurança
Layer 7 + Slackware Linux 12 + Kernel 2.6.25 + IPTables 1.4 (passo a passo)
Obs.:
Fazer o download dos pacotes:
Kernel:
http://www.kernel.org/pub/linux/kernel/v2.6/linux-2.6.25.tar.bz2
Iptables 1.4.0:
http://www.netfilter.org/projects/iptables/files/iptables-1.4.0.tar.bz2
Layer7:
http://downloads.sourceforge.net/l7-filter/netfilter-layer7-v2.18.tar.gz?modtime=1209437315&big_mirror=0
Protocolos do Layer7:
http://downloads.sourceforge.net/l7-filter/l7-protocols-2008-04-23.tar.gz?modtime=1208987798&big_mirror=0
Remover a instalação anterior do iptables:
# removepkg iptables
Descompactar os pacotes:
# cd /usr/src
# tar -jxvf /root/linux-2.6.25.tar.bz2 -C /usr/src
# tar -jxvf /root/iptables-1.4.0.tar.bz2 -C /usr/src
# tar -zxvf /root/netfilter-layer7-v2.18.tar.gz -C /usr/src
# tar -zxvf /root/l7-protocols-2008-04-23.tar.gz-C /usr/src
Aplicando os patches:
# cd /usr/src/linux
# patch -p1 < ../netfilter-layer7-v2.18/kernel-2.6.25-layer7-2.18.patch
No iptables:
# cd /usr/src/iptables-1.3.4
# patch -p1 < ../netfilter-layer7-v2.18/iptables-1.4-for-kernel-2.6.20forward-layer7-2.18.patch
# chmod +x extensions/.layer7-test
Importando as configurações do kernel anterior:
# cp /boot/(config) /usr/src/linux-2.6.25/.config
# make oldconfig
(enter para todas as questões)
Compilando o Kernel:
# make menuconfig
Networking-->
Networking options -->
Network Packet Filtering framework (Netfilter) -->
Core Netfilter Configuration -->
(M) layer7 match suport #MARCAR COMO MÓDULO
(M) string match support #MARCAR COMO MÓDULO
# make
# make modules
# make modules_install
Copiando a imagem para o kernel novo:
# cp /usr/src/linux-2.6.25/arch/i386/boot/bzImage /boot/bzImage
# cp /usr/src/linux-2.6.25/System.map /boot/
# cd /boot
# rm -rf vmlinuz
# ln -s bzImage vmlinuz
Adicionando ao LILO:
# vim /etc/lilo.conf
# lilo
Compilando iptables:
# make SBIN_DIR=/sbin LIBDIR=/lib
# make SBIN_DIR=/sbin LIBDIR=/lib install
Instalando os protocolos do Layer7:
# cd /usr/src/l7-protocols-2008-04-23
# make install
# reboot
Exemplos de regras:
Site dos protocolos suportados no layer7:
Referências:
- Testado com as versões abaixo citadas;
- Utilize por sua conta e risco;
- Os procedimentos foram todos executados como superusuário (root).
Fazer o download dos pacotes:
Kernel:
http://www.kernel.org/pub/linux/kernel/v2.6/linux-2.6.25.tar.bz2
Iptables 1.4.0:
http://www.netfilter.org/projects/iptables/files/iptables-1.4.0.tar.bz2
Layer7:
http://downloads.sourceforge.net/l7-filter/netfilter-layer7-v2.18.tar.gz?modtime=1209437315&big_mirror=0
Protocolos do Layer7:
http://downloads.sourceforge.net/l7-filter/l7-protocols-2008-04-23.tar.gz?modtime=1208987798&big_mirror=0
Remover a instalação anterior do iptables:
# removepkg iptables
Descompactar os pacotes:
# cd /usr/src
# tar -jxvf /root/linux-2.6.25.tar.bz2 -C /usr/src
# tar -jxvf /root/iptables-1.4.0.tar.bz2 -C /usr/src
# tar -zxvf /root/netfilter-layer7-v2.18.tar.gz -C /usr/src
# tar -zxvf /root/l7-protocols-2008-04-23.tar.gz-C /usr/src
Aplicando os patches:
# cd /usr/src/linux
# patch -p1 < ../netfilter-layer7-v2.18/kernel-2.6.25-layer7-2.18.patch
No iptables:
# cd /usr/src/iptables-1.3.4
# patch -p1 < ../netfilter-layer7-v2.18/iptables-1.4-for-kernel-2.6.20forward-layer7-2.18.patch
# chmod +x extensions/.layer7-test
Importando as configurações do kernel anterior:
# cp /boot/(config) /usr/src/linux-2.6.25/.config
# make oldconfig
(enter para todas as questões)
Compilando o Kernel:
# make menuconfig
Networking-->
Networking options -->
Network Packet Filtering framework (Netfilter) -->
Core Netfilter Configuration -->
(M) layer7 match suport #MARCAR COMO MÓDULO
(M) string match support #MARCAR COMO MÓDULO
# make
# make modules
# make modules_install
Copiando a imagem para o kernel novo:
# cp /usr/src/linux-2.6.25/arch/i386/boot/bzImage /boot/bzImage
# cp /usr/src/linux-2.6.25/System.map /boot/
# cd /boot
# rm -rf vmlinuz
# ln -s bzImage vmlinuz
Adicionando ao LILO:
# vim /etc/lilo.conf
# lilo
Compilando iptables:
# make SBIN_DIR=/sbin LIBDIR=/lib
# make SBIN_DIR=/sbin LIBDIR=/lib install
Instalando os protocolos do Layer7:
# cd /usr/src/l7-protocols-2008-04-23
# make install
# reboot
Exemplos de regras:
#Bloqueio do menssager
iptables -A FORWARD -m layer7 --l7proto msnmessenger -j DROP
#Bloqueio do orkut usando o math string
iptables -A FORWARD -m string --string "orkut" --algo bm -j DROP
iptables -A FORWARD -m layer7 --l7proto msnmessenger -j DROP
#Bloqueio do orkut usando o math string
iptables -A FORWARD -m string --string "orkut" --algo bm -j DROP
Site dos protocolos suportados no layer7:
Referências:
- Slackware 11 + kernel2.6.18 + Layer7 + iptables/
- L7-filter Supported Protocols
- L7-filter Kernel Version HOWTO