AS3下安装ipp2p模块成功

        参考了好几篇文章的做法都算完成,没有从头到尾按照某一篇文章完成,因为我直接编译不成功,又不知道问题出在哪里,只好出了下策,不过总算是成功了。

     一、我的环境是RAS3,已经安装了gcc编译环境
            [root@localhost iptables]# uname -sr
            Linux 2.4.21-4.ELsmp
            [root@localhost iptables]# iptables -v
            iptables v1.2.8: no command specified
            Try `iptables -h' or 'iptables --help' for more information.
           

           1、到http://www.ipp2p.org/下载ipp2p的最新版本(同时支持2.4和2.6的内核)
           2、到http://www.netfilter.org/下载iptables (我下了iptables 1.2.8)
           3、到http://ftp.netfilter.org/pub/patch-o-matic-ng/snapshot/下载
patch-o-matic-ng

        分别解压以上文件到/usr/src下
        cd /usr/src
        ln -s iptables-1.2.8 iptables
        ln -s linux-2.4 linux
            
        给netfilter打被丁,把version.h拷贝一份,修改
#define UTS_RELEASE "2.4.21-4.ELcustom" 为 #define UTS_RELEASE "2.4.21-4.ELsmp"
          cd /usr/src/linux
          make mrproper
          make menuconfig
       什么不做,保存退出,然后把Makefile改一下,我是修改成了EXTRAVERSION = -4.ELsmp
        cd /usr/src/patch-o-matic-ng-20050810
       KERNEL_DIR=/usr/src/linux-2.4 IPTABLES_DIR=/usr/src/iptables-1.2.8 ./runme ipp2p
        KERNEL_DIR=/usr/src/linux-2.4 IPTABLES_DIR=/usr/src/iptables-1.2.8 ./runme time
        KERNEL_DIR=/usr/src/linux-2.4 IPTABLES_DIR=/usr/src/iptables-1.2.8 ./runme connlimit
回答yes就可以了
 这时候内核文件中已经包含这几个模块补丁了

编译kernel的modules
cd /usr/src/linux
make mrproper
make menuconfig
在Device Drivers->Networking support->Networking options->Network packet filtering (replaces ipchains)
->IP: Netfilter Configuration中把下面的三项M选中.
TIME match support
IPP2P match support
CONNLIMIT match support
保存退出

cd /usr/src/linux
make dep
make modules (按其中一篇参考文章的说法,可以是make modules SUBDIRS=drivers/net,但是我在编译时发现似乎有时可以生成有时在没有提示错误的情况下也没有生成.o文件,所以我还是老老实实地编译所有模块了)
编译完成后
cp /usr/src/linux/net/ipv4/netfilter/ipt_ipp2p.o  /lib/modules/2.4.21-4.ELsmp/kernel/net/ipv4/netfilter/ipt_ipp2p.o
cp /usr/src/linux/net/ipv4/netfilter/ipt_time.o  /lib/modules/2.4.21-4.ELsmp/kernel/net/ipv4/netfilter/
cp /usr/src/linux/net/ipv4/netfilter/ipt_connlimit.o  /lib/modules/2.4.21-4.ELsmp/kernel/net/ipv4/netfilter/

chmod +x  /lib/modules/2.4.21-4.ELsmp/kernel/net/ipv4/netfilter/ipt_ipp2p.o
chmod +x  /lib/modules/2.4.21-4.ELsmp/kernel/net/ipv4/netfilter/ipt_time.o
chmod +x  /lib/modules/2.4.21-4.ELsmp/kernel/net/ipv4/netfilter/ipt_connlimit.o

这时尝试使用insmod ipt_ipp2p,发现已经可以成功载入,再使用
iptables -A FORWARD -m ipp2p --ipp2p -j DROP
提示没有找到文件/lib/iptables/libipt_ipp2p.so,那应该是还要再编译iptables生成相应的文件才行了,于是转到/usr/src/iptables下,
make KERNEL_DIR=/usr/src/linux
我这里可以成功编译,编译后
cp /usr/src/iptables/extensions/libipt_ipp2p.so /lib/iptables/
cp /usr/src/iptables/extensions/libipt_time.so /lib/iptables/
这里使用
iptables -A FORWARD -m ipp2p --ipp2p -j DROP
没有错误提示,应该是成功载入了。
为了查看是否可以拦截到bt数据
先清空iptables 链表
iptables -F
再输入
iptables -A FORWARD -m ipp2p --ipp2p -j LOG --log-prefix "ipp2p:packet deny"
iptables -A FORWARD -m ipp2p --ipp2p -j DROP
这里cat /var/log/messages
可以看到如下数据
Dec 31 09:49:07 localhost kernel: ipp2p:packet denyIN=eth0 OUT=eth1 SRC=192.168.77.36 DST=63.222.6.2
2 LEN=46 TOS=0x00 PREC=0x00 TTL=126 ID=1538 PROTO=UDP SPT=1921 DPT=4885 LEN=26
Dec 31 09:49:07 localhost kernel: ipp2p:packet denyIN=eth0 OUT=eth1 SRC=192.168.67.140 DST=217.216.5
2.123 LEN=153 TOS=0x00 PREC=0x00 TTL=126 ID=23890 DF PROTO=TCP SPT=1147 DPT=4662 WINDOW=65535 RES=0x
00 ACK PSH URGP=0
4662正是电骡的端口,既然可以匹配到记录里了,那也应该是可以拦截到了并drop了,所以应该是正常的了,不过为了不影响速度,最好还是不记录到日志中为好
iptables -F
iptables -A FORWARD -m ipp2p --ipp2p --bit --apple --winmx --soul --ares -j DROP

另外,按照ipp2p官方站点上的文档,-ipp2p已经等同于--edk --kazaa --gnu --dc了,所以只用一个--ipp2p规则就可以等同于这几个了,不用写那么多。

原文:
filter rules using IPP2P
Basically netfilter allows to control custom matching modules by using the switch "-m". That's the way to configure IPP2P with the following syntax:
iptables -A FORWARD -m modulename --moduleoption1 --moduleoption2 ... -j JUMPTARGET
To use IPP2P select "ipp2p" as modulename and one or more of the available options. Maybe the most important one is "--ipp2p" as sum of all exact and well tested match options. At the moment the following matches are equal:

-m ipp2p --ipp2p
-m ipp2p --edk --kazaa --gnu --dc

==================================================

附官方上的一个表格

可以看到ipp2p模块对各种bt软件的拦截能力。
另有一个限速的方法,迟些再试,明天元旦了,放松的时候到了
01# iptables -t mangle -A PREROUTING -p tcp -j CONNMARK --restore-mark
02# iptables -t mangle -A PREROUTING -p tcp -m mark ! --mark 0 -j ACCEPT
03# iptables -t mangle -A PREROUTING -p tcp -m ipp2p --ipp2p -j MARK --set-mark 1
04# iptables -t mangle -A PREROUTING -p tcp -m mark --mark 1 -j CONNMARK --save-mark

05# iptables -t mangle -A POSTROUTING -o eth0 -m mark --mark 1 -j CLASSIFY --set-class 1:12
06# iptables -t mangle -A POSTROUTING -o eth1 -m mark --mark 1 -j CLASSIFY --set-class 2:12

    1、 参考http://www.linuxeden.com/forum/t133932.html
           http://www.linuxeden.com/forum/t133387.html
        http://www.ipp2p.org/docu_en.html
          

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值