Out of the box I tend to find WOL under Ubuntu will not work, despite WOL being enabled in a PC's BIOS. The way I've often resolved this is to install ethtool which allows the querying settings of an ethernet device and the changing of settings. Read on...
To install ethtool either use the Ubuntu package manager or manually run:
sudo apt-get install ethtool
Then query your ethernet device to check it supports WOL :
sudo ethtool eth0
If you see "Supports Wake-on: g" then you're supported
To enable WOL you will likely need to stick the following line into your /etc/rc.local file, this sets up the ethernet card to respond to WOL magic packets. The command does not appear to be persistent hence it needs to be run as part of every boot:
sudo ethtool -s eth0 wol g
Updated March 2012: As per rokafeller's comment below WOL can work on the Microserver under Ubuntu (10.04, 10.10 and 11.10, not sure about 11.04) with some simple tweaking. To get WOL to work the ethernet interface must be properly brought down as part of the system shutdown. This should be performed as part of run levels rc0 and rc6, noting that Linux typically has 7 different run levels (or operating modes):
- rc0.d - System Halted
- rc1.d - Single User Mode
- rc2.d - Single User Mode with Networking
- rc3.d - Multi-User Mode - boot up in text mode
- rc4.d - Not yet Defined
- rc5.d - Multi-User Mode - boot up in X Windows
- rc6.d - Shutdown & Reboot
sudo vi /etc/rc6.d/K99wol_poweroff
It may contain:
ifconfig eth0 down
Change the script's permissions to make it executable:
sudo chmod 755 /etc/rc6.d/K9ls /etc/rc0.d/K99wol_poweroff
Copy the script to work on system halt as well:
sudo cp /etc/rc6.d/wol_poweroff.sh /etc/rc0.d/K99wol_poweroff
Change permissions to make it executable:
sudo chmod 755 /etc/rc0.d/K99wol_poweroff
To test power down the machine, sudo shutdown now or sudo poweroff , and use your favourite WOL tool to send a magic packet. Thanks to rockafeller and everyone else who have commented with various solutions.
Note I've found in my case the script must start with K## where ## is the scripts priority number 99 means that it is one of the last script to run in the rc# directory.
Comment prior to the March 2012 update: Sadly on the HP Microserver this [working WOL] isn't currently the case. Wake On Lan has proven to be an issue on the Microserver despite making the appropriate setting changes I have been unable to get WOL working under *nix and have not been able to find anyone on the internet with a solution on people with similar issues.The Microserver uses a Broadcom BCM5732 ethernet chipset which uses the Broadcom maintained Tg3 drivers these are now the only drivers that Broadcom maintain for *nix.
It's apparent that this is a common issue for the BCM5732 under *nix, under Windows people are reporting success with WOL depending on the flavour of Windows. So it looks like I'll be hanging on for a driver update from Broadcom that will enable WOL under *nix.