Marcio Cunha

How to configure Wake-on-LAN on Linux to turn on PC

Learn how to configure Wake-on-LAN on Linux step by step. Adjust ethtool, map MAC addresses, and power on remote workstations over your local network.

Marcio Cunha•6 min
Also available in:PortuguêsEspañol
Summary
  • Wake-on-LAN relies on an electrical signal sent by the network interface card to wake the motherboard.
  • The BIOS or UEFI settings must have remote startup enabled to keep the network card powered.
  • The ethtool utility checks and modifies the magic packet sleep state on the network interface.
  • The magic packet travels across the data link layer using the physical MAC address of the target machine.
  • Traffic monitoring tools like tcpdump help diagnose packet delivery failures during setup.

What is Wake-on-LAN and how it works in practice

Have you ever imagined being able to turn on a computer located in another room or under your desk without pressing the physical power button? That is exactly what Wake-on-LAN, often abbreviated as WoL, does. In practice, it is a protocol that allows you to wake up a shut-down or low-power computer using a signal sent across your local area network. The secret behind this magic is that your computer's network interface card remains partially powered even after the operating system shuts down, patiently waiting for a specific instruction.

This instruction goes by a curious name: a magic packet. It is a special block of network data containing a repeating sequence of bytes followed by the MAC address, which is the unique and unchangeable identifier of the destination network card. When the network card captures this packet on the local network, it sends an electrical signal directly to the motherboard, commanding the power supply to turn the entire computer on. Before initiating any software configuration in Linux, it is essential to ensure that your hardware supports the technology and that preliminary adjustments are made in the motherboard.

Preparing BIOS and UEFI to accept remote signals

No Linux operating system configuration will work if your computer's motherboard ignores network signals while the equipment is powered off. Therefore, the first real step happens even before the system boots, by entering the BIOS or UEFI setup screen of your machine. Each motherboard manufacturer organizes menus differently, but you will generally find the option to wake the machine under power management tabs, advanced features, or integrated network settings.

Look for terms such as 'Wake on LAN', 'Power On by PCIe', 'PME Event WakeUp', or 'Resume on LAN' and change their state to 'Enabled'. On many modern motherboards equipped with integrated network controllers from Intel or Realtek, there may also be an option related to power-saving states on network connections, known as Energy Efficient Ethernet, which sometimes needs to be disabled to prevent the card from completely shutting down its listening circuit. Save the changes in the BIOS and restart your computer normally to boot into your favorite Linux operating system.

Checking and configuring ethtool on the network interface

Once the operating system is running, we need to verify whether the Linux kernel and the network card driver recognize the power management features correctly. For this, we use ethtool, which is a standard command-line utility to query and modify network card and driver parameters. In practice, it acts as a detailed control panel for your network adapter, letting you check connection speed, duplex mode, and, of course, support for wake-up magic packets.

Open your Linux terminal and find your network interface name using the ip link or ifconfig command. Let's assume your main interface is called eth0 or enp3s0. To check the current Wake-on-LAN state, run the command with administrative privileges. If you prefer to monitor network traffic to understand if packets are arriving properly, you can consult our practical guide on how to use tcpdump to capture network packets on Linux before proceeding with ethtool adjustments.

sudo ethtool enp3s0

The output on the screen will display a specific section called 'Wake-on'. If the letter 'd' appears next to it, it means the feature is disabled. To change it and allow the card to accept magic packets, use ethtool passing the 'g' parameter, which instructs the interface to enable WoL listening. If you want to apply an extra layer of security to your machine while tuning interfaces, it is worth checking the recommendations on how to configure UFW on Linux to secure your server against unwanted access.

sudo ethtool -s enp3s0 wol g

Making the configuration persistent across system reboots

The big detail that catches many users by surprise is that changes made directly via ethtool in the command line are temporary. This means that as soon as you restart or completely turn off the computer, the network card driver will revert to its factory default state, disabling the Wake-on-LAN feature. To ensure the command runs automatically every time the system boots, we need to create a persistent rule using systemd or NetworkManager startup scripts.

The most elegant and modern way in Linux is to create a custom systemd service that executes the ethtool command right after the network interface becomes active. To do this, create a service file with your favorite text editor in the system services directory, inserting the necessary instructions to trigger the ethtool command automatically during the operating system boot process.

[Unit]
Description=Enable Wake-on-LAN on network interface
After=network.target

[Service]
Type=oneshot
ExecStart=/usr/sbin/ethtool -s enp3s0 wol g

[Install]
WantedBy=multi-user.target

Save the file with the name wol.service in the /etc/systemd/system/ directory and enable it with the commands systemctl enable wol.service and systemctl start wol.service. This way, you ensure that the system is always prepared to receive the wake-up signal, even after power outages or scheduled maintenance that require full reboots of the server or workstation.

Sending the magic packet from another network device

Now that the target machine is properly configured in the BIOS, ethtool, and made persistent via systemd, it is time to test the functionality in practice. To send the magic packet, you will need another device connected to the same local network, which can be a laptop, a Raspberry Pi, another Linux server, or even an Android smartphone through dedicated apps. Sending requires only two crucial pieces of information: the MAC address of the target machine's network card and the broadcast IP address of your local network.

If you are using a Linux system on the sending computer, the most common utility for this task is the etherwake or wakeonlan package. Install the tool using your distribution's package manager and run the command providing the physical address of the machine you wish to turn on. In practice, this command will build the packet with the synchronization bytes and transmit it to all equipment on the local network via the broadcast address.

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

Replace AA:BB:CC:DD:EE:FF with the actual MAC address of your target computer's network card, and wlan0 with the network interface of the device sending the command. If the target machine turns on immediately after executing the command, congratulations: your configuration was successful from end to end, enabling fully remote power management. To explore these architectural concepts further in production, see our related technical analysis on How to test Schottky diodes on a circuit board with a multimeter.

Final thoughts on local networks and troubleshooting

Configuring Wake-on-LAN on Linux is an extremely useful process for system administrators and homelab enthusiasts who want to save electricity by keeping servers and workstations powered off when not in active use. However, it is worth noting that the traditional protocol was designed to operate strictly within the same local area network (LAN), as broadcast packets generally do not cross edge routers without advanced UDP packet forwarding configurations on port 7 or 9.

If the computer refuses to turn on after all steps, check whether the network card keeps its LEDs on or blinking faintly when the machine is shut down, which indicates standby power is being supplied by the motherboard. If the LEDs are off, the problem certainly lies in the BIOS configuration or power-saving restrictions imposed by the power supply. With patience and step-by-step validation, you eliminate bottlenecks and achieve a fully automated and efficient environment.