Wake-On-LAN (WOL) on Ubuntu 22.04
Wake-On-LAN (WOL) is a technology that allows one computer to remotely Wake Up another computer on a local area network (LAN). It requires the support of the computer's network card and motherboard. To configure WOL on Ubuntu 22.04, you will need to use the ethtool command to enable it.
First, you need to find out where ethtool is installed. This terminal command will do that:
foc@ubuntu22:~$ sudo --preserve-env systemctl edit --force --full wol-enable.service
[Unit] Description=Enable Wake-up on LAN [Service] Type=oneshot ExecStart=/sbin/ethtool -s enp2s0 wol g
[Install] WantedBy=basic.target
Replace enp2s0 value with the computer's network interface name. Next, install the ethtool package:
foc@ubuntu22:~$ sudo apt install ethtool -y
Then check if the network card supports wake-on-LAN using this command:
foc@ubuntu22:~$ sudo ethtool enp2s0
Settings for enp2s0: ... Supports Wake-on: pumbg Wake-on: d Link detected: yes
The expression “Wake-on:d” indicates that the wake-on-lan feature of the network card is supported but deactivated. To enable it, run the following command:
foc@ubuntu22:~$ sudo ethtool -s enp2s0 wol g
Settings for enp2s0: ... Supports Wake-on: pumbg Wake-on: g Link detected: yes
Some motherboard manufacturers require you to change the settings in the BIOS to enable this feature.
Finally, create a systemd service to enable WOL at startup:
foc@ubuntu22:~$ sudo --preserve-env systemctl edit --force --full wol-enable.service
[Unit] Description=Enable Wake-up on LAN [Service] Type=oneshot ExecStart=/sbin/ethtool -s enp2s0 wol g
[Install] WantedBy=basic.target
After creating the service, reload and enable it:
foc@ubuntu22:~$ sudo systemctl daemon-reload foc@ubuntu22:~$ sudo systemctl enable wol-enable.service Created symlink /etc/systemd/system/basic.target.wants/wol-enable.service → /etc/systemd/system/wol-enable.service
Enabling Wake-on-Lan on Ubuntu 22.04 is relatively easy once you know the steps. First you need to find out which network interface you are using, then you need to install the ethtool package and use the command to check if your network card supports wake-on-Lan. Once it is confirmed, you need to run the command to enable WOL. Finally, create a systemd service to enable WOL at startup. After completing these steps, you should be able to use Wake-on-Lan on your Ubuntu 22.04 machine.
Citations :
- http://ubuntuguide.net/remotely-turn-on-ubuntu-from-lan
- https://www.unifiedremote.com/tutorials/how-to-configure-wake-on-lan-on-windows
- https://necromuralist.github.io/posts/enabling-wake-on-lan/
- https://www.maketecheasier.com/enable-wake-on-lan-ubuntu/
- https://www.golinuxcloud.com/wake-on-lan-ubuntu/
- https://www.cyberciti.biz/tips/linux-send-wake-on-lan-wol-magic-packets.html