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

16.04wakeonlan

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

Best Answer

I've found a better way that worked for me. At least a cleaner way. Apparently Ubuntu changed upstart for systemd, in Ubuntu 15.04, Ubuntu 16.04 and presumably next versions too. I'm new to both systems but this worked for me.

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.

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:

Related Question