What is a Wake-on-LAN magic packet?
How do you send a Wake-on-LAN magic packet with PowerShell?
Can Wake-on-LAN work across networks or subnets?
I found a simple Powershell script on another question/answer site that works. I made some minor changes (added comment block explaining how to use it, added parameters so the necessary info can be provided up front).
Here it is:
<#
Send-WOL.ps1
Sends "magic" Wake on LAN packet to attempt to wake the target computer
It is necessary to specify another computer on the same subnet as the target since the packet
is only broadcast to the subnet the target is on
Parameters: Target (required) : MAC address of target (xx:xx:xx:xx:xx:xx)
RemoteIP (required): IP address of another computer on the same subnet as target
#>
# Setup params
Param(
[Parameter(Mandatory=$true)][String]$Target,
[Parameter(Mandatory=$true)][String]$RemoteIP
)
Write-Verbose -Message "Converting MAC address $($Target) to a byte array" -Verbose
$MacByteArray = $Target -split "[:-]" | ForEach-Object { [Byte] "0x$_"}
[Byte[]] $MagicPacket = (,0xFF * 6) + ($MacByteArray * 16)
Write-Verbose -Message "Broadcasting Wake-on-LAN packet to target." -Verbose
Invoke-Command -ComputerName $RemoteIP -ScriptBlock {
$UdpClient = New-Object System.Net.Sockets.UdpClient
$UdpClient.Connect(([System.Net.IPAddress]::Broadcast),7)
$UdpClient.Send($using:MagicPacket,$using:MagicPacket.Length)
$UdpClient.Close()
}
https://www.gammadyne.com/cmdline.htm#wol works, and it´s "only" 193K (go-wol is around 5MB).
I will put a batch script around it and then I´m done.
A deep link into the router setup would be smaller, but I guess that the AVM software does not allow that.
Only wish remaining is to hibernate the machine via Magic Packet, but my NIC is probably too old for that. I think I will use PuTTY for that.
Thanks everyone for digging!
Try WakeOnLan (AppStore) or wol — both are open source, both are available through MacPorts (and possibly through Homebrew as well).
Install the wakeonlan package using Homebrew:
$ brew install wakeonlan
(It's a Perl script for waking up computers via Wake-On-LAN magic packets.)
When installed, you can send a "magic packet" from your Terminal to any device using its IP (Internet Protocol) and MAC (Media Access Control) address.
Here's an example of a typical use:
$ wakeonlan -i 192.168.1.255 -p 1234 01:02:03:04:05:06
The scripts takes 2 arguments, the MAC address of the NIC, and an IP address.
Note: The IP address argument is tricky and isn't what you'd think.
For a NIC on your local subnet, use the broadcast-address of this subnet. (e.g. subnet 192.168.10.0 with netmask 255.255.255.0, use 192.168.10.255)
For example, I have a Synology NAS manually configured with the IP address of 10.0.1.100 with a subnet mask of 255.255.255.0 and a router address of 10.0.1.1.
The correct IP address to use is not that of the device, but instead the broadcast-address of the subnet.
Continuing on my example, I used the following command to successfully wake up my Synology:
$ wakeonlan -i 10.0.1.255 -p 7 01:02:03:04:05:06
(Naturally, substitute the actual values of your device and network for your situation.)
You can get more information from the wakeonlan man page, man makeonlan, or a quick glossary of commands from wakeonlan -h.