Table of Contents

Enable Wake-on-LAN persistent

This guide was tested on Ubuntu 22 and Debian 11/12.

Check current setting and enable manually

Firstly find out the interface on which WoL should be enabled. Therefore use ifconfig that is shipped with the net-tools-package on Debian/Ubuntu:

ifconfig

Your output may look like this:

enp1s0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.0.2  netmask 255.255.255.0  broadcast 192.168.0.255
        inet6 fe80::ed26:e33:5d38:2468  prefixlen 64  scopeid 0x20<link>
        ether xx:xx:xx:xx:xx:xx  txqueuelen 1000  (Ethernet)
        RX packets 138808  bytes 178312866 (178.3 MB)
        RX errors 0  dropped 3324  overruns 0  frame 0
        TX packets 70435  bytes 59140948 (59.1 MB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0
 
lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536
	[...]
 
wlp2s0: flags=4099<UP,BROADCAST,MULTICAST>  mtu 1500
        ether xx:xx:xx:xx:xx:xx  txqueuelen 1000  (Ethernet)
        RX packets 0  bytes 0 (0.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 0  bytes 0 (0.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

Then check the current Wake-on-LAN-state with ethtool. (Package to install has the same name):

sudo apt install ethtool
ethtool <interface>

Replace <interface> for examle with enp1s0, if this is the ID of your interface.

The output may now look like this:

Show/Hide

Important are the following lines:

        [...]
        Supports Wake-on: pumbg
        Wake-on: d
	[...]

If the line Supports Wake-on: contains g, then Wake-on-LAN ist supported.

If the line Wake-on: already says Wake-on: g, then WoL is already enabled, if not, you can enable it with:

sudo ethtool -s <interface> wol g

Enable automatically at boot

If not enabled in BIOS WoL has to be enabled before shutting down. This can be done by a system service:

Firstly create the service file:

sudo nano /etc/systemd/system/wol-enable.service

And add this content:

[Unit]
Description=Configure Wake-up on LAN
After=network-online.target
 
[Service]
Type=oneshot
ExecStart=/sbin/ethtool -s <interface> wol g
 
[Install]
WantedBy=basic.target

Remind to change the <interface>.

Then save the file and enable the service with:

sudo systemctl enable wol-enable.service

Sourced from wiki.ubuntuusers.de