一、重新编译内核

1、合并kernel+layer7补丁

[root@localhost ~]# tar -jxvf linux-2.6.25.19.tar.gz2 -C /usr/src/

[root@localhost ~]# tar -zxvf netfilter-layer7-v2.20.tar.gz -C /usr/src/

[root@localhost ~]# cd /usr/src/linux-2.6.25.19/

[root@localhost linux-2.6.25.19]# patch -p1 < /usr/src/netfilter-layer7-v2.20/kernel-2.6.25-layer7-2.20.patch

2、配置新内核

[root@localhost linux-2.6.25.19]# cp /boot/config-2.6.18-164.el5 .config

[root@localhost linux-2.6.25.19]# make menuconfig

1

2

 

3

4

Code Netfilter Configuration

5

将“Netfilter connection tracking suport (NEW)”选择编译为模块(M),需选取此

项才能看到layer7支持的配置。

6

将layer7、string、state、time、IPsec、iprange、connlimit……等编译成模块,根

据需要看着办。

7

8

IP: Netfilter Configuration

1

将“IPv4 connection tracking support (require for NAT)”编译成模块。

2

将“Full NAT”下的“MASQUERADE target support”和“REDIRECT target

support”编译成模块。

3 

编译及安装模块、新内核

[root@localhost linux-2.6.25.19]# make

[root@localhost linux-2.6.25.19]# make modules_install

[root@localhost linux-2.6.25.19]# make install

重启选择使用新的内核(2.6.25.19)引导系统.

[root@localhost linux-2.6.25.19]# vim /etc/grub.conf

编辑结果:

[root@localhost linux-2.6.25.19]# reboot

二、重新编译iptables  

1、卸载现有iptables

[root@localhost ~]# cd /etc/init.d

[root@localhost init.d]# cp iptables iptables.bak

[root@localhost init.d]# cd

[root@localhost ~]# rpm -e iptables --nodeps

2、合并iptables+layer7补丁

[root@localhost ~]# tar -jxvf iptables-1.4.2.tar.bz2 -C /usr/src

[root@localhost ~]# cd /usr/src/netfilter-layer7-v2.20/iptables-1.4.1.1-for-kernel-2.6.20forward/

[root@localhost iptables-1.4.1.1-for-kernel-2.6.20forward]# cp *  /usr/src/iptables-1.4.2/extensions/

3、编译安装

[root@localhost iptables-1.4.1.1-for-kernel-2.6.20forward]# cd /usr/src/iptables-1.4.2/

[root@localhost iptables-1.4.2]# ./configure --prefix=/ --with-ksource=/usr/src/linux-2.6.25.19

[root@localhost iptables-1.4.2]# make

[root@localhost iptables-1.4.2]# make install

[root@localhost iptables-1.4.2]# mv /etc/init.d/iptables.bak /etc/init.d/iptables

[root@localhost iptables-1.4.2]# service iptables start
清除防火墙规则:                                           [确定]
把 chains 设置为 ACCEPT 策略:filter                       [确定]
正在卸载 Iiptables 模块:                                  [确定]
应用 iptables 防火墙规则:                                 [确定]

4、安装l7-protocols模式包

[root@localhost ~]# tar -zxvf l7-protocols-2008-10-04.tar.gz  -C /etc/

[root@localhost ~]# mv /etc/l7-protocols-2008-10-04/ /etc/l7-protocols