Is there an award for this?
This commit is contained in:
80
rss.xml
80
rss.xml
@@ -14,48 +14,44 @@
|
||||
<p>DATE: Thu 19 Dec 2024 18:35 By: konsthol@pm.me</p>
|
||||
</blockquote>
|
||||
<h1 id="the-magic-of-wake-on-lan">The magic of Wake-On-LAN</h1>
|
||||
<p>Years ago, some good friends of mine gifted me for my birthday, a
|
||||
Raspberry Pi 4 with 2GB of ram. It was and still is the most thoughful
|
||||
gift anyone has ever gotten for me. It aligns perfectly with my hobbies
|
||||
and I used it for a long time as a VPN server using WireGuard and I also
|
||||
played around with Pi-hole for a while as a network-wide ad blocker.</p>
|
||||
<p>Eventually I became more interested in cloud computing and started
|
||||
self hosting many services on a VPS that I rent through MVPS. It has 4GB
|
||||
of ram and has currently many of the services I use in a day-to-day
|
||||
basis like my Gitea server, Searx, NTFY and many others. While it was
|
||||
definetely doable for the Raspberry Pi to host these, the 2GB of ram
|
||||
would not allow for every service to be run at the same time. You see,
|
||||
my friends were lucky to even find one because it was in the middle of
|
||||
the chip shortage problems.</p>
|
||||
<p>One day as I was thinking about what kind of projects could I utilize
|
||||
a single Raspberry Pi for, it hit me. A simple Wake-On-LAN server. It
|
||||
requires almost no resources as it just needs to stay on and send out
|
||||
wol packages when I need it to. The Raspberry Pi is connected using
|
||||
Wi-Fi to the same network as my laptop. Usually if I wanted to wake my
|
||||
laptop up using Wake-On-LAN I would need to have it plugged with an
|
||||
ethernet cable with the router. However, the Raspberry Pi has an
|
||||
ethernet port and a cable has two ends. Which lead me to try to connect
|
||||
one end to the Pi and another one to the laptop. At first I begun with a
|
||||
simple shell script that used etherwake. A simple command-line tool that
|
||||
sends Wake-On-LAN Magic Packets. It worked like a charm. I had enabled
|
||||
Wake-On-LAN in my laptop’s BIOS, it was enabled on the operating system,
|
||||
which I checked using ethtool and it was super easy to remotely wake my
|
||||
laptop up using a Termux shortcut on my phone which used ssh to connect
|
||||
to the Raspberry Pi and from there execute the etherwake command.</p>
|
||||
<p>That setup was wonderful but I wanted to make it even better. It
|
||||
wasn’t actually a Wake-On-LAN server at this point. The only service
|
||||
that was running on the Pi was SSH and I just used a command to wake
|
||||
just my laptop up. So after some research I came across Flask. With
|
||||
Flask I managed to make an actual server that used routes,
|
||||
authentication, logging rate limits and everything needed to make it
|
||||
robust, secure and functional. The main reason I currently prefer my
|
||||
project over etherwake, even though etherwake is still a great tool that
|
||||
follows the Unix philosophy “Do one thing and do it well”, is because of
|
||||
it’s dynamic nature. I can configure a .env file with many device’s MAC
|
||||
addresses and have as many possible routes as the number of the devices.
|
||||
So for a laptop and a desktop I have LAPTOP_MAC=“itsmac” and
|
||||
DESKTOP_MAC=“itsmac” and can wake them up using http requests in the
|
||||
route /wol/laptop and /wol/desktop respectively.</p>
|
||||
<p>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.</p>
|
||||
<p>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.</p>
|
||||
<p>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.</p>
|
||||
<p>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.</p>
|
||||
<p>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.</p>
|
||||
<p>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.</p>
|
||||
<p>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.</p>
|
||||
<p><a
|
||||
href="/images/pic-selected-19-12-24_19-10-42.png">Mascot</a><br /></p>
|
||||
<p>I would suggest anyone to take a look at my project’s repo and if
|
||||
|
||||
Reference in New Issue
Block a user