Recent Posts

Archives

Topics


« | Main | »

Using the ReadyNAS as a Wake-on-LAN Device

By dbott | January 30, 2010

At work, I occasionally have the need to do some computer updates at remote locations.  Under normal circumstances, I can use Windows Group Policy to update/install software, however, not every application supports installation via GPO. There are commercial products that you can pay for and license that makes managing a number of devices at multiple locations quite easy, but of course, it requires something that we don’t have a lot of: money.

Additionally, many of our public access terminals have security software installed that prevents software from being installed or automatically rolls-back the machine to a known state after each reboot. In order to allow software to be installed/updated, the security software must be disabled.

Using the ReadyNAS as a wake-on-lan device requires a few things:

At work, I have written a few scripts that allow me to wake the PCs at my remote sites.  The basic process is as follows:

1. SSH into branch NAS:

- ssh root@192.168.129.2 for Grantham-NAS
- ssh root@192.168.131.2 for Merritt-NAS

2. At the command prompt type:

wakeonlan -f /backup/utilites/wakeonlan/grantham.wol
wakeonlan -f /backup/utilites/wakeonlan/merritt.wol

The grantham.wol and merritt.wol files are just text files that I wrote up that contain the MAC address (00:13:72:xx:xx:xx), subnet broadcast address (192.168.129.255) and port number (7) as well as some comments (#) for each PC on the network:

Epsilon:/backup/utilities/wakeonlan# cat grantham.wol

# Mac Address       IP-Address  Computer Name
# GRAN_CIRC1
00:13:72:xx:xx:xx       192.168.129.255 7
# 192.168.129.59
# GRAN_CIRC2
00:13:72:xx:xx:xx      192.168.129.255 7
# 192.168.129.62
# GRAN_CIRC3
00:13:72:xx:xx:xx   192.168.129.255 7
# 192.168.129.65

Other notes:

I also use the ReadyNAS as a DHCP server.  I have another write-up here that offers some insight on how to do it, as well as add additional options, such as static leases.  If you’re already using the ReadyNAS as a DHCP server, you can utilize some commands to get useful information for your script, such as the MAC address:

1. Viewing active leases to get the MAC address:

Grantham-NAS:~# dumpleases -f /var/lib/misc/udhcpd.leases
Mac Address       IP-Address      Expires in
00:13:72:xx:xx:xx 192.168.129.55  6 days, 20 hours, 31 minutes, 0 seconds
00:13:72:xx:xx:xx 192.168.129.53  6 days, 18 hours, 34 minutes, 16 seconds
00:13:72:xx:xx:xx 192.168.129.54  6 days, 6 hours, 10 minutes, 39 seconds
00:13:72:xx:xx:xx 192.168.129.67  6 days, 18 hours, 51 minutes, 49 seconds
00:13:72:xx:xx:xx 192.168.129.56  6 days, 18 hours, 41 minutes, 46 seconds
00:13:72:xx:xx:xx 192.168.129.71  6 days, 18 hours, 53 minutes, 48 seconds
00:13:72:xx:xx:xx 192.168.129.61  6 days, 23 hours, 52 minutes, 47 seconds
00:13:72:xx:xx:xx 192.168.129.73  6 days, 23 hours, 45 minutes, 6 seconds
00:13:72:xx:xx:xx 192.168.129.58  6 days, 23 hours, 36 minutes, 4 seconds
00:13:72:xx:xx:xx 192.168.129.69  6 days, 23 hours, 13 minutes, 45 seconds
00:13:72:xx:xx:xx 192.168.129.70  6 days, 23 hours, 32 minutes, 28 seconds
00:13:72:xx:xx:xx 192.168.129.50  6 days, 18 hours, 40 minutes, 26 seconds
00:13:72:xx:xx:xx 192.168.129.51  6 days, 18 hours, 40 minutes, 3 seconds
00:13:72:xx:xx:xx 192.168.129.66  6 days, 6 hours, 31 seconds
00:13:72:xx:xx:xx 192.168.129.63  6 days, 18 hours, 41 minutes, 17 seconds
00:13:72:xx:xx:xx 192.168.129.52  6 days, 1 hours, 34 minutes, 0 seconds
00:13:72:xx:xx:xx 192.168.129.57  6 days, 20 hours, 9 minutes, 46 seconds
00:13:72:xx:xx:xx 192.168.129.62  6 days, 23 hours, 4 minutes, 5 seconds
00:00:00:00:00:00 192.168.129.59  expired
00:00:00:00:00:00 192.168.129.60  expired
00:13:72:xx:xx:xx 192.168.129.64  expired
00:13:72:xx:xx:xx 192.168.129.65  6 days, 23 hours, 24 minutes, 4 seconds

2. I also temporarily updated the udhcpd.conf file with auto_time 60 to update the lease file to every minute while testing.

Grantham-NAS:~# cat /etc/udhcpd.conf
# This file is auto-generated.  Do not modify!
auto_time       60
interface       eth0
option wins     192.168.128.25
option dns      192.168.128.25
option dns      192.168.128.35
option domain   mydomain.ca
option lease    604800
option subnet   255.255.255.0
option router   192.168.129.1
start   192.168.129.50
end     192.168.129.199

3. Getting MAC addresses from within Windows:

From command line type “getmac /s computername

C:\>getmac /S gran_circ1

Physical Address    Transport Name
=================== ==========================================================
00:13:72:xx:xx:xx   \Device\Tcpip_{0E96113B-5F1C-4200-8F81-4D0E83E39AE1}

At this point, the computers will begin to boot and I use open-source tools such as VNC and iTALC to remotely control the computers and disable any security software.

Topics: ReadyNAS, Tech | 7 Comments »

7 Responses to “Using the ReadyNAS as a Wake-on-LAN Device”

  1. Hacking the ReadyNAS DHCP Server | The Bott Blog Says:
    January 30th, 2010 at 12:13 pm

    [...] Using the ReadyNAS as a Wake-on-LAN Device [...]

  2. Using the ReadyNAS as a Wake-on-LAN Device | The Bott Blog | Drakz Free Online Service Says:
    January 31st, 2010 at 3:42 pm

    [...] here: Using the ReadyNAS as a Wake-on-LAN Device | The Bott Blog Share and [...]

  3. Unofficial ReadyNAS Getting Started Guide | The Bott Blog Says:
    February 2nd, 2010 at 1:01 pm

    [...] Using the ReadyNAS as a Wake-on-LAN Device [...]

  4. Michael Rudge Says:
    September 26th, 2010 at 2:50 pm

    Really cool post. Many thanks!

    I am a newb and have just managed to get this working :) I thought other newb’s might be interested in a few more details that are involved. Here are some comments that may help.

    1. Put APT on the ReadyNAS

    This will allow you to add the required packages later.

    Install this add-in to the ReadyNAS and restart.

    http://www.readynas.com/download/addons/4.00/APT_1.0.bin

    APT goes into /usr/bin on the ReadyNAS. SSH to the ReadyNAS and go to this directory. Then run

    apt-get update

    2. Put wakeonlan on the ReadyNAS

    In /usr/bin type

    apt-get install wakeonlan

    This will run through the download and install of the wakeonlan script.

    3. Make sure the require Perl modules are loaded

    By default, I found that a Perl module called Std.pm was missing from my ReadyNAS. Trying to update the Perl installed does not work. So download Perl again

    wget http://www.readynas.com/packages/readynas/perl-modules_5.8.8-7.infrant2_all.deb

    4. Then expand the package.

    dpkg-deb -x perl-modules_5.8.8-7.infrant2_all.deb /

    The above command puts the new files over the existing files in /user/share/perl/5.8.8 which I did not want to do so I did

    dpkg-deb -x perl-modules_5.8.8-7.infrant2_all.deb /usr/share/perl/5.8.8.7

    which put all the sub-dirs below the directory specified. But that was not a problem. I just moved the file I needed from where it was to where I needed it.

    cp /usr/share/perl/5.8.8.7/usr/share/perl/5.8.8/Getopt/Std.pm /usr/share/perl/5.8.8/Getopt/Std.pm

    5. Test

    The document mentioned above says to set up files to store MAC addresses to wake up. This is fine, but the format in his doc did not work for me. Also, during testing I found that specifying an IP address sometimes stopped the wakeonlan working, so I would recommend just putting the MAC address in the .wol file. The .wol file can go anywhere you like.

    For example, if you have a machine called server01, then just make a file called server01.wol using vi (the .wol is just for convenience). If server01′s Wake-on-LAN capable NIC has MAC addres 11-22-33-44-55-66, then have your file read

    11:22:33:44:55:66

    So say the file is now /backup/wol/server01.wol

    6. Then to wake the machine, just run the following command

    /usr/bin/wakeonlan -f /usr/backup/wol/server01.wol

    7. Notes

    I found with my PC that WOL would only work when the PC was hibernated, not shut down. I am pretty sure this is a motherboard-specific thing. I tried playing with the settings for allowing WOL in the Device Manager (look in Advanced Properties on the NIC, “Wake-On-Lan after Shutdown” but this started leading to my machine immediately starting up after hibernate, or sometimes at least. After some more testing it looks like it has stopped doing that. In any case, you can test with the machine you are working with. It may be that I had something else going on as well…

  5. r00n Says:
    November 8th, 2010 at 5:35 pm

    Hi… there is no model mentioned in this post. Does that mean that this is working on the Netgear ReadyNAS Duo RND2000 as well? I am looking around for a NAS and sending WOL packages to my computers is a must. I don’t need a NAS which is a WOL Client.

  6. dbott Says:
    November 8th, 2010 at 6:28 pm

    The how-to should work with any x86-based ReadyNAS (Ultra, Pro, NVX, 2100, 3100, 3200, 4200).

    See post #4 by Michael Rudge for the steps on setting up WoL for sparc-based units (Duo, NV/NV+, X6/600, 1000s/1100).

  7. r00n Says:
    November 9th, 2010 at 4:39 am

    Thanks! For me the reason for buying the device! I will place my order today!