Enable WOL on Debian NIC

apt-get install ethtool

ethtool eth0
	Settings for eth0:
	       Supports Wake-on: g
	       Wake-on: d
	       Link detected: yes

Here we can see that wakeonlan support is available because of the g, but
it's disabled. (This is explained in the manpage which you can read with "man
ethtool"). To enable the magic packet support run:

	ethtool -s eth0 wol g

Now you should be able to see that it's turned on:

	ethtool eth0
		Settings for eth0:
		       Supports Wake-on: g
		       Wake-on: g
		       Link detected: yes

--------------------------------------------------------------------------------

To Get the MAC Address of Node

	ping -c 1 hostname
	  64 bytes from router (192.168.4.1): icmp_seq=1 ttl=64 time=0.9 ms

	arp hostname
	  Address           HWtype  HWaddress          Flags Mask  Iface
	  router.local.lan  ether   00:12:17:46:8C:E0  C           eth0

Send WOL Packet

There are several pieces of software for sending the wakeonlan packets inside
the Debian archive:

	etherwake
	apt-get install etherwake
		Requires root privileges and available in all Debian
		distributions.

	wakeonlan
		Can be used by all users, but only in the Sarge (testing)
		and unstable (Sid) repositories.
	apt-get install wakeonlan
	wakeonlan 00:12:17:46:8C:E0
		Sending magic packet to 255.255.255.255:9 with 00:12:17:46:8C:E0
		This sends the magic wake on lan packet to the machine on the
		LAN with the hardware address "08:00:20:C2:1E:F6" which we
		previously determined belonged to the machine "router".

--------------------------------------------------------------------------------

Copied from Discussion Board:

The ethtool setting must be run each time the machine boots, it is reset when
the system brings the interface up. You could create an init script to do it
for you.

Instead of creating an init script, I add a line to /etc/network/interfaces:
	iface eth0 inet dhcp
	up ethtool -s eth0 wol g
	-or-
	up ethtool -s $IFACE wol g

I needed to do that, but I also needed to disable "ifdown" when shutting the
computer down. Appearently ifdown puts my nic (a realtek chipset card) into
the non-wol-enabled state again.

I edited /etc/init.d/networking and commented out the line:
	"ifdown -a --exclude=lo"
and everything worked.

BTW the article mentions a little cable to connect nic and motherboard; on
more recent PC's this is not necessary anmore (or even possible). The system
works via PCI and the option in the BIOS might also be labeled "Wake on PCI".

I couldn't make wakeonlan work on my local network attached to the eth1
interface, this did the job:
	etherwake -i eth1

Everything works pretty much out of the box if you shut down Linux with
"poweroff" etc.

PHP Script to manage LAN of hosts with WOL:
	http://www.marki-online.net/WoL/

WOL over Internet and behind a rooter (which accept WOL and redirect it). I
tried a few things with wakeonlan, but I did not succed. I guess the problem
is in the subnetmask and the way to send it.
	http://www.depicus.com/wake-on-lan/woli.aspx


Here is a script that reads your /etc/dhcp3/dhcpd.conf file and wakes all
computers registered in it by mac address. Use it to wake up all computers
on your LAN.
	open ( FILE, "/etc/dhcp3/dhcpd.conf" );
	while (  ) {
		($mac) = ($_ =~ /(([a-fA-F0-9]{2}:){5}[a-fA-F0-9]{2})/);
		if ( $mac =~ /[a-fA-F0-9]{2}:/ ){
			`etherwake -i eth1 $mac`;
		}
	}
	close (FILE);

--------------------------------------------------------------------------------