The following steps work for the 'buntus (tested on kubuntu 8.04) and probably all debian derived distros, mandriva
et al have a different way of setting up networking, but I expect the same principles can be made to apply.
I have followed many HOWTOs to get WOL working. They didn't work.
I have even posted to a few threads here on LQ about the problem. No joy.
Some sites advised editing the
/etc/init.d/halt script to remove the
-i option when
halt is finally called. This should work, but didn't, so I left that file alone.
Some sites advise running
ethtool -s eth0 wol g as a startup script. That didn't work either.
The problem is that when linux shuts down, it completely powers off the LAN card. This saves a small amount of electricity, but the card is now truly OFF so it can no longer listen for the "Magic Packet" that is supposed to wake it up and make the computer boot.
Today I found a solution that works for me:
- I am assuming that
eth0 is your LAN connection.
- You need the following utilities to be installed:
ethtool and
wakeonlan
- You need to know the MAC address of the LAN card in the PC you want to wake up. You can find the MAC address like this:
ifconfig eth0 | grep HW
- You may need to check that WOL is enabled in that PCs BIOS
- You need to check that that LAN card supports WOL (not all do) with
ethtool eth0
You'll need to be root to make these changes:
Create a very small script called
activateWOL
It looks like this
Code:
#!/bin/bash
ethtool -s eth0 wol g
make it executable and move it into
/usr/bin/
Now
add a line to the
/etc/network/interfaces file, in the part relevant to
eth0 to call that script, like this
Code:
auto lo
iface lo inet loopback
address 127.0.0.1
netmask 255.0.0.0
auto eth0
iface eth0 inet static
address 10.0.0.4
netmask 255.255.255.0
gateway 10.0.0.2
post-down /usr/bin/activateWOL
Restart networking to make sure this change is noticed:
/etc/init.d/networking restart
What this does is re-enable the WOL capability of the card after it has been shut down. It seems stupid to have to have a script with only one command in it, but when I tried just putting
post-down ethtool -s eth0 wol g in the interfaces file, it didn't work.
When the PC has shut down and has kept WOL activated, I notice a little green light by the ethernet connector, even though the PC is "powered off".
Now you can now wake that pc from another PC on your LAN with the command
wakeonlan macaddress like this
Code:
wakeonlan 00:11:2E:A0:0B:55
With a bit of port-forwarding, I can now wake up, and shut down my home server from anywhere connected to the internet. Linux is awesome sometimes.