Using Wake On Lan so you don't have to use your fingers
Published on : 2025-03-14 14:52
WakeOnLan is a very useful feature, especially if you're a lazy
person. With WakeOnLan you can start your machines without walking
or using your fingers and push the power button.
IMG A photo of how I wake up my cluster
- What you need
You only need 2 things: wakeonlan and ethtool. You can easily
install them with:
sudo apt install wakeonlan ethtool
wakeonlan is needed on the machine you'll be using to send the
wake up command while ethtool is used to configure your network
card.
- Using ethtool to enable Wake-on-LAN
- + Find the Network Adapter (in my case it's `enp1s0`)
ip a
- + Check if WakeOnLan is supported
sudo ethtool enp1s0 | grep "Wake-on"
You should see something like ` Supports Wake-on: pumbg`.
To enable WakeOnLan you have to:
sudo ethtool --change enp1s0 wol g
Right now WakeOnLan is enabled but the setting is not persistent.
- + Persist Wake-on-LAN After Reboot
sudo pico /etc/systemd/system/wol.service
Add the following and replace `enp1s0` with your network card
[Unit]
Description=Enable Wake On Lan
[Service]
Type=oneshot
ExecStart = /usr/sbin/ethtool --change enp1s0 wol g
[Install]
WantedBy=basic.target
- + Enable the service:
sudo systemctl enable wol.service
- Using wakeonlan to start your computers
In order to wake up your computers with a magic wakeonlan packet
you need to know it's MAC address. You can easily find it with
sudo ethtool -P enp1s0
Once you get the MAC address you can easily wake the computer up
from another computer using the wakeonlan command:
wakeonlan "D2:CB:3B:20:DC:AE"
I have create a small bash script to wake up all my 3 Lenovo M53's
at once:
#!/bin/bash
# MAC addresses (Not the real ones)
MAC1="D2:CB:3B:20:DC:AE" # lenovo1 mac
MAC2="D2:CB:3B:20:DD:37" # lenovo2 mac
MAC3="D2:CB:3B:20:D6:04" # lenovo3 mac
# Wake up the three computers
echo "Waking up lenovo1 ..."
wakeonlan $MAC1
echo "Waking up lenovo2 ..."
wakeonlan $MAC2
echo "Waking up lenovo3 ..."
wakeonlan $MAC3
echo "All computers should be waking up now."
DIR Back to my phlog