Restoring Remote Wake-on-LAN on Headless Linux Servers Without BIOS Displays

Enable remote Wake-on-LAN on a headless Linux server without installing a graphics card. Diagnose power registers, configure ethtool, and deploy a persistent systemd service for reliable remote boots.

Illustration for: Restoring Remote Wake-on-LAN on Headless Linux Servers Without BIOS Displays
AI-generated illustration
Difficulty: IntermediateTime: about 1 hourTested on my setup

Tested on: Tested on a headless Intel Xeon E5 v4 server with an Intel C610/X99 chipset motherboard running Linux with AMI BIOS 5.11.

Before you start

Running a headless Linux server without integrated graphics is ideal for power efficiency and space, but it complicates power management after an outage. When a server lacks a video output or integrated GPU, opening the chassis, installing a temporary display adapter, and navigating unfamiliar BIOS menus just to adjust AC recovery settings is inconvenient and invasive.

In this guide you will configure Wake-on-LAN so you can switch your headless server on remotely, learn why messing with low-level chipset registers does not work, and make it all survive reboots with a systemd service.

What you need

  • Headless Linux server with a wired Ethernet connection
  • Root or sudo privileges on your server
  • pciutils (for setpci) and ethtool packages installed
  • util-linux package (for rtcwake fallback testing)
  • A secondary computer or device on the same local network to send magic packets
  • Target server Ethernet interface MAC address

Step 1 · Identify Your Network Interface and Hardware MAC

Before modifying power or network settings, determine the exact name and MAC address of your wired Ethernet interface.

Run ip link show to list your network interfaces. Identify the wired adapter (commonly named eth0, enp9s0, or similar) and record its 6-byte hardware MAC address. You will need this address whenever sending a magic packet.

List network interfaces and MAC addresses
ip link show

Step 2 · Optional: Peek at the Power Recovery Register (Intel Chipsets Only)

On my board (an Intel C610/X99 chipset), what happens after a power outage is controlled by a register of the LPC bridge. I only READ it, to understand why the server did not come back on its own. The command below is read-only. Skip this step if your board is not an Intel chipset, or if you are not curious: it is not needed for the rest of the guide.

On my machine the value read was 0x18c9. Always write down what you read before changing anything else.

Read current power management register
sudo setpci -s 00:1f.0 a4.w

Step 3 · What I Tried (and Why You Should Not Repeat It)

It is tempting to turn on "power on after AC loss" by writing that register from Linux. I tried it on my board, and it did not work: the firmware rewrote the value during shutdown or the next boot, so the change never lasted. Another bit in the same register turned out to be locked by the firmware.

I am NOT giving you the write command on purpose. Writing raw PCI configuration registers is specific to one chipset, it can hang the machine, and on another board it can change something completely different. Because raw register tricks do not survive power cycles, Wake-on-LAN (the next steps) is the far more reliable way to power the server on remotely.

Step 4 · Enable Magic Packet Wake-on-LAN via Ethtool

Next, examine your network card's hardware capabilities using ethtool. Replace YOUR_INTERFACE with your actual network device name (for example, eth0 or enp9s0).

Look for Supports Wake-on:. If it lists g, your hardware supports Magic Packet wake-up. Check the current status in Wake-on:. In most distributions, it defaults to d (disabled).

Enable Magic Packet reception by setting wol g.

Check and enable Wake-on-LAN on your interface
# Check current Wake-on-LAN status
sudo ethtool YOUR_INTERFACE | grep Wake

# Enable Wake-on-LAN for magic packets
sudo ethtool -s YOUR_INTERFACE wol g

Step 5 · Execute a Safe Controlled Shutdown with an RTC Alarm Fallback

Testing remote wake commands on a headless server carries the risk of leaving the machine powered off if the network packet fails. To safeguard access, schedule an RTC wake alarm using rtcwake before shutting down.

Use systemd-run to schedule a fallback wake timer for 240 seconds (4 minutes) into the future. Once the server powers down into S5, keep the power cord plugged in so the motherboard continues receiving 5V standby power.

Schedule fallback shutdown and RTC wake alarm
sudo systemd-run --on-active=45 /usr/sbin/rtcwake -m off -s 240

