# Installing DNClient

DNClient connects a device to your Managed Nebula network. It comes in three variants:

- [DNClient Desktop](/docs/glossary/dnclient-desktop/) is an app for macOS and Windows laptops and workstations. You enroll and manage networks from its menu bar or taskbar icon.
- [DNClient Server](/docs/glossary/dnclient-server/) runs `dnclient` as a background service with no user interface. Use it on servers, on Linux, and in containers.
- [Mobile Nebula](/docs/get-started/mobile-nebula/) is the app for iOS and Android phones and tablets.

Each method below ends by enrolling the host with an enrollment code. A Managed Nebula administrator gets the code from the admin panel after creating or [re-enrolling](/docs/guides/managing-hosts/#re-enroll-a-host) the host. If your organization has set up [endpoint SSO](/docs/guides/setting-up-sso/), DNClient Desktop users can instead enroll by signing in with your identity provider, with no code.

**Tab: macOS**

## macOS

### DNClient Desktop \{#macos-desktop\}

DNClient Desktop supports macOS 13 (Ventura) and later. You need an administrator account to install it, and any network it connects to is available to every user of the computer.

#### Install with Homebrew \{#macos-desktop-homebrew\}

If you use [Homebrew](https://brew.sh), install the `dnclient` cask:

```sh
brew install --cask dnclient
```

Then open DNClient Desktop and continue to [enroll](#enrollment-macos).

#### Install from the download \{#installation-macos\}

1. Download DNClient Desktop for macOS from the [downloads page](/downloads/?os=macos) and open `DNClient-Desktop.dmg`.
2. Drag the DNClient Desktop icon onto the Applications shortcut.
3. Open DNClient Desktop from Spotlight, Launchpad, or the Applications folder.

#### Enroll \{#enrollment-macos\}

The first time the app opens, it walks you through letting it run in the background at startup, which it needs to start DNClient connections. After you click "Get started", macOS shows a notification that a background item was added. Hover over the notification, click Options, then Allow, and enter your password.

1. Click the DNClient Desktop icon in the menu bar and select "Join network".
2. To sign in with your organization's identity provider through [endpoint SSO](/docs/guides/setting-up-sso/), click "Authenticate with email" and finish signing in in the browser window that opens.
3. To use an enrollment code instead, click "Enter it here" next to "Have an enrollment token?", paste the code, and click "Enroll device".

The network connects once enrollment finishes and reconnects each time the app starts. To disconnect a network or stop it from connecting at startup, use the DNClient Desktop menu.

### DNClient Server \{#macos-server\}

#### Install with Homebrew \{#macos-homebrew\}

1. Install the `dnclient-server` cask:

```sh
brew install --cask dnclient-server
```

2. Install `dnclient` as a service, start it, and enroll the host, replacing `<ENROLL_CODE>` with your enrollment code. The service runs the binary from Homebrew's `bin` directory, so `brew upgrade --cask dnclient-server` updates it in place.

```sh
sudo dnclient install
sudo dnclient start
sudo dnclient enroll -code <ENROLL_CODE>
```

#### Install the standalone binary \{#macos-binary\}

DNClient Server for macOS comes as a standalone binary and as a `.dmg`. The two are identical, except that the `.dmg` suits offline installs, because its signing information doesn't need to be fetched from Apple's servers.

1. Copy the link for the latest `dnclient` binary or `DNClient-Server.dmg` from the [downloads page](/downloads/?os=macos), under "All available architectures".
2. From the directory you want `dnclient` in, download it, replacing `<DL_URL>` with that link:

```sh
curl -O <DL_URL>
```

3. If you downloaded `DNClient-Server.dmg`, mount it and copy the binary out. If you downloaded the binary, make it executable:

```sh
sudo chmod +x dnclient
```

4. Install `dnclient` as a service. The service runs the binary from its current directory, so move it first if you want it somewhere else.

```sh
sudo ./dnclient install
```

5. Start `dnclient`. As a service, it starts again on every reboot.

```sh
sudo ./dnclient start
```

6. Enroll the host, replacing `<ENROLL_CODE>` with your enrollment code:

```sh
sudo ./dnclient enroll -code <ENROLL_CODE>
```

**Tab: Windows**

## Windows

### DNClient Desktop \{#windows-desktop\}

DNClient Desktop supports Windows 10 and Windows Server 2016 (build 10240) and later. You need an administrator account to install it, and any network it connects to is available to every user of the computer.

#### Install with winget \{#windows-desktop-winget\}

If you use [winget](https://learn.microsoft.com/windows/package-manager/winget/), run:

```powershell
winget install DefinedNet.DNClient.Desktop
```

Then open DNClient Desktop and continue to [enroll](#enrollment-windows).

#### Install from the download \{#installation-windows\}

1. Download DNClient Desktop for your architecture (AMD64 or ARM64) from the [downloads page](/downloads/?os=windows) and open `DNClient-Desktop.msi`.
2. Follow the installer's prompts, and allow it to make changes to your computer when Windows asks.
3. Open DNClient Desktop.

DNClient Desktop can install updates automatically. See [Upgrading DNClient](/docs/get-started/upgrade/#windows-desktop) for when it does and how to change it.

#### Enroll \{#enrollment-windows\}

When DNClient Desktop opens, no window appears, but its icon is added to the taskbar's notification area. If you don't see it, click the "Show hidden icons" arrow (^).

1. Click the DNClient Desktop icon in the taskbar and select "Join network".
2. To sign in with your organization's identity provider through [endpoint SSO](/docs/guides/setting-up-sso/), click "Authenticate with email" and finish signing in in the browser window that opens.
3. To use an enrollment code instead, click "Enter it here" next to "Have an enrollment token?", paste the code, and click "Enroll device".

The network connects once enrollment finishes and reconnects each time the app starts. To disconnect a network or stop it from connecting at startup, use the DNClient Desktop menu.

### DNClient Server \{#windows-server\}

Run the commands below in a PowerShell terminal started as Administrator.

#### Install with winget \{#windows-winget\}

If you use [winget](https://learn.microsoft.com/windows/package-manager/winget/), install the package, then enroll the host, replacing `<ENROLL_CODE>` with your enrollment code. The package installs `dnclient` as a service and starts it. It doesn't add `dnclient.exe` to your `PATH`, so run it by its full path.

```powershell
winget install DefinedNet.DNClient.Server
& 'C:\Program Files\Defined Networking\DNClient\dnclient.exe' enroll -code <ENROLL_CODE>
```

#### Install the MSI \{#windows-msi\}

1. Download `DNClient-Server.msi` for your architecture from the [downloads page](/downloads/?os=windows), under "All available architectures". To download it on the host from PowerShell instead, copy its link and run the following, replacing `<DL_URL>` with that link:

```powershell
curl.exe -O <DL_URL>
```

2. Open the MSI. It installs `dnclient`, sets it up as a service, and starts it.

3. Enroll the host, replacing `<ENROLL_CODE>` with your enrollment code:

```powershell
& 'C:\Program Files\Defined Networking\DNClient\dnclient.exe' enroll -code <ENROLL_CODE>
```

**Tab: Linux**

## Linux

On Linux, DNClient runs as DNClient Server. On distributions that use APT (such as Debian and Ubuntu), RPM (such as Fedora and RHEL), or pacman (Arch), install it from a package. The package puts the binary at `/usr/bin/dnclient`, registers a systemd service, and picks up new versions through your normal system updates. On other distributions, use the [standalone binary](#linux-binary).

### Install from the package repository

**Tab: APT**

For Debian, Ubuntu, Linux Mint, Pop!\_OS, and other APT-based distributions.

1. Install `curl` and CA certificates. Minimal and desktop installs, including Ubuntu Desktop, may not include `curl`.

```sh
sudo apt-get update
sudo apt-get install -y ca-certificates curl
```

2. Add the Defined Networking signing key. The `install` command creates the keyring directory if your distribution doesn't already have one.

```sh
sudo install -m 0755 -d /etc/apt/keyrings
sudo curl -fsSL https://dl.defined.net/gpg.asc -o /etc/apt/keyrings/defined-net.asc
```

3. Add the repository:

```sh
echo "deb [signed-by=/etc/apt/keyrings/defined-net.asc] https://dl.defined.net/stable/apt stable main" \
  | sudo tee /etc/apt/sources.list.d/defined-net.list > /dev/null
```

4. Install `dnclient` and enable the service so it starts on boot:

```sh
sudo apt-get update
sudo apt-get install dnclient
sudo systemctl enable --now dnclient
```

**Tab: RPM**

For RHEL, Fedora, Rocky Linux, Alma Linux, CentOS Stream, Amazon Linux, and other `dnf`-based distributions.

1. Add the repository:

```sh
sudo curl -fsSL https://dl.defined.net/stable/rpm/defined-net.repo -o /etc/yum.repos.d/defined-net.repo
```

2. Install `dnclient` and enable the service so it starts on boot:

```sh
sudo dnf install dnclient
sudo systemctl enable --now dnclient
```

**Tab: Arch (AUR)**

For Arch Linux, Manjaro, EndeavourOS, and other Arch-based distributions, Defined Networking maintains the [`dnclient`](https://aur.archlinux.org/packages/dnclient) package in the Arch User Repository.

1. Install the package with your AUR helper, or build it manually with `makepkg`:

```sh
# with an AUR helper
yay -S dnclient

# or manually
git clone https://aur.archlinux.org/dnclient.git
cd dnclient
makepkg -si
```

2. Enable the service so it starts on boot:

```sh
sudo systemctl enable --now dnclient
```

With the service running, enroll the host, replacing `<ENROLL_CODE>` with your enrollment code:

```sh
sudo dnclient enroll -code <ENROLL_CODE>
```

Confirm the service is running and the host has a certificate:

```sh
systemctl status dnclient
sudo dnclient info
```

:::note

The package ships its own systemd unit, so the packaged build has no `install`, `uninstall`, `start`, or `stop` subcommands. Manage the service with `systemctl` instead. To connect the host to more than one network, use the `dnclient@.service` template unit, for example `sudo systemctl enable --now dnclient@production`.

:::

### Service configuration

The packaged service takes its settings from environment variables, which it reads from a file whose location depends on the distribution:

| Distribution                        | Environment file          |
| ----------------------------------- | ------------------------- |
| Debian, Ubuntu, and other APT-based | `/etc/default/dnclient`   |
| RHEL, Fedora, and other RPM-based   | `/etc/sysconfig/dnclient` |
| Arch-based                          | `/etc/conf.d/dnclient`    |

The package ships this file with every setting commented out, so the defaults below apply until you edit it. A named instance reads its own file with the instance name appended, such as `/etc/default/dnclient.production` for `dnclient@production.service`. That file is optional and the package doesn't create it.

| Variable | Default | Description |
| --- | --- | --- |
| `DNCLIENT_STATE_DIR` | `/var/lib/defined` | Directory holding enrollment state. A named instance stores its state in a subdirectory, such as `/var/lib/defined/production/`. |
| `DNCLIENT_LOG` | unset | File to write logs to. When unset, logs go to stdout, where journald captures them. |
| `DNCLIENT_SERVER` | `https://api.defined.net` | API server used for enrollment, certificate rotation, and configuration updates. |
| `DNCLIENT_NAME` | unset | Instance name. The template unit sets this per instance, so enable `dnclient@<name>.service` rather than setting it here. |

Restart the service to apply a change:

```sh
sudo systemctl restart dnclient
```

Only the service reads this file. `dnclient` commands you run yourself use the defaults unless you set the variable in your own shell or pass the matching flag (`-config`, `-log`, `-server`, `-name`).

### Install the standalone binary \{#linux-binary\}

Use this method on distributions the package repository doesn't cover, or where you don't want a system package. You'll need to repeat these steps by hand for each upgrade.

1. Copy the link for the latest `dnclient` binary for your architecture from the [downloads page](/downloads/?os=linux), under "All available architectures".
2. From the directory you want `dnclient` in, download it, replacing `<DL_URL>` with that link:

```sh
curl -O <DL_URL>
```

3. Make `dnclient` executable:

```sh
sudo chmod +x dnclient
```

4. Install `dnclient` as a service. The service runs the binary from its current directory, so move it first if you want it somewhere else.

```sh
sudo ./dnclient install
```

5. Start `dnclient`. As a service, it starts again on every reboot.

```sh
sudo ./dnclient start
```

6. Enroll the host, replacing `<ENROLL_CODE>` with your enrollment code:

```sh
sudo ./dnclient enroll -code <ENROLL_CODE>
```

**Tab: Docker**

## Docker

The [`definednet/dnclient`](https://hub.docker.com/r/definednet/dnclient/) image runs DNClient Server in a container on Linux hosts. It carries the same release as the packages on dl.defined.net.

1. Install [cosign](https://docs.sigstore.dev/cosign/system_config/installation/) v3 or newer.

2. Verify the image with the Defined Networking Docker signing key. Images for DNClient 1.0.0 and later are signed. To use a specific version, verify and run that tag instead of `latest`.

```sh
cosign verify --key https://dl.defined.net/docker-cosign.pub definednet/dnclient:latest
```

3. Run the container, replacing `<ENROLL_CODE>` with your enrollment code. `NET_ADMIN` lets the container create the tun device, and the `defined` volume keeps the host's enrollment across restarts, so `DN_ENROLLMENT_CODE` is only needed on the first run.

```sh
docker run -d \
  --name dnclient \
  --network host \
  --cap-add NET_ADMIN \
  --volume defined:/etc/defined \
  --env DN_ENROLLMENT_CODE="<ENROLL_CODE>" \
  --restart unless-stopped \
  definednet/dnclient:latest
```

**Tab: iOS and Android**

## iOS and Android

Install Mobile Nebula from the [App Store](https://apps.apple.com/us/app/id1509587936) for iPhone and iPad, or [Google Play](https://play.google.com/store/apps/details?id=net.defined.mobile_nebula) for Android.

Then enroll the device by scanning the QR code from the admin panel, opening the enrollment link on the device, or entering the enrollment code in the app. [Enroll the device](/docs/get-started/mobile-nebula/#enroll-the-device) in the Mobile Nebula guide walks through each.

## Troubleshooting

If a host doesn't connect, check its logs. The [Viewing DNClient logs guide](/docs/guides/viewing-dnclient-logs/) covers every variant and platform. Once a host is enrolled and online, you can also stream its logs and run diagnostic commands from the admin panel, without signing in to the machine. See [Running host diagnostics](/docs/guides/host-diagnostics/).

If you're switching a computer between DNClient Server and DNClient Desktop, [uninstall](/docs/get-started/uninstall/) the one you're replacing and enroll the computer again with a new code. See [re-enroll a host](/docs/guides/managing-hosts/#re-enroll-a-host).
