天天看點

Ubuntu9.04安裝L7-filter

一、準備工作

1、Ubuntu9.04的核心版本是2.6.28-11-generic,可以用指令uname -r來檢視核心版本

2、L7-filter安裝有兩種方法:

1)安裝Userspace版的L7-filter
2)安裝核心版的L7-filter

本方法采取方法2),即更新核心的方法安裝核心版的L7-filter。

3、下載下傳以下檔案:

1)iptables-1.4.11.1.tar.bz2,安裝最新的iptables軟體,iptables是運作于netfilter之上的應用層軟體。

2)l7-protocols-2009-05-28.tar.gz,最新的Layer7協定,其中包含了L7所需的比對模式。

3)linux-2.6.30.5.tar.gz,将linux核心更新到2.6.30.5版本。

4)netfilter-layer7-v2.22.tar.gz,更新netfilter,并用來給核心打支援Layer7的更新檔。

4、更新軟體源,安裝配置核心的工具

1)找一個和自己網絡比對的軟體源,如教育網源、電信網源等。我是電信網就選了網易的更新源。

#sudo gedit /etc/apt/sources.list

添加以下源位址到sources.list檔案中,删除原來的所有内容。

deb http://tel.mirrors.163.com/ubuntu/ lucid main restricted universe multiverse
deb http://tel.mirrors.163.com/ubuntu/ lucid-security main restricted universe multiverse
deb http://tel.mirrors.163.com/ubuntu/ lucid-updates main restricted universe multiverse
deb http://tel.mirrors.163.com/ubuntu/ lucid-proposed main restricted universe multiverse
deb http://tel.mirrors.163.com/ubuntu/ lucid-backports main restricted universe multiverse
deb-src http://tel.mirrors.163.com/ubuntu/ lucid main restricted universe multiverse
deb-src http://tel.mirrors.163.com/ubuntu/ lucid-security main restricted universe multiverse
deb-src http://tel.mirrors.163.com/ubuntu/ lucid-updates main restricted universe multiverse
deb-src http://tel.mirrors.163.com/ubuntu/ lucid-proposed main restricted universe multiverse
deb-src http://tel.mirrors.163.com/ubuntu/ lucid-backports main restricted universe multiverse
           

執行更新源指令

#sudo apt-get update

2)安裝程式設計工具和配置核心的工具

#sudo apt-get install build-essential kernel-package libncurses5-dev

有的攻略說要安裝initramfs,其實安裝kernel-package就包含了initramfs功能了,額外安裝initramfs反而會導緻無法進入X桌面。

二、打更新檔、更新核心

1、把以上下載下傳的4個檔案複制到/usr/src目錄下,執行以下指令。

#cd /usr/src

#tar -zxvf linux-2.6.30.5.tar.gz

#tar -zxvf netfilter-layer7-v2.22.tar.gz

#tar -zxvf l7-protocols-2009-05-28.tar.gz

#tar -xjf iptables-1.4.11.1.tar.bz2

2、給linux核心打更新檔

#cd /usr/src/linux-2.6.30.5

#patch -p1 <../netfilter-layer7-v2.22/kernel-2.6.25-2.6.28-layer7-2.22.patch

3、編譯核心

#cd /usr/src/linux-2.6.30.5

#make menuconfig

進入核心配置界面後,勾選以下兩個選項,儲存退出。

Networking support -->Networking options --> Network packet filtering framework(Netfilter)--> 

Core Netfilter Configuration--> 勾選layer7 match support和Layer 7 debugging output

#cd /usr/src/linux-2.6.30.5

#make                                         //大約要一個小時,是以可以幹點其他的事情

#make modules_install

#make install

4、生成initrd鏡像檔案、修改grub

#cd /usr/src/linux-2.6.30.5

#mkinitramfs -o /boot/initrd.img-2.6.30.5  2.6.30.5

   //最後的參數2.6.30.5是版本号,要與/lib/modules下相應的檔案夾名相同

#sudo gedit /boot/grub/menu.lst

如果Ubuntu是硬裝的,就在menu.lst後面添加以下代碼:

title  Ubuntu 9.04, kernel 2.6.30.5
kernel /boot/vmlinuz-2.6.30.5  root=/dev/sda1  ro  quiet  splash
initrd /boot/initrd.img-2.6.30.5
quiet
           
如果Ubuntu是wubi安裝的,就在menu.lst後面添加以下代碼:
title  Ubuntu 9.04, kernel 2.6.30.5
root   (hd0,0)/ubuntu/disks
kernel /boot/vmlinuz-2.6.30.5 root=/dev/sda1 loop=/ubuntu/disks/root.disk ro quiet splash
initrd /boot/initrd.img-2.6.30.5
quiet
           

以上menu.lst中的“root=”後面的内容填寫UUID和主分區路徑都行。

接下來reboot,就能進入更新到2.6.30.5版本核心的Ubuntu了。

三、安裝更新iptables

#cd /usr/src

#tar -jxvf iptables-1.4.11.1.tar.bz2

#cd iptables-1.4.11.1

#cd /usr/src/netfilter-layer7-v2.22/iptables-1.4.3forward-for-kernel-2.6.20forward

#cp libxt_layer7.*   /usr/src/iptables-1.4.11.1/extensions/

#cd /usr/src/iptables-1.4.11.1

#./configure  --prefix=/  --with-ksource=/usr/src/linux-2.6.30.5

#make

#make install

現在可以用iptables -V指令檢視一下iptables版本,可以看到已經被更新了。

四、安裝l7-protocols模式包

#cd /usr/src

#tar -zvxf l7-protocols-2009-05-28.tar.gz

#cd l7-protocols-2009-05-28

#make install 

繼續閱讀