Wake up device when connecting to it via RDP

Hello everybody.
I want to make automatic of procedure waking up my laptop, when I connecting to it via RDP.
I have a port forwarding and script, which waking up my device:

tool wol interface=ether5 mac=90:E6:BA:9D:**:**

Can I make some rule, which running this script after NAT-Rule is run?
Thanks for your help in advance and sorry for language - it’s not my native.

I can suggest you to use vpn, at first it is more secure and the second - you can run scripts on user log in/out

Not exacly what I want. I can connect from my work office or from any point of Internet to my Home LAN, but not in every connection need to wake laptop :frowning:

look at this Wiki post, i think it can help to solve your problem
https://wiki.mikrotik.com/wiki/Log_Parser_-_Event_Trigger_Script
based on it you can parse nat event
And don’t forget - your laptop will need some time to wake up after getting WOL message, so you will have to reconnect after it will start

Wake up at RDP connection is easily possible with this:

/ip firewall nat
add chain=dstnat dst-address=<public address> protocol=tcp dst-port=3389 \
    action=add-src-to-address-list address-list=rdp address-list-timeout=<time>
add chain=dstnat dst-address=<public address> protocol=tcp dst-port=3389 \
    action=dst-nat to-addresses=<laptop address>

And then add this to scheduler with period shorter than from dstnat rule:

:if ([:len [/ip firewall address-list find where list=rdp]] > 0) do={
  :log info "rdp wake up..."
  /tool wol interface=<lan> mac=<mac>
}

The trouble is, your laptop is likely to be awake all the time, because port scanning bots work 24/7.

cool) if modify it a little bit, than it can be used like “port knocking” for wake up the PC

Sob, thanks for your help!
I done it by your manual.
Source added to list for 5 seconds, and script running every 1 second (I watch for my CPU Usage - it’s about 3-6% of loading).
First time, when I connect - connection RDP not working - it’s normal, laptop is sleeping.
Second time (after about 5-10 sec) it’s connecting successfully.
About scanning this port by bots, i’m not affraid - because my external RDP-port not standart.
Thank’s again!

Running the script every second seems a little extreme to me, but as long as you’re aware that it can affect the router, … :slight_smile: