2

Ubuntu's networking stack is constantly evolving and most previous information on enabling Wake-on-LAN for an interface is outdated (like the Ubuntu wiki).

Now that Ubuntu uses Netplan instead of /etc/network/interfaces, how do I enable Wake-on-LAN automatically whenever a particular interface comes up?

rgov
  • 388
  • 1
  • 2
  • 15

3 Answers3

1

I fixed it by adding a file to /etc/netplan, named /etc/netplan/50-wol.yaml

the contents of the file are: (fill in your own mac-address).

network:
  version: 2
  renderer: NetworkManager
  ethernets:
    enp2s0:
      match:
        macaddress: XX:XX:XX:XX:XX:XX 
      wakeonlan: true
      dhcp4: yes
user114676
  • 206
  • 1
  • 4
0

The wiki tells us we need to run ethtool -s <interface> wol g when the interface comes up.

Although Ubuntu 20.04 has ifupdown scripts under /etc/network/if-up.d, Netplan provides different guidance on how to run post-up hook scripts that suggests using networkd-dispatcher.

The manual page for networkd-dispatcher does not explain how to detect which interface is going down but the source code shows several environment variables that get set including IFACE.

So we can create /etc/networkd-dispatcher/routable.d/50-wake-on-lan (and chmod +x it) with a script like this:

#!/bin/sh -eu

case "$IFACE" in
    enp60s0)
        ethtool -s <interface> wol g
        ;;
esac
rgov
  • 388
  • 1
  • 2
  • 15
0

For me really helped this post: https://forum.manjaro.org/t/troubles-with-setting-up-wol/24815/3

TLDR: execute sudo systemctl disable tlp

TLP is for power management on laptops etc. It is unlikely that you will need TLP on a system that you want to be able to remotely start a machine.

After execution of the command above WoL became persistent and you don't need to apply netplan after every reboot.

  • While this link may answer the question, it is better to include the essential parts of the answer here and provide the link for reference. Link-only answers can become invalid if the linked page changes. - [From Review](/review/late-answers/1292191) – David Apr 12 '23 at 06:38