sudo apt-get install ethtool
Now execute the command to set the wake on lan mode to on "g". You may need to tweak the eth0 piece to match the correct Ethernet interface.
sudo ethtool -s eth0 wol g
And confirm the setting with:
sudo ethtool eth0
At this point you can halt the machine and wake it but.. the setting is only temporary so you need to install a boot script in the server to make it permanent. Nothing is worst than shutting down the server while you are remote only to have it never come back on the next activation.
sudo vi /etc/init.d/wakeonlan
Now add the text.
#!/bin/sh ethtool -s eth0 wol g exit
Set execute permissions on the script:
sudo chmod a+x /etc/init.d/wakeonlan
Now at this point is is best to confirm the script actually works, unless you like making problems to fix.. So run it. And then install the script for startup:
update-rc.d -f /etc/init.d/wakeonlan defaults
Confirm output the install worked without errors.
Now your right to go. Dont forgot to get the MAC address from an ifconfig and then shutdown with:
sudo halt
Then simply send the magic packet(crafted from the Mac addres) to you local intranets broadcast address and the machine should wake up. If you want it to work from remote, map a random port or your NAT that will recast it to the local broadcast address and your done.
If it doesn't work then there are a range of problem items to check:
- Confirm bios wake in LAN is on
- Confirm for older bios's wake signal from pci is on
- Confirm that the router led is indicating that the wire is connected and the link powered.
- Confirm the router firewall isnt filtering the wake on LAN, often ports 7 or 9.
- Confirm the wake on LAN tool is not a BS tool that doesn't work. There are a surprising number of them for how simple the magic packet is. For windows try Wolcmd.exe, ubuntu: wakeonlan, and the dd-wrt routers wol service also works nicely.
- Confirm that the machine wasn't hard powered off. this tends to kill the sleeping ethernet controller and prevent the wakeup after that point.