Contents

Setting Up Wake-on-LAN (WOL) in Linux

Instructions for configuring remote power-on of a computer over the network.

First, you need to check that the Wake on LAN feature is enabled in the BIOS/UEFI. Next, install ethtool and check the settings.

shell

sudo apt update && sudo apt install ethtool
sudo ethtool enp8s0 | grep "Wake-on"

If the output shows the value d, it means the mode is disabled. Change the mode to Wake on MagicPacketg. You can find more about the modes in the documentation.

shell

sudo ethtool --change enp8s0 wol g

The problem with manual changes is that it only works until the system is rebooted. Therefore, you need to add it to the startup using one of the following methods:

In your configuration, for example in /etc/netplan/10-init.yaml, you need to add the wakeonlan option.

yaml

network:
  version: 2
  ethernets:
    enp8s0:
      dhcp4: true
      wakeonlan: true

In your configuration, for example in /etc/network/interfaces, you need to add the ethernet-wol option.

ini

auto enp8s0
iface enp8s0 inet dhcp
        ethernet-wol g

You need to check what your connection is called in the system and change its operation mode.

shell

nmcli con show
sudo nmcli c modify "netplan-enp8s0" 802-3-ethernet.wake-on-lan magic
nmcli c show "netplan-enp8s0" | grep 802-3-eth

Check your interfaces and adjust the necessary one.

shell

networkctl list
sudo networkctl edit enp8s0

And add the option

ini

[Link]
WakeOnLan=magic

Then activate the changes

shell

sudo networkctl reload
sudo networkctl reconfigure

If the previous options did not work for some reason, you can do this through systemd.

Create a new service

shell

sudo systemctl edit wol.service --full --force

And add the setting for Wake on MagicPacket.

ini

[Unit]
Description=Enable Wake-on-LAN
After=network-online.target
[Service]
Type=oneshot
ExecStart=/sbin/ethtool --change enp8s0 wol g
[Install]
WantedBy=network-online.target

Reload the modified service configurations and start it.

shell

sudo systemctl daemon-reload
sudo systemctl enable wol.service
sudo systemctl start wol.service
systemctl status wol

Put your computer to sleep with sudo systemctl suspend or turn it off with sudo systemctl poweroff. The indicator on the computer’s network card may not light up, depending on the manufacturer, but it must be lit on the switch (even if it’s yellow), otherwise the magic packets will not reach your network card.

Next, from another computer, send the command to turn it on, specifying the MAC address of the computer to be turned on.

shell

sudo apt update && sudo apt install etherwake
sudo etherwake -i ens3 11:22:33:44:55:66

Related Content