Wake on LAN

This is a simple way that you can use the NSLU to boot up your PCs remotely via a web page. This can be useful for occasions such as needing remote access to a PC when it is switched off. As the NSLU is on 24/7 we use this small device to wake the others.

The NSLU will need to be on the same LAN as the PC, and the PC will need to be configured with WakeOnLan capability enabled.

  • Login as root using SSH
  • Install haserl and wakelan
ipkg install haserl
ipkg install wakelan
ipkg install lighttpd

Add the following text to the file, substituting the 00:12:34:56:78:90 for the MAC address of the target PC. You may also change the displayed text if you wish.

Place this code somewhere in you DocumentRoot for lighttpd its: /opt/share/www/lighttpd

# wakeup-pc.hs
content-type: text/html

<h2>Sent wake-up command to PC</h2>
<? /opt/bin/wakelan 00:12:34:56:78:90 ?>

Configure you web server I'm using LIGHTTPD for its size and capability. Enable MOD_CGI and all files with the .hs extension as haserl CGI scripts.

cgi.assign = (".hs" => "/opt/bin/haserl")

Now just point your browser at http://nslu/wakeup-pc.hs and your server will magically turn itself on.

There are bells and whistles that could be added to the script however this should be enough to provide basic functionality and get you on your way.

Taking the example a little further you can construct a nice STATUS display using something like this:

ipkg install arping

CSS: Stylesheet for the table wol-style.zip

Table design adapted from: http://veerle.duoh.com/index.php/blog/comments/a_css_styled_table

content-type: text/html

check() {
  /opt/sbin/arping -c1 -q $1
  if [ $? -ne 0 ]; then
    echo DOWN
   echo UP
linkage() {
  echo wake-$1.hs
    <title>Server State</title>
    <link rel="stylesheet" href="style.css">
     <caption>Server status</caption>
     <? for i in cheese bingo wombat; do ?>
     <tr><td><? echo $i ?></td><td> <? check $i ?> </td><td><a href=<? linkage $i ?>>Wakeup</a></td></tr>
     <? done ?>
  • nslu/wakeonlan.txt
  • Last modified: 2009/11/27 17:54
  • by