---
obj: concept
wiki: https://en.wikipedia.org/wiki/Wake-on-LAN
arch-wiki: https://wiki.archlinux.org/title/Wake-on-LAN
---

# Wake on LAN
Wake-on-LAN (WoL or WOL) is an Ethernet or Token Ring computer networking standard that allows a computer to be turned on or awakened from sleep mode by a network message.

## Magic Packet
The magic packet is a frame that is most often sent as a broadcast and that contains anywhere within its payload 6 bytes of all 255 (FF FF FF FF FF FF in hexadecimal), followed by sixteen repetitions of the target computer's 48-bit MAC address, for a total of 102 bytes.

Since the magic packet is only scanned for the string above, and not actually parsed by a full protocol stack, it could be sent as payload of any network- and transport-layer protocol, although it is typically sent with [UDP](UDP.md).

### Creating & sending magic packet
There exists various software for creating magic packets. This is an example in [Python](../dev/programming/languages/Python.md)
```python
import socket

def wol(lunaMacAddress: bytes):
    s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
    s.setsockopt(socket.SOL_SOCKET, socket.SO_BROADCAST, 1)

    magic = b'\xff' * 6 + lunaMacAddress * 16
    s.sendto(magic, ('<broadcast>', 7))

if __name__ == '__main__':
    # pass to wol the mac address of the Ethernet port of the appliance to wakeup
    wol(b'\x00\x15\xB2\xAA\x5B\x00')
```

## Setup
WOL must first be enabled in the UEFI / BIOS of the computer.

### Setup on [Linux](../linux/Linux.md)
To check and enable WOL on [Linux](../linux/Linux.md) the tool `ethtool` is used.

#### Check if WoL is enabled:
```
$ ethtool <interface> | grep Wake-on
Supports Wake-on: pumbag
Wake-on: d
```

If `Supports Wake-on:` only shows `d` WOL is not supported on that interface.

#### Enable WoL with this command:
```
ethtool -s <interface> wol g
```

To enable WOL persistently one can use [Systemd](../linux/systemd/Systemd.md):

File: `/etc/systemd/system/wol@.service`
```toml
[Unit]
Description=Wake-on-LAN for %i
Requires=network.target
After=network.target

[Service]
ExecStart=/usr/bin/ethtool -s %i wol g
Type=oneshot

[Install]
WantedBy=multi-user.target
```

Then activate this new service by starting `wol@<interface>.service`.
