Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I want to enable wake-on-lan for my network cards, for always. The community guide recommends adding the relevant command to /etc/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?

share|improve this question

2 Answers 2

up vote 6 down vote accepted

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:

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
share|improve this answer
2  
I always thought wake on lan was a BIOS feature. –  con-f-use Jun 9 '11 at 22:38
    
@con-f-use It requires cooperation between BIOS and NIC. Both must support WOL. Furthermore, at least my nic has a bad habit of disabling wol after boot. The Ubuntu community wiki implies this is the case for many a computer. –  djeikyb Jun 9 '11 at 23:22
    
@con-f-use This superuser.sx thread on how power and rebooting works is also interesting as it relates to WOL. –  djeikyb Jun 10 '11 at 5:38

Create new file, let's say wakeonlanconfig, and put below lines to it:

#!/bin/bash
ethtool -s eth0 wol g
exit

Next set the permissions of the file, making it executable:

chmod a+x wakeonlanconfig

And finally make the script run on startup:

update-rc.d -f wakeonlanconfig defaults

For mor details please visit: http://lukasz-lademann.blogspot.com/2013/01/how-set-up-wol-wake-on-lan-on-thin.html

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.