Last Updated on Sep 2, 2020
There’s a feature in network cards, which allows to power on a PC if a certain “magic packet” is received on the physical (MAC) address of the network interface.
This tutorial assumes that your PC’s network card supports this feature, and that it’s enabled in the BIOS. You also need to know the MAC address of your PC’s (wired) network card, and the IP won’t hurt either.
I feel using the Raspbian operating system for this.
Install the “wakeonlan” package
sudo apt-get install wakeonlan
Insert your PC’s MAC address after the wakeonlan command, and see how the command sends the magic packet using the broadcast address 255.255.255.255, on Wake-on-LANs default port 9.
According to WikiPedia “A special definition exists for the IP broadcast address 255.255.255.255. It is the broadcast address of the zero network or 0.0.0.0, which in Internet Protocol standards stands for this network, i.e. the local network. Transmission to this address is limited by definition, in that it is never forwarded by the routers connecting the local network to other networks.” So, yeah, the packet is send across your whole local network, and it should hit your PC’s LAN network card, and turn on your PC.
pi@luckberry ~ $ wakeonlan 50:AF:73:1F:A8:0A
Sending magic packet to 255.255.255.255:9 with 50:AF:73:1F:A8:0A
The PC should power on! That’s it :)
Bonus task: You can also make an alias so you don’t have to remember the MAC address.
alias wakeitup="wakeonlan 50:AF:73:1F:A8:0A"
This vanishes when you restart your Pi, but there is way to make it permanent, outlined here.