1

我在我的应用程序中使用了 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(所有人都一样)与我的问题有什么关系吗?

最好的 yash

4

1 回答 1

0

您的接口驱动程序需要支持将 iface 置于混杂模式以收集不直接发送到您的 NIC 的数据包。

于 2013-01-18T08:58:41.230 回答