Remote Power Button for Your PC

Wake on WAN

Himura Kazuto
Apr 3, 2018 · 7 min read

I love having all my computers off when I don’t need them. This saves plenty of power, makes me reboot regularly (good for Windows), and probably even prolongs my hardware lifetime. But you never know when you may need to connect to your home or office PC via RDP or TeamViewer to complete some urgent and critical task. If that PC is off, you can’t log into it, right? In fact, you can turn it on remotely from the Internet. If you haven’t heard about WoL or tried to make it work without luck, read on, let’s make it work together!

Meet Wake on LAN

If your router’s configuration is flexible enough, you can even catch that packet from the Internet and broadcast it as required.

The protocol is radically simple. All you need to do is to send a so-called Magic Packet to your network’s broadcast IP (e.g., or even and port 9. The magic packet is a UDP datagram that should begin with six 0xFF bytes, then contain the MAC-address of your target PC repeated 16 times. That’s all. 144 bytes with magic power. If your LAN-card receives a magic packet with its MAC while waiting for it, the LAN-card tries to turn the computer on via ACPI. And yes, it waits for the magic packet when the entire system is completely turned off (just don’t remove the plug from the socket).

The WoL protocol is simple in theory, but in practice, it turns up to be a challenging thing to set up. Here are some possible issues when we are trying to deal with magic packets from the Internet (the most convenient case):

  1. You can be behind your provider’s NAT and unable to accept incoming connections.
  2. Your provider can block incoming connections on port 9 (or even all ports, for safety).
  3. Your router can be not capable of forwarding a port to a broadcast address.
  4. Your LAN-card can be off. It happens when something is not configured, or in case of a failure.
  5. Your ACPI can be configured to ignore the PCI wake requests.

The issues in first three items are not solved smoothly: you need to change either your provider or your router or both. So, there’s no way to turn on your PC from the Internet if your provider and/or router are junk, right? In fact, you can use an always-on single-board PC like Raspberry Pi which listens for a command sent from the Internet and broadcasts a magic packet. That’s what we are going to set up in this article! But first, I’ll try to summarize everything you should do with your Windows PC to make it accept WoL packets.

Configure Wake on LAN

1. Configure LAN-card

  • Proceed to Change Adapter Options.
  • Right-click your primary Ethernet adapter and choose Properties.
  • Click Configure to open the device properties.
  • Proceed to the Advanced tab.
  • Set Wake Up Capabilities to Magic Packet or Magic Packet & Pattern Match.
  • Set Shutdown Wake Up to Enabled.

Uncheck everything on Power Management tab (you can try to check everything, but this configuration may not work for some reason):

The MAC-address of this adapter will also be required in the future, you can find it by double-clicking your primary Ethernet adapter and choosing Details. The Physical Address is what you need there, save this string on your smartphone (or paper, if you still use it).

2. Enable Shutdown

  • Right-click the Start button and open Power Options.
  • Open the old interface using the Additional Power Options on the right side.
  • Click the Choose what the power buttons do link on the left side.
  • Unlock the checkboxes using the Change settings that are currently unavailable link.
  • Uncheck the Turn on fast startup option.

3. Configure ACPI

In SETUP, enable everything related to Wake on LAN and also allow PCI devices to power the PC on.


If you were able to wake your PC using your smartphone connected to your Wi-Fi, it’s time to configure Wake on LAN over the Internet.

Wake on Cloud

  • Getting a single-board PC (Omega2, C.H.I.P., Raspberry Pi, etc.) or taking the one you already have.
  • Configuring a Cloud4RPi service, which allows you to send a Power On command from anywhere.

Single-board PC

  • Follow the Getting Started sections in the Cloud4RPi documentation to get the sample code working. If you face any problems, feel free to contact the developers, this team is very responsive.
  • Install the wakeonlan Python package using the pip install wakeonlan command
  • Implement the function that broadcasts a magic packet and the one that pings your PC (to ensure that the WoL request worked). I did it in a separate file
  • Change the variables section in the sample file and add two new variables.

The full code is presented in my cloud4rpi-wol repository, feel free to clone it and use my code.

Note that I use a NetBIOS name instead of an IP address to ping my PC. This will work if you install the libnss-winbind package and add the wins option to the hosts line in the /etc/nsswitch.conf file:

sudo apt install libnss-winbind
sed "s/^hosts:.*/& wins/" /etc/nsswitch.conf | sudo tee /etc/nsswitch.conf


Unfortunately, Cloud4RPi has no Big Red Button widget, although the Switch widget does the great job in sending True into the wake_pc function. The function always makes it switch off right after switching on, but it doesn’t matter.

You can now turn on your PC from anywhere. Isn’t that great?

Note that the Wi-Fi is off, which means my smartphone is not in the same local network with my PC


sudo ~/cloud4rpi-wol/

Now it starts with the system and sends logs to journald. You can control the service as follows:

sudo service cloud4rpi start|stop|restart|status



Cloud control panel for your IoT projects

Himura Kazuto

Written by



Cloud control panel for your IoT projects

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade