免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 3185 | 回复: 3
打印 上一主题 下一主题

[网络子系统] 抓取ARP数据包问题 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2011-12-04 00:40 |只看该作者 |倒序浏览
看了http://bbs.chinaunix.net/thread-1940183-1-1.html帖子后,试验NF_ARP_FORWARD,我的理解这是挂载到bridge的FORWARD上,所以我建立了一个br0,包含eth0和eth1,然后写了自己的模块但是没有抓到任何数据包(bridge肯定已经forward了arp数据包),请问这是为什么呢?
  1. #include <linux/version.h>
  2. #include <linux/module.h>
  3. #include <linux/kernel.h>
  4. #include <linux/netfilter.h>
  5. #include <linux/netfilter_bridge.h>
  6. #include <linux/netfilter_arp.h>

  7. static unsigned int myarp_callback(
  8.         unsigned int hooknum,
  9.     struct sk_buff *skb,
  10.     const struct net_device *in,
  11.     const struct net_device *out,
  12.     int (*okfn)(struct sk_buff *))
  13. {
  14.         printk("Recv ARP forward packet\n");
  15.         return NF_ACCEPT;
  16. }

  17. static struct nf_hook_ops my_arphook[] = {
  18.         {
  19.                 .hook       = myarp_callback,
  20.                 .owner      = THIS_MODULE,
  21.                 .pf         = NF_ARP,
  22.                 .hooknum    = NF_ARP_FORWARD,
  23.                 .priority         = NF_BR_PRI_FIRST,
  24.         }
  25. };

  26. static int __init arptest_init(void)
  27. {
  28.         int ret = 0;

  29.         ret = nf_register_hooks(my_arphook, ARRAY_SIZE(my_arphook));
  30.         if (ret < 0)
  31.         {
  32.                 printk("can't register hooks.\n");
  33.                 return -1;
  34.         }
  35.         printk("insmod myarp success\n");
  36.         return 0;
  37. }
  38. static void __exit arptest_exit(void)
  39. {
  40.         nf_unregister_hooks(my_arphook, ARRAY_SIZE(my_arphook));
  41.         printk("rmmod myarp success\n");
  42.         return;
  43. }
  44. module_init(arptest_init);
  45. module_exit(arptest_exit);
复制代码

论坛徽章:
0
2 [报告]
发表于 2011-12-05 18:02 |只看该作者
有哪位接触过这部分啊?这个模块需要那些内核支持呢,我写普通的nf模块都能抓到包,在NF_INET_PRE_ROUTING点上也能抓到所有bridge的ip包,但是上面的代码就是抓不到arp包,我内核如下已经选中:
  1. │Symbol: BRIDGE_NETFILTER [=y]─────                                     .─────────────────────────────────── . │.  │Prompt: Bridged IP/ARP packets filtering                                                                                                            . │
  2.   │  Defined at net/Kconfig:162                                                                                                                        . │  │  Depends on: NET [=y] && BRIDGE [=m] && NETFILTER [=y] && INET [=y] && NETFILTER_ADVANCED [=y]                                                     . │.  │  Location:                                                                                                                                         . │
  3.   │    -> Networking support (NET [=y])                                                                                                                . │  │      -> Networking options                                                                                                                         . │.  │        -> Network packet filtering framework (Netfilter) (NETFILTER [=y])                                                                          . │
  4.   │          -> Advanced netfilter configuration (NETFILTER_ADVANCED [=y])
复制代码
但是,ebtables是没有开启的,请问ebtables是必须的嘛?
  1. < >   Ethernet Bridge tables (ebtables) support  --->
复制代码

论坛徽章:
0
3 [报告]
发表于 2013-07-15 15:32 |只看该作者
协议号错了!

论坛徽章:
0
4 [报告]
发表于 2013-07-17 11:12 |只看该作者
>>但是,ebtables是没有开启的,请问ebtables是必须的嘛?

不启用,怎么过滤?
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

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

清除 Cookies - ChinaUnix - Archiver - WAP - TOP