Welcome 微信登录

首页 / 操作系统 / Linux / 为iptables增加layer7补丁(Linux2.6.25内核)

系统环境
RHEL5 [2.6.18-164.el5]软件环境http://www.kernel.org/pub/linux/kernel/v2.6/linux-2.6.25.19.tar.bz2
http://www.netfilter.org/projects/iptables/files/iptables-1.4.2.tar.bz2http://ie.archive.Ubuntu.com/sourceforge/l/l7/l7-filter/netfilter-layer7-v2.20.tar.gz
http://ie.archive.ubuntu.com/sourceforge/l/l7/l7-filter/l7-protocols-2008-10-04.tar.gz目标功能
为iptables增加layer7补丁,实现应用层过滤。
一、重新编译内核1、将所需软件下载并上传到家目录[root@localhost ~]# ll总计 99824-rw------- 1 root root 1175 08-30 04:50 anaconda-ks.cfgdrwxr-xr-x 2 root root 4096 08-30 21:14 Desktop-rw-r--r-- 1 root root 35236 08-30 04:50 install.log-rw-r--r-- 1 root root 3995 08-30 04:49 install.log.syslog-rw-r--r-- 1 root root 435891 09-18 11:43 iptables-1.4.2.tar.bz2-rw-r--r-- 1 root root 128196 09-18 11:43 l7-protocols-2008-10-04.tar.gz-rw-r--r-- 1 root root 48622017 09-18 11:43 linux-2.6.25.19.tar.bz2-rw-r--r-- 1 root root 174790 09-18 11:43 netfilter-layer7-v2.20.tar.gz2、合并kernel+layer7补丁[root@localhost ~]# tar jxvf linux-2.6.25.19.tar.bz2 -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.patch3、配置新内核[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//配置内核时,在“Networking ---> Networking Options ---&gt; Network Packet filtering framework (Netfilter) ”处主要注意两个地方:
    1) ---&gt; Core Netfilter Configuration
        //将“Netfilter connection tracking suport (NEW)”选择编译为模块(M),需选取此项才能看到layer7支持的配置。
        //将layer7、string、state、time、IPsec、iprange、connlimit,tcp……等编译成模块。    2) ---&gt; IP: Netfilter Configuration
        //将“IPv4 connection tracking support (require for NAT)”编译成模块。
        //将“Full NAT”下的“MASQUERADE target support”和“REDIRECT target support”编译成模块。4、编译及安装模块、新内核[root@localhost linux-2.6.25.19]make && make modules_install && make install5、编译安装成后,重启选择使用新的内核(2.6.25.19)引导系统二、重新编译iptables1、将原来的iptables备份[root@localhost ~]# uname -r
2.6.25.19              //查看内核版本[root@localhost init.d]# cp iptables iptables.bak[root@localhost init.d]# iptables    //查看原来的iptables版本iptables v1.3.5: no command specifiedTry `iptables -h" or "iptables --help" for more information.2、卸载现有iptables[root@localhost init.d]# rpm -e iptables --nodepswarning: /etc/sysconfig/iptables-config saved as /etc/sysconfig/iptables-config.rpmsave3、合并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]# ll总计 16-rw-r--r-- 1 1000 1000 9356 2008-08-22 libxt_layer7.c-rw-r--r-- 1 1000 1000 648 2008-08-22 libxt_layer7.man[root@localhost iptables-1.4.1.1-for-kernel-2.6.20forward]# cp * /usr/src/iptables-1.4.2/extensions/4、编译安装[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-ksouce=/usr/src/linux-2.6.25.19/[root@localhost iptables-1.4.2]# make && make install5、将原备份iptables还原[root@localhost iptables-1.4.2]# mv /etc/init.d/iptables.bak /etc/init.d/iptables[root@localhost iptables-1.4.2]# ll /etc/init.d/iptables -rwxr-xr-x 1 root root 7460 09-18 17:24 /etc/init.d/iptables6、启动iptables[root@localhost ~]# service iptables restart7、安装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-protocols8、测试[root@localhost ~]# iptables -t filter -A FORWARD -m layer7 --l7proto qq -j DROP[root@localhost ~]# iptables -LUbuntu下计划任务cron的使用Ubuntu 12.04以及 Window 下使用共享打印机相关资讯      IpTables 
  • CentOS Samba 服务器 Iptables 和   (今 07:14)
  • iptables超全详解  (09月01日)
  • Iptables防火墙 基础知识  (08月19日)
  • Iptables工作原理使用详解  (09月06日)
  • iptables中NAT表  (08月25日)
  • Linux 为FTP 服务器添加iptables规  (08月11日)
本文评论 查看全部评论 (0)
表情: 姓名: 字数


评论声明
  • 尊重网上道德,遵守中华人民共和国的各项有关法律法规
  • 承担一切因您的行为而直接或间接导致的民事或刑事法律责任
  • 本站管理