歡迎來到Linux教程網
Linux教程網
Linux教程網
Linux教程網
Linux教程網 >> Linux基礎 >> Linux教程 >> iptables--L7-filter實現高級管理

iptables--L7-filter實現高級管理

日期:2017/2/28 15:44:23   编辑:Linux教程

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

如圖所示:

找到這個位置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
編譯完成

Copyright © Linux教程網 All Rights Reserved