wake on lan not working if i turn of with ubuntu

I just ran into this problem after upgrading two properly configured machines to 18.04. I remember that Ubuntu moved to netplan and found an answer from paulgj in the forums that made it work again for me. You may try this if the existing answers don't work.

I got it working by adding the macaddress match lines, here is the full .yaml file:

network:
  version: 2
  renderer: networkd
  ethernets:
    enp2s0:
      match:
        macaddress: 50:e5:49:b3:fc:97
      dhcp4: true
      wakeonlan: true

Note: you need to change enp2s0 and 50:e5:49:b3:fc:97 and save it in /etc/netplan/ with a .yaml extension. I hope this configuration did not disable anything that's going to haunt me in the upcoming weeks.


Edit: for desktops you should replace renderer: networkd with renderer: NetworkManager and then run sudo netplan apply.


It is an old thread, but there is no answer accepted and mine problem was similar, except that it is a mac mini dual boot MacOs and Ubuntu 18.04; on Mac suspend I could WOL from a Windows 10 machine; on Ubuntu suspend nothing happens... And I too have the

marcelo@Ubuntu-Macmini:~$ sudo ethtool -s wlp3s0 wol g
[sudo] senha para marcelo: 
Cannot get current wake-on-lan settings: Operation not supported
  not setting wol

So, I did all the steps at this question, better explained here but it still didn't work; but I read this thread and:

  1. did a sudo lshw -C network

    *-network
    descrição: Ethernet interface produto: NetXtreme BCM57765 Gigabit Ethernet PCIe fabricante: ... nome lógico: enp2s0f0 ... autonegotiation=on broadcast=yes ***driver=tg3***

  2. after this, knowing that the driver is tg3:

sudo gedit /etc/default/acpi-support

I changed the

# Add modules to this list to leave them in the kernel over suspend/resume
MODULES_WHITELIST=""

to

MODULES_WHITELIST="tg3"

And after restart the network service it worked as a charm, but only with Magic Packets, that is cool; to provide tha Magic Packets I'm using a python script, adapted from here; I said adapted because this script is for Python 2, and my setup is Python 3. Hope this helps someone.


Since it works in Windows than you know the problem lies within the Linux OS so the solution is... it depends. Either way you are going to need to know the name of the network interface. Run the following:

ip a

The interface with an IPv4 address (that isn't the loopback) is the one that we are looking for. The output looks like:

1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host
       valid_lft forever preferred_lft forever
2: ens160: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000
    link/ether 00:0c:29:f1:bb:ec brd ff:ff:ff:ff:ff:ff
    inet 192.168.1.12/24 brd 192.168.1.255 scope global dynamic ens160
       valid_lft 5919sec preferred_lft 5919sec
    inet6 fe80::20c:29ff:fef1:bbec/64 scope link
       valid_lft forever preferred_lft forever 

So the interface on this system is ens160.

Network Manager

See this post: How to enable Wake On Lan (WOL) in Ubuntu 16.04 If the following doesn't work, there is another method along with this one (that I blatently stole from loco.loop), that may be what you need.

If you used the Ubuntu Desktop ISO to install your system than you are using NetworkManager to control your network interfaces and you will need to do the following:

Systemd is how Ubuntu has decided to go so we might as well get used to it and use it to turn on WOL every time the system boots. Create /etc/systemd/system/[email protected] and add the following to 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

Next we need to enable the service to run at boot:

sudo systemctl enable wol@enp3
sudo systemctl start wol@enp3

Netplan

If you were a bit more adventurous and installed Ubuntu Server than your interfaces are controlled via systemd-networkd and Ubuntu has added the Netplan.io front end to help configure it. There will be a YAML file in the /etc/netplan/ directory in the form: 0X-something.yaml, lets take a look:

/etc/netplan/50-cloud.init.yaml

# This file is generated from information provided by
# the datasource.  Changes to it will not persist across an instance.
# To disable cloud-init's network configuration capabilities, write a file
# /etc/cloud/cloud.cfg.d/99-disable-network-config.cfg with the following:
# network: {config: disabled}
network:
  version: 2
  ethernets:
    ens160:
      dhcp4: true
  vlans:
    mgmt.10:
      id: 10
      link: ens160
      dhcp4: true
      dhcp6: false
    user.20:
      id: 20
      link: ens160
      dhcp4: true
      dhcp6: false

All that is needed is to add `wakeonlan: true' to the ens160 section. So it will look like this:

...
network:
  version: 2
  ethernets:
    ens160:
      dhcp4: true
      wakeonlan: true
  vlans:
    mgmt.10:
...

This is a YAML file and they are very picky about spacing so make sure the text you add is directly in line with the other text in the section.

Now we need to generate, test and apply the new config (the generation step isn't completely necessary but I've included it here for completeness):

sudo netplan generate
sudo netplan try

And assuming the test succeeds, if it doesn't the configuration will revert and you most likely got the formatting wrong, now run:

sudo netplan apply

@LiveWireBT's answer worked for me.

https://askubuntu.com/a/1072862/874871

Don't forget to run the apply command after you've changed the configuration.

$ sudo netplan apply