Wake on Lan when connection to Nas

Hello.

I have a NAS in my network, that should be accessible from my LAN and over VPN connections.
To save some power, my NAS shuts down after some time.

I want the routerboard to send a WOL-Packet, when I access the IP of the NAS.

My Idea was to run a script on a new connection over the firewall to the NAS but I found no way of doing this.

The other problem is, that as the NAS is on the same Local Network not alle connections run over the Router - so my second Idea was to do some kind of Port Knocking on the router to run the script.

Does anyone have any idea?

The same question. RB433 is my home router. NAS is inside LAN.

RB433 ether1 is WAN
PB433 ether2 is LAN

After 2 hours when no activity - NAS going down from energy saving purposes.

I would like to avoid manual WoL sending is necessary before NAS use.

Any working solution?

I think I heard that you can make a script run when a DHCP server leases out an IP address?
If that is true, you could simply make that the trigger for the router to send out the magic-packet.

Just an idea.

You mean everytime when new machine is powered on, DHCP server (mikrotik) serves the IP to DHCP client, and then in the same time WoL script is run. Correct?

Yup.

Check out “lease-script” here: wiki.mikrotik.com/wiki/Manual:IP/DHCP_Server