# Upgrading DNClient

Upgrade DNClient the same way you [installed](/docs/get-started/install/) it. Find your platform and the method you used below.

**Tab: macOS**

## macOS

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

DNClient Desktop shows a notice in its menu when a newer version is available.

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

```sh
brew upgrade --cask dnclient
```

#### Download \{#macos-desktop-download\}

1. Download the latest DNClient Desktop for macOS from the [downloads page](/downloads/?os=macos).
2. Quit DNClient Desktop by clicking its menu bar icon and choosing "Quit".
3. Open the `DNClient-Desktop.dmg` you downloaded.
4. Drag the DNClient Desktop icon onto the Applications shortcut, and choose "Replace" to replace the existing app.
5. Open DNClient Desktop again.

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

#### Homebrew \{#homebrew-installations\}

Upgrade the cask, then restart the service so it runs the new binary:

```sh
brew upgrade --cask dnclient-server
sudo dnclient stop
sudo dnclient start
dnclient -version # check your updated version!
```

#### Standalone binary \{#macos-binary\}

Download the latest `dnclient` binary for macOS from the [downloads page](/downloads/?os=macos), under "All available architectures", then:

```bash
sudo dnclient stop
sudo dnclient uninstall
cp ./dnclient $LOCATION_WHERE_YOU_INSTALLED_DNCLIENT/dnclient
chmod +x $LOCATION_WHERE_YOU_INSTALLED_DNCLIENT/dnclient
sudo dnclient install
sudo dnclient start
dnclient -version # check your updated version!
```

**Tab: Windows**

## Windows

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

DNClient Desktop 0.9.10 and later can install updates automatically. Fresh installs turn automatic updates on, except installs run as SYSTEM, such as from MDM or Group Policy, which leave them off. Installs upgraded from 0.9.9 or earlier keep them off. Turn automatic updates on or off from the DNClient Desktop menu in the taskbar. While they're off, the menu offers each new version for you to install.

To set automatic updates when deploying the MSI, pass `AUTOUPDATE=1` or `AUTOUPDATE=0`. This also changes the setting on a computer that already has DNClient Desktop installed:

```powershell
# Install DNClient Desktop with automatic updates on. Use AUTOUPDATE=0 to turn them off.
msiexec /i DNClient-Desktop.msi AUTOUPDATE=1
```

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

```powershell
winget upgrade DefinedNet.DNClient.Desktop
```

#### Download \{#windows-desktop-download\}

Download the latest DNClient Desktop from the [downloads page](/downloads/?os=windows), open `DNClient-Desktop.msi`, and click through the setup wizard. It replaces the installed version.

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

#### winget \{#windows-winget\}

```powershell
winget upgrade DefinedNet.DNClient.Server
```

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

Download the latest `DNClient-Server.msi` from the [downloads page](/downloads/?os=windows), under "All available architectures", and run it against the directory you originally installed DNClient in. It replaces the previous installation.

Either way, check the version afterward:

```powershell
& 'C:\Program Files\Defined Networking\DNClient\dnclient.exe' -version
```

**Tab: Linux**

## Linux

### Package installations \{#linux-package-installations\}

Upgrade `dnclient` the same way you upgrade anything else on the system. On APT and RPM, the package restarts the service for you.

**Tab: APT**

```bash
sudo apt-get update
sudo apt-get install --only-upgrade dnclient
dnclient -version # check your updated version!
```

**Tab: RPM**

```bash
sudo dnf upgrade dnclient
dnclient -version # check your updated version!
```

**Tab: Arch (AUR)**

Rebuild the package with your AUR helper, which pulls the latest version. `pacman` does not restart services, so restart DNClient yourself, including any named instances:

```bash
yay -S dnclient
sudo systemctl try-restart 'dnclient.service' 'dnclient@*.service'
dnclient -version # check your updated version!
```

### Standalone binary installations

Download the latest `dnclient` binary for your architecture from the [downloads page](/downloads/?os=linux), under "All available architectures", then:

