IMQ i layer7 – część 1
No i oczywiście światłowód jest, ale nie ma konwertera… Oto Polska właśnie. A może Polacy??
Mniejsza z tym – pierwszą część już mam opracowaną, więc się podzielę. W drugiej przedstawię przykładowy skrypt ograniczający łącze.
1. Pobieramy kernel i rozpakowujemy go:
Kernel 2.6.27.24
tar -xjvf linux-2.6.27.24.tar.bz2 -C /usr/src
ln -s /usr/src/linux-2.6.27.24 /usr/src/linux
2. Pobieramy patche IMQ oraz layer7 i nakładamy na jądro:
IMQ patch
layer7 patch
cp linux-2.6.27.21-imq-test3.diff /usr/src/linux/linux-imq.diff
tar -xzvf netfilter-layer7-v2.21.tar.gz -C /usr/src
cp /usr/src/netfilter-layer7-v2.21/kernel-2.6.25-2.6.28-layer7-2.21.patch /usr/src/linux/linux-layer7.patch
cd /usr/src/linux
patch -p1 < linux-imq.diff
patch -p1 < linux-layer7.patch
3. Pobieramy plik konfiguracyjny jądra (można wykorzystać z bieżącego kernela) i kopiujemy do katalogu ze źródłami:
Slackware config huge 2.6.27.7-smp
cp config-huge-smp-2.6.27.7-smp /usr/src/linux/.config
4.Uruchamiamy konfigurowanie jądra (potwierdzamy wszystkie zmiany dotyczące IMQ oraz layer7 za pomocą “y” lub “m”):
make oldconfig
5. Następuje długotrwała kompilacja jądra.
6. Instalujemy moduły do katalogu /lib/modules/2.6.27.24-smp:
make modules_install
7. Instalujemy jądro do katalogu /boot:
make install
8. Na wszelki wypadek dopisujemy do Lilo obecnie wykorzystywany kernel:
mcedit /etc/lilo.conf
===============
(…)
image = /boot/vmlinuz.old
root = /dev/md0
label = LinuxOLD
read-only
(…)
===============
lilo -v
9. Należy załadować moduły jądra:
modprobe xt_layer7
modprobe xt_IMQ
Teraz przystępujemy do przekompilowania iptables:
10. Pobieramy iptables i rozpakowujemy:
iptables 1.4.2
tar -xjvf iptables-1.4.2.tar.bz2 -C /usr/src
ln -s /usr/src/iptables-1.4.2 /usr/src/iptables
11. Kopiujemy pliki z kodem źródłowym layer7:
cp /usr/src/netfilter-layer7-v2.21/iptables-1.4.1.1-for-kernel-2.6.20forward/libxt_layer7.* /usr/src/iptables/extensions/
12. Pobieramy i nakładamy patch IMQ:
iptables IMQ
cp iptables-1.4.1-imq.diff /usr/src/iptables/iptables-imq.diff
cd /usr/src/iptables
patch -p1 < iptables-imq.diff
13. Kompilujemy iptables:
./configure –prefix=/usr
make && make install
W ten sposób mamy przygotowany system do filtrowania usług i ograniczania łącza.
Hmm dziwne robię wszystko według Twojego opisu (Debian Lenny, czysty sys) i przy kompilacji iptables wywala mi:
libxt_layer7.c:25:39: warning: linux/netfilter/xt_layer7.h: Nie ma takiego pliku ani katalogu
libxt_layer7.c:48: warning: ’struct xt_layer7_info’ declared inside parameter list
libxt_layer7.c:48: warning: its scope is only this definition or declaration, which is probably not what you want
libxt_layer7.c: In function ‘parse_protocol_file’:
libxt_layer7.c:92: error: ‘MAX_PROTOCOL_LEN’ undeclared (first use in this function)
libxt_layer7.c:92: error: (Each undeclared identifier is reported only once
libxt_layer7.c:92: error: for each function it appears in.)
libxt_layer7.c:95: error: dereferencing pointer to incomplete type
libxt_layer7.c:101: error: ‘MAX_PATTERN_LEN’ undeclared (first use in this function)
libxt_layer7.c:103: error: dereferencing pointer to incomplete type
libxt_layer7.c: At top level:
libxt_layer7.c:249: warning: ’struct xt_layer7_info’ declared inside parameter list
libxt_layer7.c: In function ‘parse_layer7_protocol’:
libxt_layer7.c:270: warning: passing argument 3 of ‘parse_protocol_file’ from incompatible pointer type
libxt_layer7.c:284: error: dereferencing pointer to incomplete type
libxt_layer7.c:284: error: dereferencing pointer to incomplete type
libxt_layer7.c:284: error: ‘MAX_PATTERN_LEN’ undeclared (first use in this function)
libxt_layer7.c: In function ‘parse’:
libxt_layer7.c:296: warning: passing argument 2 of ‘parse_layer7_protocol’ from incompatible pointer type
libxt_layer7.c:298: error: dereferencing pointer to incomplete type
libxt_layer7.c: In function ‘print’:
libxt_layer7.c:339: error: dereferencing pointer to incomplete type
libxt_layer7.c:340: error: dereferencing pointer to incomplete type
libxt_layer7.c: In function ’save’:
libxt_layer7.c:348: error: dereferencing pointer to incomplete type
libxt_layer7.c:348: error: dereferencing pointer to incomplete type
libxt_layer7.c: At top level:
libxt_layer7.c:355: error: invalid application of ’sizeof’ to incomplete type ’struct xt_layer7_info’
libxt_layer7.c:356: error: invalid application of ’sizeof’ to incomplete type ’struct xt_layer7_info’
make[2]: *** [libxt_layer7.oo] Błąd 1
make[2]: Opuszczenie katalogu `/usr/src/iptables-1.4.2/extensions’
make[1]: *** [all-recursive] Błąd 1
make[1]: Opuszczenie katalogu `/usr/src/iptables-1.4.2′
make: *** [all] Błąd 2
Tom
21 wrzesień 2009 at 19:22
Zrobiłem tak:
krok 1:
cp /usr/src/linux-2.6.27.24/include/linux/netfilter/xt_layer7.* /usr/src/iptables/include/linux/netfilter/
cp /usr/src/linux-2.6.27.24/include/linux/netfilter_ipv4/ipt_IMQ.* /usr/src/iptables/include/linux/netfilter_ipv4
cp /usr/src/linux-2.6.27.24/include/linux/netfilter/xt_IMQ.* /usr/src/iptables/include/linux/netfilter/
cp /usr/src/linux-2.6.27.24/include/linux/netfilter_ipv6/ip6t_IMQ.* /usr/src/iptables/include/linux/netfilter_ipv6/
po tej operacji skompilowały się źródła, ale instalator zgłosił:
Libraries have been installed in:
/usr/lib
If you ever happen to want to link against installed libraries
in a given directory, LIBDIR, you must either use libtool, and
specify the full pathname of the library, or use the `-LLIBDIR’
flag during linking and do at least one of the following:
– add LIBDIR to the `LD_LIBRARY_PATH’ environment variable
during execution
– add LIBDIR to the `LD_RUN_PATH’ environment variable
during linking
– use the `-Wl,–rpath -Wl,LIBDIR’ linker flag
– have your system administrator add LIBDIR to `/etc/ld.so.conf’
zrobiłem wiłc śledztwo i:
testowy:/usr/src/iptables# iptables -m layer7 –help
iptables v1.4.2: Couldn’t load match `layer7′:/lib/xtables/libipt_layer7.so: cannot open shared object file: No such file or directory
testowy:/# find / | grep layer7.so
/usr/src/iptables-1.4.2/extensions/libxt_layer7.so
/usr/libexec/xtables/libxt_layer7.so
czyli wrzucił do /usr/libexec zamiast do /lib
zrobiłem więc myk:
mv /usr/libexec/xtables/* /lib/xtables/
i iptables widzi moduły.
Dzięki za dobre How-to. Jedne z lepszych na necie
Tom
21 wrzesień 2009 at 20:05
a i jeszcze to:
wget http://downloads.sourceforge.net/project/l7-filter/Protocol%20definitions/2009-05-28/l7-protocols-2009-05-28.tar.gz?use_mirror=biznetnetworks
tar xvvf l7-protocols-2009-05-28.tar.gz
mv l7-protocols-2009-05-28 l7-protocols
Tom
21 wrzesień 2009 at 21:56