20080202-1400
Kernel-2.6.24 + iptables-1.4.0 + L7-filter-2.17 + ipp2p-0.8.2 on Debian 4.0
คราวนี้ ผมไม่ใช้ ipp2p-0.8.1_rc1 จาก patch-o-matic แล้ว จะใช้ ipp2p-0.8.2 จาก ipp2p.org แทน บวกกับ patch ที่แอบขโมยมาจาก gentoo 🙂
1.
apt-get update
apt-get install build-essential
apt-get install kernel-package
apt-get install libncurses5-dev
2.
cd /usr/src/
wget http://www.kernel.org/pub/linux/kernel/v2.6/linux-2.6.24.tar.bz2
tar xvjf linux-2.6.24.tar.bz2
ln -s linux-2.6.24 linux
wget http://nchc.dl.sourceforge.net/sourceforge/l7-filter/netfilter-layer7-v2.17.tar.gz
wget http://jaist.dl.sourceforge.net/sourceforge/l7-filter/l7-protocols-2008-01-16.tar.gz
wget http://iptables.org/projects/iptables/files/iptables-1.4.0.tar.bz2
tar xvzf l7-protocols-2008-01-16.tar.gz
tar xvzf netfilter-layer7-v2.17.tar.gz
tar xvjf iptables-1.4.0.tar.bz2
ln -s iptables-1.4.0 iptables
3. patch linux kernel & iptables with l7-filter
cd /usr/src/linux
patch -p1 < ../netfilter-layer7-v2.17/kernel-2.6.22-2.6.24-layer7-2.17.patch
cd ../iptables
patch -p1 < ../netfilter-layer7-v2.17/iptables-1.4-for-kernel-2.6.20forward-layer7-2.17.patch
chmod +x extensions/.layer7-test
4. config and compile kernel
cd /usr/src/linux
cp /boot/config-2.6.18-5-686 ./.config
make menuconfig
เลือกไปที่
Networking –> Networking options –> Network packet filtering framework (Netfilter) –> Core netfilter configuration
เลือกเพิ่ม
<M> Netfilter connection tracking support
<M> “layer7” match support
[*] Layer 7 debugging output
ส่วนอันอื่นที่ยังไม่ได้เลือก ก็สามารถเลือกได้ ตามต้องการ สำหรับผม ในการติดตั้งครั้งนี้ จะเลือกทุกอันเลย โดยจะเลือกเป็นโมดูล [M] ไว้ก่อน
แล้ว exit ออกมา โดยกด Esc 2 ครั้งติดๆกัน แล้วไปที่ IP: Netfilter Configuration เลือกเพิ่ม
<M> IPv4 connection tracking support (required for NAT)
<M> Full NAT
อยู่ด้านล่างสุดเลย แล้ว exit ออกมา โดยกด Esc 2 ครั้ง ไปเรื่อยๆ จนกระทั่งปรากฏหน้าจอ
Do you wish to save your new kernel configuration?
ให้กด Enter เพื่อบันทึกค่าคอนฟิก
5. คอมไพล์และสร้าง kernel image ใหม่ ขั้นตอนนี้ต้องรอนานหน่อยนะครับ
make-kpkg clean
make-kpkg --initrd --append-to-version=-l7 kernel_image kernel_headers
6. หลังจากรอคอยมานาน ต่อไปก็ติดตั้ง kernel ใหม่
cd /usr/src
dpkg -i linux-image-2.6.24-l7_2.6.24-l7-10.00.Custom_i386.deb
dpkg -i linux-headers-2.6.24-l7_2.6.24-l7-10.00.Custom_i386.deb
ตรวจสอบไฟล์ /boot/grub/menu.lst ว่าค่า default เป็นเคอร์เนลที่ติดตั้งใหม่
shutdown -r now
8. คอมไพล์และติดตั้ง iptables
cd /usr/src/iptables
make KERNEL_DIR=/usr/src/linux
make install
mv /usr/src/l7-protocols-2008-01-16 /etc/l7-protocols
9. คอมไพล์และติดตั้ง ipp2p
cd /usr/src
wget http://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://sources.gentoo.org/viewcvs.py/*checkout*/gentoo-x86/net-firewall/ipp2p/files/ipp2p-0.8.2-iptables-1.4.0.patch
tar xvzf ipp2p-0.8.2.tar.gz
cp -a ipp2p-0.8.2 ipp2p-0.8.2.orig
cd ipp2p-0.8.2
patch -p1 <../ipp2p-0.8.2-kernel-2.6.22.patch
patch -p1 <../ipp2p-0.8.2-iptables-1.4.0.patch
# ถ้าใช้ ld จะมีปัญหาในการโหลดโมดูล แก้ให้ใช้ gcc ที่บรรทัดท้ายๆของไฟล์ Makefile
vi Makefile
…
libipt_ipp2p.so: libipt_ipp2p.c ipt_ipp2p.h
$(CC) $(CFLAGS) $(IPTABLES_OPTION) $(IPTABLES_INCLUDE) -fPIC -c libipt_ipp2p.c
@# ld -shared -o libipt_ipp2p.so libipt_ipp2p.o
$(CC) -shared -o libipt_ipp2p.so libipt_ipp2p.o
clean:
-rm -f *.o *.so *.ko .*.cmd *.mod.c
endif
make
cp libipt_ipp2p.so /usr/local/lib/iptables/
cp ipt_ipp2p.ko /lib/modules/2.6.24-l7/kernel/net/netfilter/
depmod -a
11. Test
iptables -A FORWARD -m ipp2p --ipp2p -j DROP
iptables -A FORWARD -m layer7 --l7proto bittorrent -j DROP
mydebian:/usr/src/ipp2p-0.8.2# iptables -nvL
Chain INPUT (policy ACCEPT 1116 packets, 82622 bytes)
pkts bytes target prot opt in out source destination
Chain FORWARD (policy ACCEPT 0 packets, 0 bytes)
pkts bytes target prot opt in out source destination
0 0 DROP all — * * 0.0.0.0/0 0.0.0.0/0 ipp2p v0.8.2 –ipp2p
0 0 DROP all — * * 0.0.0.0/0 0.0.0.0/0 LAYER7 l7proto bittorrent
Chain OUTPUT (policy ACCEPT 664 packets, 91251 bytes)
pkts bytes target prot opt in out source destination
mydebian:/usr/src/ipp2p-0.8.2# lsmod | egrep 'ipp2p|layer7'
xt_layer7 11236 1
nf_conntrack 62720 2 nf_conntrack_ipv4,xt_layer7
ipt_ipp2p 6848 1
x_tables 14372 3 xt_layer7,ipt_ipp2p,ip_tables
ขอบคุณครับสำหรับบทความดีๆ เคยติดตามบทความตอนที่ยังเป็น kernal เวอร์ก่อนผมลองทำตามแล้วเวลาใช้งานจริง ขึ้น error แบบนี้ครับ
layer7: couldn’t get conntrack
ซึ่งในส่วน IP: Netfilter Configuration เลือกหมดเลยครับ
หลังจากอ่านบทความใหม่นี้อีกรอบ ผมจะลองทำดูอีกรอบนะครับ แล้วจะมารายงานผมครับ
ความเห็น โดย delphi — กุมภาพันธ์ 5, 2008 @ 6:34 pm |
This is very good tutorial. I don’t know what is it language and don’t know what is county , but everything is understandable. Good job!
ความเห็น โดย scibior — เมษายน 16, 2008 @ 3:36 am |
ขอบคุณครับ ของผมเป็น Debian lenny amd64 ครับ
ผมทำตามแล้วปรากฎว่าได้ผลครับ
โหลดบิตไม่ได้เลย
ขออนุญาติแปะลิงค์ไว้ที่ http://www.debianclub.org/node/243 นะครับ
จะได้แชร์ความรู้ให้คนอื่นด้วยครับ
ความเห็น โดย mansuang — เมษายน 19, 2008 @ 8:59 pm |
[…] ขออนุญาต คุณสุชาตินะครับ ขอเอามาแปะไว้ก่อน จาก https://suchart.wordpress.com/2008/02/02/kernel-2624-iptables-140-l7-filter-217-ipp2p-082-on-debian-4… […]
Pingback โดย Kernel-2.6.24 + iptables-1.4.0 + L7-filter-2.17 + ipp2p-0.8.2 on Debian 4.0 by Mr.Prasert Teppap — มิถุนายน 27, 2008 @ 10:40 am |
I’m always getting a segmentation fault and ipp2p doesn’t work at all.
# iptables -A FORWARD -m ipp2p –ipp2p -j DROP
Segmentation fault
where iptables -m ipp2p –help works ok.
Any ideas?
ความเห็น โดย Stelios — กันยายน 16, 2008 @ 9:45 pm |
Strace output for further info:
execve(”/usr/local/sbin/iptables”, [“iptables”, “-A”, “FORWARD”, “-m”, “ipp2p”, “–ipp2p”, “-j”, “MARK”, “–set-mark”, “0x01”], [/* 18 vars */]) = 0
brk(0) = 0×8054000
access(”/etc/ld.so.nohwcap”, F_OK) = -1 ENOENT (No such file or directory)
mmap2(NULL, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0xb7fb5000
access(”/etc/ld.so.preload”, R_OK) = -1 ENOENT (No such file or directory)
open(”/etc/ld.so.cache”, O_RDONLY) = 3
fstat64(3, {st_mode=S_IFREG|0644, st_size=23241, …}) = 0
mmap2(NULL, 23241, PROT_READ, MAP_PRIVATE, 3, 0) = 0xb7faf000
close(3) = 0
access(”/etc/ld.so.nohwcap”, F_OK) = -1 ENOENT (No such file or directory)
open(”/lib/tls/i686/cmov/libdl.so.2″, O_RDONLY) = 3
read(3, “\177ELF\1\1\1\3\3\1p\n00″…, 512) = 512
fstat64(3, {st_mode=S_IFREG|0644, st_size=9684, …}) = 0
mmap2(NULL, 12412, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0xb7fab000
mmap2(0xb7fad000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0×1) = 0xb7fad000
close(3) = 0
access(”/etc/ld.so.nohwcap”, F_OK) = -1 ENOENT (No such file or directory)
open(”/lib/tls/i686/cmov/libc.so.6″, O_RDONLY) = 3
read(3, “\177ELF\1\1\1\3\3\1\260e\1″…, 512) = 512
fstat64(3, {st_mode=S_IFREG|0755, st_size=1364388, …}) = 0
mmap2(NULL, 1369712, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0xb7e5c000
mmap2(0xb7fa5000, 12288, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0×149) = 0xb7fa5000
mmap2(0xb7fa8000, 9840, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0xb7fa8000
close(3) = 0
mmap2(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0xb7e5b000
set_thread_area({entry_number:-1 -> 6, base_addr:0xb7e5bad0, limit:1048575, seg_32bit:1, contents:0, read_exec_only:0, limit_in_pages:1, seg_not_present:0, useable:1}) = 0
mprotect(0xb7fa5000, 4096, PROT_READ) = 0
munmap(0xb7faf000, 23241) = 0
brk(0) = 0×8054000
brk(0×8075000) = 0×8075000
open(”/usr/local/lib/iptables/libipt_ipp2p.so”, O_RDONLY) = 3
read(3, “\177ELF\1\1\1\3\3\1\300\4″…, 512) = 512
fstat64(3, {st_mode=S_IFREG|0755, st_size=11594, …}) = 0
mmap2(NULL, 11252, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0xb7fb2000
mmap2(0xb7fb4000, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0×1) = 0xb7fb4000
close(3) = 0
— SIGSEGV (Segmentation fault) @ 0 (0) —
+++ killed by SIGSEGV +++
Process 6301 detached
ความเห็น โดย Stelios — กันยายน 16, 2008 @ 9:50 pm |