Send WoL request to a machine behind zerotrust tunnel

I’d love to wake up remote machine with a wakeonlan (macos) packet . I can access it through the setup ssh tunnel just fine, but need WoL feature.

How do I do that?

You should be able to do this with UDP, assuming you know the MAC-address of the target device: Wake-on-LAN - Wikipedia.

The magic packet is a frame that is most often sent as a broadcast and that contains anywhere within its payload 6 bytes of all 255 (FF FF FF FF FF FF in hexadecimal), followed by sixteen repetitions of the target computer’s 48-bit MAC address, for a total of 102 bytes.

Since the magic packet is only scanned for the string above, and not actually parsed by a full protocol stack, it could be sent as payload of any network- and transport-layer protocol, although it is typically sent as a UDP datagram to port 0 (reserved port number)…

However, there is no way to do this natively with Cloudflare Tunnel, so you would have to use a third-party tool or write a script yourself.

I’ve tried using script from the brew package wakeonlan
wakeonlan -i xx.xx.xx.xx -p 22 xx:xx:xx:xx

But I’m not sure it’s actullay working. How can I test that?

When albert says there’s no way to do that via the Cloudflare Tunnel, they mean there’s no way to send the WOL ‘magic packet’ (not really magic ;-)) to the destination via the tunnel. You’ll have to run the WOL utility on another internal host that’s on the same LAN as the target to be woken up - presumably the machine you have ssh access to.
As to making WOL work, that can be non-trivial and is certainly not a Cloudflare topic; lots of existing info out there if you look.

Hi, Sorry for necromancing this issue. But, I am facing something similar and this is the solution that I am planning to implement - Setup a raspberry pi zero in the same wifi network and setup cloudflare tunnel on the same. SSH into the raspberry pi zero over the internet through the cloudflare zerotrust tunnel and send a WOL packet to the target machine.

I also found this interesting piKVM blog that might be useful if you want hardware level access to the machine - TuM'Fatig - PiKVM using a Raspberry Pi Zero 2W