I've ubuntu server on lan with static IP within lan, I use router: DSL-2640B.
For waking I use program called "wolcmd".
From within lan network it is very easy to wake up the machine.
I just issue command:
/Users/usr/Downloads/wolcmd [mac] [lan IP] 255.255.255.0 9
And server comes online.
From WAN I came up with this trick (but it is long and tedious) and I wonder if there is simpler way to do this!!.
So I ssh into router from WAN and do
arp add [lan IP] [ff:ff:ff:ff:ff:ff]
than I issue command from WAN
/Users/usr/Downloads/wolcmd [mac] [public IP] 255.255.255.255 9
At this point I ssh back to router, and ping local IP of server... ping goes and server is up.
than I modify arp entry yet once more
arp add [lan IP] [mac]
Only after this last change my server is accessible from WAN.
I'm not a network expert, I discovered this trick simply by trying different options to get my server turn on... so I'm sure there is logic behind, which by expert could be slimmed down and made easier!
I just want to use wolcmd whenever I want to turn server on, and not mess with router every time.