pcap - 不适用于特定接口

时间:2013-01-18 08:55:34

标签: pcap tcpdump

我使用过我的应用程序中使用的pcap库。它以前工作。

我没有对我的代码进行任何更改,但无法仅在特定接口“eth0”上捕获数据包。但是对于像eth1和wlan0这样的其他接口,它可以按预期工作。

Ifconfig命令的输出是:

eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 10.1.14.128  netmask 255.255.255.0  broadcast 10.1.14.255
        inet6 fe80::5642:49ff:fee1:3a03  prefixlen 64  scopeid 0x20<link>
        ether 54:42:49:e1:3a:03  txqueuelen 1000  (Ethernet)
        RX packets 476  bytes 53618 (52.3 KiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 365  bytes 61306 (59.8 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0
        device interrupt 18  

eth1: flags=4099<UP,BROADCAST,MULTICAST>  mtu 1500
        inet6 fe80::280:c8ff:fe3c:fe04  prefixlen 64  scopeid 0x20<link>
        ether 00:80:c8:3c:fe:04  txqueuelen 1000  (Ethernet)
        RX packets 34500  bytes 48274193 (46.0 MiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 0  bytes 1732834 (1.6 MiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 16436
        inet 127.0.0.1  netmask 255.0.0.0
        inet6 ::1  prefixlen 128  scopeid 0x10<host>
        loop  txqueuelen 0  (Local Loopback)
        RX packets 10775  bytes 1170782 (1.1 MiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 10775  bytes 1170782 (1.1 MiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

wlan0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 134.96.174.7  netmask 255.255.248.0  broadcast 134.96.175.255
        inet6 fe80::226:c7ff:fe9d:1f00  prefixlen 64  scopeid 0x20<link>
        ether 00:26:c7:9d:1f:00  txqueuelen 1000  (Ethernet)
        RX packets 981018  bytes 1250676710 (1.1 GiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 248507  bytes 31718095 (30.2 MiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

这些标志ID(所有人都一样)是否与我的问题有关。?

最佳

佳日

1 个答案:

答案 0 :(得分:0)

接口的驱动程序需要支持将iface放入promiscous mode以收集不直接发送到NIC的数据包。