import {Note} from "@/components/mdx";

# Synology Installation

The NetBird client (agent) allows a peer to join a pre-existing NetBird deployment. If a NetBird deployment is not yet available, there are both managed and [self-hosted](https://docs.netbird.io/selfhosted/selfhosted-quickstart) options available.

## Installation

Installing a NetBird Peer on Synology will require a few additional steps compared to a typical Linux install despite using the same single line command to get everything going.

1. Ensure your user has administrative privileges. _Control Panel > User & Group > User > Click User and Edit > User Groups > Ensure “administrators” is checked._
2. Enable SSH Connectivity. _Control Panel > Terminal & SNMP > Terminal > Check the box next to “Enable SSH Service” > Click Apply_
3. Login to your user using SSH. If you’re unsure if your Synology IP address it can be found under _Control Panel > Info Center > Network > DNS_ or using the [Synology Find Tool](https://finds.synology.com/). Open a terminal and run the command to connecting replacing the user and IP address with your own.

```bash
ssh user@192.168.0.53
```

4. Install with one command.

```bash
curl -fsSL https://pkgs.netbird.io/install.sh | sudo sh
```

5. Add your Synology NAS as a Peer using the steps from [Add peers to your NetBird network](https://docs.netbird.io/manage/peers/add-machines-to-your-network) in the documentation.

## Reboot Script

In some cases on Synology, the NetBird service will not have the correct modules loaded on a reboot. In this case you’ll need to run a script every time you reboot your NAS. To automate this process, you can create a scheduled task in the Synology DSM.

1. _Control Panel > Task Scheduler > Create > Triggered Task > User defined script_.
2. Now you’ll have a _Create Task_ dialog box. Give a task name such as “Netbird Reboot”. Set the _User > Root_ and the _Event > Boot-up_. Make sure the Enable Box is checked.
3. Next, click on _Task Settings_ and copy/paste the script in the text field under _Run command > User-defined script_.

```sh
#!/bin/sh

# Create the necessary file structure for /dev/net/tun
if [ ! -c /dev/net/tun ]; then
  if [ ! -d /dev/net ]; then
    mkdir -m 755 /dev/net
  fi
  mknod /dev/net/tun c 10 200
  chmod 0755 /dev/net/tun
fi

# Load the tun module if not already loaded
if !(lsmod | grep -q "^tun\s"); then
  insmod /lib/modules/tun.ko
fi
```
4. If you’d like to see the logs for this task, select the task you create and click on Settings. Check the box that says Save output results, select a save location, and click OK. Now, if you select the task and **Action > View Result**, you’ll see any error logs and status.

## Running with a Setup Key
In case you are activating a server peer, you can use a [setup key](/manage/peers/register-machines-using-setup-keys) as described in the steps below.
> This is especially helpful when you are running multiple server instances with infrastructure-as-code tools like ansible and terraform.

1. Login to the Management Service. You need to have a `setup key` in hand (see [setup keys](/manage/peers/register-machines-using-setup-keys)).

```bash
  netbird up --setup-key <SETUP KEY>
```

Alternatively, if you are hosting your own Management Service provide `--management-url` property pointing to your Management Service:
```bash
  netbird up --setup-key <SETUP KEY> --management-url http://localhost:33073
```

> You could also omit the `--setup-key` property. In this case, the tool will prompt for the key.

2. Check connection status:
```bash
  netbird status
```

3. Check your IP:

```bash
  ip addr show wt0
```

## Updating

If you used the one-command script to install, you can follow this to update:

```bash
netbird down
curl -fsSLO https://pkgs.netbird.io/install.sh
chmod +x install.sh
./install.sh --update
netbird up
```

## Uninstallation
The most straightforward method is to use NetBird's built-in uninstall command. You'll need to connect to your Synology NAS via SSH to execute these commands.

1. SSH into your Synology NAS: If you haven't already, enable SSH in your Synology's Control Panel under Terminal & SNMP. Then, use an SSH client to connect to your NAS. Switch to the root user:
```bash
sudo -i
```
2. Run the uninstall command: Once connected, execute the following command:
```bash
netbird service uninstall
```
3. Remove NetBird binary and configuration files.

/usr/local/bin/netbird: The installation script placed the NetBird binary here.
/var/lib/netbird: This directory contains the NetBird configuration files.

You can use the rm command to delete these files and directories:
```bash
rm /usr/local/bin/netbird
rm -rf /var/lib/netbird
```
**Important:** Be very careful when using the `rm -rf` command, as it will permanently delete the specified files and directories. Double-check the paths before executing the command.

4. Remove the Peer from the NetBird UI.

For a complete cleanup, you should also remove the Synology NAS as a peer from your NetBird account. Log in to the NetBird web UI. Navigate to the Peers section. Find the peer corresponding to your Synology NAS and delete it.

## Video Walkthrough

<YouTube videoId="9VKOAe_T038" />

## Support Us

- Star us on [GitHub](https://github.com/netbirdio/netbird)
- Follow us [on X](https://x.com/netbird)
- Join our [Slack Channel](/slack-url)
- NetBird release page on GitHub: [releases](https://github.com/netbirdio/netbird/releases/latest)