Step 6 · Send the Magic Packet from a Client Machine

Approximately 60 seconds after the headless server has completely powered down, send a magic packet from a secondary workstation on the same local network.

You can send the packet from another Linux host using wakeonlan, or from a Windows workstation using a quick PowerShell command. Send the packet to your server's MAC address over UDP port 9 using the subnet broadcast address.

In testing, the magic packet woke the server minutes before the RTC timer expired, proving that Wake-on-LAN functions even when chipset register bit 3 (PME_B0_S5_DIS) remains set to 1.

Send magic packet via Linux CLI
# Using the wakeonlan utility
wakeonlan -i 192.168.1.255 YOUR_SERVER_MAC
Send magic packet via PowerShell
$mac = [Net.NetworkInformation.PhysicalAddress]::Parse("YOUR_SERVER_MAC".Replace(":", ""))
$packet = [byte[]](,0xFF * 6) + ($mac.GetAddressBytes() * 16)
$client = New-Object System.Net.Sockets.UdpClient
$client.Connect([System.Net.IPAddress]::Broadcast, 9)
$client.Send($packet, $packet.Length)
$client.Close()

Step 7 · Create a Persistent Systemd Wake-on-LAN Service

When you log back into the server after waking it up, running ethtool YOUR_INTERFACE | grep Wake will reveal that Wake-on has reverted back to d (disabled).

To make Wake-on-LAN persistent across all boots and shutdowns, create a dedicated systemd oneshot service that executes ethtool -s YOUR_INTERFACE wol g during startup and before system shutdown.

Create /etc/systemd/system/server-wol.service
[Unit]
Description=Persistent Wake-on-LAN Configuration
After=network.target

[Service]
Type=oneshot
RemainAfterExit=yes
ExecStart=/usr/sbin/ethtool -s YOUR_INTERFACE wol g
ExecStop=/usr/sbin/ethtool -s YOUR_INTERFACE wol g

[Install]
WantedBy=multi-user.target
Enable and start the systemd service
sudo systemctl daemon-reload
sudo systemctl enable --now server-wol.service
sudo systemctl status server-wol.service

Step 8 · Integrate Power Outage Recovery with UPS and Triggers

In headless environments backed by an uninterruptible power supply (UPS), standard shutdown scripts often send a killpower command (shutdown.return) to cycle power.

However, if your motherboard does not automatically boot when AC power is restored, cutting UPS power leaves the server off. Instead, configure your UPS daemon to gracefully shut down the server into S5 without cutting the UPS output power. The network adapter will remain powered by standby 5VSB.

An external lightweight device (such as a single-board computer powered from mains electricity outside the UPS) can then automatically broadcast the magic packet once utility power returns.

Check Wake-on-LAN status after service activation
ethtool YOUR_INTERFACE | grep Wake

Troubleshooting

Network interface reverts to 'Wake-on: d' after rebooting.

Verify that your systemd unit is enabled and running. Run sudo systemctl status server-wol.service and confirm the path to ethtool is valid. If needed, check journal logs with journalctl -u server-wol.service.

Server fails to power on when receiving the magic packet.

Ensure the server remains connected to AC power so the power supply can provide 5VSB standby current to the motherboard. Check that the client is broadcasting to the correct local subnet (e.g. 255.255.255.255 or your subnet broadcast address) and that the target MAC address has no typos.

PCI register 0xA4 reverts to 0x18c9 after shutdown or boot.

Motherboard BIOS firmware and SMI routines frequently overwrite power management registers during POST. Do not rely on setpci for persistence; use the automated ethtool systemd service to keep Wake-on-LAN armed instead.

The rtcwake command returns 'command not found'.

rtcwake is typically located in /usr/sbin/rtcwake which is restricted to administrative paths. Execute it using full path notation or through sudo /usr/sbin/rtcwake.

Server clock resets or the system performs a double reboot upon cold start.

A depleted CR2032 CMOS battery causes the motherboard to lose RTC time and repeat memory training cycles whenever mains power is interrupted. Replace the CR2032 coin cell on the motherboard.

