Tuesday, September 11, 2012

Wake-on-LAN

Wake-on-LAN (WOL) is an Ethernet networking standard that allows a server to be turned on by a network message. You need to send 'magic packets' to wake-on-lan enabled ethernet adapters and motherboards, in order to switch on the called systems. Make sure you connect the NIC (eth0 or eth1) with the motherboard, and enable the WOL function in the BIOS [1].

Enable BIOS to support WOL

Power Management Setup => Wake-Up by PCI Card => Enabled
or
Power => Wake on LAN from S5 => Power on


Enable LAN card to support WOL

Install tool ethtool:

# apt-get install ethtool

Add the following to /etc/network/interfaces:

allow-hotplug eth0
iface eth0 inet static
address 192.168.0.55
netmask 255.255.255.0
gateway 192.168.0.1
post-up /sbin/ethtool -s eth0 wol g
post-down /sbin/ethtool -s eth0 wol g


Send 'magic packet'

Install tool wakonlan:

# apt-get install wakeonlan

Wake up PC on the same LAN

# wakeonlan aa:bb:cc:dd:ee:ff

where aa:bb:cc:dd:ee:ff is the MAC of the PC being wake up

Wake up PC over internet

# wakeonlan -i 123.1.2.456 -p 6 aa:bb:cc:dd:ee:ff

Send 'magic packet' using UDP to IP address 123.1.2.456 with port number 6. Make sure the destination router forward the magic packet to PC being wake up.

References:
  1. HowTo: Wake Up Computers Using Linux Command [ Wake-on-LAN ( WOL ) ]
    http://www.cyberciti.biz/tips/linux-send-wake-on-lan-wol-magic-packets.html