Sign up ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free.

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?

share|improve this question

2 Answers 2

up vote 10 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 (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
share|improve this answer
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 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:

ethtool -s eth0 wol g

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:

share|improve this answer

Your Answer


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.