Wednesday, May 8, 2024
 Popular · Latest · Hot · Upcoming
12
rated 0 times [  12] [ 0]  / answers: 1 / hits: 22962  / 1 Year 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

 Answers
5

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

script
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
done
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

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

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

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

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