Community discussions

MikroTik App
 
shakalov
just joined
Topic Author
Posts: 4
Joined: Wed Apr 27, 2016 12:38 pm

Wake up device when connecting to it via RDP

Wed May 31, 2017 11:25 am

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.
 
Shadeofspirit
Member Candidate
Member Candidate
Posts: 203
Joined: Fri May 27, 2016 12:15 am
Location: Minsk
Contact:

Re: Wake up device when connecting to it via RDP

Wed May 31, 2017 11:54 am

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
 
shakalov
just joined
Topic Author
Posts: 4
Joined: Wed Apr 27, 2016 12:38 pm

Re: Wake up device when connecting to it via RDP

Wed May 31, 2017 12:36 pm

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 :(
 
Shadeofspirit
Member Candidate
Member Candidate
Posts: 203
Joined: Fri May 27, 2016 12:15 am
Location: Minsk
Contact:

Re: Wake up device when connecting to it via RDP

Wed May 31, 2017 12:42 pm

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 :(
look at this Wiki post, i think it can help to solve your problem
https://wiki.mikrotik.com/wiki/Log_Pars ... ger_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
 
Sob
Forum Guru
Forum Guru
Posts: 9188
Joined: Mon Apr 20, 2009 9:11 pm

Re: Wake up device when connecting to it via RDP

Wed May 31, 2017 4:02 pm

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 <time> 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.
 
Shadeofspirit
Member Candidate
Member Candidate
Posts: 203
Joined: Fri May 27, 2016 12:15 am
Location: Minsk
Contact:

Re: Wake up device when connecting to it via RDP

Wed May 31, 2017 4:22 pm

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 <time> 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
 
shakalov
just joined
Topic Author
Posts: 4
Joined: Wed Apr 27, 2016 12:38 pm

Re: Wake up device when connecting to it via RDP

Wed May 31, 2017 5:56 pm

Wake up at RDP connection is easily possible with this:

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

The trouble is, your laptop is likely to be awake all the time, because port scanning bots work 24/7.
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!
 
Sob
Forum Guru
Forum Guru
Posts: 9188
Joined: Mon Apr 20, 2009 9:11 pm

Re: Wake up device when connecting to it via RDP

Wed May 31, 2017 6:00 pm

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