歡迎來到Linux教程網
Linux教程網
Linux教程網
Linux教程網
Linux教程網 >> Linux基礎 >> Linux教程 >> iptables實現應用層的包過濾

iptables實現應用層的包過濾

日期:2017/2/28 14:42:40   编辑:Linux教程

iptables實現應用層的包過濾

平台:
linux5.4
源碼包:
iptables-1.4.2.tar.bz2
l7-protocols-2008-10-04.tar.gz
linux-2.6.25.19.tar.bz2
netfilter-layer7-v2.20.tar.gz


卸載原有的iptables、可以先把iptables的啟動腳本提前備份一份;等後面重新編譯iptables時再復制過來。
( /etc/init.d/iptables )
而後把源碼包解壓縮到 /usr/local/src/下;
步驟:
一、重新編譯內核
1、合並kernel+layer7補丁
# tar jxvf linux-2.6.25.19.tar.gz2 -C /usr/src/
# tar zxvf netfilter-layer7-v2.20.tar.gz -C /usr/src/
# cd /usr/src/linux-2.6.25.19/
# patch-p1 < /usr/src/netfilter-layer7-v2.20/kernel-2.6.25-layer7-2.20.patch
2、配置新內核
# cp/boot/config-2.6.18-8.el5 .config
【 可以沿用原本的內核 或者升級內核 】
# make menuconfig
【 配置內核時,在“Networking ---> Networking Options ---> NetworkPacket filtering framework (Netfilter) ”處主要注意兩個地方:
1) ---> Core Netfilter Configuration
//將“Netfilter connection tracking suport (NEW)”選擇編譯為模塊(M),需選取此項才能看到layer7支持的配置。
//將layer7、string、state、time、IPsec、iprange、connlimit……等編譯成模塊,根據需要看著辦。
2) ---> IP: Netfilter Configuration
//將“IPv4 connection tracking support (require for NAT)”編譯成模塊。
//將“Full NAT”下的“MASQUERADE target support”和“REDIRECT target support”編譯成模塊。
--->.config
3、編譯及安裝模塊、新內核
# make&& make modules_install && make install
【 編譯安裝成後後,重啟選擇使用新的內核(2.6.25.19)引導系統 】
二、重新編譯iptables
1、卸載現有iptables
# rpm -eiptables --nodeps


2、合並iptables+layer7補丁
# tar jxvfiptables-1.4.2.tar.bz2 -C /usr/src/
# cd /usr/src/netfilter-layer7-v2.20/iptables-1.4.1.1-for-kernel-2.6.20forward/
# cp libxt_layer7.c libxt_layer7.man /usr/src/iptables-1.4.2/extensions/


3、編譯安裝
# cd /usr/src/iptables-1.4.2/


# ./configure --prefix=/ --with-ksource=/usr/src/linux-2.6.25.19
# make&& make install


4、安裝l7-protocols模式包
# tar zxvfl7-protocols-2008-10-04.tar.gz -C /etc/
# mv /etc/l7-protocols-2008-10-04 /etc/l7-protocols


這個時候測試頁是無任何規則的:

更多詳情見請繼續閱讀下一頁的精彩內容: http://www.linuxidc.com/Linux/2013-10/91883p2.htm

Copyright © Linux教程網 All Rights Reserved