Marcio Cunha

How to configure Wake on LAN on Linux to turn on servers

Learn step-by-step how to enable Wake on LAN on Linux servers and dispatch magic packets across the network to power on remote machines.

Marcio Cunha•5 min
Also available in:PortuguêsEspañol
Summary
  • Wake on LAN sends a special network signal to wake up powered-down network interface cards.
  • The network card requires continuous standby power from the motherboard even when the OS is shut down.
  • The ethtool utility allows checking and modifying support for remote power-on features.
  • Magic packets require the unique physical MAC address of the target network interface.
  • Testing local traffic with tcpdump helps confirm UDP packet transmission on the correct port.

What is Wake on LAN and how it works in practice

Imagine being able to turn on a computer located in another room, or even another building, without needing to press its physical power button. Wake on LAN, frequently abbreviated as WoL, is a network standard that allows exactly that: waking up a shut-down or low-power machine using a signal sent across the local network. In practice, this means the server's network card continues to receive a small amount of electrical power even when the operating system is completely powered down, staying on standby waiting for a specific command.

This command is popularly known as a magic packet. It is a specialized data packet sent across the network containing a repeated sequence of bytes followed by the unique physical address of the destination network card, called the MAC address. When the network card captures this exact sequence amidst local traffic, it interprets the signal as an ignition command and sends an electrical pulse to the motherboard, triggering full hardware initialization. Before moving on to software configurations, keep in mind that for advanced connectivity diagnostics during these tests, you can consult our guide on how to inspect network packets with tcpdump on Linux.

How to verify if the network card supports the feature

The first practical step in the Linux operating system is to confirm whether the machine's hardware supports remote awakening. Not all network cards have the necessary internal circuitry or come enabled from the factory. To investigate the current state of the network interface, we use a command-line tool called ethtool, which is designed precisely to query and adjust physical and logical parameters of network interfaces.

Open your Linux server terminal and run the command below to list available interfaces and identify the name of your primary network adapter, which is usually named something like eth0 or enp3s0.

ip link show

With the interface name in hand, run ethtool passing the device name to inspect power management capabilities. In practice, we look for specific fields indicating the letter 'g', which represents support for the magic packet.

sudo ethtool enp3s0

How to enable Wake on LAN permanently on Linux

If the previous command returns that Wake on LAN capability is disabled, represented by the letter 'd' in the corresponding field, you can enable it immediately using the same tool. However, note that this change made directly via the command line is usually temporary and gets lost as soon as the server reboots. To ensure the setting survives reboots, we need to configure an initialization service or system rule.

To activate the feature in the current session, run the following command with administrative privileges, replacing the interface name with your actual adapter:

sudo ethtool -s enp3s0 wol g

To make this configuration permanent in systemd-based distributions, the cleanest approach is to create a custom service or configure a network rule. Many modern distributions allow managing this directly in network configuration files or through a small script executed right at the beginning of the operating system boot.

How to configure motherboard BIOS and UEFI

Even if the Linux operating system is perfectly configured, the server will refuse any remote wake commands if the motherboard is set to completely cut power to network ports when the computer is turned off. To resolve this, you need to physically reboot the server and access the BIOS or UEFI configuration screen during the initial boot process, usually by pressing keys like Delete, F2, or F12.

Inside the BIOS interface, look for sections related to power management, advanced configuration, or onboard device settings. Common terms include Power Management, Wake on LAN, Resume on LAN, or PME Event Wakeup. Change these options to the enabled position, save changes, and exit while rebooting the equipment. Without this hardware-level bridge, the operating system will not have enough power to keep the network card listening to the local network.

How to trigger the magic packet from another machine

With the server properly configured in both Linux and the BIOS, it is time to test the operation by sending the magic packet from a client computer connected to the same local network. To do this, we must gather two fundamental pieces of information from the machine to be turned on in advance: the MAC address of the network card and the IP or broadcast address of the network.

Install the packet dispatch tool on your control computer and run the command specifying the MAC address of the target server. In practice, the command sends a burst of data across the link layer that reaches all local devices, but only the network card with the matching MAC reacts to the call. To complement this implementation in production environments, see our related technical analyses on How to test PT100 temperature sensor with multimeter and Corrupted Excel file? How to recover sheets and extract data.

sudo apt install etherwake
sudo etherwake -i eth0 AA:BB:CC:DD:EE:FF

Final Considerations and Troubleshooting

Configuring Wake on LAN in Linux server environments transforms the routine of administering laboratories and local infrastructures, allowing energy savings by keeping machines turned off when not in use. If the server refuses to turn on after following all steps, verify if the network card is connected via a physical cable, as Wi-Fi connections generally do not support the feature reliably, alongside checking routing restrictions and firewalls that might block UDP packets on the utilized port.

Keeping these procedures documented ensures agile service recovery and simplifies the operation of distributed environments without requiring constant physical presence at the server rack. Always test commands after firmware updates on the motherboard, as some updates tend to reset power management options to factory defaults.