I'm trying send a WOL packet from a bash script under Mojave, much like https://stackoverflow.com/a/31588036/9370650, without any third-party utilities, such as the nifty https://github.com/jpoliv/wakeonlan.
I don't, however, seem to be able to successfully broadcast anything at all to 255.255.255.255 on port 9 using netcat.
If I listen to UDP port 9 like this:
$ nc -uv -l 9 -w0
netcat then reports the WOL packet when I run the perl-based
wakeonlan script I mentioned above.
But, if I try to do my own UDP broadcast to 255.255.255.255:9, like this:
$ echo "hello" | nc -vu 255.255.255.255 9
it isn't seen by my listening instance of netcat.
For the record, the output from my attempt to broadcast looks like this:
found 0 associations found 1 connections: 1: flags=82<CONNECTED,PREFERRED> outif (null) src 192.168.1.7 port 51674 dst 255.255.255.255 port 9 rank info not available
I'm not a networking expert, so I'm likely misunderstanding something here.
Any thoughts on what I'm doing wrong?