# Synology NAS

Source: https://tiltas.openpanel.sh/docs/devices/synology

> Run Tiltas on a Synology NAS with DSM 7.2 Container Manager, with or without TUN, and share your home LAN.

Tiltas runs on a Synology NAS as a container in Container Manager (DSM 7.2 and later). The image is for 64-bit
processors: Intel, AMD and 64-bit ARM models. The NAS joins your Network as a Server, and it can share your home LAN
with your other Devices.

## 1. Get a Join key

1. In the [console](/app), open **Join keys** and choose **Create Join key**.
2. Name it after the machine, such as “synology”. Leave **Reusable** off: the key then adds one Server and is spent.
3. Create it and copy the key, which starts with `qlj_`. It is shown once and works for 7 days unless you chose
   otherwise.

## 2. Choose kernel or userspace networking

DSM does not load the TUN driver that kernel networking needs. You can turn it on with a task that runs at boot, or
skip this step and use userspace networking, which needs nothing: DSM's own pages and shares are still reachable from
your other Devices, and the NAS can still share your LAN. What each gives:
[kernel or userspace networking](/docs/devices/docker#kernel-or-userspace-networking).

For kernel networking:

1. Open **Control Panel** → **Task Scheduler** → **Create** → **Triggered Task** → **User-defined script**.
2. Name it “Tiltas TUN”, set the user to **root** and the event to **Boot-up**.
3. Under **Task Settings**, paste this script, save, then select the task and choose **Run** once.

```bash title="Run command"
#!/bin/sh
# Tiltas: TUN for kernel networking (DSM does not load it at boot)
if [ ! -c /dev/net/tun ]; then
  [ -d /dev/net ] || mkdir -m 755 /dev/net
  mknod /dev/net/tun c 10 200
  chmod 0755 /dev/net/tun
fi
lsmod | grep -q "^tun" || insmod /lib/modules/tun.ko
```

## 3. Create the project

1. In File Station, make the folder `tiltas` inside the `docker` shared folder.
2. In **Container Manager**, open **Project** → **Create**. Name it `tiltas`, choose that folder as the path and
   **Create docker-compose.yml** as the source.
3. Paste the file below with your Join key. For userspace networking, delete the `cap_add` and `devices` lines.
4. Finish the wizard. Container Manager downloads the image and starts the container.

```yaml title="docker-compose.yml"
services:
  tiltas:
    image: tiltas-registry.openpanel.sh/tiltas/tiltas:latest
    container_name: tiltas
    restart: unless-stopped
    network_mode: host
    cap_add: [NET_ADMIN]
    devices: ["/dev/net/tun:/dev/net/tun"]
    environment:
      TILTAS_JOIN_KEY: qlj_your_join_key
      TILTAS_HOSTNAME: synology
      # TILTAS_ROUTES: 192.168.1.0/24
    volumes:
      - ./state:/var/lib/tiltas
```

`network_mode: host` puts the NAS itself in your Network. The sign-in is kept in `state` in the project folder; keep it,
and the container stays the same Device through restarts and updates. The Join key is read on the first start only.

## 4. Check that it is online

In the console, **Devices** lists `synology` as **Online** with its address, such as `100.64.0.7`. It is a Server:
other Devices reach it only where an [Access rule](/docs/access) or a [Service](/docs/services) allows.

In Container Manager the container shows as running and healthy; its log says whether it uses kernel or userspace
networking. Over SSH:

```bash
sudo docker exec tiltas tiltas status
```

## 5. Share your home LAN

Your LAN is the network your router hands out, written as a subnet: a NAS at `192.168.1.20` with the mask
`255.255.255.0` is on `192.168.1.0/24`.

In the project's YAML, uncomment `TILTAS_ROUTES` with your LAN and start the project again so the container is
recreated. Then:

1. In the console, open **Devices**, then `synology`. Under **Subnet routes** the LAN shows as **Offered**: switch it on
   to approve it.
2. Open **Access rules** and choose **Add a rule**: under **Who**, who may use the LAN; under **May reach**, a
   **Subnet**, `192.168.1.0/24`, with ports if you want to narrow it.

Nothing reaches the LAN until both are done: approving shares the route, the rule says who may use it. More in
[Subnet routers](/docs/access/subnet-routers).

## Update

Over SSH, in the project folder:

```bash
cd /volume1/docker/tiltas
sudo docker compose pull && sudo docker compose up -d
```

On older Container Manager versions the command is `docker-compose`. Or stop the project, update the image under
**Image** when Container Manager offers it, and start the project again. Either way the container reconnects as the same
Device.

## Remove

1. Over SSH, run `sudo docker exec tiltas tiltas logout`. It removes the Device from your Network. Or remove it in the
   console under **Devices**.
2. In Container Manager, stop the project and delete it, then delete the `tiltas` folder.
3. If you made the TUN task, delete it in Task Scheduler.

If Tailscale also runs on this NAS, see [Tiltas and Tailscale on one machine](/docs/troubleshooting/tailscale).
