Tuesday, December 17, 2013

Use Wake-on-LAN (WOL) on FreeNAS from external networks

Problem: need ability to wake up machines on one network from a remote / external location (and, not have to leave one machine on all the time in order to remote-in simply to wake another system). 
- WOL is not Internet friendly because most routers will not deal with this type of broadcast traffic (and some ISP's block it anyway).
- would like to be able to leave only the FreeNAS server running, for a variety of reasons. So, why not use it for WOL? This allows all other machines to sleep, until you need to access one. 

Here's one way to set it up:

  1. FreeNAS server^ - open source, excellent, low energy consumption (automatically lowers based on use); many, many features. If you have a USB stick (4GB+) and an old system, that's it! Using ZFS storage pools you can add old drives too.
  2. One or more machines with a (wired) NIC capable of accepting WOL "magic packet"
  3. Telnet app (we will be using Mocha Telnet Lite (free) for iPad/iPhone)
  4. Static IP of router in front of the machines you wish to wake (i.e. your home router), on the same network as the FreeNAS system (or, see OPTIONAL 'A' below)
    1. Admin access to the router, to setup port-forwarding for Telnet/SSH 22 (or your custom port, as configured in FreeNAS

OPTIONAL Components:
A. Dynamic DNS (DDNS) - visit DynDNS and sign up for Remote Access or the hosting package (the latter if you want to use your own or register a new domain), otherwise, simply pick one of the free domains offered (i.e. <yourname>.dyndns-remote.com:22 (or your custom port #))

  • DDNS should be configured on your router if you have other services (i.e. additional open ports). Alternatively, if you are only using the services offered by FreeNAS, then you can turn on DDNS service on that system (see Fig. 1 - enable SSH, below for reference)

B. Splashtop Remote client & Streamer  - this is our favorite "rdp" app. Using an iPad (or PC) you can quickly, easily connect to any number of remote machines; keep all of them "headless" if you like. The Splashtop Remote client will allow to a. see if the machine is awake, and b. connect to it!

The FreeNAS Setup: 
Once you have your FreeNAS system up and running, simply turn on the SSH service. 

Fig. 1 - enable SSH

Fig. 2 - Configure SSH (need root to execute 'wake')
set custom port here, if desired

Telnet configuration - again, we are using Mocha Telnet Lite, but the required information is similar for other apps or command line.
  1. Add the FreeNAS server and test your connection, ensuring that you can connect on port 22 (or whatever port you configured in Fig. 2, above).

Fig. 3 - setup a Macro

OPTIONAL: Setting up the Macro first will allow you to copy & paste the line needed to execute the 'wake' command, into a fake server config, so you can keep track of the macros, as they relate to each machine (Benefit - you will not need to remember each MAC address and type it every time*): 
Fig. 4 - add a fake server to store your macro, along 
with a name to define which machine has that MAC

With setup complete, try to login via Telnet and execute the command.
1. Login to the FreeNAS server:


2. Click 'Menu' from the bottom row of commands to access a Macro, or simply type the wake command with the correct interface (use ifconfig to identify the interface, if needed) and MAC address. 


3. Click 'Macro' - ideally your machine will be sleeping at this point.

4. Select the correct Macro from the list, as shown:


5. If the wake command executes correctly the cursor will simply return on a new line.
Now, using Splashtop (or VNC, RDP, et al) connect to the now awake machine to confirm that everything worked correctly. 

For myself, friends, family and customers, this setup works well (at nearly no cost, or no cost at all depending upon the options and software used). 

^note that we do suggest use of a battery backup (UPS) for the FreeNAS system and any drives connected to it. FreeNAS does support many different types (UPS/PDU)), through an included service (provided by NUT). If you do use one, simply open the Shell from within the FreeNAS UI and execute: 
upsc ups@localhost
This command will output the current status and configuration parameters. 

*one alternative to using the "fake server" approach would be to simply maintain a listing of MAC/Systems in a text file. But then you need to copy and paste and jump back and forth between apps. Since we normally use an iPad (or Samsung Tablet), our preference leans toward ease of use & efficiency. 

No comments:

Post a Comment