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?


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
  • 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
  • Does this need to be changed for systemd? – Nathan Osman Jan 1 '16 at 20:56
  • @NathanOsman please add a systemd answer! this solution is still relevant to older but still supported LTS releases – djeikyb Jan 2 '16 at 5:35

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: http://lukasz-lademann.blogspot.com/2013/01/how-set-up-wol-wake-on-lan-on-thin.html


In Ubuntu 16.04 additionally set WOL_DISABLE=N in /etc/default/tlp to avoid getting WOL disabled by TLP power management.


Add NETDOWN=no in /etc/default/halt to prevent powering off the network card during shutdown

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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