ข่าว: ข่าวประกาศ

  • 27 เมษายน 2024, 02:46:54

เข้าสู่ระบบด้วยชื่อผู้ใช้ รหัสผ่าน และระยะเวลาในเซสชั่น

ผู้เขียน หัวข้อ: Ubuntu 9.10 + iptables 1.4.5 + layer7 + IMQ + ipset + ipp2p  (อ่าน 17190 ครั้ง)

admin

  • Administrator
  • Hero Member
  • *****
  • กระทู้: 3820
    • ดูรายละเอียด
    • อีเมล์
Ubuntu 9.10 + iptables 1.4.5 + layer7 + IMQ + ipset + ipp2p
« เมื่อ: 03 มีนาคม 2010, 13:13:52 »
หัวข้อนี้ จะเป็นขั้นตอนการเตรียม kernel สำหรับ os Ubuntu 9.10 เพื่อรองรับการใช้งาน l7, imq , ipset และ ipp2p

สำหรับ Ubuntu 9.10 นั้น จะใช้ kernel version 2.6.31 ซึ่ง iptables ที่เหมาะสมกับ kernel ตัวนี้มากที่สุด

ก็คือ version 1.4.5 เนื่องจาก iptables version นี้ รองรับ function ใหม่ ๆ ที่อยู่บน kernel 2.6.31 ครบทุก function

ขั้นตอนในการเตรียม source code , patch file และ ขั้นตอนการ compile เป็นดังนี้

source code

kernel 2.6.31
apt-get source linux-source-2.6.31

iptables 1.4.5
http://www.netfilter.org/projects/iptables/files/iptables-1.4.5.tar.bz2

ipset
http://ipset.netfilter.org/ipset-4.2.tar.bz2

IMQ
http://www.linuximq.net/patchs/linux-2.6.31.6-imq.diff
http://www.linuximq.net/patchs/iptables-1.4.4-imq.diff

IPP2P
http://www.ipp2p.org/downloads/ipp2p-0.8.2.tar.gz
http://sources.gentoo.org/viewcvs.py/*checkout*/gentoo-x86/net-firewall/ipp2p/files/ipp2p-0.8.2-kernel-2.6.22.patch
http://aur.archlinux.org/packages/ipp2p/ipp2p/ipp2p-0.8.2-kernel-2.6.28.patch
http://aur.archlinux.org/packages/ipp2p/ipp2p/ipp2p-0.8.2-iptables-1.4.0.patch
http://aur.archlinux.org/packages/ipp2p/ipp2p/ipp2p-0.8.2-iptables-1.4.1.patch

Layer7 patch
http://downloads.sourceforge.net/project/l7-filter/l7-filter%20kernel%20version/2.22/netfilter-layer7-v2.22.tar.gz?use_mirror=nchc

Layer7 protocol
http://downloads.sourceforge.net/project/l7-filter/Protocol%20definitions/2009-05-28/l7-protocols-2009-05-28.tar.gz?use_mirror=nchc

ทำการเริ่มขั้นตอนการ patch kernel เพื่อเตรียม compile

1. ติดตั้ง tools ต่างๆ ที่จำเป็นสำหรับการ compile

apt-get update
apt-get install build-essential kernel-package libncurses5-dev fakeroot

2. ทำการ download ubuntu kernel source

cd /usr/src
apt-get source linux-source-2.6.31
ln -s linux-2.6.31 linux

3. ทำการ download iptables 1.4.5

wget http://www.netfilter.org/projects/iptables/files/iptables-1.4.5.tar.bz2
tar xvjf iptables-1.4.5.tar.bz2
ln -s iptables-1.4.5 iptables

4. เตรียม patch IMQ และ Layer 7

wget http://www.linuximq.net/patchs/linux-2.6.31.6-imq.diff
wget http://downloads.sourceforge.net/project/l7-filter/l7-filter%20kernel%20version/2.22/netfilter-layer7-v2.22.tar.gz?use_mirror=nchc
wget http://downloads.sourceforge.net/project/l7-filter/Protocol%20definitions/2009-05-28/l7-protocols-2009-05-28.tar.gz?use_mirror=nchc
tar xvzf netfilter-layer7-v2.22.tar.gz
tar xvzf l7-protocols-2009-05-28.tar.gz
mv l7-protocols-2009-05-28 /etc/l7-protocols

5. ทำการ patch IMQ และ Layer7

cd linux
patch -p1 < ../netfilter-layer7-v2.22/kernel-2.6.25-2.6.28-layer7-2.22.patch
patch -p1 < ../linux-2.6.31.6-imq.diff

6. ทำการ config เตรียม compile

cp /boot/config-2.6.31-14-server ./.config
make menuconfig

