How To: Implementing Matter with Docker (or Container Manager) on a Synology Disk Station

This is a little write up from my implementation of Matter on a Synology within a containerized environment. Note that the continued development of openHAB5 and its Matter binding or a DSM update may cause this method to break. Also note that multiple restarts of the openHAB container, Container Manager or the Synology NAS may be necessary.

Assumptions:

Synology DiskStation is running DSM 7.2+

openHAB version 5.0.0+ is running in a containerized environment within Container Manager

The container is on the host network. I.E.: “network_mode: host” within docker compose or equivalent.

A Thread Border Router (TBR) such as an Apple TV 4K exists on your network within the same VLAN as the container’s host network.

The Matter Controller add-in is installed within openHAB. See Matter - Bindings | openHAB.

The Matter Controller Node ID is set per the above instructions

Limitations:

This has only been implemented with a container running on the network in host mode. Other network configurations may be possible but have not been tested.

Container Manager (Container Manager → Network → Host) will always show IPv6 as “Disabled”. This is a bug within Container Manager.

While this can be invoked within the DiskStation GUI, terminal access to the DiskStation is helpful for any debugging. This is accomplished using putty or similar SSH client. See How can I sign in to DSM/SRM with root privilege via SSH? - Synology Knowledge Center

Other Considerations:

This method relies on scripts developed by others. Please review these scripts before installing. These scripts will be run using root privileges. Do so at your own risk. Running these scripts with lower privileges may be possible but has not been tested here.

Background:

In order for Matter to work on a DiskStation under a containerized environment. IPv6 has to be enabled on the network and DiskStation and IPv6 must be functional within the containerized environment. Additionally, IPv6 routing must be established within the routing table between a Matter controller and the host network on which the container resides.

Because the DiskStation runs a customized Linux distribution, full IPv6 is not enabled out-of-the-box in Container Manager and the IPv6 routing is not enabled between the host network and the containers.

This method uses two scripts to enable the IPv6 functionality needed to pass IPV6 packets into the openHAB container.

Before running the below scripts, be sure IPv6 has been enabled on LAN1 of the DiskStation:

  • Within the DiskStation GUI, Open Control Panel and navigate to Network → Network Interface.
  • Select LAN1 and press Edit in the top menu bar.
  • Select IPv6 within the Edit box.
  • Select “Auto” for the IPv6 setup.

When properly enabled, double clicking on the LAN1 network within the Network Interface page should indicate an IPv6 address starting with “fe80::”

Script 1: Enabling IPv6 on the Host Network.

Credit to Dave Russell (007revad on GitHub)

Script and instructions are located here: GitHub - 007revad/Synology_ContainerManager_IPv6: Enable IPv6 for Container Manager’s bridge network

This script adds the lines “IPV6 : True” and "fixed-cidr-v6 : fe80::1/64 " to the /var/packages/ContainerManager/etc/dockerd.json file.

In addition, this script runs error checking by verifying DSM version, container manager is installed, variables haven’t been set and that the script running is the latest version.

