Thursday, July 21, 2016

Turning Off Wake-On-LAN on Linux Laptops

I noticed my Dell Latitude laptop running Kubuntu 16.04 that even after shutting down completely, the battery was still being drained. The problem is that wake-on-lan is generally turned on by default. Unless you need WOL for some reason — turn it off.

Andi Dittrich has a great article on how to disable wake-on-lan in post 15.10 Ubuntu systems (you need to use a different method if still using versions older than 15.10).

The core method is to create a file named wol.service in /etc/systemd/system/ with:

[Unit]
Description="Disable WOL"

[Service]
Type=oneshot
ExecStart=/sbin/ethtool -s wol d

[Install]
WantedBy=multi-user.target

Then run: sudo systemctl enable wol.service

Run sudo ethtool and check it shows "Wake-on: d" after reboot to ensure it has worked.

2 comments:

  1. This works well, but upon suspend/resume, wake-on-lan will be enabled again. To fix this, modify your systemd service file (wol.service) to this instead:

    [Unit]
    Description="Disable WOL"
    After=suspend.target

    [Service]
    Type=oneshot
    ExecStart=/sbin/ethtool -s wol d

    [Install]
    WantedBy=multi-user.target suspend.target

    ReplyDelete
    Replies
    1. Hi Christan,

      Thanks for the tip. I rarely use suspend for any length of time, so hadn't noticed that it flips the WOL back on.

      Cheers!

      Delete