Mikrotik Script — Wake On LAN All Devices from DHCP

A lit­tle script to wake up all Mikrotik devices on your net­work that have a DHCP lease, using Wake On LAN.

It may be a good idea to set your DHCP lease expiry to some­thing long like 7 days. A short expiry may mean dynam­ic leas­es have expired if the device has been switched off for some time.

It should also wake up any devices with sta­t­ic leas­es, so you could also set all your devices as sta­t­ic in your DHCP.

/ip dhcp-serv­er lease
:fore­ach i in=[find] do={
:put ([get $i address].”,”.[get $i mac-address].”,”.[get $i server].”,”.[get $i host-name].”,”.[get $i expires-after])
:exe­cute { /tool wol interface=bridge [get $i mac-address] }