-
Notifications
You must be signed in to change notification settings - Fork 48
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
Any work around to run w/o root priv? #6
Comments
Unfortunately, icmplib uses raw sockets to forge ICMP packets, which require root privileges to run. ICMP is a network-layer protocol. Only raw sockets allow us to modify the IP header. However, I will see if there is a solution. If there is one, it will certainly be implemented in the v2 scheduled for the beginning of next year. |
Hi 👋 There is a solution to allow the library to be used without being root. It consists of using a I continue my tests. |
|
@hramcovdv Thank you for your participation. I hadn't thought about it and it's a good solution for those who want to use this library without root privileges. However, @hramcovdv @csulit Here is the command line to execute: sudo setcap cap_net_raw+ep $(realpath $(which python3)) The downside of this method is that it allows all python scripts to use raw sockets without being root. Anyway, I'm not sure there is a better solution. |
Just passing through during a late night of code spelunking and I noticed your comments in regards to the ICMP ECHO identifier getting lost with DGRAM/ICMP. I have been down this road before and yes, that tidbit of information was a bit difficult to track down. In that configuration, Linux is replacing the identifier with the local port number of the socket. And yes, for some reason Linux assigns a (seemingly fictitious) port number to these DGRAM/ICMP sockets. macOS/Darwin/BSD don't seem to do any of this trickery. https://lwn.net/Articles/420800/ So, if you are ok with the local "port" number (getsockname will get that) as an identifier under Linux; you're all set. Note, in Python of course you will get that from getsockname pre-flipped in host byte order; but it will come back to you in the reply in network byte order. Best Regards |
@nvannote Your comment is very interesting. A big thank you for your participation! I hadn't noticed this behavior. However, this solution doesn't work on Windows. I have to think about it. |
Hello everyone! I am pleased to announce that the next major version of icmplib ( For this, all the foundations of the library will be completely reworked without loss of compatibility with the current high-level functions The performances will also be improved with a single thread for the Many more cool features to come 🎉 Of course the library will always be as light. Thank you for using and participating in this project 😄 |
Exciting!! |
@csulit Thanks! 😄 The release of the new version is getting closer. I am planning a release for mid-November and... maybe tomorrow for a beta version! |
You're Welcome :) thank you for sharing! |
Hi 👋 icmplib 2.0 can now be tested in an experimental version! Don't hesitate to tell me about potential bugs 😄 To install the new version, follow these instructions: # Uninstall icmplib
pip3 uninstall icmplib
# Download and extract this repository
wget -qO- https://github.com/ValentinBELYN/icmplib/archive/master.tar.gz | tar -xzf -
cd icmplib-master
# Install the version under development:
python3 setup.py install Pingdef ping(address, count=4, interval=1, timeout=2, id=PID, source=None,
privileged=True, **kwargs): Since the documentation is not yet up to date on GitHub, here are the new parameters and exceptions for the
Traceroutedef traceroute(address, count=2, interval=0.05, timeout=2, id=PID, max_hops=30,
source=None, fast=False, **kwargs): Parameters and exceptions for the
Thank you for your feedbacks! 👍 |
icmplib 2.0 will be available on November 15th! You can now download the pre-release version by following these instructions: # Uninstall icmplib
pip3 uninstall icmplib
# Download and extract this repository
wget -qO- https://github.com/ValentinBELYN/icmplib/archive/master.tar.gz | tar -xzf -
cd icmplib-master
# Install the version under development
python3 setup.py install The |
Hi 👋 icmplib 2.0 is now available! All the foundations of the library have been completely reworked to make it even faster. You can now use the library without root privileges. 🎉 |
It looks like root privs are still required: macOS 12.2 |
Hi @max-block, The
This is a technical constraint. To capture responses from intermediate gateways, I have to use raw sockets which require root privileges. When you have any questions, please feel free to open a new issue. Your question is interesting and might interest other people. Opening a dedicated issue (unless another is already open on this subject) allows it to be more visible. |
Hello!
During handling of the above exception, another exception occurred: Traceback (most recent call last): Does anyone know how to fix |
Hi @tuser-code, Use instead: host = ping('192.168.2.1', count=10, interval=0.5, timeout=1, privileged=False) If you are using Raspberry Pi OS, you need to configure your system before: Finally, feel free to open a new issue when you have any questions or encounter any bugs 😉 |
Thank you Valentine. My mistake is that I did not read the readme file. Everything works now! |
I'm planning to include this on my flask api project something like http://url/icmplib/ping/192.168.1.1 and will give a response of json.
The text was updated successfully, but these errors were encountered: