Here is a quick How To on how to set up a remote Windows PC on your home network, how to create a VPN tunnel to VPN into that network remotely, how to use Wake on LAN to wake up that Windows PC remotely, and how to then use Microsoft Remote Desktop to work on that PC, from anywhere in the world. 
I just set this up for a new Desktop I built, and this is a writeup of that process.
It will go into detail on almost every step - except for one. My ISP already provides me with a static public IP address (that only changes once every few years), so I didnt have to set up Dynamic DNS, to be able to address my router (and home network) from the internet at large. I already have and know that IP. So if you have a dynamically changing IP address that gets assigned to you by your ISP - you are on your own on that one.
(Usually google DDNS and your router firmware (f.e. Tomato (see https://old.reddit.com/r/TomatoFTW/ )), to get pointed into the correct direction.
)
1. Setting up Wake on LAN (WOL).
Not as easy as you'd think.
Windows requires quite a few settings to be changed for this, and it is dependent on your motherboard/motherboard vendor as well. And on your router (more on that later). Here are the steps for an ASUS mainboard under Windows 10:
Follow all of those steps:
https://rog.asus.com/forum/showthread.php?93081-HERO-Wake-on-LAN#post693575
(Then it still didnt work for me.
)
Then follow those steps as well:
(src: https://rog.asus.com/forum/showthre...ing-from-shutdown-Asus-Deluxe-Z170#post714468 (minus the registry tweak which wasn't needed. I already edited it out in the code box above))
After that the Asus motherboard and Windows 10 were set up and ready for WOL.
But then your router still can block or not forward the magic packet (the thing that makes your PC turn on via LAN) - so that is also something you have to sort out.
My router runs under Tomato (open source firmware), which has a 'Wake on LAN' feature in the tools section, where you just enter the Mac address of your PCs NIC (network card) in a textbox, and hit wake - which will wake up that PC always. Which is good for testing, but we'll make sure that magic packets to wake up the PC can be sent from other devices as well.
Power usage for my PC (ROG Strix B450-I motherboard) shut down, with WOL still possible is about 1.75 watt, but you should check yours to make sure your's is not 10+ times higher.
(Depends on the powersupply and motherboard.)
2. Once WOL works for you, you can install "Microsoft Remote Desktop" (on the device that will control the PC) and "Microsoft Remote Desktop Assistant" (on the PC = device that will be controlled). Both are free. I also would encourage you to buy Synergy ( https://symless.com/synergy ), which allows you to seamlessly and wirelessly share one devices (f.e. laptop) keyboard and mouse, with the PC you are trying to control. Synergy works better, if you are in the same room as the PC and have a monitor thats on - and just want to control that PC from a laptop f.e.. So no screen mirroring. "Microsoft Remote Desktop" would be what you'd use if you need screen mirroring (f.e. because your monitor is turned off, or you are remoting in from anywhere in the world (and arent in the same room)).
(If you use a Macbook to control a Windows PC via Synergy - you need to enter your Macs IP address on the PC side, network address translation with the Macs name doesnt seem to work in Synergy.
)
With that you now can turn on and remotely control the Windows PC from within your home network.
As we also want this to work from anywhere in the world, the next step is to talk a bit about router choice.
-
As you basically need to set up a VPN tunnel on your router, so you can VPN into your home network - you need a router that supports that. If you are new to this, and want to get this to work on the cheap, I'd recommend an Asus RT-AC66U router (used for under 100 bucks, I got mine for 70USD a while back), running on a replacement open source firmware. I personally use Tomato (open source firmware) - so all the following steps are written for Tomato specifically, but also should give you an idea about what steps you'd go through in general.
Also - with flashing your router to a replacement open source firmware, you are on your own.
You can brick them in the process - which is why I recommended you get a cheap enough, but still good, router if you are starting out..
(Asus RT-AC66U)
-
3. Making sure you can send wake on lan magic packets from other devices (not just the router) on Tomato.
Tomato kicks devices that are turned off out of the ARP cache after a while, which prevents them from being turned on via WOL from other devices (lets say a laptop). They can always be turned on remotely via the Tools/Wake on Lan menu in Tomato (the router menu), but there is also a work around in the form of a Tomato firewall script that fixes the issue.
You can set that up by following this tutorial
https://justinmontgomery.com/wake-on-lan-configuring-your-pc-tomato-iphone
There also is a part in there that tells you to set a UDP port forward to that 192.168.1.254 address, which you should do as well (so WOL later works over the VPN as well). Also ff:ff:ff:ff:ff:ff in that tutorial is not a placeholder, but the real deal.
Later on you are addressing 192.168.1.254 with the MAC address of the device you want to wake up, and Tomato does the rest.
After following those steps, waking up the PC should work from any device in the network, always.
4. Setting up the OpenVPN Server on your Tomato router
For this, you first need to generate your OpenVPN certificates and keys.
I did this on MacOS, following this tutorial
https://firxworx.com/blog/it-devops...eys-for-openvpn-server-with-easyrsa-on-macos/
It first walks you through installing XCode, and brew, and then through the entire certificates/key generation process. (Using 2048 key size is fine for Tomato on the RT-AC66U)
Depending on the OS you are using to generate the key pairs, your process might vary - but you can use the tutorial to look up all the certificates/keys that need to be generated, as well as how EasyRSA ( https://github.com/OpenVPN/easy-rsa/releases ) would be used to generate them. There also is a windows version of EasyRSA you could use, where the certificates/keys generation process should be similar.
Once you have all your certificates and keys, you can set up the OpenVPN Server in Tomato, using them, with the help of the following blogpost -
DISCLAIMER: Only use the images in the following blogpost to guide you through setting up the OpenVPN Server. (Dont use any of the info on generating the certificates or keys - we already did that.
If you only stick to the images, they'll tell you everything thats needed.
)
https://lassesunix.wordpress.com/20...n-a-tomato-router-with-tunnelblick-as-client/
Once the server is set up (using the config options from the images above, and your keys (content of your key files)) and running, you only need to provide your VPN client of choice the ca.crt, and the client .crt and .key files (all generated with EasyRSA in the steps before), in addition to a configuration file that tells it the server side settings.
Most VPN clients can use a config.ovpn file for that, which you would generate with a texteditor and drop into the same folder as the ca.crt, and the client .crt and .key files - and that in my case looks as follows:
Make sure you replace 55.255.55.255 with the public IP of your home network, and androidclient.crt and androidclient.key with the names of your client .crt and .key files respectively (EasyRSA allowed you to name those freely. In the tutorial it was suggested you create one for every client that would be connecting to your VPN tunnel on the router (Android Phone, Mac Laptop, ...). Then save the textfile.
Usually doubleclicking the config.ovpn should be enough to finally import the VPN credentials into your VPN client software of choice (it is f.e. for Tunnelblick), but that may vary depending on the VPN software you use. Still you should have everthing thats necessary at this point.
The next step is to test out if your VPN connection to your home router (running Tomato) is working (which it should at this point
), f.e. by using your smartphones hotspot as an internet connection, and then trying to VPN into your home network.
If it works, yay for you.. 
--
5. Once the VPN connection is established
- Waking up the PC using WOL via your home networks public IP and the port you defined should work. (Actually this should work regardless of you being VPN tunneled to your home network or not..
)
Here is an example how that command would look with wakeonlan (command line program that can be installed with brew on a Mac (brew install wakeonlan)):
Where
55.255.55.255 would be your public IP
8089 the port (UDP) you forwarded 192.168.1.254 to in Tomato
and
d4:4d:64:46:51:15 the MAC address of the PC you are trying to wake up.
After your PC has been woken up, give it some time to boot, and then connect with Microsoft Remote Desktop - and thats basically all.
(Synergy in my case doesnt work if you are tunneld in via a VPN, but usually you wouldnt want to use that from a remote location anyhow.
)
-
All thats left for me is to leave you with a MacOS applescript (save as an .app with Script Editor) to wake your PC and either start Synergy or Microsoft Remote Desktop - in case you are using a Macbook to remote into your PC (wakeonlan needs to be installed via brew ( https://brew.sh/ )):
If you choose local it will launch Synergy, if you choose remote it will wait 37 seconds (for the PC to boot) and then start Microsoft Remote Desktop.
And thats it.
Potential use cases? I don't know, I just set it up..
Remote gaming via Microsoft Remote Desktop is kind of out of the question (latency), also GOG Galaxy will crash, when you are using the PC via Microsoft Remote Desktop. Its a thing... 
Have fun, if you are attempting something similar.
I just set this up for a new Desktop I built, and this is a writeup of that process.
It will go into detail on almost every step - except for one. My ISP already provides me with a static public IP address (that only changes once every few years), so I didnt have to set up Dynamic DNS, to be able to address my router (and home network) from the internet at large. I already have and know that IP. So if you have a dynamically changing IP address that gets assigned to you by your ISP - you are on your own on that one.
(Usually google DDNS and your router firmware (f.e. Tomato (see https://old.reddit.com/r/TomatoFTW/ )), to get pointed into the correct direction.
1. Setting up Wake on LAN (WOL).
Not as easy as you'd think.
Follow all of those steps:
https://rog.asus.com/forum/showthread.php?93081-HERO-Wake-on-LAN#post693575
(Then it still didnt work for me.
Then follow those steps as well:
Code:
WINDOWS...
Open device manager, find your NIC, open, drivers tab - Update driver. If nothing found, download directly from manufacturer website
Once updated, reboot.
After reboot, open NIC properties\Power Management tab:
Tick all boxes - Allow computer to turn off device, allow to wake up, only allow magic packet.
Open NIC properties\Advanced tab and (where available):
Set Enable PME = ENABLED
Set Energy Efficient Ethernet / Green etc = DISABLED
Wake on Magic Packet = ENABLED
Wake on Pattern Match = ENABLED
Reboot, then after reboot shutdown.
After that the Asus motherboard and Windows 10 were set up and ready for WOL.
But then your router still can block or not forward the magic packet (the thing that makes your PC turn on via LAN) - so that is also something you have to sort out.
My router runs under Tomato (open source firmware), which has a 'Wake on LAN' feature in the tools section, where you just enter the Mac address of your PCs NIC (network card) in a textbox, and hit wake - which will wake up that PC always. Which is good for testing, but we'll make sure that magic packets to wake up the PC can be sent from other devices as well.
Power usage for my PC (ROG Strix B450-I motherboard) shut down, with WOL still possible is about 1.75 watt, but you should check yours to make sure your's is not 10+ times higher.
2. Once WOL works for you, you can install "Microsoft Remote Desktop" (on the device that will control the PC) and "Microsoft Remote Desktop Assistant" (on the PC = device that will be controlled). Both are free. I also would encourage you to buy Synergy ( https://symless.com/synergy ), which allows you to seamlessly and wirelessly share one devices (f.e. laptop) keyboard and mouse, with the PC you are trying to control. Synergy works better, if you are in the same room as the PC and have a monitor thats on - and just want to control that PC from a laptop f.e.. So no screen mirroring. "Microsoft Remote Desktop" would be what you'd use if you need screen mirroring (f.e. because your monitor is turned off, or you are remoting in from anywhere in the world (and arent in the same room)).
(If you use a Macbook to control a Windows PC via Synergy - you need to enter your Macs IP address on the PC side, network address translation with the Macs name doesnt seem to work in Synergy.
With that you now can turn on and remotely control the Windows PC from within your home network.
As we also want this to work from anywhere in the world, the next step is to talk a bit about router choice.
-
As you basically need to set up a VPN tunnel on your router, so you can VPN into your home network - you need a router that supports that. If you are new to this, and want to get this to work on the cheap, I'd recommend an Asus RT-AC66U router (used for under 100 bucks, I got mine for 70USD a while back), running on a replacement open source firmware. I personally use Tomato (open source firmware) - so all the following steps are written for Tomato specifically, but also should give you an idea about what steps you'd go through in general.
Also - with flashing your router to a replacement open source firmware, you are on your own.
-
3. Making sure you can send wake on lan magic packets from other devices (not just the router) on Tomato.
Tomato kicks devices that are turned off out of the ARP cache after a while, which prevents them from being turned on via WOL from other devices (lets say a laptop). They can always be turned on remotely via the Tools/Wake on Lan menu in Tomato (the router menu), but there is also a work around in the form of a Tomato firewall script that fixes the issue.
You can set that up by following this tutorial
https://justinmontgomery.com/wake-on-lan-configuring-your-pc-tomato-iphone
There also is a part in there that tells you to set a UDP port forward to that 192.168.1.254 address, which you should do as well (so WOL later works over the VPN as well). Also ff:ff:ff:ff:ff:ff in that tutorial is not a placeholder, but the real deal.
After following those steps, waking up the PC should work from any device in the network, always.
4. Setting up the OpenVPN Server on your Tomato router
For this, you first need to generate your OpenVPN certificates and keys.
I did this on MacOS, following this tutorial
https://firxworx.com/blog/it-devops...eys-for-openvpn-server-with-easyrsa-on-macos/
It first walks you through installing XCode, and brew, and then through the entire certificates/key generation process. (Using 2048 key size is fine for Tomato on the RT-AC66U)
Depending on the OS you are using to generate the key pairs, your process might vary - but you can use the tutorial to look up all the certificates/keys that need to be generated, as well as how EasyRSA ( https://github.com/OpenVPN/easy-rsa/releases ) would be used to generate them. There also is a windows version of EasyRSA you could use, where the certificates/keys generation process should be similar.
Once you have all your certificates and keys, you can set up the OpenVPN Server in Tomato, using them, with the help of the following blogpost -
DISCLAIMER: Only use the images in the following blogpost to guide you through setting up the OpenVPN Server. (Dont use any of the info on generating the certificates or keys - we already did that.
https://lassesunix.wordpress.com/20...n-a-tomato-router-with-tunnelblick-as-client/
Once the server is set up (using the config options from the images above, and your keys (content of your key files)) and running, you only need to provide your VPN client of choice the ca.crt, and the client .crt and .key files (all generated with EasyRSA in the steps before), in addition to a configuration file that tells it the server side settings.
Most VPN clients can use a config.ovpn file for that, which you would generate with a texteditor and drop into the same folder as the ca.crt, and the client .crt and .key files - and that in my case looks as follows:
Code:
client
dev tun
proto udp
remote 55.255.55.255 1194
resolv-retry infinite
nobind
persist-key
persist-tun
ca ca.crt
cert androidclient.crt
key androidclient.key
ns-cert-type server
comp-lzo
verb 4
float
Make sure you replace 55.255.55.255 with the public IP of your home network, and androidclient.crt and androidclient.key with the names of your client .crt and .key files respectively (EasyRSA allowed you to name those freely. In the tutorial it was suggested you create one for every client that would be connecting to your VPN tunnel on the router (Android Phone, Mac Laptop, ...). Then save the textfile.
Usually doubleclicking the config.ovpn should be enough to finally import the VPN credentials into your VPN client software of choice (it is f.e. for Tunnelblick), but that may vary depending on the VPN software you use. Still you should have everthing thats necessary at this point.
The next step is to test out if your VPN connection to your home router (running Tomato) is working (which it should at this point
--
5. Once the VPN connection is established
- Waking up the PC using WOL via your home networks public IP and the port you defined should work. (Actually this should work regardless of you being VPN tunneled to your home network or not..
Here is an example how that command would look with wakeonlan (command line program that can be installed with brew on a Mac (brew install wakeonlan)):
Code:
/usr/local/bin/wakeonlan -i 55.255.55.255 -p 8089 d4:4d:64:46:51:15
55.255.55.255 would be your public IP
8089 the port (UDP) you forwarded 192.168.1.254 to in Tomato
and
d4:4d:64:46:51:15 the MAC address of the PC you are trying to wake up.
After your PC has been woken up, give it some time to boot, and then connect with Microsoft Remote Desktop - and thats basically all.
-
All thats left for me is to leave you with a MacOS applescript (save as an .app with Script Editor) to wake your PC and either start Synergy or Microsoft Remote Desktop - in case you are using a Macbook to remote into your PC (wakeonlan needs to be installed via brew ( https://brew.sh/ )):
Code:
set x to isAppLoaded("Synergy")
if x then
do shell script "curl -X POST https://maker.ifttt.com/trigger/HDMI2/with/key/00000yoRGEN000kkF00000"
do shell script "ps aux | grep -i Synergy | awk '{print $2}' | xargs kill -9 & $COMMAND & $EXIT"
else
display dialog "Local or Remote?" with title "Chose connection method" buttons {"Local", "Remote", "Cancel"} default button "Local" cancel button "Cancel"
if the button returned of the result is "Remote" then
do shell script "/usr/local/bin/wakeonlan 192.168.1.254 d4:4d:64:46:51:15"
do shell script "/usr/local/bin/wakeonlan -i 55.255.55.255 -p 8089 d4:4d:64:46:51:15"
delay 37
tell application "Microsoft Remote Desktop"
activate
end tell
else if the button returned of the result is "Local" then
do shell script "/usr/local/bin/wakeonlan 192.168.1.254 d4:4d:64:46:51:15"
do shell script "/usr/local/bin/wakeonlan -i 55.255.55.255 -p 8089 d4:4d:64:46:51:15"
do shell script "curl -X POST https://maker.ifttt.com/trigger/HDMI4/with/key/00000yoRGEN000kkF00000"
tell application "Synergy"
activate
end tell
end if
end if
on isAppLoaded(app_name)
tell application "System Events"
set app_list to every application process whose name contains app_name
if the (count of app_list) > 0 then
return true
else
return false
end if
end tell
end isAppLoaded
And thats it.
Potential use cases? I don't know, I just set it up..
Have fun, if you are attempting something similar.
Last edited by notimp,