How does WOL (Wake-On LAN) work?

Ok, there isn't much good information about this on the net, so here's my wisdom:

How Wake-on-LAN works

So the whole point of WoL is to turn your computer on remotely using the network. Obviously if your computer were actually completely off, then there's no way this can work, so when modern computers are turned "off", the ethernet card actually remains on, in a (hopefully) low power state, listening for WoL packets.

When WoL was first created, you could set your network card to signal the BIOS to turn your computer on when there was any network activity. That is, whenever an ethernet frame (or maybe an IP packet; I'm not 100% sure) is seen by the network card. Seems kind of reasonable, but in reality it is useless because occasionally random packets flying over the network will wake your computer up for no reason. To fix this, someone invented MagicPacket™! By setting your card to MagicPacket™ mode, it will only wake the computer when it sees data containing your network card's MAC address repeated 6 times (as far as I remember). Now, random packets won't annoyingly wake your computer. This is also the reason you need to put your MAC address into WoL tools; so it can construct the MagicPacket™.

You might have noticed a small flaw with MagicPacket™: Anyone on the network can see you MAC address, so if you are trying to use WoL on an untrusted local network (e.g. a university), annoying people could keep waking your computer. Don't quote me on this, but looking at the ethtool man page it looks like someone has "invented" SecureOn™ for MagicPacket™. This apparently lets you set the MAC address that your card listens for, effectively turning it into a private password.

How the packet gets to your computer

Now here's the tricky part. Ethernet was designed to send data between computers that are on. This doesn't play well with WoL, which wants to send packets to computers that are off.

The first hurdle is that off computers don't really have IP addresses. Therefore you cannot send a WoL packet to an IP address (tools that let you put in your IP address are really asking for the IP address of a router, which is on). Instead, WoL packets are broadcast to every connected ethernet device. You can - in good routers - manually associate an IP address with a MAC address, but most routers don't allow this, and will drop IP packets that are sent to off computers.

Broadcasting packets works, but there is a problem...

Why it isn't very good

The problem is, most routers don't allow you to forward packets to a broadcast address. Ideally what you want in your typical "I'm at work and I want stuff from my home computer" WoL setup is to forward from external port 9 (for example; see below) to 255.255.255.255:9. Routers simply won't do it. I did actually eventually find out how to do it for a speedtouch ADSL router, but it involved hand-editing config files.

Probably the only real way you will get this to work is by installing a decent third party router firmware, such as Tomato or DD-WRT. These have WoL tools built into the web interface. It's not quite so neat since you then can't do cool things like using your phone to auto-wake your computer when you get home. But still. I haven't actually tried, but you may be able to get those firmwares to do forward-to-broadcast. Who knows.

Port 7 and Port 9

Lots of guides say you must use port 7 or you must use port 9, and you're thinking "why?", "which one?". The answer is, it doesn't matter. You can use any port; 80, 666, it doesn't matter. The network card on your computer doesn't care which port the MagicPacket™ is send to, as long as it receives it, and it has the MAC address repeated in it. And if you do manage to get WoL-forwarding to work you can use any port there too (and then put the corresponding port in your WoL tool).

The reason 7 and 9 are recommended is because they were the ports used by a couple of completely useless servers that haven't been used by anyone since the 80s. Just like port 80 is the port for the web, port 7 is the port for the "echo" server which repeats everything back to the sender, and is a massive security vulnerability, and port 9 is the port for the "discard" server which simply discards all the data it receives and never sends anything back. They're completely useless now but I guess maybe they were good for network testing back when the internet was new (the 70s).

Troubleshooting - My computer won't turn on!

The first thing to check is that you receive the MagicPacket™ when your computer is on. For that, download wireshark (google it), tell it to listen to port 9 (or 7 or whatever), and send a WoL packet. You should see it. If you don't, the problem will be relatively easy to fix, or at least diagnose.

If you get the packet, but your computer still won't turn on, it gets a bit more tricky.

First, go into the BIOS/UEFI, and make sure an option like "Allow PCI to wake computer" or similar is enabled. Also enable the PCIe option. Second, on linux use ethtool to enable WoL for your network card. Something like ethtool -s eth0 wol bgm. In windows you find the option "Allow this device to wake up the computer" and maybe there are some MagicPacket™ options there somewhere. I dunno I'm not using windows right now.

Now, hopefully it will work. But maybe it only works for a few minutes (or even seconds) after you turn off your computer! Oh no! This is a problem with the router. I recommend you get a different one. Seriously, Tomato-USB is awesome.


Basically, when your machine is plugged in, even turned off, some maintain some very basic functions such as the network card.

They can be configured so that when a special instruction is received, it can power up the machine.

The easiest way to start is simply, if you have an integrated NIC, look in the BIOS and see if it supports it. If you have an actual Network card, you may not be able to use it... But it is worth seeing if you have a slot for a Wake On Lan Chip or cable

Also, as for saving energy, you need to obviously turn on your device! You need to have a router that can turn on devices based on a schedule or a wireless mobile or similar that you can send the instruction from - obviously though, you may just be better off turning the machine on via its power button!

Wikipedia has a good article on Wake On Lan


Wake on LAN (WoL) support is implemented on the motherboard of a computer and the network interface, and as such, is not dependent on the operating system running on the hardware, although the operating system can sometimes control the WoL behaviour. If the network interface is a plug-in card rather than being integrated into the motherboard, the card may need to be connected to the motherboard by a cable. Motherboards with an embedded Ethernet controller which supports WoL do not need a cable.


Wake on lan will (probably) not work if your computer is behind a firewall. To get it to work you have to have open ports in the company's firewall to let the message through and send it towards your computer.

One way to get around this is if you have access to a computer behind your firewall that is always on and send your WOL-signal from that computer.

Tags:

Wake On Lan