Greetings,
I want to send broadcast udp from a script.
This works but is not broadcast:
echo -n "this is my message\r\n" | nc -u 192.168.0.12 5100
The broadcast version does not work:
echo -n "this is my message\r\n" | nc -u 192.168.0.255 5100
Suggestions on the right way to do this are welcome!
Thanks in advance,
Steve.
looking for the word 'broadcast' in the manual page for nc finds this:
-b allow UDP broadcasts
Interestingly enough, the -b option is only listed in the man page for some versions, but not others, of nc. I'm running both ubuntu and archlinux and have a different version on each (both are openBSD netcat though). I've tried -b on both and neither works. In the case where it's not listed in the man page, I get the expected "usage:..." response. In the one where it is listed in the man page I get "nc: Protocol not available". Both cases have been run from root...
I have not tried either the "traditional" netcat or the GNU netcat yet. I would be nice if someone out there actually knew if it worked and on what...
Or if someone could suggest a better way to do it...
---------- Post updated at 09:01 PM ---------- Previous update was at 04:42 PM ----------
never got nc to work and found many messages on the web regarding others who also couldn't get it to work. However, the following (from itsaunixsystem.com/unix/?p=5) does work as expected:
echo -n "message\r\n" | socat - udp-datagram:192.168.0.255:5100,broadcast