I have an Asus RT-N56U onto which I installed OpenWrt Chaos Calmer version 15.05.1.

Everything seems to work OK, but I need the ability to WOL from the internet and I had a really hard time setting this up with OpenWrt.  I have other routers that are supported by dd-wrt an they were always relatively easy to set up for WOL over the internet.

Basically, you have to set up port forwarding for UDP port 9 to go to some unused ip address in your subnet (like 192.168.1.254).  Then you need to create an ARP mapping from whatever ip addess you just forwarded to the broadcast MAC address (ff:ff:ff:ff:ff:ff) so that your magic packet can be sent to all hosts on your local network.

So I did this in OpenWrt but WOL would not work outside my local network.  After spending a lot of time on this (basically because I know very little about Linux systems) I was able to verify that my port forwarding was working just fine.  My ARP entry, however, was not being created so I started focusing on that.

From a shell session, if I executed the command that I had put in my startup script (at /etc/rc.local)

ip neigh add 192.168.1.254 lladdr ff:ff:ff:ff:ff:ff nud permanent dev br-lan

then the ARP entry would be created and WOL over the internet worked just fine.

Eventually I came to the conclusion that I may be running into a race condition and perhaps my startup ip command was being run before the ip package was initialized.  To test this I put a sleep command before my ip command in rc.local

sleep 2
ip neigh add 192.168.1.254 lladdr ff:ff:ff:ff:ff:ff nud permanent dev br-lan

and after a reboot the ARP entry was being created!

This is good news, but I am wondering if there is a better way to code this.  Sleeping for some static amount of time is never a good solution for dealing with a race condition.  Does anyone know of any way either through brute force polling or some more sophisticated event mechanism to determine when the ip package is available to be used so that I can assure that I never jump the gun when issuing my ip command?