```bash
sudo dnclient stop
sudo dnclient uninstall
cp ./dnclient $LOCATION_WHERE_YOU_INSTALLED_DNCLIENT/dnclient
chmod +x $LOCATION_WHERE_YOU_INSTALLED_DNCLIENT/dnclient
sudo dnclient install
sudo dnclient start
dnclient -version # check your updated version!
```

### Moving from the standalone binary to a package

You can switch a standalone binary installation to the [package](/docs/get-started/install/#linux) so that future upgrades come through your package manager. Your enrollment state lives in `/var/lib/defined` and is left in place, so the host stays enrolled and does not need a new enrollment code.

The standalone `dnclient install` writes its service unit to `/etc/systemd/system/dnclient.service`. The package ships its unit under `/lib/systemd/system` (`/usr/lib/systemd/system` on RPM and Arch), and a unit in `/etc` takes precedence. If you install the package without first removing the standalone unit, the old unit shadows the package's and your package upgrades stop affecting the running service.

Remove the standalone service and its binary before installing the package. `dnclient uninstall` removes only the unit, and a leftover binary in `/usr/local/bin` still comes ahead of the package's `/usr/bin/dnclient` on the default `PATH`. If you run named instances, stop and uninstall each of those with `-name` as well, and enable the package's `dnclient@<name>.service` in their place afterward.

```bash
sudo dnclient stop
sudo dnclient uninstall
sudo rm $(command -v dnclient)
```

Then follow the [package install steps](/docs/get-started/install/#linux). Skip the enrollment step, since the host is already enrolled.

### Moving Linux state to /var/lib/defined

DNClient 0.9.4 moved the Linux state directory from `/etc/defined` to `/var/lib/defined`. This migration is optional: a host that enrolled before 0.9.4 keeps working from `/etc/defined`, because DNClient falls back to the old directory when the new one holds no enrolled networks. However, it will log a warning until the migration is performed.

To move the state and clear the warning, stop DNClient and move the files. The move relocates every instance's state at once, so stop all named instances too, not just the one that logged the warning. Named instances run as `dnclient@<name>` on a package installation and `dnclient.<name>` on a standalone one.

```bash
sudo systemctl stop dnclient
sudo mkdir -p /var/lib/defined && sudo mv /etc/defined/* /var/lib/defined/ && sudo rmdir /etc/defined
```

For a package installation, that's the whole migration. Start the new service again with `sudo systemctl start dnclient` and you're done.

For standalone binary installation, re-create the service unit before starting it. An older `dnclient install` pinned `-config /etc/defined` into the unit, so moving the files without rewriting it would strand the service on the now-empty directory. `dnclient install` refuses to write over an existing unit, so uninstall first:

```bash
sudo dnclient uninstall
sudo dnclient install
sudo dnclient start
```

Repeat this for each named instance (`ls -l /var/lib/defined`), passing `-name` to every command. DNClient's startup warning lists the exact commands for the instances it finds.

**Tab: Docker**

## Docker

Verify and pull the new image, then replace the container. The `defined` volume keeps the host's enrollment, so the new container doesn't need an enrollment code. To move to a specific version, use that tag instead of `latest`.

```sh
cosign verify --key https://dl.defined.net/docker-cosign.pub definednet/dnclient:latest
docker pull definednet/dnclient:latest
docker rm -f dnclient
docker run -d \
  --name dnclient \
  --network host \
  --cap-add NET_ADMIN \
  --volume defined:/etc/defined \
  --restart unless-stopped \
  definednet/dnclient:latest
```

**Tab: iOS and Android**

## iOS and Android

Mobile Nebula updates automatically through the App Store or Google Play, like your other apps. To get a new version sooner, open its [App Store](https://apps.apple.com/us/app/id1509587936) or [Google Play](https://play.google.com/store/apps/details?id=net.defined.mobile_nebula) page and tap "Update".

## 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).
