AS3下安装ipp2p模块成功

    技术2022-05-11  101

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

         一、我的环境是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的modulescd /usr/src/linuxmake mrpropermake menuconfig在Device Drivers->Networking support->Networking options->Network packet filtering (replaces ipchains)->IP: Netfilter Configuration中把下面的三项M选中. TIME match support IPP2P match supportCONNLIMIT match support保存退出cd /usr/src/linuxmake depmake 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.ocp /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.ochmod +x  /lib/modules/2.4.21-4.ELsmp/kernel/net/ipv4/netfilter/ipt_time.ochmod +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.22 LEN=46 TOS=0x00 PREC=0x00 TTL=126 ID=1538 PROTO=UDP SPT=1921 DPT=4885 LEN=26Dec 31 09:49:07 localhost kernel: ipp2p:packet denyIN=eth0 OUT=eth1 SRC=192.168.67.140 DST=217.216.52.123 LEN=153 TOS=0x00 PREC=0x00 TTL=126 ID=23890 DF PROTO=TCP SPT=1147 DPT=4662 WINDOW=65535 RES=0x00 ACK PSH URGP=04662正是电骡的端口,既然可以匹配到记录里了,那也应该是可以拦截到了并drop了,所以应该是正常的了,不过为了不影响速度,最好还是不记录到日志中为好iptables -Fiptables -A FORWARD -m ipp2p --ipp2p --bit --apple --winmx --soul --ares -j DROP另外,按照ipp2p官方站点上的文档,-ipp2p已经等同于--edk --kazaa --gnu --dc了,所以只用一个--ipp2p规则就可以等同于这几个了,不用写那么多。原文:filter rules using IPP2PBasically 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 JUMPTARGETTo 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-mark02# iptables -t mangle -A PREROUTING -p tcp -m mark ! --mark 0 -j ACCEPT03# iptables -t mangle -A PREROUTING -p tcp -m ipp2p --ipp2p -j MARK --set-mark 104# iptables -t mangle -A PREROUTING -p tcp -m mark --mark 1 -j CONNMARK --save-mark05# iptables -t mangle -A POSTROUTING -o eth0 -m mark --mark 1 -j CLASSIFY --set-class 1:1206# 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          


    最新回复(0)