Enabling Wake on LAN in OpenWRT

Aug 17, 2014

When I switched from DD-WRT to OpenWrt on my TL-WR1043ND router, I couldn't find a WOL page in the UI. Here is how to enable it:

Go to the System, Software menu, search for the luci-app-wol package and install it...


Be sure to click the "Available packages" tab

..and you are done. Too easy! Not quite.

The new Network, Wake on LAN menu item relies on arp tables to present you with the list of devices to wake up. There are some problems though:

  • If OpenWRT hasn't seen the device yet, it won't be on the list. If the device hasn't been seen for a while, the arp table clears and your host drops off the list.
  • You also need to populate the hosts file if you want hostnames rather than IP/MAC address pairs to choose from in your WOL dropdown.

To work around the arp expiring you can use ip neigh add but you still have to update the hosts file. Instead, I decided to edit the LuCI UI code directly to hardcode in my devices.

The source for the WOL page is fairly simple and can be found in your router at /usr/lib/lua/luci/model/cbi/wol.lua

At lines 56-58 (as at revision 10467), you want to comment out the loop where it calls sys.net.mac_hints and replace it with something like this which has your hard coded MAC and hostnames:

--sys.net.mac_hints(function(mac, name)
-- host:value(mac, "%s (%s)" %{ mac, name })
host:value("FF:EE:DD:C1:BA:AD", "FirstPC")
host:value("FF:EE:DD:C2:1C:C0", "SecondPC")
host:value("FF:EE:DD:C3:1F:E1", "HTPC")

Save your changes, revisit the menu Network, Wake on LAN and OpenWRT will now present a clean list of hostnames that it won't forget when the ARP table clears.


Command Line Interface

If one day you find that you can SSH to your router but can't access the UI (I'm looking at you corporate firewall) then you can fallback to the CLI interface by executing...

/usr/bin/etherwake -D "FF:EE:DD:C3:1F:E1"

The -D parameter increases the debug level to stdout. Without it, the command runs silently.

If you don't want to keep a list of MAC Addresses somewhere, create a script wakeHtpc.sh and add your etherwake command to it.

Run chmod +x wakeHtpc.sh over it to allow execution and then run it with ./wakeHtpc.sh