While the instructions indicate the script must be installed via the SSH console, this script can also be installed via the DiskStation GUI. To install it via the GUI, complete the following steps:

  1. Download the zip file per the GitHub instructions, then save the zip file to your desktop.

  2. Extract the contents of the zip file. This will provide you with a single directory containing sub directories and files.

  3. Move the extracted folder to an accessible directory on the DiskStation. This can be done via File Station on the GUI. It is recommended us use a shared directory such as “public” on your DiskStation.

  4. Create a task under Task Scheduler on your DiskStation to run this script:
    a. Go to Control Panel → Task Scheduler
    b. Create a new task by selecting Create → Triggered Task → User Defined Script.
    c. In the Create task dialog box, name the task (what you name it is unimportant).
    d. Select the “root” user from the user pull down box. This may require some scrolling in the dialog box.
    e. Select the event as “Boot-Up”
    f. Uncheck the “Enabled” box. If this is enabled it will throw an error at startup due to the time it takes Container Manager to start. These settings should persist through a reboot.
    g. Under the run command settings enter the following, where [path] is the location of the directory where you copied the folder to earlier (See notes below):

      bash /[path]/Synology_ContainerManager_IPv6-2.0.5/ syno_containermanager_ipv6.sh
    

    h. Select OK
    i. Accept the warning dialog box by pressing OK.
    j. Enter the root password in the Enter Password dialog box.
    k. Press submit.

  5. The task will appear in the task list

  6. Highlight the task and select “Run” from the top menu.

  7. Confirm you want to run the task.

  8. Once the task completes, select the task again, then from the top menu, select Action → View Result.

  9. Select View Details in the Run Result window.

  10. You should see within the “Contents of /var/packages/ContainerManager/etc/dockerd.json” section an entry for “ipv6”: true and an entry for “fixed-cidr-v6”: “fe80::1/64”

*Notes: The file name assumes you are using version 2.0.5 of this script. Check the name of the folder extracted from the .zip file to ensure it is correct under step 4(g).
Also note that if you copied the folder onto the DiskSatation using File Manager, you may have to add /volume1 to the directory name. For example, a file saved within File Manager to “public” should be referenced as /volume1/public within your script.

Script 2: Enabling IPv6 Routing on the Host Network

Credit to psynikal from the Home Assistant community forums.

Link: Matter Server Docker Container on Synology NAS / Home Assistant Core - #16 by psynikal - Matter/Thread - Home Assistant Community

Copy the following script to your Task Scheduler on the DiskStation:

  1. Create a task under Task Scheduler on your DiskStation to run this script:
    a. Go to Control Panel → Task Scheduler
    b. Create a new task by selecting Create → Triggered Task → User Defined Script.
    c. In the Create task dialog box, name the task (what you name it is unimportant).
    d. Select the “root” user from the user pull down box. This may require some scrolling in the dialog box.
    e. Select the event as “Boot-Up”
    f. Keep “Enabled” checked
    g. Under the run command settings copy and paste the following script:
#!/bin/sh
set -e

IFACE="eth0"
RDISC_OUTPUT=$(rdisc6 "$IFACE")

echo "Extracting ULA routes..."

echo "$RDISC_OUTPUT" | awk '
  BEGIN { prefix = ""; from = "" }
  /^ Prefix|^ Route/ && $3 ~ /^fd/ { route = $3 }
  /^ from / { from = $2; print route, from; route = "" }
' | sort -u | while read -r prefix router; do
  [ -z "$prefix" ] && continue
  [ -z "$router" ] && continue

  echo "ULA/Route: $prefix via $router"

  ip -6 route show | grep -q "$prefix" && {
    echo "Removing existing route to $prefix"
    ip -6 route del "$prefix" 2>/dev/null || true
  }

  echo "Adding route to $prefix via $router on $IFACE"
  ip -6 route add "$prefix" via "$router" dev "$IFACE" && echo "Added"
done
  1. The task will appear in the task list
  2. Highlight the task and select “Run” from the top menu.
  3. Confirm you want to run the task.
  4. Once the task completes, select the task again, then from the top menu, select Action → View Result.
  5. Select View Details in the Run Result window.
  6. You should see entries for extracting the ULA routes and adding the ULA routes.
  7. Now, restart the DiskStation. Give the DiskStation several minutes to restart the openHAB instance. Once available, navigate to the openHAB GUI. Attempt to add a Matter device per the instructions here: Matter - Bindings | openHAB
    Matter discussion on openHAB is located here: Matter Binding

Have fun. Hope this works for you. I am no expert at any of this, so don’t expect much help from me troubleshooting as every configuration is different. This worked for me, but if it doesn’t for you, it may give you some insight as to where issues may lie. Please feel free to add any observations.

Good Luck,
Old Ag

2 Likes