Wake-on-LAN mini tutorial
Cremona, December 2021.

This page is in the "junk" directory! Make sure you check some better material as well, on the main page.

Hello everyone!
In this page, we'll see how to power on computers with Wake-on-LAN. The way this works is that you send a "Magic Packet" (that's really how it's called), that instructs your machine to wake up. You can send this magic packet yourself, via command line on some computer connected to the network, or in some cases you could use some functionality of the router itself. This magic packet must be received through the ethernet NIC (Network Interface Card), and will not work with wireless NICs. Also, for this to work, you must be in the same LAN as the target machine.
On the target machine you need to:

  1. Enable "Wake-on-LAN" (WOL) on the BIOS (assuming that it is supported by your BIOS \& motherboard);
  2. Enable it on the operating system of the target machine (yes, you also need to do that).

Enabling WOL in the BIOS

First, go into the BIOS and find the Wake-on-LAN feature. In my case, it is under Power -> Automatic Power On -> Wake on LAN, and I need to set this to "Primary".

Enabling WOL in the Operating System

Again, this is a necessary step. First, you should check that the ethernet NIC allows for WOL. Run the command (you can substitute to "enp3s0" the name of your ethernet NIC):


$ sudo ethtool enp3s0


You should see a line saying "Wake-on:" and a letter. If the letter is "g", this may work straight out. But if the letter is "d", then WOL is disabled and you will need to set it to "g". In either case, I suggest that you introduce an instruction in the /etc/network/interfaces file, that will enable it whenever the interfaces are configured by the operating system. In the file, you should have:


auto eth0
iface eth0 inet static
up ethtool -s enp3s0 wol g


Then, you reboot the system, and let it switch on again. Congratulations, you should have WOL correctly set up now!

CAVEATS: Notice that the WOL may not work in some particular situations. For instance, if you have powered off the machine manually (brutally) while the system was booting, it is possible that the next time, WOL won't work. Why? Because most likely the system didn't manage to switch on the NIC card uwing the "ethtool" command that you specified in /etc/network/interfaces. If this happens, just switch on the system, let it boot until it reaches the login screen, and then shut it down correctly, from within the operating system. At that point, the network interfaces are probably well configured and WOL will work from the next time.

Sending the Magic Packet from another computer

As mentioned, you can sometimes send the WOL Magic Packet from the router itself. Another option (perhaps more common) is to send it from another computer located in the same LAN. To do that from a Linux computer, you can use the etherwake tool (sudo apt install etherwake). You will need to specify through which interface of the origin computer you want to send the package. In the following example, I'm connected to the LAN via the wifi, through the wlp3s0 wireless interface, so I will specify:


$ sudo etherwake -i wlp3s0 74:27:ea:e0:3b:48


That's pretty much it.

Cheers!
-Stefano       [BACK TO THE HOMEPAGE]