免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
楼主: ShadowStar
打印 上一主题 下一主题

[网络管理] IPP2P模块修改版,最新0.99.16 [复制链接]

论坛徽章:
0
71 [报告]
发表于 2007-11-25 19:46 |只看该作者
又出来新的版本了?不错啊,又要新的一轮测试了!

论坛徽章:
0
72 [报告]
发表于 2007-11-26 13:43 |只看该作者
楼主,请问怎样能将drop掉的包再进行分析?就是我想知道是哪个ip地址在使用p2p软件,能够实现吗?

论坛徽章:
0
73 [报告]
发表于 2007-11-26 15:05 |只看该作者
终于编译通过了

对源代码进行了修改,现把修改的部分贴上

  1. diff -dru ipp2p-0.99.6-r1/Makefile ipp2p-0.99.6-r1.new/Makefile
  2. --- ipp2p-0.99.6-r1/Makefile    2007-11-23 18:16:57.000000000 +0800
  3. +++ ipp2p-0.99.6-r1.new/Makefile        2007-11-26 13:20:47.000000000 +0800
  4. @@ -2,7 +2,7 @@
  5. obj-m := ipt_ipp2p.o

  6. else
  7. -KERNEL_SRC = /usr/src/linux
  8. +KERNEL_SRC = ../linux-2.6.22.8
  9. #KERNEL_SRC ?= $(firstword $(wildcard /lib/modules/$(shell uname -r)/build /usr/src/linux))
  10. ifeq ($(KERNEL_SRC),)
  11. $(error You need to define KERNEL_SRC)
  12. @@ -28,7 +28,7 @@
  13. ifndef $(IPTABLES_SRC)
  14. IPTVER = \
  15.         $(shell $(IPTABLES_BIN) --version | $(SED) -e 's/^iptables v//')
  16. -IPTABLES_SRC = $(wildcard /usr/src/iptables-$(IPTVER))
  17. +IPTABLES_SRC = $(wildcard ../iptables-$(IPTVER))
  18. #IPTABLES_SRC = /var/tmp/portage/net-firewall/iptables-1.3.8-r1/work/iptables-1.3.8
  19. endif

  20. @@ -46,7 +46,7 @@

  21. IPTABLES_OPTION = -DIPTABLES_VERSION=\"$(IPTABLES_VERSION)\"
  22. CC = gcc
  23. -CFLAGS = -O3 -Wall
  24. +CFLAGS = -O2 -Wall


  25. all: modules libipt_ipp2p.so
  26. diff -dru ipp2p-0.99.6-r1/libipt_ipp2p.c ipp2p-0.99.6-r1.new/libipt_ipp2p.c
  27. --- ipp2p-0.99.6-r1/libipt_ipp2p.c      2007-11-21 14:19:05.000000000 +0800
  28. +++ ipp2p-0.99.6-r1.new/libipt_ipp2p.c  2007-11-26 14:20:15.000000000 +0800
  29. @@ -67,23 +67,24 @@


  30. static void
  31. -init(struct ipt_entry_match *m, unsigned int *nfcache)
  32. +init(struct ipt_entry_match *m)
  33. {
  34.      struct ipt_p2p_info *info = (struct ipt_p2p_info *)m->data;

  35. -    *nfcache |= NFC_UNKNOWN;
  36. +//    *nfcache |= NFC_UNKNOWN;

  37.      /*init the module with default values*/
  38.      info->cmd = 0;
  39.      info->debug = 0;

  40. +    memset(info, 0, sizeof(struct ipt_p2p_info));
  41. +
  42. }

  43. static int
  44. parse(int c, char **argv, int invert, unsigned int *flags,
  45. -       const struct ipt_entry *entry,
  46. -       unsigned int *nfcache,
  47. +       const void *entry,
  48.         struct ipt_entry_match **match)
  49. {
  50.      struct ipt_p2p_info *info = (struct ipt_p2p_info *)(*match)->data;
  51. @@ -341,7 +342,7 @@


  52. static void
  53. -print(const struct ipt_ip *ip,
  54. +print(const void *ip,
  55.          const struct ipt_entry_match *match,
  56.         int numeric)
  57. {
  58. @@ -375,7 +376,7 @@


  59. static void
  60. -save(const struct ipt_ip *ip, const struct ipt_entry_match *match)
  61. +save(const void *ip, const struct ipt_entry_match *match)
  62. {
  63.      struct ipt_p2p_info *info = (struct ipt_p2p_info *)match->data;

复制代码



配置文件部分的差异可以不考虑,主要是那些函数定义部分的参数,我是参考set模块改写的,现在能够正常编译并运行

论坛徽章:
0
74 [报告]
发表于 2007-11-26 16:43 |只看该作者

回复 #1 ShadowStar 的帖子

内核:
2.6.22 源码 /usr/src/linux-2.6.22
iptables:
1.3.8 源码 /usr/src/iptables-1.3.8

步骤:
改Makefile
1、KERNEL_SRC= /usr/src/linux-2.6.22
2、IPTABLES_SRC = /usr/src/iptables-1.3.8
3、$(CC) -shared -o libipt_ipp2p.so libipt_ipp2p.o 改为 ld -shared -o libipt_ipp2p.so libipt_ipp2p.o
4、make
5、cp libipt_ipp2p.so /lib/iptables
6、cp ipt_ipp2p.ko /lib/modules/2.6.22/kernel/net/ipv4/netfilter
7、depmod -a
8、service iptables stop
9、rmmod ipt_ipp2p
10、service iptables start

运行iptables -m ipp2p --help
提示
iptables v1.3.8: Couldn't load match `ipp2p'
请问是为什么?需要重启机器么?

论坛徽章:
0
75 [报告]
发表于 2007-11-26 17:38 |只看该作者
原帖由 zhy0414 于 2007-11-26 13:43 发表
楼主,请问怎样能将drop掉的包再进行分析?就是我想知道是哪个ip地址在使用p2p软件,能够实现吗?


可以在mangle表进行LOG

论坛徽章:
0
76 [报告]
发表于 2007-11-26 17:39 |只看该作者
原帖由 springwind426 于 2007-11-26 15:05 发表
终于编译通过了

对源代码进行了修改,现把修改的部分贴上

diff -dru ipp2p-0.99.6-r1/Makefile ipp2p-0.99.6-r1.new/Makefile
--- ipp2p-0.99.6-r1/Makefile    2007-11-23 18:16:57.000000000 +0800
+ ...


非常感谢

论坛徽章:
0
77 [报告]
发表于 2007-11-26 17:41 |只看该作者
原帖由 getCookieID 于 2007-11-26 16:43 发表
内核:
2.6.22 源码 /usr/src/linux-2.6.22
iptables:
1.3.8 源码 /usr/src/iptables-1.3.8

步骤:
改Makefile
1、KERNEL_SRC= /usr/src/linux-2.6.22
2、IPTABLES_SRC = /usr/src/iptables-1.3.8
3 ...


第3步,对于1.3.8版的iptables,不要修改Makefile中的
  1. $(CC) -shared -o libipt_ipp2p.so libipt_ipp2p.o 改为 ld -shared -o libipt_ipp2p.so libipt_ipp2p.o
复制代码

论坛徽章:
0
78 [报告]
发表于 2007-11-26 19:53 |只看该作者

  1.      /*init the module with default values*/
  2.      info->cmd = 0;
  3.      info->debug = 0;

  4. +    memset(info, 0, sizeof(struct ipt_p2p_info));
  5. +
  6. }
复制代码

这个似乎没有必要

论坛徽章:
0
79 [报告]
发表于 2007-11-26 21:40 |只看该作者
原帖由 ShadowStar 于 2007-11-26 17:38 发表


可以在mangle表进行LOG



mangle表可以给ip包打标记,怎吗能记录下来源地址?

论坛徽章:
0
80 [报告]
发表于 2007-11-26 23:55 |只看该作者
原帖由 zhy0414 于 2007-11-26 21:40 发表



mangle表可以给ip包打标记,怎吗能记录下来源地址?

可以
# iptables -t mangle -I PREROUTING -p udp --dport 53 -j LOG
# tail -4 /var/log/messages
[quote]
Nov 26 23:54:33 PT_LINUX kernel: IN=HOME OUT= PHYSIN=ath0 MAC=00:14:78:71:0f:23:00:1b:77:37:54:10:08:00 SRC=172.17.39.103 DST=202.106.46.151 LEN=57 TOS=0x00 PREC=0x00 TTL=128 ID=48145 PROTO=UDP SPT=4286 DPT=53 LEN=37
Nov 26 23:54:57 PT_LINUX kernel: IN=HOME OUT= PHYSIN=ath0 MAC=00:14:78:71:0f:23:00:1b:77:37:54:10:08:00 SRC=172.17.39.103 DST=202.106.46.151 LEN=70 TOS=0x00 PREC=0x00 TTL=128 ID=48292 PROTO=UDP SPT=4286 DPT=53 LEN=50
Nov 26 23:55:03 PT_LINUX kernel: IN=HOME OUT= PHYSIN=eth1 MAC=00:14:78:71:0f:23:00:0a:e6:a9:64:a2:08:00 SRC=172.17.39.108 DST=202.106.0.20 LEN=59 TOS=0x00 PREC=0x00 TTL=128 ID=11185 PROTO=UDP SPT=1029 DPT=53 LEN=39
Nov 26 23:55:09 PT_LINUX kernel: IN=HOME OUT= PHYSIN=ath0 MAC=00:14:78:71:0f:23:00:1b:77:37:54:10:08:00 SRC=172.17.39.103 DST=202.106.46.151 LEN=80 TOS=0x00 PREC=0x00 TTL=128 ID=48357 PROTO=UDP SPT=4286 DPT=53 LEN=60

[/quote]
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP