How to enable Wake On Lan (WOL) in Ubuntu 16.04 LTS?

share|improve this question

In order for WOL to work, make sure your ethernet interface is properly being shut down by your system when you poweroff.

Try the following:

  1. Create a bash script called wol_poweroff.sh on the /etc/rc6.d/ directory:

    sudo nano /etc/rc6.d/wol_poweroff.sh
    
  2. Put this code in it:

    #!/bin/bash
    ifconfig eth0 down
    poweroff
    
  3. Copy it to the /etc/rc0.d directory (so it also works with halt):

    sudo cp /etc/rc6.d/wol_poweroff.sh /etc/rc0.d/wol_poweroff.sh
    
  4. Make them both executable:

    sudo chmod 755 /etc/rc6.d/wol_poweroff.sh
    sudo chmod 755 /etc/rc0.d/wol_poweroff.sh
    

Now test to see if it works by powering down your machine with sudo shutdown now or sudo poweroff and using a WOL tool to send a magic packet to it.


That was the only thing that worked for me. I found those steps at a bug report at launchpad.net.

According to the author, Robbie Williamson, this works because of the following:

To get WOL to work the ethernet interface must be properly brought down as part of the system shutdown. This should be performed as part of run levels rc0 and rc6, noting that Linux typically has 7 different run levels (or operating modes):

rc0.d - System Halted

rc1.d - Single User Mode

rc2.d - Single User Mode with Networking

rc3.d - Multi-User Mode - boot up in text mode

rc4.d - Not yet Defined

rc5.d - Multi-User Mode - boot up in X Windows

rc6.d - Shutdown & Reboot


Source: https://bugs.launchpad.net/ubuntu/+source/ifupdown/+bug/981461

share|improve this answer

Run the following in the terminal:

sudo ethtool -s {your network interface} wol g 
sudo ethtool {your network interface}

you should see a g next to wake on lan after writing the second command

source

share|improve this answer

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

http://linrunner.de/en/tlp/docs/tlp-configuration.html

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

Enable Wake on LAN in /etc/network/interfaces when static network configuration is used.

# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).
# The loopback network interface

auto lo
iface lo inet loopback
# The primary network interface

auto eth0
iface eth0 inet static
        address 192.168.0.10
        netmask 255.255.255.0
        gateway 192.168.0.1
        dns-nameservers 192.168.0.1
        up ethtool -s eth0 wol g

Enable wake on lan in BIOS, enter the BIOS setup and look for something called "Wake up on PCI event", "Wake up on LAN" or similar. Change it so that it is enabled. Save your settings and reboot.

https://help.ubuntu.com/community/WakeOnLan

Warning some motherboards / network controllers don't support WOL from the cold boot (S5 state, where the power to the system is physically turned off and back on again). In that case, at least one power cycle (power up, shutdown) has to be performed. To mitigate to the problem, the BIOS can be configured to power up when AC is restored and schedule a shutdown inside Ubuntu afterwards. Refer to the motherboard's manual for further details.

share|improve this answer
    
This worked for me on 14.04 LTS. Thank you! – TenLeftFingers May 22 '16 at 16:56

I've found a better way that worked for me. At least a cleaner way. I'm posting this because while googling Ubuntu 16 wol and other similar searches I came across with this post several times. This could help somebody else.

Apparently Ubuntu changed upstart for systemd, this in Ubuntu 15, Ubuntu 16 and presumably next versions too. I'm new to both systems but this worked for me.

To keep WOL working, I had to re-enable it every time the system booted. To avoid doing this manually I used systemd for this purpose. This is what I did:

  1. First, create the file /etc/systemd/system/wol@.service (keep the @ symbol). Put this in it:

    [Unit]
    Description=Wake-on-LAN for %i
    Requires=network.target
    After=network.target
    
    [Service]
    ExecStart=/sbin/ethtool -s %i wol g
    Type=oneshot
    
    [Install]
    WantedBy=multi-user.target
    
  2. Enable this for the interface on boot, run the following command (change eth3 with your interface):

    systemctl enable wol@eth3
    

    You should see something like this:

    Created symlink from /etc/systemd/system/multi-user.target.wants/wol@eth3.service to /etc/systemd/system/wol@.service.
    
  3. To check if it's enabled, run the following command (change eth3 with your interface) and it should return enabled:

    systemctl is-enabled wol@eth3
    
  4. To test this, reboot and run (change eth3 with your interface):

    ethtool eth3
    

    You should see a line with the following:

    Wake-on: g
    


Sources:

share|improve this answer
    
+1 this is way better. should be the accepted one. – Stefanos Kalantzis Nov 29 '17 at 20:27

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.