无法打开设备 eth0:eth0:套接字:无效参数

Couldn't open device eth0: eth0: socket: Invalid argument

我正在尝试使用来自 GitHub 的简单 DHCP client。当我尝试 运行 这个客户端时,它失败了

eth0 MAC : C8:6B:00:E5:52:5E
Couldn't open device eth0: eth0: socket: Invalid argument

有什么建议吗? 谢谢!

显然 pcap_open_live() returns 与 NULL

pcap_open_live() returns a pcap_t * on success and NULL on failure. If NULL is returned, errbuf is filled in with an appropriate error message. errbuf may also be set to warning text when pcap_open_live() succeds; to detect this case the caller should store a zero-length string in errbuf before calling pcap_open_live() and display the warning to the user if errbufis no longer a zero-length string. errbufis assumed to be able to hold at least PCAP_ERRBUF_SIZE chars.

您可能需要调查您的卡。

以 root 身份检查:

su -c "lspci | grep -i ether"

检查此设备是否确实 eth0

/usr/sbin/ethtool -i eth0

dmesg | grep eth0