Lab 1 ubuntu9.04 kernel 2.6.28.9 +layer7v2.21+iptablev1.4.3.2+imq+ipset3.0

apt-get update
apt-get install build-essential kernel-package libncurses5-dev fakeroot
cd /usr/src/
apt-get source linux-source-2.6.28
chmod -R a-s /usr/src
ln -s linux-2.6.28 linux
wget Download Linux layer 7 packet classifier from SourceForge.net
wget Download Linux layer 7 packet classifier from SourceForge.net
wget http://iptables.org/projects/iptables/files/iptables-1.4.3.2.tar.bz2
wget http://www.linuximq.net/patchs/iptab....2-imq_xt.diff
wget http://www.linuximq.net/patchs/linux...imq-test2.diff
tar xvzf l7-protocols-2009-05-28.tar.gz
tar xvzf netfilter-layer7-v2.21.tar.gz
tar xvjf iptables-1.4.3.2.tar.bz2
ln -s iptables-1.4.3.2 iptables

cd /usr/src/linux
patch -p1 < ../netfilter-layer7-v2.21/kernel-2.6.25-2.6.28-layer7-2.21.patch
patch -p1 < ../linux-2.6.28.9-imq-test2.diff
cd /usr/src/iptables
patch -p1 < ../iptables-1.4.3.2-imq_xt.diff
cp ../netfilter-layer7-v2.21/iptables-1.4.1.1-for-kernel-2.6.20forward/*.* /usr/src/iptables/extensions
cd/usr/src/linux
cp /boot/config-2.6.28-11-server ./.config
make menuconfig

-----------------------------------------------
ให้เอา Xen guest support ออก ตรง
Processor type and features >> Paravirtualized guest support >> Xen guset support
เนื่องจาก Source Code ไม่มี Code ของ XEN

เลือกไปที่

Networking –> Networking options –> Network packet filtering framework (Netfilter) –> Core netfilter configuration
เลือกเพิ่ม
<M> Netfilter connection tracking support
<M> “layer7″ match support
• Layer 7 debugging output
• “IMQ” target support
ส่วน อันอื่นที่ยังไม่ได้เลือก ก็สามารถเลือกได้ ตามต้องการ สำหรับผม ในการติดตั้งครั้งนี้ จะเลือกทุกอันเลย โดยจะเลือกเป็นโมดูล [M] ไว้ก่อน
แล้ว exit ออกมา โดยกด Esc 2 ครั้งติดๆกัน แล้วไปที่ IP: Netfilter Configuration เลือกเพิ่ม

<M> IPv4 connection tracking support (required for NAT)
<M> Full NAT
กด esc ออกมาเรื่อยๆจนขึ้นให้ save ให้ save
-----------------------------------------------------

make-kpkg clean
make-kpkg --initrd --append-to-version=-l7 kernel_image kernel_headers
dpkg -i linux-image-2.6.28.9-l7_2.6.28.9-l7-10.00.Custom_i386.deb
dpkg -i linux-headers-2.6.28.9-l7_2.6.28.9-l7-10.00.Custom_i386.deb
shutdown -r now
ip link set imq0 up
ifconfig

-----------------------------------------------------
*ผลการรัน ifconfig หลังจากสั่ง ip link set imq0 up จะมี imq0 เพิ่มมานอกจาก interface network card
imq0 Link encap:UNSPEC HWaddr 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00
UP RUNNING NOARP MTU:16000 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:11000
RX bytes:0 (0.0 B) TX bytes:0 (0.0 B)

---------------------------------------------

Cd /usr/src/
Wget http://ipset.netfilter.org/ipset-3.0.tar.bz2
tar xvjf ipset-3.0.tar.bz2
cd /usr/src/ipset-3.0
KERNEL_DIR=/usr/src/linux make
KERNEL_DIR=/usr/src/linux make install

cp kernel/include/linux/netfilter_ipv4/ip_set.h /usr/src/iptables/include/linux/netfilter_ipv4/


------------------------------------------------------------------

*การ patch ipatable 1.4.11 ให้ support L 7
iptables 1.4.1.1 and newer
Copy libxt_layer7.c and libxt_layer7.man (from the subdirectory of the "Layer 7 patches" package that the README points you to) to the extensions/ directory of your iptables source. Then:
• "./configure --with-ksource=/path/to/patched/kernel_source" (use the full path)
• "make"
• (as root) "make install"
----------------------------------------------------

cd /usr/src/iptables
./configure --with-ksource=/usr/src/linux
Make
Make install
Iptables –m set –help (ทดสอบการทำงาน ipset)
mv /usr/src/l7-protocols-2009-05-28 /etc/l7-protocols
iptables -A FORWARD -m layer7 --l7proto bittorrent -j DROP
iptables –nvL

--------------------------------------------
*ผลการรัน iptables -nvL
Chain INPUT (policy ACCEPT 112 packets, 8282 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 LAYER7 l7proto bittorrent

Chain OUTPUT (policy ACCEPT 123 packets, 12404 bytes)
pkts bytes target prot opt in out source destination
----------------------------------------------------

cd /usr/src
wget http://ipp2p.org/downloads/ipp2p-0.8.2.tar.gz
wget ViewCVS Repository Listing*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
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


----------------------------------------------------
ใช้ winscp edit ไฟล์ libipt_ipp2p.c
Search exit_error แก้เป็น xtables_error (แก้ทุกตัวเพราะ iptable 1.4.3.2 เปลี่ยน เป็น function นี้)
ไปcode ด้านล่าง แก้ .version ตาม code ด้านล่าง
.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)),
.help = &help,
----------------------------------------------------------

# ถ้าใช้ 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/libexec/xtables/
cp ipt_ipp2p.ko /lib/modules/2.6.28.9-l7/kernel/net/netfilter/
depmod –a

iptables -A FORWARD -m ipp2p --ipp2p -j DROP
iptables -nvL

---------------------------------------
ผลการรัน iptable –nvL หลังจากสั่ง iptables -A FORWARD -m ipp2p --ipp2p -j DROP
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
--------------------------------------

ทีี่มา : ubuntu9.04+imq+layer7+ipset+ipp2p
WARNING
คำเตือน: นี่คือกระทู้เก่าแล้ว
การสนทนานี้เป็นที่เก่ากว่า 90 วัน ข้อมูลที่ปรากฏอยู่ในนั้นอาจไม่เป็นปัจจุบัน


กระทู้อื่นๆล่าสุดในฟอรั่มเดียวกันนี้: