Tuesday, October 3, 2023
 Popular · Latest · Hot · Upcoming
rated 0 times [  12] [ 0]  / answers: 1 / hits: 22851  / 6 Months ago, wed, april 19, 2023, 6:07:24

I want to enable wake-on-lan for my network cards, for always. The community guide recommends adding the relevant command to /etc/network/interfaces. In past experiences editing Ubuntu conf files, it's extremely likely that the network interface file is written anew every boot, if not every apt upgrade. What's the best way to ensure that wake-on-lan is enabled every boot?

More From » networking


A boot script run after the network cards are configured should do the trick. Ubuntu uses upstart. After reading about upstart jobs, ethtool, writing an upstart script, and searching the interwebs for a better solution, I came up with this from jevinskie (you'll want to put this in a file in /etc/init):

start on started network

for interface in $(cut -d: -f1 /proc/net/dev | tail -n +3); do
logger -t 'wakeonlan init script' enabling wake on lan for $interface
ethtool -s $interface wol g
end script

  • Starts when the nics are initialised

  • Grabs the nic names from /proc/net/dev

  • Logs actions to syslog

  • Acts on all nics found

  • Requires ethtool, so make sure it's installed first:

    sudo apt-get install ethtool

If you want to imbue just one nic with the power of awakening, something like this is more appropriate:

start on started network

logger -t 'wakeonlan init script' enabling wake on lan for $interface
ethtool -s $interface wol g
end script

[#44716] Thursday, April 20, 2023, 6 Months  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.

Total Points: 114
Total Questions: 122
Total Answers: 126

Location: Mauritania
Member since Sun, Oct 17, 2021
2 Years ago