Overview of Wake On Lan setup and usage
Here's an overview of how to set up Wake On LAN on a computer, how to find it's MAC address and finally how to wake it up. This is merely a high level view on what steps are required.
Setup Wake On LAN
In my case I was using a Asus ROG motherboard so I searched how to set up Wake On LAN on asus rog motherboard. The following guide helped me changed BIOS settings as well as network device settings. Asus FAQ Set up Wake On LAN
Get MAC Address
Once its set up, one wonders how to actually wake up a remote computer.
It is done by sending a so called magic packet to the remote computer.
When the computer is off, the network card only knows to respond to requests that go directly to its MAC address,
which is why using IP of that computer won't work. So, how do we get the MAC address?
I searched for how to get my Windows computer's MAC address, which now has Wake On LAN set up. Using Powershell one can run
Get-CimInstance win32_networkadapterconfiguration | select description, macaddress
If a computer is unavailable, there are a few different options like NMap, checking ARP cache after using ping etc.
Wake up remote computer
So, Wake On LAN is set up, you have the MAC address and you're on the same network?
Save the code as a .ps1 file, replace the MAC address and run it!
$Mac = "1A:2B:3C:4D:5E:6F"
$MacByteArray = $Mac -split "[:-]" | ForEach-Object { [Byte] "0x$_"}
[Byte[]] $MagicPacket = (,0xFF * 6) + ($MacByteArray * 16)
$UdpClient = New-Object System.Net.Sockets.UdpClient
$UdpClient.Connect(([System.Net.IPAddress]::Broadcast),7)
$UdpClient.Send($MagicPacket,$MagicPacket.Length)
$UdpClient.Close()
Conclusion
Hopefully that gets you on the right track to waking up remote computers. There might be future posts that dive deeper into some of these subjects, like how to wake up a compute on a different subnet.