Fixed script to wake computer on access.

I was looking for a script to send Wake On Lan packets to computers on access at found one on mikrotik’s wiki.

Unfortunately it didn’t work out of the box so I had to fix it. I fixed it and improved to take into account DHCP leases rather than hardcoded addresses.

:local interface bridge-local;

:foreach i in=[/ip firewall address-list find where list=wakeOnLan] do={
  :local wakeAddress [/ip firewall address-list get $i address];
  :foreach j in=[/ip dhcp-server lease find where address=$wakeAddress] do={
    :local wakeMacAddress [/ip dhcp-server lease get $j mac-address];
    :log info "Sending WoL to $wakeMacAddress via $interface";
    /tool wol mac=$wakeMacAddress interface=$interface
  }
  /ip firewall address-list remove $i;
}

Hopefully someone can update wiki article.