What I learned

  • Low-level chipset registers (such as GEN_PMCON_3) cannot be reliably held across boots using setpci alone, as motherboard firmware or SMI routines overwrite them during POST or S5 transitions.
  • Theoretical register interpretations do not always match empirical behavior: despite register bit 3 (PME_B0_S5_DIS) being locked to 1, the network card successfully triggered system wake-up from S5 upon receiving a magic packet.
  • Ethtool Wake-on-LAN configuration is volatile in Linux and must be explicitly re-armed via a systemd unit or network configuration upon every boot.
  • Using rtcwake as a timed safety net allows you to test remote power states on headless machines without risking permanent lockout if the wake packet fails.

Next steps

  • Deploy an automated wake script on a secondary network device (such as a Raspberry Pi plugged into wall power) to broadcast magic packets when utility power returns.
  • Explore native network configuration directives, such as WakeOnLan=magic in systemd-networkd, as an alternative to a standalone systemd service.
  • Test Wake-on-LAN behavior after a simulated complete power disconnect (G3 state) to verify if your specific network card retains its armed state when standby power drops.

Get the code

Systemd unit definitions, configuration templates, and magic packet scripts for restoring remote Wake-on-LAN on headless Linux servers.

View the code on GitHub →

Files in the repository (6)

README.md

README.md
# Headless Server Wake-on-LAN Power Recovery

This repository provides configuration files and helper scripts to enable persistent Wake-on-LAN (WoL) on headless Linux servers without requiring a physical monitor or BIOS changes.

## Overview

Many headless servers lack integrated graphics, making it difficult to adjust BIOS power management settings such as AC power loss recovery. Furthermore, attempting to modify LPC chipset registers (such as `GEN_PMCON_3`) using `setpci` often fails because the motherboard BIOS rewrites these registers during POST or shutdown.

This project provides:
- A systemd oneshot service to persistently arm your Ethernet interface for Magic Packet reception (`ethtool -s <iface> wol g`).
- A safe testing script combining `rtcwake` fallback alarms with controlled shutdowns.
- Cross-platform wake scripts (Bash and PowerShell) to remotely power on your server.

## Requirements

- Headless Linux server with root or sudo access.
- Wired Ethernet connection supporting Magic Packet Wake-on-LAN.
- Installed packages on the server: `ethtool`, `pciutils`, `util-linux`.
- A client machine (Linux, macOS, or Windows) on the same local subnet to send magic packets.

## Installation

1. Copy the systemd service template to your system directory:
   ```bash
   sudo cp systemd/server-wol.service /etc/systemd/system/server-wol.service
   ```

2. Edit `/etc/systemd/system/server-wol.service` and replace `YOUR_INTERFACE` with your actual network device name (e.g. `eth0` or `enp9s0`):
   ```bash
   ip link show
   sudo nano /etc/systemd/system/server-wol.service
   ```

3. Reload systemd and enable the service:
   ```bash
   sudo systemctl daemon-reload
   sudo systemctl enable --now server-wol.service
   ```

4. Verify that Wake-on-LAN is armed:
   ```bash
   ethtool YOUR_INTERFACE | grep Wake
   ```
   The output should show `Wake-on: g`.

## Testing Wake-on-LAN Safely

To test remote wake-up without getting locked out of your server if the magic packet fails, run the RTC fallback test script:

```bash
sudo ./scripts/test-rtcwake-fallback.sh
```

This arms an RTC wake alarm 4 minutes into the future and shuts the server down. Send a magic packet from your client device using `scripts/send-wol.sh` or `scripts/send-wol.ps1` within 2 minutes. If Wake-on-LAN succeeds, your server boots immediately. If it fails, the RTC alarm powers the server back on automatically.

systemd/server-wol.service

systemd/server-wol.service
[Unit]
Description=Persistent Wake-on-LAN Configuration
After=network.target

[Service]
Type=oneshot
RemainAfterExit=yes
ExecStart=/usr/sbin/ethtool -s YOUR_INTERFACE wol g
ExecStop=/usr/sbin/ethtool -s YOUR_INTERFACE wol g

[Install]
WantedBy=multi-user.target

config/wol.env.example

