Extending Service Discovery Cabilities on ReadyNAS

Background

The ReadyNAS appliance can advertise the services available on their system through the Bonjour or UPnP protocols.  These service discovery protocols can greatly simplify the client connection and configuration problems.  The web administration interface provides an easy method of controlling some of the services advertised, but there may be additional services running on the ReadyNAS that do not have an administrative interface for controlling their advertisement.

Because the ReadyNAS uses the open-source project avahi to handle service discovery, documentation on extending the list of services to be advertised is readily available.  With this information, it is relatively easy to create new service records for additional services and simplify the user experience.

Setup

In order to create additional avahi service records, it is necessary to enable root SSH access to the ReadyNAS system.

The service file is a simple XML file which defines a service-group record.  The service-group record contains a number of elements which may vary according to the service being advertised.  The two essential elements are the name record, which defines the displayed name for the service in question, and the service record, which defines the type, port, and any other connection-related information.

The name element has one possible attribute – replace-wildcards – which can take a value of “yes” or “no”.  If the attribute is present and the value is “yes”, then a %h can be used in the value which will be automatically substituted with the host name of the system.

The service element groups together the necessary information for service connectivity.  The two most essential elements it contains are the type element and the port element.  The type is the is the official service type as defined by RFC 2782 and the port is simply the listening port number.

Depending on the service, there may be additional elements or attributes that are necessary to have a properly formatted service file.  Be sure to consult the documentation to ensure the service is properly defined before making any changes.

Example

The following is an example configuration that enables service discovery for SSH:


<?xml version="1.0" standalone='no'?>
<service-group>
<name replace-wildcards="yes">SSH on %h</name>
<service>
<type>_ssh._tcp</type>
<port>22</port>
</service>
</service-group>

To activate this service, perform the following actions:

  1. Login (via ssh) as “root” to the ReadyNAS appliance.
  2. Navigate to the configuration directory.

    cd /etc/avahi/services

  3. Create a new file named ssh.service containing the configuration information listed above.
  4. Restart the avahi service to load the new service file.

    kill -SIGHUP `ps ax | grep avahi | grep -v grep | awk '{ print $1 }'`

Customizing the ReadyNAS Bonjour (UPnP) Names

Background

The ReadyNAS appliance can use the standard service discovery protocols (Bonjour, UPnP) to advertise the services it offers which can greatly simplify client configuration.  While it can easily enable/disable the discovery protocols with the web administration interface, it does not provide a means of customizing the service names.

Because ReadyNAS is based on the Linux operating system, it is able to use the open source solution avahi to handle the service discovery.  This service can easily be configured to display alternate names.

Setup

The ReadyNAS system uses a stock template for each service it is able to advertise.  When activated, the appropriate template is processed into a service record which is used by the avahi daemon to advertise the various services.  In order to effect a persistent change, the template itself must be modified with the desired service name.  Directly modifying the service record will result in the changes being lost should the template be reprocessed.

The template is a simple XML file which defines a service-group record.  The service-group record contains a number of elements which may vary according to the service being advertised.  The only element which is necessary to modify for customizing the displayed name is the <name> element.

The value of the <name> element contains the text of the service advertisement.  If the replace-wildcards="yes" attribute is set, the text may include a %h which will automatically be expanded into the hostname.  If the replace-wildcards attribute is absent or set to “no”, then no hostname expansion will occur.  It is suggested that the names advertise both the hostname and the service in order to avoid confusion.

Here is an example (stock) template for the AFP (Apple Filing Protocol) service:

<?xml version=”1.0″ standalone=’no’?><!–*-nxml-*–>
<service-group>
<name replace-wildcards=”yes”>%h (AFP)</name>
<service>
<type>_afpovertcp._tcp</type>
<port>548</port>
</service>
</service-group>

In order to access the necessary configuration files, the EnableRootSSH patch must first be successfully installed.

  1. Disable both the Bonjour and UPnP discovery services using the ReadyNAS web administration interface.
  2. Login (via ssh) as “root” to the ReadyNAS appliance.
  3. Navigate to the configuration directory.

    cd /etc/avahi/services

  4. Make a backup of the original configuration file for safety.

    cp afp.template afp.template.orig

  5. Edit the <name> element by replacing the value with the desired text.  If the replace-wildcards="yes" attribute is set, then the hostname will be substituted for a %h in the value text.

    <name replace-wildcards="yes">AFP on %h</name>

  6. Re-enable the Bonjour and UPnP discovery services using the ReadyNAS web administration interface.

Multiple Media Directories with ReadyDLNA

Background

With a recent upgrade of the ReadyNAS firmware, Infrant (now Netgear) introduced the streaming service “ReadyDLNA”.  This is actually an open source project (”minidlna”) initiated by a Netgear engineer.  This DLNA (”Digital Living Network Alliance”) streaming service is capable of delivering audio, video, and pictures to a number of DLNA-compliant media players.

The ReadyDLNA service works quite well but does not provide a means of specifying multiple media directories in the ReadyNAS web administration interface.  It also does not expose the capability to assign “roles” to the different directories through the web interface.

Setup

In order to access the necessary configuration files, the EnableRootSSH patch must first be successfully installed.  Enhancements to the web interface to permit easier access to these “hidden” configuration options have been promised for future versions, but currently the only means of altering them is through directly editing the configuration files.

To add multiple media directories for the ReadyDLNA service:

  1. Login (via ssh) as “root” to the ReadyNAS appliance.
  2. Navigate to the configuration directory.

    cd /etc

  3. Make a backup of the original configuration file for safety.

    cp minidlna.conf minidlna.conf.orig

  4. Edit the minidlna.conf file by creating additional “media_dir” entries with the appropriate path.  For the ReadyNAS appliances, all the data is typically stored on a single volume (“/c”) with the sharepoint name being the next item on the path and then the directory name(s).

    media_dir=/c/media/Music
    media_dir=/c/media/Videos
    media_dir=/c/media/Pictures
    media_dir=/c/torrents/BitTorrent

  5. Restart the ReadyDLNA service.  (The easiest way to do this is to simply reboot the ReadyNAS appliance.)

Another “hidden” feature of the minidlna service is the ability to assign roles to the different media directories.  This can help restrict the type of content listed for a particular playback device.  There are three roles that may be assigned:  Audio (“A”), Video (“V”), and Pictures (“P”).  If no role is assigned to a media directory, then all media types will be indexed.

To assign roles to the media directories:

  1. Login (via ssh) as “root” to the ReadyNAS appliance.
  2. Navigate to the configuration directory.

    cd /etc

  3. Make a backup of the original configuration file for safety.

    cp minidlna.conf minidlna.conf.orig

  4. Edit the minidlna.conf file “media_dir” entries by specifying the role (“A”, “V”, or “P”) before the path.  The role and path should be comma-delimited.

    media_dir=A,/c/media/Music
    media_dir=V,/c/media/Videos
    media_dir=P,/c/media/Pictures
    media_dir=V,/c/torrents/BitTorrent

  5. Restart the ReadyDLNA service.  (The easiest way to do this is to simply reboot the ReadyNAS appliance.)