Failing to send Wake-On-LAN UDP packet with netcat 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&lt;CONNECTED,PREFERRED&gt;
    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?
I've likely answered my own question:

The BSD version of netcat included with macOS lacks the -b (broadcast) flag.

And even though 255.255.255.255 is a special global address for broadcasting to the entire subnet, simply sending to it apparently isn't enough to imply/accomplish a broadcast without that missing -b flag.

So, my impression is that the macOS version of netcat simply won't do what I'm trying to do.

If I were to install an alternate netcat implementation using homebrew or some other source, it might accomplish it--but at that point, I'd rather just depend on having wakeonlan installed.

I'll leave this answer here, but unaccepted, hoping that someone with more low-level networking know-how provides a better answer at some point.

Edit: Also, if one were going to install other software due to netcat limitations, it looks like socat (described as "netcat on steroids") would likely be something to seriously consider, instead of just an alternate version of netcat.