Note to self.
Put crudely, a VPN connection makes it seem like remote computer(s) are on your LAN. Generally, the devices you can see on the same VPN connection will have IP addresses of the form:
192.168.XXX.YYY
where XXX is the same for all of them and YYY is specific to each computer. Once you have opened your VPN gateway, you can use SSH or RDP (or whatever) to interact with the machines.
Now, because you can address each machine with an IP4 address, you can also wake them up over ‘LAN’.
Wake on LAN is a protocol that most modern Ethernet cards support. Let’s say you have a desktop computer at your office, and you want to run a remote session on it from home. But the remote computer is asleep (to save power, say). You can see it is not responding (insert your own XXX and YYY):
c:\> ping 192.168.XXX.YYY Pinging 192.168.XXX.YYY with 32 bytes of data: Request timed out. Request timed out. Request timed out. Request timed out.
So you cannot log in. But maybe, if you have the requisite information, you can wake it up. One tool for use on Windows is wolcmd (https://www.depicus.com/wake-on-lan/wake-on-lan-cmd).
To use it, you need the MAC address of the computer, so you might have to plan this in advance.
The network properties of the computer that you want to be able to wake up (if waking Windows) will somewhere have a field called something like:
Physical address (MAC): 21-21-22-23-24-25
So when you have access to the computer that you want to be able to wake up, go into settings and search ‘network’ and choose ‘View your network properties’ and note the MAC address, and maybe the IP and computer name as well (useful for logging in remotely). On Linux, the ip (or older ifconfig) command should be your friend. If on Windows, you might also want to go into Device Manager, find your network adapter and check its power properties. You’ll need ‘Allow this device to wake the computer’ turned on — that allows the network card to wake the computer. You’ll probably also want ‘Only allow a magic packet to wake the computer’ as well, just to make sure it only wakes up when you want it to. These are often on by default, but it’s work checking while you have access to the computer of interest. For Linux users, ethtool is your friend.
Then, if you are on a computer inside the same LAN/VPN as the computer you want to wake, you can run wolcmd from the command line thus, with the MAC address as the first field (assuming wolcmd is in your PATH):
c:\> wolcmd 212122232425 255.255.255.255 255.255.255.255 4343
and then check:
c:\> ping 192.168.XXX.YYY Pinging 192.168.XXX.YYY with 32 bytes of data: Reply from 192.168.XXX.YYY: bytes=32 time=37ms TTL=127 Reply from 192.168.XXX.YYY: bytes=32 time=40ms TTL=127 Reply from 192.168.XXX.YYY: bytes=32 time=33ms TTL=127 Reply from 192.168.XXX.YYY: bytes=32 time=33ms TTL=127 Ping statistics for 192.168.XXX.YYY: Packets: Sent = 4, Received = 4, Lost = 0 (0% loss), Approximate round trip times in milli-seconds: Minimum = 33ms, Maximum = 40ms, Average = 35ms
So there is now a connection and you can run your RDP session, say, or get your files off, whatever. If you are logging in to a Windows computer, and you sleep the remote machine at the end of your session, you’ll get cut off, but you can wake it up again and log in again later.
wolcmd can be used outside a LAN/VPN, I believe, but only if the computer in question has its own IP address. Most computers don’t, because it is assigned locally by the router, so you need to be ‘inside’ whatever network is local to the computer you want to wake up, which usually means you’ve run a VPN and can use the simpler 255.255.255.255 notation as above. The more detailed notation is something like:
c:\> wolcmd 212122232425 192.168.XXX.YYY 255.255.255.0 9
The last number (9 here) is a port, and I can’t tell you what it should be — 7 is the default, I think.
Anyway, this allows the remote computer to be asleep most of the time (so saving a bit of energy) but still accessible when needed.