Trouble with wakeonlan with Ubuntu 20.04
Solution 1:
If the cause is WoL settings not being persistent after reboot as explained in the previous answer, there is a simpler solution, which is posted here: https://askubuntu.com/a/1051894/883129
- Make sure you have
ethtool
andwakeonlan
installed. - Create
/etc/network/if-up.d/wol_fix
file with the following content:
where [card] is the name of your ethernet adapter, such as#!/bin/sh /sbin/ethtool -s [card] wol g
eth0
,enp4s0
etc. (you can check this withifconfig
command). - Then run:
sudo chmod +x /etc/network/if-up.d/wol_fix
Solution 2:
I recently upgraded to Linux Mint 20. After re-installing the "wakeonlan" package I noticed it was not working. It turned out that upon shutdown, the wakeonlan option was being disabled. Here's how I worked around it.
On the computer you want to be able to wake up remotely...
Become root...
sudo su
Install the wakeonlan program on the computer you want to be able to wake up remotely.
apt install wakeonlan
Find your ethernet adapter, mine was called 'enp10s0' (usually called 'eth0').
ifconfig -a
Check the ethernet adapter to see what "Wake-on" is set to. See below link for diffent options and what they mean. https://www.thomas-krenn.com/en/wiki/Wake_On_LAN_under_Linux
ethtool enp10s0
Non-interactive creation of script which will set the "Wake-on" option to "g" which means "Wake on MagicPacket". For the next step (systemd) to work correctly, you must have the she-bang line included on the first line of the file.
cat >> /root/wol_fix.sh <<EOF
#!/bin/bash
ethtool -s enp10s0 wol g
EOF
Set correct permissions for the fix script.
chmod 755 /root/wol_fix.sh
Non-interactive creation of script which will run on boot to run the fixing script.
cat >> /etc/systemd/system/wol_fix.service <<EOF
[Unit]
Description=Fix WakeOnLAN being reset to disabled on shutdown
[Service]
ExecStart=/root/wol_fix.sh
Type=oneshot
RemainAfterExit=yes
[Install]
WantedBy=multi-user.target
EOF
Reload the systemd manager configuration.
systemctl daemon-reload
Enable to wol_fix service script.
systemctl enable wol_fix.service
NOTE: must reboot for the on-boot script to take effect. Or you can run the /root/wol_fix.sh script manually this time only before your next shutdown or reboot.
reboot
On computer you want to use to remotely wake up your other computer...
# [another_computer]$
Non-interactive creation of script to wake up computers on network. The "255" means only broadcast to a specific subset of the IP range on the local network.
cat >> /home/$USER/wakeuppc.sh <<EOF
wakeonlan -i 192.168.1.255 <MAC ADDRESS>
EOF
Add execute permisson for the wakeonlan caller script.
chmod +x /home/$USER/wakeuppc.sh
Solution 3:
Ubuntu allows Netplan for configuration. So, add the macaddress
key and enable wakeonlan
in /etc/netplan/00-installer-config.yaml
. E.g.
ethernets:
en01:
match:
macaddress: xx:xx:xx:xx:xx:xx
dhcp4: true
wakeonlan: true