Did you know that you can remotely wake up a sleeping PC by sending a “magic packet” to your network adapter? I find this immensely useful for my PC that sits with my remote imaging setup. With a normal PC, you have two options when you want to walk away from your PC and have it “shut down”: Power off or sleep.
Powering off removes everything from memory, flushes the disk caches and removes any traces of your running programs. Sleeping saves the memory state, the desktop state so you can restore at that point in time.
At the end of my session I put my PC into sleep mode which puts the CPU into hibernation mode, dumps the memory state of the applications and basically waits for someone to come back again – which will restore your desktop session to precisely where you left off. In terms of power usage for modern PCs, it is barely traceable in sleep mode compared to powered off mode so it has numerous advantages to do this: namely it is much faster in terms of getting going again and starting my astrophotography runs for the evening!
Now, normally, when a PC is in sleep mode, someone has to tap a key or a mouse button click to get it going. On a remote PC where you don’t have a keyboard or mouse attached – your desktop is over software-based RDP (Remote Desktop Protocol) session – so how do you wake it up? The answer is: Wake-On-Lan (or WOL).
WOL sends a magic packet to the network adapter that kicks your PC back into life again. To do it you need the tool that sends the magic packet.
What You Need
If you’ve not followed my tutorial on setting up a Windows 10 PC for remote astrophotography work, go visit it now. The idea of a remote PC is that it gives you that same desktop session from another machine, that acts as if you’re directly connected to that PC. Very handy on cold dark nights when you want to be in the warmth rather than stood outside with your equipment!
- Remote desktop PC
- Wake-On-Lan tool
- LAN/NIC (not WiFi) Adapter
How To Do It
On the REMOTE PC
The first thing to do is to ensure your network adaptor (NIC) supports Wake-On-Lan.
It begins with making a change in the BIOS. The BIOS is the first set of information you see when you first turn on your PC. Most users tend to not have to go into this, as you can (temporarily) prevent your PC from booting if you choose the wrong setting. Don’t worry – you go back into the BIOS and just undo your change if that happened.
Have a look at this article for the BIOS section first.
The rest of this howto specifically calls out changes once our Windows PC has booted so we can carry on from there:
- Head over to Device Manager and expand your list of Network Adapters
- Right click on the network adapter you are using and click Properties
- If your adapter has a Power Management tab click on this and put a check in the following options. If not skip to step 4:
- Allow this device to wake the computer
- Only allow a magic packet to wake computer
- Allow this device to wake the computer
- Under the Advanced tab, scroll down the list of options to find “Wake on Magic Packet” and make sure it is Enabled.
- Click OK
We need to get the MAC address of this network card, also known as the Physical Address. This is universally unique address belonging to that card and differs from the network address (IP address) that your network card gets assigned on your network. To do this, it is easiest to do this from the command line:
- In the Windows search bar type: cmd
(and then press Enter)
Under older Windows, Start… Run and type: cmd and then press Enter
- Now type: ipconfig /all
- This will present a ton of useful information about your network connections – one being Physical Address. Make sure you’re viewing the one that has an IPv4 Address assigned, because that is going to be the one that is used on your network, if you have multiple installed. Copy down the 6 pairs of characters and numbers, e.g. 90-61-AE-C8-C3-B7 as will be using this address when we send over the magic packet.
More information can be found here: https://www.laptopmag.com/articles/find-mac-address-windows-10
On the CLIENT PC
Now that the remote PC is configured, we need to install a tool on our client PC (the one we use the RDP client on to connect to the remote PC).
# yum install wakeonlan # Red Hat based Linux PCs # apt install wakeonlan # Ubuntu/Debian/Pi based PCs
- Under Windows, install a free tool called Wake On Lan from here: https://sourceforge.net/projects/aquilawol/
- Follow these instructions to configure Wake On Lan: https://www.groovypost.com/howto/enable-wake-on-lan-windows-10/
Now with our tools configured, we can use them to wake up our remote PC. With our remote PC set to sleep, we can now wake it up – either using Wake On Lan as described above in step 2.
For Unix/Linux based PCs we do the following. From the MAC address we collected above, we simply change the – characters into the more familiar : notation and we issue the following command.
$ wakeonlan 90:61:AE:C8:C3:87
This will say it is sending a magic packet using 255.255.255.255 (general broadcast) to that address to wake up.
Now you can simply RDP to your remote PC.
What We Did
Sending your remote imaging PC to sleep saves energy and makes startup times much quicker. It restores your desktop session as it was when you clicked on Sleep rather than having to load up your tools from a fresh boot. However, to wake up a remote PC that is sleeping, where there isn’t a keyboard or mouse attached – which is very common for remote imaging PCs (also known as headless PCs), then you need to be more creative. That is where Wake-On-Lan (WOL) comes in. You’re basically prodding the network card to tell it to wake up. And to do that you need a tool to send that special packet that does the waking up. So once you’ve configured your remote PC to act upon this special packet, and you’ve installed the right tools on your client PC, you can remotely wake up your PC so you can continue your remote PC session.