Chinaunix首页 | 论坛 | 博客
  • 博客访问: 170531
  • 博文数量: 64
  • 博客积分: 13
  • 博客等级: 民兵
  • 技术积分: 345
  • 用 户 组: 普通用户
  • 注册时间: 2011-12-20 21:17
文章分类
文章存档

2012年(64)

分类:

2012-07-11 16:49:52

一、简介
 iptables layer7的功能可以实现对应用层软件的过滤,例如:限制qq、迅雷等软件,这样对一些公司和学校非常有用。下面介绍具体的实现过程。
二、总体步骤概括
 (1)给内核打补丁,并重新编译内核。
 (2)给iptables源码打补丁,并重新编译iptables
 (3)安装l7proto
三、给内核打补丁并重新编译内核
 (1)下载软件包:linux-2.6.28.10.tar.gz,netfilter-layer7-v2.22.tar.gz.
 (2)给内核打补丁。执行以下命令。


点击(此处)折叠或打开

  1. #tar zxvf linux-2.6.28.10.tar.gz -C /usr/src (一定要解压到/usr/src中)
  2.  #tar zxvf netfilter-layer7-v2.22.tar.gz -C /usr/src(同上)
  3. #cd /usr/src #ln -s linux-2.6.28.10 linux
  4. #cd /usr/src/linux/
  5. #patch -p1 < ../netfilter-layer7-v2.22/kernel-2.6.25-2.6.28-layer7-2.2.22.pach
  6. #cp /boot/config-2.6.18-164.el5 /usr/src/linux/.config
  7. #make menuconfig
 (3)配置内核参数  

        


 (4)开始编译内核

点击(此处)折叠或打开

  1. #make
  2. #make modules_isntall
  3. #make install

  编译安装完内核之,就可以从前系统,进入刚编译好的系统,对iptables打补丁。
四、给iptables打补丁,并重新编译iptables
 (1)

点击(此处)折叠或打开

  1. #cp /etc/init.d/iptables /tmp/
  2. #cp /etc/sysconfig/iptables-config /tmp
   这两步的主要功能是为启动iptables而准备,即:可以用service iptables [start|restart|stop]等命令。
 (2)

点击(此处)折叠或打开

  1. #rpm -e iptables-ipv6 iptables ipstate --nodeps (此命令卸载原有的iptables) 先下载iptables-1.4.6.tar.bz2,然后将其解压到/usr/src目录中
  2. #tar jxvf iptables-1.4.6.tar.bz2 -C /usr/src
  3. #cd /usr/src/iptables-1.4.6
  4. #cp /usr/src/netfilter-layer7-v2.22/iptables-1.4.3forward-for-kernel-2.6.20forward/ libxt_layer7.* ./extensions/
  5.  # ./configure --prefix=/usr --with-ksource=/usr/src/linux
  6. # make
  7. # make install
安装完成后启动iptables:

点击(此处)折叠或打开

  1. #mv /tmp/iptables-conifg /etc/sysconfig/
  2. #mv /tmp/iptables /etc/rc.d/init.d/
  3. #vim /etc/rc.d/init.d/iptables (在末行模式下输入:
  4. #service iptables start
五、安装 l7-protocls

点击(此处)折叠或打开

  1. # tar zxvf l7-protocols-2009-05-28.tar.gz
  2. # cd l7-protocols-2009-05-28
  3. # make install
六、指定限制QQ规则

点击(此处)折叠或打开

  1. # iptables [specify table & chain] -m layer7 --l7proto [protocol name] -j [action] (基本规则)
  2. # iptables -A FORWARD -m layer7 --l7proto qq -j DROP

阅读(1669) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~