Ubuntu - Configure Wake on LAN

Ubuntu Linux WoL ajboni 6/8/2020

I tried to set up WoL on my Linux Mint box. But it wasn't working...

First I've checked that Wake on LAN was enabled in the motherboard. Then I've found out that the driver did not have it enabled by default/

$ sudo ethtool enp7s0 | grep Wake
    Supports Wake-on: pumbg
    Wake-on: d

That d on Wake-on: means disabled. To enable:

$ sudo ethtool -s enp7s0 wol g

And it worked!!! The issue is that this setting is lost after reboot. The (Arch Wiki)[https://wiki.archlinux.org/index.php/Wake-on-LAN#Enable_WoL_on_the_network_adapter] to the rescue!

$ sudo nano /etc/systemd/system/wol@.service

Added this content:

[Unit]
Description=Wake-on-LAN for %i
Requires=network.target
After=network.target

[Service]
ExecStart=/sbin/ethtool -s %i wol g
Type=oneshot

[Install]
WantedBy=multi-user.target

And finally:

$ sudo systemctl enable wol@enp7s0

Now power off and it should work.

NOTE: It won't work after hard poweroff or energy loss.