-
Notifications
You must be signed in to change notification settings - Fork 674
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
RawSocketDevice cannot bind NIC on the centos7.9 #1640
Comments
Could you provide the minimum compilable sample code? Also please provide the NIC information if possible ( |
ok , here is my sample code:
here is my NIC information
My veth1 network card has no network traffic, so under normal circumstances, it should not be able to capture any data. However, this code is still able to capture packets, and these packets should be coming from eth0. After I modified the RawSocketDevice.cpp code to include a bind operation, I was able to meet my requirement of capturing packets on the bound network card. Please check if there is an issue with the code. I am looking forward to your response. |
@vectorzjl I don't remember why we're using |
@vectorzjl I did some testing and your solution seems to be working! Would you consider opening a PR with the fix? |
I won't consider pushing PR, I hope you can fix it yourself |
@seladb Both |
|
Thanks for pulling out the relevant documentation @vectorzjl ! I opened a PR to make this change: #1642 But unfortunately CI fails on Linux as we get PcapPlusPlus/Pcap++/src/RawSocketDevice.cpp Line 563 in 573effc
A link to the failing CI: https://github.com/seladb/PcapPlusPlus/actions/runs/11851898136/job/33029159452?pr=1642 Any idea why we get |
@seladb you can try enable promiscuous mode on a raw socket, which allows the network interface card (NIC) to receive all traffic passing through it, not just packets destined for the local machine, you need to follow different steps depending on your operating system. WindowsOn Windows, you can use the
LinuxOn Linux, you can use the
By following these steps, you can enable promiscuous mode on raw sockets in both Windows and Linux operating systems. Note that these operations typically require administrative privileges. |
Thank @vectorzjl ! I didn't think about setting promiscuous mode for the socket 🤦♂️ I tried setting promiscuous mode, but it failed in GitHub Actions with Failing CI: https://github.com/seladb/PcapPlusPlus/actions/runs/11930346556/job/33250959818 |
Interesting, |
When setting promiscuous mode in a Docker container, the container may need to be in privileged mode (--privileged) or have specific Linux capabilities, such as NET_ADMIN. Privileged mode grants the container additional permissions, allowing it to access all devices on the host, including network interfaces. |
It sounds weird, because we already use the promiscuous mode for |
@vectorzjl I tried this approach as well, and it didn't work. I even tried running it on GitHub Actions Runner VM (without docker) but it failed with the same error 😕 And as you can see here, both failed with the same error Any idea how to approach this? |
When I use RawSocketDevice to capture data, binding to the network card does not take effect, and it captures data from all available network cards. Perhaps I should use bind in the implementation to bind to the network card. Adding the following code should allow normal binding to the network card for data capture.
The text was updated successfully, but these errors were encountered: