Ok, I created a system to remotely turn on my Ubuntu desktop.
The main story is that I have an Ubuntu desktop in my hall room, but when I’m at home, I don’t have access to it. Back then, I only had a basic idea of what SSH was and almost no understanding of networking concepts.
I used GPT and managed to connect to my Ubuntu machine using my laptop while I was in my hall — using the private IP only — and I was very happy. Little did I know that it wouldn’t be accessible from home, since I wouldn’t be under the same network.
After the vacation, I came back and tried to debug why I couldn’t connect from home even though I could connect while in my hall. I got to know that I needed a public IP. Public IPs were expensive… then I learned about Tailscale.
But the problem was that for Tailscale, I needed to keep my Ubuntu machine turned on all the time.
At the same time, there is periodic load-shedding in my hall every day at 6 AM and 12 AM. So the PC wouldn’t stay on even if I wanted it to. And honestly, I didn’t want to keep it on for the whole vacation either. I love my PC and didn’t want it to “sweat” for no reason (even though I know modern PCs are fine running continuously).
So I needed one thing: a way to turn on my PC remotely. After that, I could use Tailscale to SSH into it from my laptop.
And one more thing — I didn’t want to spend a penny. (Though I almost did — I bought a $2 domain, but at least I can use it for other things.)
After digging a bit, I learned about Wake-on-LAN (WoL), where the motherboard’s network interface card (NIC) listens for a “magic packet” and turns on the PC when it receives one.
So I needed a device that:
- I could reach from outside my hall through the internet
- Would stay powered on all the time
- Could send the magic packet to my desktop
I had an ESP32 lying around from my last semester’s microcontroller project.
Well… that should work.
But after trying, I figured out I couldn’t directly reach the ESP32 from the internet. And I couldn’t install Tailscale or similar software on the ESP32 (it doesn’t run a full OS). An easy option would have been a Raspberry Pi — but since my motto was “don’t spend a penny,” I looked for alternatives.
Now I know that an MQTT broker would have been enough to solve the problem — but I didn’t know that back then. So bear with me 😄
I realized something important: even though I couldn’t reach the ESP32 from the internet directly, the ESP32 itself could reach the internet as a client.
That changed everything.
Instead of making ESP32 a server, I made it a client. The ESP would connect to some external server and listen for commands.
Now the problem was: I needed some always-available server — something like AWS or GCP — just to turn on my PC once or twice a day.
After searching, I discovered Cloudflare Tunnel, which exposes a local machine to the internet.
Boom.
My laptop (or later the desktop) would act as the server, exposed via Cloudflare Tunnel, and the ESP32 would periodically check that endpoint. Whenever the ESP received a “wake” request from the server, it would send the magic packet to the PC — and it would turn on.
That solved the remote boot problem.
But as I mentioned earlier, there’s periodic load-shedding in my hall.
Here’s the tricky part:
If the PC loses power completely, the NIC may not remain powered in standby mode. That means it cannot listen for the magic packet until the system has booted at least once after power is restored.
So I enabled “automatic power on after AC power loss” in the BIOS.
Now the PC would boot automatically after a power cut.
But that created a new issue:
If the PC was intentionally shut down before the power cut, it would still boot when power came back. I would then need to manually SSH into it and shut it down again.
And I wanted to automate that too.
Since the ESP32 doesn’t run a full OS, I couldn’t easily SSH into Ubuntu from it (or at least I couldn’t at that time).
So I did something clever:
I wrote a FastAPI script on the Ubuntu desktop that:
- Runs automatically at startup (via systemd)
- Listens for shutdown requests
Now I added logic to the ESP32:
- If the last command sent was “shutdown”
- And the PC boots after a power cut
- The ESP detects that state and sends a shutdown request to the FastAPI endpoint
The PC then shuts itself down automatically.
And that’s how the loop closes.
I surely learned more networking than my university assignments and surely enjoyed more than memorizing Wireshark commands.
Here is the code if you want a look and is by no means industry standard .
https://github.com/aorko01/RemoteWake
Top comments (0)