Sunday, May 5, 2024
 Popular · Latest · Hot · Upcoming
0
rated 0 times [  0] [ 0]  / answers: 1 / hits: 1687  / 2 Years ago, thu, may 26, 2022, 5:39:56

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?


More From » networking

 Answers
6

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

[#576] Friday, May 27, 2022, 2 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
allowiel

Total Points: 189
Total Questions: 103
Total Answers: 105

Location: Slovenia
Member since Thu, Mar 18, 2021
3 Years ago
allowiel questions
Thu, Jul 14, 22, 06:53, 2 Years ago
Sun, Nov 14, 21, 05:51, 3 Years ago
Sat, Jun 5, 21, 02:52, 3 Years ago
Thu, Dec 23, 21, 23:05, 2 Years ago
;