ปรับแต่งค่า

Networking –> Networking options –> Network packet filtering framework (Netfilter) –> Core netfilter configuration

<M> "IMQ" target support
<M> "layer7" match support

ทำการ save แล้วก็ compile

*** เพิ่มความเร็วในการ compile ด้วย export CONCURRENCY_LEVEL=3 (จำนวน Core cpu + 1) ***

make-kpkg clean
make-kpkg --initrd --append-to-version=-l7-imq kernel_image kernel_headers

--- รอจนกระทั่ง compile เสร็จ ---

7. ทำการติดตั้ง kernel ตัวใหม่ แล้วก็ reboot เตรียม compile iptables, ipset และ ipp2p ต่อไป

cd ..
dpkg -i *.deb

reboot

8. เตรียมไฟล์ สำหรับ compile iptables

cd /usr/src
wget http://ipset.netfilter.org/ipset-4.2.tar.bz2
wget http://www.linuximq.net/patchs/iptables-1.4.4-imq.diff
wget http://www.ipp2p.org/downloads/ipp2p-0.8.2.tar.gz
wget http://sources.gentoo.org/viewcvs.py/*checkout*/gentoo-x86/net-firewall/ipp2p/files/ipp2p-0.8.2-kernel-2.6.22.patch
wget http://aur.archlinux.org/packages/ipp2p/ipp2p/ipp2p-0.8.2-kernel-2.6.28.patch
wget http://aur.archlinux.org/packages/ipp2p/ipp2p/ipp2p-0.8.2-iptables-1.4.0.patch
wget http://aur.archlinux.org/packages/ipp2p/ipp2p/ipp2p-0.8.2-iptables-1.4.1.patch

9. patch IMQ สำหรับ iptables

cd iptables
patch -p1 < ../iptables-1.4.4-imq.diff

10. patch Layer7 สำหรับ iptables

cp ../netfilter-layer7-v2.22/iptables-1.4.3forward-for-kernel-2.6.20forward/libxt_layer7.* extensions/

11. ทำการ compile iptables

./configure --with-ksource=/usr/src/linux
make
make install

12. ทำการ compile ipset

cd ..
tar xvjf ipset-4.2.tar.bz2
cd ipset-4.2
KERNEL_DIR=/usr/src/linux make
KERNEL_DIR=/usr/src/linux make install

13. ทำการ compile ipp2p

cd ..
tar xvzf ipp2p-0.8.2.tar.gz
cd ipp2p-0.8.2
patch -p1 < ../ipp2p-0.8.2-kernel-2.6.22.patch
patch -p1 < ../ipp2p-0.8.2-kernel-2.6.28.patch
patch -p1 < ../ipp2p-0.8.2-iptables-1.4.0.patch
patch -p1 < ../ipp2p-0.8.2-iptables-1.4.1.patch

ทำการแก้ไขไฟล์  libipt_ipp2p.c แก้ คำว่า exit_error เป็น xtables_error (ใช้ ctrl+w กับ ctrl+r)
pico libipt_ipp2p.c

และทำการแก้ structure ด้านล่าง เป็น
struct xtables_match ipp2p=
{
    .next           = NULL,
    .name           = "ipp2p",
    .family         = PF_INET,
   .version        = XTABLES_VERSION,
    .size           = XT_ALIGN(sizeof(struct ipt_p2p_info)),
    .userspacesize  = XT_ALIGN(sizeof(struct ipt_p2p_info)),

เสร็จแล้วทำการ save

ต่อไปแก้ไฟล์ Makefile

pico Makefile

แก้ด้านล่างเป็น

libipt_ipp2p.so: libipt_ipp2p.c ipt_ipp2p.h
        $(CC) $(CFLAGS) $(IPTABLES_OPTION) $(IPTABLES_INCLUDE) -fPIC -c libipt_ipp2p.c
       $(CC) -shared -o libipt_ipp2p.so libipt_ipp2p.o

เปลี่ยนตัว compile จาก ld เป็น cc

เสร็จแล้วทำการ save

make
cp libipt_ipp2p.so /usr/local/libexec/xtables/
cp ipt_ipp2p.ko /lib/modules/2.6.31.6-l7-imq/kernel/net/netfilter/
depmod –a

เป็นอันเสร็จเรียบร้อย

« แก้ไขครั้งสุดท้าย: 10 ธันวาคม 2010, 13:26:29 โดย admin »
<a href="http://www.hadyaiinternet.com/images/inetcafe.swf" target="_blank" rel="noopener noreferrer" class="bbc_link bbc_flash_disabled new_win">http://www.hadyaiinternet.com/images/inetcafe.swf</a>


There are no comments for this topic. Do you want to be the first?