2013年4月28日星期日

Centos 如何配置iptables匹配域名过滤

升级内核的方法:

内核下载地址:  www.kernel.org

L7的相关文件  http://l7-filter.clearfoundation.com/downloads/start

iptables   http://www.netfilter.org

升级内核到2.6.28 并支持L7/string

解压源码包


tar xzf linux-2.6.28.tar.gz
tar xjf iptables-1.4.10.tar.bz2
tar xzf l7-protocols-2009-05-28.tar.gz
tar xzf netfilter-layer7-v2.22.tar.gz

cd linux-2.6.28

make mrproper  清理工作

patch -p1 < /usr/src/netfilter-layer7-v2.22/kernel-2.6.25-2.6.28-layer7-2.22.patch  #打上L7补丁


make menuconfig

Networking--Networking options--Network packet filtering (replaces ipchains)--Core Netfilter Configuration
把L7和支持 string 等选上
make

make modules
make modules_install
make install

重启系统 
#uname -a 
Linux localhost.localdomain 2.6.28 
编译iptables 支持layer7
cd /usr/src/netfilter-layer7-v2.22/iptables-1.4.3forward-for-kernel-2.6.20forward/
cp libxt_layer7.* /usr/src/iptables-1.4.10/extensions/


上面两步必须操作,这样iptables才能支持,因为新版本的iptables不用打补丁了,直接复制过去即可
cd /usr/src/iptables-1.4.10/
./configure --prefix=/ --with-ksource=/usr/src/linux-2.6.28
make
make install
#iptables -V 
iptables v1.4.10
安装协议
cd /usr/src
cd l7-protocols-2009-05-28
make install


#iptables -t mangle -I PREROUTING -m layer7 --l7proto edonkey -j DROP

如没有提示 则无问题





第二种方法:我刚刚测试过

首先确认内核版本: uname   -r    

例如:[root@localhost iptables-1.4.10]# uname -r

2.6.18-194.el5



这样我从kernel上下载2.6.18的内核

linux-2.6.18.tar.bz2



下载:l7-protocols-2009-05-28  (L7的主程序)

netfilter-layer7-v2.6 (内核的补丁)



内核下载地址:  www.kernel.org

L7的相关文件  http://l7-filter.clearfoundation.com/downloads/start

iptables   http://www.netfilter.org

解压源码包


tar xzf linux-2.6.18.tar.bz2
tar xjf iptables-1.3.5.tar.bz2
tar xzf l7-protocols-2009-05-28.tar.gz
tar xzf netfilter-layer7-v2.6.tar.gz

cd linux-2.6.18
make mrproper  清理工作

patch -p1 <../netfilter-layer7-v2.6/kernel-2.6.18-layer7-2.6.patc  #打上L7补丁(根据内核版本)


make menuconfig

Networking--Networking options--Network packet filtering (replaces ipchains)--Core Netfilter Configuration
把L7支持 string 等选上
make modules_prepa

没有评论:

发表评论

在PVE使用虚拟 USB 存储设备 + ARPL 引导 DSM

  部分内容来自: https://blog.myds.cloud/archives/synoboot-usb-image-in-pve-virtual-machine.html 虚拟机建好之后,打开配置文件 nano /etc/pve/qemu-server/100.conf ...