iptables--L7-filter实现高级管理


l7-filter是一个定义在应用层上的来过滤数据包的。它可以按照不同的应用进行过滤,比如过滤聊天工具QQ、MSN、eDonkey等应用。

详细信息可以查看http://l7-filter.sourceforge.net/

接下来讲述l7-filter的编译安装和使用:
1、准备工作:
内核:linux-2.6.28.10.tar.gz
l7协议:l7-protocols-2009-05-28.tar.gz
l7过滤包:netfilter-layer7-v2.22.tar.gz
2、解压内核,为内核打补丁,编译内核
# tar zxvf  linux-2.6.28.10.tar.gz  -C  /usr/src
# tar zxvf  netfilter-layer7-v2.22.tar.gz  -C  /usr/src
# ln –s  /usr/src/linux-2.6.28.10/   /usr/src/linux
# cd /usr/src/linux/
# patch -p1  <  ../netfilter-layer7-v2.22/kernel-2.6.25-2.6.28-layer7-2.22.patch
# cp /boot/config-2.6.18-164.el5  /usr/src/linux/.config
# make  menuconfig

如图所示:

iptables--L7-filter实现高级管理

找到这个位置Networking support → Networking Options →
Network packet filtering framework →Code Netfilter Configuration,选中以下几个模块:
<M>  Netfilter connection tracking support
<M>  “layer7” match support
<M>  “string” match support
<M>  “time”  match support
<M>  “iprange”  match support
<M>  “connlimit”  match support
<M>  “state”  match support
<M>  “conntrack”  connection  match support
<M>  “mac”  address  match support
<M>  "multiport" Multiple port match support
然后在Networking support → Networking Options →
Network packet filtering framework → IP: Netfilter Configuration下
选择如下几个模块:
<M>IPv4 connection tracking support (required for NAT)
<M>Full NAT
   <M>MASQUERADE target support     
   <M>NETMAP target support 
   <M>REDIRECT target support
当然可以根据自己的需要,进行定制自己的内核。
内核定制完成之后就可以进入编辑的阶段了
# make
# make modules_install
# make install
然后打开/boot/grub/grub.conf 把默认的启动项设置为新内核
重新启动系统
3、卸载以前安装的iptables,编译安装iptables-1.4.6
# cp /etc/init.d/iptables ~/iptables  备份iptables脚本,方便后面应用
# cp /etc/sysconfig/iptables-config .  备份iptables的配置文件
# rpm  -e  iptables-ipv6  iptables  iptstate  --nodeps
# tar jxvf iptables-1.4.6.tar.bz2 –C  /usr/src
# cd /usr/src/iptables-1.4.6
# cp ../netfilter-layer7-v2.22/iptables-1.4.3forward-for-kernel \
-2.6.20forward/libxt_layer7.*   ./extensions/
# ./configure  --prefix=/usr  --with-ksource=/usr/src/linux
# make
# make install
编译完成

  • 1
  • 2
  • 下一页

相关内容