Select Page

NextDNS with UniFi Dream Machine (UDM)

I was using NextDNS when I decided to get an UniFi Dream Machine (UDM) and switch to the built-in content filtering. However, I wasn’t particularly impressed with its beta feature and after using it for a few months I decided to turn back to NextDNS.

Thankfully it is possible to integrate NextDNS with the UDM router. The UniFi OS doc page is pretty useful alongside the Conditional Configuration page.

Essentially, I had SSH already enabled on the UDM so I’ve installed NextDNS with:

sh -c 'sh -c "$(curl -sL"'

An error is noticed as is unable to start the service the Ubuntu (Debian) way. Well, this is UniFi OS so it can be ignored.
The prompt is awaiting for a Configuration ID to be provided but we do that below with a separate command to cover multiple IDs, so I’ve just pressed CTRL+C.

I have then set a specific configuration to match my NextDNS Configuration IDs with the different Networks on the UDM, and restarted the service:

nextdns config set -config e2h243 -config -config -setup-router
nextdns restart

This way I can view the Logs in the UI for the individual LAN devices. E.g.:
NextDNS Logs via Unifi UDM

The service logs are also useful to monitor after the restart:

watch -d "nextdns log"

UniFi Dream Router update: On the UDR, in order to get to see the correct hostnames in NextDNS we also did:

nextdns config set -auto-activate -report-client-info
nextdns restart