Remotely wake up NAS when IPs are active in LAN

  • Hello,


    i have an openmediavault server running with RAID 5 on a HP Proliant N40L Microserver. I liked to have my NAS been shutdown automatically when all my PCs/Handys/openVPN Clients/RaspberryPis are offline. That means that i am not at home. It works perfectly with the Auto Shutdown Plugin ("Shutdown" to S4).


    But when i switch on my PC at home or connect it with openVPN i did not always want to manually switch the NAS back on. Therefor i wrote a bash Script for my Router, which wakes the NAS with Wake on LAN (WOL) if any of my IPs is pingable (better on a router side: IP is on the ARP cache).


    Now the Auto Shutdown Plugin switches off my NAS when i am not at home. But when i come back and need it - the Tomato Router switches it automatically back on. This saves Money --> "green IT" ;D


    I wrote a small howto (in german) here:
    http://www.och-group.de/2013/0…r-wol-wake-on-lan-wecken/


    You will find the most recent version of the bash script there. If you have any suggestions, please message to me :)
    knumsi



    Ps: Sorry for my unperfect english, i am from germany (Bavaria)


    UPDATE (16.10.2013):
    - I made some updates in the script. I splitted config and Script so you can wget/unzip the script from somewhere (wget) and keep the settings configurable in your admin interface.


    UPDATE (03.05.2013):
    - in (near) future you will find some english instructions on how to install the script the easy way on a DD-WRT and a tomato based router

  • Thank you for your answer. I just made some changes, because the hostname detection did not work properly. That is resolved in bugfix version 1.1.1


    I am looking forward for your experience report on the DD-WRT router.

  • knumsi,


    I have had a little play with your script and DD-WRT. I seem to have it working with a few minor changes.


    I'll keep testing but it seems good so far!


  • Thank you very much lewsut,


    i am just wondering why it does not work with the given ETH interface br0 (where you set your broadcast adress)


    But according to this:
    http://www.dd-wrt.com/wiki/index.php/Internal_device_network
    you could give eth0 instead of br0 a try.


    any of your interfaces should return your broadcast adress (192.168.1.255) when using this command (where "$ETH" could be something like br0 eth0 eth1 vlan0 vlan1):
    ifconfig $ETH | awk '/Bcast/ {split ($3,A,":"); print A[2]}'


    when you know the correct interface, you would not have to change anything beyond line 51 :)


    Please tell me if this works, then i will publish the update with your suggestions :)


    Thanks
    knumsi

  • You were not too far out with your guess!


    After too many test :) It seems the DD-WRT WOL tool just does not like the way we were doing things. It acts like it's working, so just carries on not actually WOLing, I get the same results when i run WOL manually.


    You will notice down the bottom (at the WOL commands) I have exchange $ETH with $BCAST this to me seems to be the easier way forward but i'm open to suggestions. Otherwise it simply refused to do anything!


    I assume Tomato could use the $BCAST variable also? I can't see any issues. Do tell me if i'm missing something.


    I have also included an image so you can see how you run something on start-up via DD-WRT (nice and easy).


    Cheers.





  • I'm the coder of the autoshutdown-plugin. Do you mind if I upload your script to github? So, every user has the latest version of the script and there are no copy and paste-errors. I'll test this asap on my FritzBox7270 ;)

  • Hey lewsut,


    thank you for your input! I realized that ether-wake (tomato) and wol (dd-wrt) dont work the same way. This is what i get using your options:

    Code
    /usr/bin/ether-wake -i 192.168.111.255 00:11:22:33:44:55
    ether-wake: SIOCGIFHWADDR on 192.168.111.255 failed: No such device


    Therefor i ended up adding a new variable (WOLOPTION) to resolve this issue and leave enough room to customize it for other OS/distributions/... Would you like to be listed as contributor for the DD-WRT option? (I will release these changes after your decision :) )



    Solo0815
    Thank you for your offer. I had to think a lot about it. As i am born and raised with SVN and dont use git, i could not maintain it any further. The other thing is: How is it related to your autoshutdown plugin? My script should/must be run on a device that is always on, not the NAS that auto shuts down (what your script does :) ) Sure, you would always get the newest version - but on the wrong device? Please tell me more - it seems that i dont understand ;)


    For your Fritzbox i think you will have to use ether-wake on interface eth0 (intf for Fritz!Box ata). Looking forward to your results.


    knumsi

  • Hi,


    I use a wrt54g with tomato 1.28, and a NAS with omv on it. I use a zotac hd-id11 with openelec. I want to turn on the NAS when the zotac is turned on.


    I tried to use your script, but nothing append when I turn on the multimedia computer.

  • The nas has the mac adress "00:22:B0:DE:F1:15"
    and you want to send a WOL packet when the ips xxx.xxx.xxx.15 or xxx.xxx.xxx.16 or the hostname "pchc" is online?


    Did you restart the router after putting the script in the init section?
    Is the complete script in the init section?
    Did you just copy-paste the script into the textarea or did you read this too: http://www.och-group.de/2013/0…-speichern-und-ausfuhren/
    What shows up in the logs of tomato?

  • you have guess right about the whole configuration.


    I restarted the router after,
    I had to remove all the commented line, cause there is a memory limitation, the script is too long.
    I tried to read the page, I don't read german, and translation gave me funny stuff.


    here is the log http://pastebin.com/j6UzFz1z
    I also forgot to mention, that all those computer are behing a giga switch.

  • The switch should not matter :)


    if you want to use the script in tomato webinterface you should put it in there this way to work:

    Code
    sleep 20
    cat >> /etc/wol_wake_ip_active.sh << “EOF”
    
    
    <<<SCRIPT CONTENT COMES HERE>>>
    
    
    EOF
    chmod ugo+x /etc/wol_wake_ip_active.sh
    /etc/wol_wake_ip_active.sh &


    That is how its running on my WRT54GL.


    And i also had to remove most of the comments :-/

  • I just figured out that I use the 1.1.1 version, not the 1.1.2,


    I will try with this,


    if not working trying 1.1.2 ( but i see there is 2 scripts now and don't know how to use it)

Jetzt mitmachen!

Sie haben noch kein Benutzerkonto auf unserer Seite? Registrieren Sie sich kostenlos und nehmen Sie an unserer Community teil!