Wake On LAN Through the Internet
Wow. Four posts in as many days! This blog is smokin’!
Firstly, I’d like to say that to add to the super l33tness of this post, I used WOL and VNC from halfway around the globe to get local admin access to my router to check all the settings necessary for this to work. l33t.
Wake on LAN is a very useful tool that allows you to send what is known as a ‘magic packet’ over a LOCAL area network to boot up a specific PC, whose MAC address appears in the packet. Googling this will give you any number of applications and tutorials to accomplish this. Getting this to work from outside your LAN however, is a tad trickier.
The first hurdle is that unless you fork out tons of dough for a fixed IP address, your ISP will allocate you a dynamic IP address, which (especially here in South Africa) can get changed as frequently as every 24 hours. To get around this, you need to sign up with someone like dyndns.org and configure your router to let them know when its IP address changes. You can then find your home network from a ‘fixed’ domain.
Next you need to tell your router that packets sent to a specific port (the one you’ll be using for WOL) needs to get forwarded to the PC you want to boot. The first step here is to assign your PC a fixed IP address, and then configure your router to pass the packets through to it.
I have a Billion 7300G Wireless ADSL Router. To make sure that it forwards the packet to the right place, under the Virtual Server settings, forward UDP packets on your chosen port to the IP address of your PC. For details on this, and for other router configurations, check out the guides on www.portforward.com.
The next problem, which took me the longest to resolve, is to get your router to remember which LAN port your PC is connected to when it’s switched off! For the Billion routers, add your PC’s IP and MAC address to the Static ARP table under the Advanced settings. I’m afraid if you have another brand of router, you’re on your own here!
Finally, you need something to send magic packets over the net. You can get applications that do this, but I wanted something a bit more mobile, so I could trigger the boot packet from anywhere, any PC. Furhter googling will get you a few web pages that do this, but most use POST data, which makes it tricky to save the IP, MAC address and port info in the shortcut/favorite. Ideally, I wanted one that did this using GET data.
So, head on over to the help page for php’s sockets and pick your flavour of magic packet code. I chose this one for its simplicity.
Make sure that the port you choose to use is open on your server. The original one I selected from my home PC had recently been blocked by Site5 for security reasons, but using other common ports shouldn’t be a problem.
If you want to use the script on my page, feel free. Just fill in your applicable info and save it either to your local bookmarks, or for portability, to somewhere like del.icio.us:
http://www.hokemon.com/scripts/wol.php?ip=your.dynamic.address.org&mac=112233445566&port=xx
I feel obliged to point out that using this script will record all this info into my server logs, so don’t get on my wrong side, or I may magic packet-spam you at ungodly hours ![]()


