Linux Wake-on-LAN Magic Packet Configuration
Wake-on-LAN (WoL) magic packet configuration allows network administrators to remotely power on dormant Linux systems by broadcasting a specialized network frame. This article explores the significance of the magic packet within the Linux operating system, detailing how it functions at the hardware and kernel levels, why it is critical for energy conservation and remote administration, and how Linux administrators configure and persist these settings.
What is the WoL Magic Packet?
A Wake-on-LAN magic packet is a standard network broadcast frame
containing a specific payload signature: six bytes of hexadecimal
FF (255 in decimal), followed by sixteen uninterrupted
repetitions of the target machine's 48-bit MAC address.
When a Linux system is shut down or placed into a low-power sleep state (such as ACPI states S3, S4, or S5), the system's Network Interface Card (NIC) remains partially powered in auxiliary mode. The NIC listens to incoming layer-2 or layer-3 traffic. When it detects this 102-byte sequence matching its physical address, it triggers a power-on signal to the motherboard via the PCI Express bus or legacy auxiliary lines.
Significance of Magic Packet Configuration in Linux
Proper configuration of the WoL magic packet in Linux holds major technical and operational significance across enterprise and home-lab environments:
- Energy Efficiency and Operational Cost Reduction: In large data centers or workstation fleets, leaving machines running 24/7 is inefficient. Magic packet support allows systems to remain fully powered off during off-peak hours and wake up instantly when needed for tasks such as backups, software deployments, or remote work sessions.
- Remote Infrastructure Management: Headless Linux servers deployed in remote locations or co-location facilities often lack expensive Out-of-Band (OOB) hardware like IPMI, iLO, or DRAC. Configuring WoL provides an inexpensive, native mechanism to cycle power states over the local network.
- Targeted Wake Signals: Unlike other WoL modes (such
as waking on any broadcast frame, unicast frame, or ARP request), the
"magic packet" mode (
gflag) ensures the machine only wakes when explicitly commanded. This prevents unwanted power-ups caused by standard network chatter or broadcast storms.
Configuring Magic Packet in Linux
For a Linux machine to respond to a magic packet, settings must align across the motherboard firmware (BIOS/UEFI), the Linux kernel driver, and user-space network managers.
BIOS/UEFI Prerequisites
Before Linux can manage WoL, the system firmware must support and permit wake events from PCI-E devices or explicitly enable Wake-on-LAN. Without this, the motherboard cuts power completely to the NIC upon shutdown.
Inspecting and Enabling via
ethtool
In Linux, the standard utility to inspect and modify NIC-level WoL
settings is ethtool.
To check the current WoL status of an interface (e.g.,
eth0):
sudo ethtool eth0Look for two key output lines:
- Supports Wake-on: Indicates what the NIC hardware
and driver support. The letter
gsignifies MagicPacket support. - Wake-on: Indicates the current active setting. If
it displays
d, WoL is disabled.
To enable magic packet detection:
sudo ethtool -s eth0 wol gAchieving Configuration Persistence
By default, changes made with ethtool are volatile and
reset after a reboot. Linux systems handle persistence through their
respective network management subsystems:
- Systemd-networkd: Administrators set
WakeOnLan=magicin the.networkconfiguration file. - NetworkManager: The connection configuration can be
modified using
nmcli c modify <connection-name> 802-3-ethernet.wake-on-lan magic. - Udev Rules: A persistent rule can be placed in
/etc/udev/rules.d/to invokeethtoolwhenever the network interface appears.
Correctly configuring the magic packet in Linux ensures that low-power states remain dependable without sacrificing remote accessibility or risking unexpected system activations.