Tuesday, September 28, 2010

how to turn on your machine remotely (wake on lan)

This feature should be supported by both your motherboard and network adapter.

First of all, search the BIOS for the appropriate entry and enable it. It should look like this "PCI wake up".

Then, using ethtool (included in the ethtool package), you should determine if wol is supported by the network adapter and if it is enabled:

myrina:~# ethtool eth0 | grep Wake
Supports Wake-on: g
Wake-on: d

The output means that wake on is supported (g) but disabled (d). For more detailed information about the ethtool abbreviations take a look at the man page.

In order to enable this feature run:

# ethtool -s eth0 wol g

This setting will be reset once the machine gets restarted. Thus, it should be run on startup by a appropriate script.

In order to wake up the machine remotely the MAC address is required. The MAC address can be retrieved using the #ifconfig eth0 command.

On the client-side, a utility such as wakeonlan is required in order to send magic packets to the target machine. The syntax is very simple: $wakeonlan MACADDRESS

If you want to turn on a machine via the internet, you should use something like this

$wakeonlan -p (port) -i (external ip address) (macaddress)

I haven't tried to wake my machine via the internet but that should work. The router should be configured to forward traffic that reaches the port specifed in the command above. The default port for magic packets is 9.

No comments: