nping does not support --source-addr in udp unprivileged mode
If I run:
nping --udp --dest-port 50000 --dest-ip 232.1.3.100 --source-ip 127.0.0.1
I get the error message:
Mode UDP requires root privileges
This error message is somewhat misleading, but it seems to be due to the "--source-ip" parameter.
However, there is no reason this should not work, nping could just bind the socket to 127.0.0.1.
Netcat was able to do this with something like "echo Hello | nc -s 127.0.0.1 -u 232.1.3.100 50000"
There is a fundamental difference between nping and nc:
Option -s in nc let you choose any locally configured IP address while --source-ip in nping allows you to pick completely arbitrary IP address. That's why the latter needs root privileges but the former does not.
Thank you for the quick response.
I get what you mean. Still, since nping has the ability to use the normal socket API as long as no options are given that require the use of raw sockets, I think it would be a nice addition to also support --source-ip in case the specified IP can be bound. I propose to make this ticket a feature request.
IMHO that will make both the CLI and the code a bit messy while the use case is a bit narrow, especially since you already have option --interface to select a local address (but not necessary every local address). A possibly cleaner choice would be to support IP addresses for interfaces.
I will tag your request as an enhancement suggestion