During the setup of an additional Linux server in the home lab, I wanted to configure wake-on-lan, to spin up the server once I need it.
First, you need to check if wake-on-lan is enabled in the BIOS, in my case it was disabled and greyed out. I needed to disable other functionalities in the power management to enable it.
In the server OS, I needed to find out the network device’s name, and I realized that
ifconfig was not installed by default on the Debian GNU/Linux
distribution.
With the following command, i found that the network device is enp2s0
instead of the default eth0. Also the output shows that wake-on-lan is
disabled on the interface.
root@server:$ ip -c a s
ethtool can be utilized to configure the network interfaces and enable
wake-on-lan (wol).
root@server:$ sudo apt-get install ethtool
root@server:$ sudo ethtool -s enp2s0 wol g
Waking up the server still did not work, and wake-on-lan was disabled on
the network interface config again. Hence, I needed to create the file
/etc/systemd/system/wol\@.service and enable a service to keep
wol active.
[Unit]
Description=Wake-on-LAN (%i)
Requires=network.target
After=network.target
[Service]
ExecStart=/sbin/ethtool -s %i wol g
Type=oneshot
[Install]
WantedBy=multi-user.target
The configuration must be reloaded in systemd and the service for the network
interface enp2s0 can be created from the template using systemctl.
root@server:$ sudo systemctl daemon-reload
root@server:$ sudo systemctl enable wol@enp2s0.service
root@server:$ sudo systemctl start wol@enp2s0.service
Fianally, the server can be started by sending the magic packet from another device to the server using the server’s IP and hardware adress.
user@client:$ wakeonlan -i 192.168.0.100 aa:bb:cc:00:11:22
Michael Hülsen