iptables实现应用层的包过滤


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


这个时候测试页是无任何规则的:

更多详情见请继续阅读下一页的精彩内容

推荐阅读:

Linux防火墙iptables详细教程

iptables+L7+Squid实现完善的软件防火墙

iptables的备份、恢复及防火墙脚本的基本使用

Linux下防火墙iptables用法规则详解

iptables的用法小结

  • 1
  • 2
  • 下一页

相关内容