Linux and Wake on LAN


The Internet servers are usually on 24×7, probably that’s why I never had the need to use the Wake on LAN feature on a computer.

I’ve just built a home server running Ubuntu Linux, using consumer grade PC parts. To avoid a big surge on my next electricity bill, I plan to only turn on the server when the sun is shining or during off peak when electricity is cheaper. It’s trivial to mention how to shutdown a Linux server via SSH, however to my surprise it’s not any harder to turn on a Linux server using WoL.

First on the server, make sure the line `ethernet-wol g` exists under the interface. eg.

auto enp0s31f6
iface enp0s31f6 inet static
address 192.168.1.51
netmask 255.255.255.0
gateway 192.168.1.1
ethernet-wol g

Save it and restart, run `sudo ethtool enp0s31f6` and if the following line appears in the output then it's a success!

Wake-on: g

Next step is to turn on WoL in BIOS. Different BIOS may call it different names but generally it’s to allow the system to power on by PCI/Network.

On Arch Linux, install wol, the command to wake up a WoL enabled computer.

sudo pacman -Sy wol
sudo wol <MAC ADDRESS>

Reference: https://wiki.archlinux.org/index.php/Wake-on-LAN

That’s it 🙂


2 responses to “Linux and Wake on LAN”