How to Configure Wake-on-LAN (WoL) in Ubuntu 22.04

Wake-on-LAN (WoL) is a networking standard that allows a computer to be turned on or awakened from sleep mode by a network message. This is incredibly useful for headless servers, media centers, or remote workstations running Ubuntu, as it allows you to power them on remotely without physical access to the power button.

Configuring Wake-on-LAN in Ubuntu 22.04 involves three stages: enabling the feature in your motherboard’s BIOS/UEFI, identifying your network interface, and configuring Ubuntu to preserve the WoL state during shutdown.

Step 1: Enable Wake-on-LAN in the BIOS/UEFI

Before the operating system can use Wake-on-LAN, the hardware must be configured to support it. The exact steps vary by motherboard manufacturer.

  1. Restart your computer and rapidly press the BIOS key (usually Delete, F2, or F12).
  2. Navigate to the Power Management, Advanced, or ACPI section.
  3. Look for a setting named Wake on LAN, Power On By PCI-E, or Resume by LAN and set it to Enabled.
  4. Save your changes and exit the BIOS.

Step 2: Identify Your Network Interface and MAC Address

Once booted into Ubuntu, open the terminal. You need to find the logical name of your ethernet interface and its physical MAC address.

ip a

Look for an interface that starts with en (such as enp3s0 or eth0). Note down this interface name. You also need to note the MAC address, which is listed next to link/ether (e.g., 00:1A:2B:3C:4D:5E). You will need this MAC address to send the magic packet later.

Step 3: Check and Enable WoL Support Using ethtool

Next, install ethtool, a utility used to query and control network driver and hardware settings.

sudo apt update
sudo apt install ethtool

Check if your network interface supports Wake-on-LAN by running (replace enp3s0 with your interface name):

sudo ethtool enp3s0 | grep Wake-on

You should see an output like this:

  • Supports Wake-on: pumbg
  • Wake-on: d

The letter g in “Supports Wake-on” means the hardware supports Magic Packets. The “Wake-on: d” means WoL is currently disabled. To enable it, run:

sudo ethtool -s enp3s0 wol g

Step 4: Make Wake-on-LAN Persistent After Reboot

The ethtool command enables WoL for the current session, but Ubuntu often resets this setting during shutdown. To make it persistent in Ubuntu 22.04, you must create a systemd service.

Create a new service file using the nano text editor:

sudo nano /etc/systemd/system/wol.service

Paste the following configuration (remember to replace enp3s0 with your actual interface name):

[Unit]
Description=Enable Wake On Lan

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

[Install]
WantedBy=basic.target

Save the file (Ctrl+O, Enter) and exit nano (Ctrl+X). Finally, enable the service so it runs automatically:

sudo systemctl daemon-reload
sudo systemctl enable wol.service
sudo systemctl start wol.service

Your Ubuntu machine is now permanently configured for Wake-on-LAN. You can turn it on from another device on the same network by sending a Magic Packet to its MAC address.

Get the best tech tips delivered straight to your inbox.

Join thousands of readers mastering Apple, Google, Microsoft, and Linux.