config/wol.env.example
# Wake-on-LAN Configuration Template
# Copy this file to wol.env and update with your network parameters.

TARGET_MAC="00:11:22:33:44:55"
BROADCAST_IP="192.168.1.255"
PORT="9"
INTERFACE="eth0"

scripts/send-wol.sh

scripts/send-wol.sh
#!/usr/bin/env bash
# Send a Wake-on-LAN magic packet using UDP broadcast

set -euo pipefail

TARGET_MAC="${1:-}"
BROADCAST_IP="${2:-255.255.255.255}"
PORT="${3:-9}"

if [[ -z "$TARGET_MAC" ]]; then
    echo "Usage: $0 <TARGET_MAC> [BROADCAST_IP] [PORT]" >&2
    echo "Example: $0 00:11:22:33:44:55 192.168.1.255 9" >&2
    exit 1
fi

# Check if wakeonlan is installed
if command -v wakeonlan >/dev/null 2>&1; then
    wakeonlan -i "$BROADCAST_IP" -p "$PORT" "$TARGET_MAC"
    exit 0
fi

# Fallback using Python 3
python3 -c '
import socket, sys

mac_str = sys.argv[1].replace(":", "").replace("-", "")
if len(mac_str) != 12:
    raise ValueError("Invalid MAC address length")

broadcast = sys.argv[2]
port = int(sys.argv[3])

mac_bytes = bytes.fromhex(mac_str)
payload = b"\xff" * 6 + mac_bytes * 16

with socket.socket(socket.AF_INET, socket.SOCK_DGRAM) as s:
    s.setsockopt(socket.SOL_SOCKET, socket.SO_BROADCAST, 1)
    s.sendto(payload, (broadcast, port))
print(f"Magic packet sent to {sys.argv[1]} via {broadcast}:{port}")
' "$TARGET_MAC" "$BROADCAST_IP" "$PORT"

scripts/send-wol.ps1

scripts/send-wol.ps1
<#
.SYNOPSIS
    Sends a Wake-on-LAN magic packet over UDP broadcast.
.EXAMPLE
    .\send-wol.ps1 -MacAddress "00:11:22:33:44:55" -BroadcastIp "192.168.1.255"
#>
[CmdletBinding()]
param(
    [Parameter(Mandatory = $true)]
    [string]$MacAddress,

    [Parameter(Mandatory = $false)]
    [string]$BroadcastIp = "255.255.255.255",

    [Parameter(Mandatory = $false)]
    [int]$Port = 9
)

$cleanMac = $MacAddress.Replace(":", "").Replace("-", "")
if ($cleanMac.Length -ne 12) {
    Write-Error "Invalid MAC address format: $MacAddress"
    exit 1
}

$mac = [Net.NetworkInformation.PhysicalAddress]::Parse($cleanMac)
$targetBytes = $mac.GetAddressBytes()
$packet = [byte[]](,0xFF * 6) + ($targetBytes * 16)

$client = New-Object System.Net.Sockets.UdpClient
try {
    $client.Connect([System.Net.IPAddress]::Parse($BroadcastIp), $Port)
    $client.Send($packet, $packet.Length) | Out-Null
    Write-Host "Magic packet successfully sent to $MacAddress via $BroadcastIp`:$Port"
} finally {
    $client.Close()
}

scripts/test-rtcwake-fallback.sh

scripts/test-rtcwake-fallback.sh
#!/usr/bin/env bash
# Execute a controlled shutdown with an RTC wake alarm fallback

set -euo pipefail

DELAY_SECONDS=45
WAKE_TIMEOUT_SECONDS=240

echo "=== Fallback RTC Wake-on-LAN Test ==="
echo "Scheduling system shutdown in ${DELAY_SECONDS} seconds."
echo "RTC fallback alarm will trigger in ${WAKE_TIMEOUT_SECONDS} seconds."
echo "Ensure your server remains connected to AC power."

sudo systemd-run --on-active="${DELAY_SECONDS}" /usr/sbin/rtcwake -m off -s "${WAKE_TIMEOUT_SECONDS}"

echo "Scheduled successfully. Monitor server power-off and transmit the magic packet within ~60 seconds."