Ubuntu 15.10 – Disable Wake on LAN (WOL) permanently

ubuntu, systemd, Wily Werewolf, notebook, battery power drain

Preface#

In some cases, Wake on LAN is enabled by default and you cannot disable it in your BIOS/UEFI because the setting is not available. On notebooks/ultrabooks, WOL can drain/discharge your battery even your device is powered-off!

There are a several guides out there, which didn’t even work. The general mistake is, that the WOL settings can only be changed as root user. Additionally they have to change on every system boot! Therefore you need a simple startup script which will do the job.

Note: this guide in only valid for Ubuntu >= 15 with systemd enabled!

Step-by-Step Guide#

Identify your network interfaces#

First of all, run ifconfig as normal user. The output will look like this:

andi@epic:/home/andi# ifconfig
enp0s25   Link encap:Ethernet  HWaddr 
....
lo        Link encap:Local Loopback
...
wlp6s0    Link encap:Ethernet  HWaddr 0
...

In this case, the wired-interface is enp0s25 (this will deviate from your setup!). Normally the device-name starts with eth – e.g. eth0, eth1.

Check the current WOL State#

As root user or with sudo privileges run the following command to obtain the current WOL state of the device. Run ethtool <devicename>

root@epic:/home/andi# ethtool enp0s25
Settings for enp0s25:
        Supported ports: [ TP ]
        Supported link modes:   10baseT/Half 10baseT/Full
                                100baseT/Half 100baseT/Full
                                1000baseT/Full
        Supported pause frame use: No
        Supports auto-negotiation: Yes
        Advertised link modes:  10baseT/Half 10baseT/Full
                                100baseT/Half 100baseT/Full
                                1000baseT/Full
        Advertised pause frame use: No
        Advertised auto-negotiation: Yes
        Speed: Unknown!
        Duplex: Unknown! (255)
        Port: Twisted Pair
        PHYAD: 2
        Transceiver: internal
        Auto-negotiation: on
        MDI-X: Unknown (auto)
        Supports Wake-on: pumbg
        Wake-on: g
        Current message level: 0x00000007 (7)
                               drv probe link
        Link detected: no

In this case, “Wake-on: g” means that WOL is enabled for incomming MagicPakets – “d” would mean that it is already disabled.

Create a systemd Startup Service#

Create a file named wol.service in /etc/systemd/system/ with your favourite text-editor, e.g. nano and add the following content:

[Unit]
Description="Disable WOL"

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

[Install]
WantedBy=multi-user.target

The placeholder <devicename> has to be replaced by the identified interface name.

Enable the Service#

Run systemctl enable wol.service – it will enable the service file

Reboot Your System for Verification!#

Finally, Run ethtool <devicename> again. Now it should show the “d” flag for “Wake-on”. This indicated that WOL is disabled for this interface! FOREVER.

root@epic:/home/andi# ethtool enp0s25
Settings for enp0s25:
....
        Transceiver: internal
        Auto-negotiation: on
        MDI-X: Unknown (auto)
        Supports Wake-on: pumbg
        Wake-on: g
....