2025-03-05
Enabling wake-on-LAN in Linux
This is probably a pretty simple, well-documented post, but just for my own reference (as usual!). I was sad when I tried to WoL (via jumpbox) after booting into Linux whilst away from home for a couple days and it didn’t work…
First, we just need to make sure the usual BIOS setting (Wake-on-LAN, Magic Packet, etc…) is enabled. – In my case on ASRock this was actually called “PCIE Devices Power On”. I’m also on a Realtek card.
Then, the simplest form of this is ensure the NIC is configured to still idle for the magic packet while sleeping (as root, where enp5s0 is my main NIC):
$ ethtool -s enp5s0 wol g
… where ‘g’ means ‘Wake on MagicPacketâ„¢’ (see ethtool man page for more details!). This should be run every reboot to make sure the NIC is still configured as such.
To confirm settings:
$ ethtool enp5s0
Settings for enp5s0:
Supported ports: [ TP MII ]
...
...
Wake-on: g
Link detected: yes
Notice that ‘Wake-on’ is ‘g’. By default (at least for me), this was ’d’ for disabled.
If you are using NetworkManager though, like the default in Fedora and as such, my setup, a more elegant solution could be to have that manage it for us. This is also quite easy, but perhaps less simple:
$ nmcli connection show
NAME UUID TYPE DEVICE
Wired connection 1 3.......-....-....-....-...........d ethernet enp5s0
...
# (My desired one is 'Wired connection 1')
$ nmcli connection modify "Wired connection 1" 802-3-ethernet.wake-on-lan magic
$ nmcli device reapply enp5s0
# (Note 'enp5s0' should be the device in the profile you edited as above 'show')
After this, you can validate using ’ethtool’ as prior simplistic approach that it all worked.
As usual (i.e. Windows), it may take your computer an extra reboot to get things to work. Always try that first if WoL doesn’t work right away! (I got stuck for a while before on an older PC because of this.)
Bonus: Windows. A similar extra config is usually also required, at least for Realtek as I’ve used. Usually you’ll need the Realtek drivers installed, then in the ‘Advanced’ section of the NIC properties, there’s a ‘Wake on Magic Packet’ setting you’ll need to enable. Then reboot once and/or twice if required and it should ‘just work’.
Bonus II: How to actually WoL? I typically have this saved in a script on my jumpbox (Rocky Linux, net-tools
package, as root, where enp1s0 is the network interface on the same network as the main PC): ether-wake -i enp1s0 <main:pc:mac:address:here>
(As usual, the MAC address of the main PC can be found with e.g. ip addr show dev enp5s0
.)