rust-pcap / pcap

Rust language pcap library
Apache License 2.0
620 stars 144 forks source link

PcapError("SIOCGIFHWADDR: No such device") on some platforms... #169

Closed LeeBrotherston closed 2 years ago

LeeBrotherston commented 3 years ago

The backtrace shows that this section is causing the PcapError("SIOCGIFHWADDR: No such device") error is:

let sniff_device = Device {
    name: matches
        .value_of("interface")
        .unwrap_or(&Device::lookup().unwrap().name)
        .to_string(),
    desc: None,
};

let mut pcap_device = Capture::from_device(sniff_device)
        .unwrap()
        .promisc(true)
        .snaplen(1522)
        .buffer_size(2048)
        .open()
        .unwrap();

Specifically the Capture::from_device

I initially blamed my code for this, however it works fine on my desktop (macOS) and other machines that I have tried it on. However running this on Debian, for example, results in the error.

Curiously, despite saying that the there is no such device, I am using the name which is successfully provided by Device::list();. Again this works as expected on my test hosts, but not Debian.

On the same host as is experiencing the problem I have used tcpdump successfully, which also uses under the hood (libpcap.so.0.8 => /usr/lib/x86_64-linux-gnu/libpcap.so.0.8 (0x00007fa4f8828000)), and so I believe that libpcap itself seems to work on that host. Which makes me believe that there is some sort of bug in the rust <> libpcap abstraction somewhere?

LeeBrotherston commented 3 years ago

Apologies one other bit of information which may be salient here, the debian install in question is running inside docker.

stappersg commented 3 years ago

For which reason is this issue open?

sekineh commented 3 years ago

The error message might suggest the device doesn’t have a hardware address (MAC address).

Which device are you working on? If it is not a Ethernet-like device, promiscuous mode might not be supported.

Wojtek242 commented 2 years ago

Stale issue. Closing - if needed, please reopen.