62 lines
2.8 KiB
Plaintext
62 lines
2.8 KiB
Plaintext
> DATE: Thu 19 Dec 2024 18:35 By: konsthol@pm.me
|
||
|
||
# The magic of Wake-On-LAN
|
||
|
||
Years ago, some good friends of mine gifted me a Raspberry Pi 4 with
|
||
2GB of RAM for my birthday. It’s hands down the most thoughtful
|
||
gift I’ve ever received, perfectly matching my hobbies. They were
|
||
lucky to even find one during the chip shortage! I initially used it
|
||
as a VPN server with WireGuard and played around with Pi-hole for
|
||
network-wide ad blocking.
|
||
|
||
Eventually, I got into cloud computing and started hosting multiple
|
||
services on a VPS I rent from MVPS. This VPS, with its 4GB of RAM,
|
||
currently runs several of my daily-use services like Gitea, Searx,
|
||
NTFY, and more. Although the Raspberry Pi could theoretically handle
|
||
these services, its 2GB of RAM limited simultaneous operations.
|
||
|
||
One day, it hit me: why not use the Raspberry Pi for a simpler
|
||
project like a Wake-On-LAN (WOL) server? It requires minimal
|
||
resources and just needs to stay on and send WOL packets. The
|
||
Raspberry Pi is connected via Wi-Fi to the same network as my laptop.
|
||
Normally, waking up my laptop with WOL would require an Ethernet
|
||
cable connection to the router, but I connected one end to the Pi and
|
||
the other to the laptop.
|
||
|
||
I started with a simple shell script using etherwake, a command-line
|
||
tool to send WOL packets. After enabling WOL in my laptop’s BIOS
|
||
and confirming it on the OS using ethtool, I could easily wake my
|
||
laptop remotely using a Termux shortcut on my phone, which SSHed into
|
||
the Raspberry Pi to execute the etherwake command.
|
||
|
||
Though this setup worked perfectly fine, I wanted to make it even
|
||
better. Initially, the Raspberry Pi only ran SSH and executed a
|
||
command to wake my laptop. So it wasn't really a WOL server. After
|
||
some research, I found Flask and created an actual WOL server. This
|
||
server had routes, authentication, logging, rate limits, and more to
|
||
ensure robustness and security.
|
||
|
||
What makes my Flask-based server so cool is its dynamic nature. I can
|
||
configure a .env file with multiple device MAC addresses, allowing
|
||
numerous routes for different devices. For instance, I have
|
||
LAPTOP_MAC="itsmac" and DESKTOP_MAC="itsmac", enabling me to wake
|
||
them via HTTP requests at /wol/laptop and /wol/desktop, respectively.
|
||
|
||
One open-source application that fits my use case is HTTP Shortcuts
|
||
from F-Droid. After configuring a specific route, I can turn it into
|
||
a widget on my home screen. This way, I can wake my laptop up with
|
||
just a tap! Plus, I use dynamic DNS, so my Pi is accessible from
|
||
anywhere.
|
||
|
||
/images/pic-selected-19-12-24_19-10-42.png The project's mascot
|
||
|
||
I would suggest anyone to take a look at my project's repo and if
|
||
they find that it fits their needs, use the setupSingleBinary.sh
|
||
script to grab the latest executable. The repo is over at
|
||
|
||
WOL-Ly
|
||
https://git.konsthol.eu/konsthol/WOL-Ly
|
||
|
||
|
||
|