Building a Wake-on-LAN Server with Raspberry Pi
Build time: 1-2 hours
Tools needed: None required
raspberry piwake on lannetworkingautomation
Wake-on-LAN lets you power on a sleeping PC remotely. A Pi relay lets you trigger this from outside your home network.
Prerequisites
On the target PC:
- Enable Wake-on-LAN in BIOS
- Enable in OS network adapter Power Management settings
- Note the MAC address (
ipconfig /allon Windows)
Install WOL Tool
sudo apt install wakeonlan -y
Send a Magic Packet
wakeonlan AA:BB:CC:DD:EE:FF
Remote Wake from Outside Your Network
SSH into your Pi via Tailscale (or WireGuard), then run the wakeonlan command. That's it — the Pi is on your LAN and can reach the target.
Simple Web UI with Flask
from flask import Flask
import subprocess
app = Flask(__name__)
TARGETS = {
"desktop": "AA:BB:CC:DD:EE:FF",
"nas": "11:22:33:44:55:66",
}
@app.route('/wake/<device>')
def wake(device):
mac = TARGETS.get(device)
if mac:
subprocess.run(['wakeonlan', mac])
return f"Waking {device}..."
return "Unknown device", 404
if __name__ == '__main__':
app.run(host='0.0.0.0', port=5000)
Access: http://raspberrypi.local:5000/wake/desktop
Scheduled Wake with Cron
# Wake desktop at 8am weekdays
0 8 * * 1-5 pi wakeonlan AA:BB:CC:DD:EE:FF