Skip to content

Code-the-Things/Morpheus-UniFi-Plugin

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Morpheus UniFi Plugin

A Morpheus Data plugin that integrates with the UniFi Network Controller (Dream Machine / UDM-Pro) to provide full DNS record management directly from the Morpheus UI.


Features

  • Full DNS CRUD — Create, read, update, and delete DNS records via the Morpheus DNS integration interface
  • Supported record types — A, AAAA, CNAME, MX, TXT, SRV, FORWARD_DOMAIN
  • IPv4 & IPv6 — Full support for both address families
  • Automatic sync — Existing UniFi DNS policies are inventoried into Morpheus on integration refresh
  • TTL "Auto" — Sending TTL 0 maps to UniFi's "Auto" TTL setting; the default for all records created through this plugin is Auto
  • API Key authentication — Uses the modern UniFi Network Integration API; no username/password or session cookies required

Requirements

Requirement Details
Morpheus version 6.x+ (plugin API compatible)
UniFi Network Controller Firmware supporting Integration API v10.x+ (Dream Machine / UDM-Pro)
Java JDK 11+ for build; plugin runs on the Morpheus JVM

Configuration

1. Generate a UniFi API Key

  1. Log in to your UniFi Network controller
  2. Navigate to Settings → Integrations → API
  3. Create a new API key and copy it

2. Add the Integration in Morpheus

  1. Navigate to Infrastructure → Network → DNS & IP Management
  2. Click + Add Integration and select UniFi
  3. Fill in the fields:
Field Description
Controller URL Base URL of your UDM/UDM-Pro, e.g. https://192.168.1.1
API Key The API key generated in step 1
Site Name UniFi site name (default: default)
Ignore SSL Errors Enable if using a self-signed certificate
Inventory Existing Import all existing DNS records from UniFi on first sync
Create PTR Records Automatically create reverse PTR records for A/AAAA entries

How It Works

API Endpoint

All DNS operations use the UniFi Network Integration API v1:

https://<controller>/proxy/network/integration/v1/sites/{siteId}/dns/policies

Authentication is via the X-API-KEY header — no session, no CSRF token.

Site Resolution

The plugin resolves the human-readable site name (e.g. default) to the internal UUID via:

GET /proxy/network/integration/v1/sites

Zone Model

UniFi has no concept of DNS zones — all records live flat under a site. The plugin creates a single synthetic zone named "UniFi DNS" (keyed by siteId) to satisfy the Morpheus zone model. All records appear under this zone.

Record Type Mapping

Morpheus Type UniFi API Type Key Fields
A A_RECORD domain, ipv4Address, ttlSeconds
AAAA AAAA_RECORD domain, ipv6Address, ttlSeconds
CNAME CNAME_RECORD domain, targetDomain, ttlSeconds
MX MX_RECORD domain, mailServerDomain, priority
TXT TXT_RECORD domain, text
SRV SRV_RECORD domain, serverDomain, service, protocol, port, priority, weight
FORWARD_DOMAIN FORWARD_DOMAIN domain, ipAddress

TTL Behaviour

  • TTL 0 = Auto in the UniFi UI (controller manages TTL automatically)
  • The default TTL for all records created by this plugin is 0 (Auto)
  • Leave the TTL field blank when creating records to use Auto

Building

Requires JDK 17 and Gradle (wrapper included).

# Windows
$env:JAVA_HOME = "C:\Program Files\Microsoft\jdk-17.0.19.10-hotspot"
.\gradlew.bat shadowJar

# Linux/macOS
JAVA_HOME=/path/to/jdk17 ./gradlew shadowJar

Output JAR: build/libs/morpheus-unifi-plugin-1.0.0-all.jar


Installation

  1. Build the plugin JAR (or download a release)
  2. In Morpheus, go to Admin → Integrations → Plugins
  3. Click + Add Plugin and upload the JAR
  4. The UniFi integration type will appear in Infrastructure → Network → DNS & IP Management

Note: When updating the plugin, fully uninstall the old version and restart the Morpheus UI service (morpheus-ctl restart morpheus-ui) before installing the new JAR to ensure plugin assets (logo, etc.) are refreshed from cache.


Reference Links

Resource URL
Morpheus Developer Docs https://developer.morpheusdata.com/docs#ipamdns-plugins
Morpheus Plugin API Javadoc https://developer.morpheusdata.com/api/index.html
UniFi Network Integration API https://developer.ui.com/network/v10.1.84/gettingstarted
UniFi Brand Assets https://techspecs.ui.com

License

This plugin is provided as-is. See LICENSE for details.