กลัวว่าแฟนๆ ของ gentoo จะน้อยใจ ที่ไม่ได้เขียนถึง ทั้งๆที่แอบไปขโมย patch เขามาใช้ เขียนคร่าวๆ พอเป็นแนวทาง
1.
mygentoo-2 ~ # emerge --sync
mygentoo-2 ~ # nano /etc/portage/package.keywords
net-firewall/iptables ~x86
net-misc/l7-filter ~x86
net-misc/l7-protocols ~x86
net-firewall/ipp2p ~x86
2.
mygentoo-2 ~ # nano /etc/portage/package.use
net-firewall/iptables l7filter
3.
mygentoo-2 ~ # emerge l7-filter
4. คอมไพล์ และติดตั้งเคอร์เนล และรีบูตเข้าสู่เคอร์เนลใหม่ สำหรับที่ผมทำ ประมาณนี้
# mount /boot
# cd /usr/src/linux
# cp .config config.1
# make menuconfig
General setup => (-l7) Local version – append to kernel release
ส่วนอันอื่่นที่เกี่ยวกับ Netfilter ก็ดูได้จากโพสต์อันก่อนๆ นะครับ ง่ายๆ ก็คือผมเลือกทั้งหมดแหละครับ โดยอันไหนเลือกเป็นโมดูลได้ก็เลือกเป็นโมดูลไว้ก่อน
นอกจากนี้ผมยังรวม scsi disk controller driver ของเครื่องเข้าไว้ในเคอร์เนลเลย จึงไม่ต้องใช้ initrd
# make
# make modules_install
# make install
# nano /boot/grub/grub.conf
default 1
timeout 5
splashimage=(hd0,0)/boot/grub/splash.xpm.gz
title=Gentoo Linux 2.6.23-gentoo-r6
root (hd0,0)
kernel /boot/kernel-genkernel-x86-2.6.23-gentoo-r6 root=/dev/ram0 init=/linuxrc ramdisk=8192 real_root=/dev/sda3 udev doscsi
initrd /boot/initramfs-genkernel-x86-2.6.23-gentoo-r6
title=Gentoo Linux 2.6.23-r6-l7
root (hd0,0)
kernel /boot/vmlinuz-2.6.23-gentoo-r6-l7 root=/dev/sda3
แล้วรีบูตเข้าสู่เคอร์เนลที่ติดตั้งใหม่
# reboot
5.
mygentoo-2 ~ # emerge iptables
6.
mygentoo-2 ~ # emerge ipp2p
7. Test
mygentoo-2 ~ # iptables -A FORWARD -m ipp2p --ipp2p -j DROP
mygentoo-2 ~ # iptables -A FORWARD -m layer7 --l7proto bittorrent -j DROP
mygentoo-2 ~ # iptables -nvL
Chain INPUT (policy ACCEPT 30 packets, 2232 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 17 packets, 1844 bytes)
pkts bytes target prot opt in out source destination
mygentoo-2 ~ #