Wake on LAN Over the Internet
You have broadband. You have an ssh server on your desktop at home. Your laptop has Wi-Fi. The coffee shop has Wi-Fi. You are just one private key exchange away from that file you left at home. Hmm… no response. Damn. That machine’s not on. You may not need it very often, but Wake on LAN is one of those technologies that pays off after only one use.
Wake on LAN
Although there seems to be come controversy over its origins, the Wake on LAN standard (WoL) has been widely adopted for remote activation of computing hardware over a live network connection. Once the catalog of requirements has been satisfied, Wake on LAN technology enables you to power on (or resume from standby) a personal computer from any Internet connection in the world. All it takes is one simple message.
It sounds like a simple thing. Send a message, computer turns on. Well, it is that simple… once you have all of the proper dominos positioned and ready to fall. In this article I will address each of the components that make Wake on LAN work, giving you a little more than you absolutely need to know to wake up your home PC from abroad.
One Eye Open
At the heart of the Rube-Goldberg machine called Wake on LAN lie your ACPI-compliant personal computer. The fact is that WoL technology can only wake up a computer that is capable of listening on the network while powered off. Since ACPI-compliant PCs never completely power off (the motherboard always draws a miniscule amount of power to enable advanced power management features), they make the ideal candidate for remote power on. [see steps 1 and 2 below]
In addition to having the proper hardware, we need to ensure that a couple of layers of software are ready to go. Both your computer?s BIOS and operating system must be configured to listen for the command to power on. [see steps 3 and 4]
The Magic Packet
At the heart of Wake On LAN is a carefully crafted message sent across the network. Specifically, we need to send a datagram (or UDP packet) that contains an optional synchronization sequence and the target computer’s network MAC address repeated 16 times. This packet is, of course, wrapped with the necessary network protocol headers to ensure that it is directed to the intended machine. Without those protocol details the message to wake a device with the MAC address 1a:3b:3c:4d:5e:64 will look something like this (bytes wrapped for printing):
0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0x1a 0x2b 0x3c 0x4d 0x5e 0x6f 0x1a 0x2b 0x3c 0x4d 0x5e 0x6f 0x1a 0x2b 0x3c 0x4d 0x5e 0x6f 0x1a 0x2b 0x3c 0x4d 0x5e 0x6f 0x1a 0x2b 0x3c 0x4d 0x5e 0x6f 0x1a 0x2b 0x3c 0x4d 0x5e 0x6f 0x1a 0x2b 0x3c 0x4d 0x5e 0x6f 0x1a 0x2b 0x3c 0x4d 0x5e 0x6f 0x1a 0x2b 0x3c 0x4d 0x5e 0x6f 0x1a 0x2b 0x3c 0x4d 0x5e 0x6f 0x1a 0x2b 0x3c 0x4d 0x5e 0x6f 0x1a 0x2b 0x3c 0x4d 0x5e 0x6f 0x1a 0x2b 0x3c 0x4d 0x5e 0x6f 0x1a 0x2b 0x3c 0x4d 0x5e 0x6f 0x1a 0x2b 0x3c 0x4d 0x5e 0x6f 0x1a 0x2b 0x3c 0x4d 0x5e 0x6f
There are a number of software utilities available that can generate and send this magic packet for you. Here are just a few of the alternatives, available in many flavors (from command-line to web-based): - Depicus has a hosted WoL utility as well as a command line and COM version for download - AMD - My own .NET library and console application that makes sending the WoL packet from VB or C# easy
If you plan on waking your machine from a network that uses a firewall to block outbound traffic you will probably need to use one of the web-based tools in the list. Providers like Depicus host a web-based WoL service free of charge while some of the other offerings require that you have access to a web hosting environment of your own. The web-based implementations serve as a proxy which you trigger with a simple web request. As most firewalls are configured to allow outbound web requests, you can send a request directly to the web-based service which will send the WoL packet to the target computer in the form of a magic packet.
You can learn much more about the magic packet at AMD’s web site.
The Route Home
It is a fairly simple task to send a WoL command to a machine on a local network. As we have seen, sending that request from within a protected network is slightly more complicated. The issue is further complicated when we consider what it will take to send the same command over the public Internet to a machine behind a firewall or NAT router (you do have one of these, don’t you?).
The solution is a ‘delayed blast’. First, a single magic packet is sent to a known port on your router (via IP address or DNS name). If properly configured, the router forwards that command as a broadcast message to every computer on the protected network. Each WoL-enabled machine on the network will compare the MAC address repeated in the magic packet to its own MAC address and, if it matches, power itself on.
Flipping the Switch
The following diagram depicts each of the components necessary to power on a remote computer over an Internet connection.
Steps
- Ensure that the computer you intend to wake up is ACPI compliant.
- Ensure that the Ethernet card in the target computer is WoL-capable. Many modern Ethernet chipsets have this capability, but it is worth a quick check in the manufacturer?s documentation. In addition, if your Ethernet connectivity is provided by a PCI Ethernet card, you will need to make sure that card is properly wired to the motherboard with a Wake On LAN connector. Motherboards with integrated Ethernet capabilities do not require this extra bit of wire.
- Enable WoL functionality in the BIOS. Because most systems ship with WoL disabled (for security reasons), you will likely have to turn this on before proceeding.
- Configure the operating system to respond to a WoL power management event. In Windows XP, right click on My Computer and select ‘Manage’. In the Computer Management interface, navigate to the Device Manager. Expand the Network Adapters group in the right pane. You will see a list of all of the network adapters installed in your computer. Double-click on your primary adapter. Navigate to the Power Management tab in the adapter properties dialog. Finally, check ‘Allow this device to bring the computer out of standby.’ and click ‘OK’ all the way back out.
- Choose your weapon. There are a number of utilities out there that can generate and send a magic packet. Keep in mind that a web-based solution is probably the best way to send the command over the public Internet.
- Make a note of the target computer’s MAC address (e.g. 1a-2b-3c-4d-5e-6f) and IP address (e.g. 192.168.1.100). You will need these later.
- (optional) If you have more than one computer on your local network at home, now would be a good time to test your configuration so far. Turn off the target computer and fire up your WoL software on one of the other machines on that network. Configure the WoL software with the information gathered above and let her rip.
- Make sure you can find your router from anywhere on the Internet. If your service provider assigns you a dynamic IP address (most do), you will need to register with a dynamic DNS service (like DynDNS) and follow their instructions for keeping your registration up to date. Once registered, you will be able to use a DNS name (like myhouse.dyndns.org) to send WoL packets across the Internet.
- Create a forwarding rule in your router configuration to forward incoming UDP traffic on a known port (of your choice) either to the broadcast address of your local subnet (e.g. 192.168.1.255) or the exact IP address of the target computer. Using the broadcast address is convenient here because it eliminates the need to know the target machine?s IP address (for all of you DHCP users out there).
- Give it a try. Turn off the target computer and use second computer to load the WoL client you selected in Step 5. Use the information noted in step 6 to send the WoL command to the target computer.
on May 11th, 2007 at 8:41 am
Great article. Thanks a lot. I’m gonna give it a try.